@bitgen/sdk 0.1.6 → 1.0.4
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/CHANGELOG.md +63 -2
- package/README.md +27 -106
- package/dist/cjs/client.d.ts +20 -8
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +33 -12
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/constants.d.ts +256 -0
- package/dist/cjs/constants.d.ts.map +1 -0
- package/dist/cjs/constants.js +214 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/error.d.ts +17 -10
- package/dist/cjs/error.d.ts.map +1 -1
- package/dist/cjs/error.js +25 -7
- package/dist/cjs/error.js.map +1 -1
- package/dist/cjs/http.d.ts +13 -8
- package/dist/cjs/http.d.ts.map +1 -1
- package/dist/cjs/http.js +135 -44
- package/dist/cjs/http.js.map +1 -1
- package/dist/cjs/index.d.ts +14 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +30 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/resources/apikeys.d.ts +18 -0
- package/dist/cjs/resources/apikeys.d.ts.map +1 -0
- package/dist/cjs/resources/apikeys.js +31 -0
- package/dist/cjs/resources/apikeys.js.map +1 -0
- package/dist/cjs/resources/asset.d.ts +17 -5
- package/dist/cjs/resources/asset.d.ts.map +1 -1
- package/dist/cjs/resources/asset.js +17 -6
- package/dist/cjs/resources/asset.js.map +1 -1
- package/dist/cjs/resources/bank.d.ts +11 -6
- package/dist/cjs/resources/bank.d.ts.map +1 -1
- package/dist/cjs/resources/bank.js +17 -9
- package/dist/cjs/resources/bank.js.map +1 -1
- package/dist/cjs/resources/core.d.ts +12 -0
- package/dist/cjs/resources/core.d.ts.map +1 -0
- package/dist/cjs/resources/core.js +22 -0
- package/dist/cjs/resources/core.js.map +1 -0
- package/dist/cjs/resources/custody.d.ts +27 -0
- package/dist/cjs/resources/custody.d.ts.map +1 -0
- package/dist/cjs/resources/custody.js +38 -0
- package/dist/cjs/resources/custody.js.map +1 -0
- package/dist/cjs/resources/customer.d.ts +20 -0
- package/dist/cjs/resources/customer.d.ts.map +1 -0
- package/dist/cjs/resources/customer.js +38 -0
- package/dist/cjs/resources/customer.js.map +1 -0
- package/dist/cjs/resources/staking.d.ts +32 -0
- package/dist/cjs/resources/staking.d.ts.map +1 -0
- package/dist/cjs/resources/staking.js +69 -0
- package/dist/cjs/resources/staking.js.map +1 -0
- package/dist/cjs/resources/trading.d.ts +24 -0
- package/dist/cjs/resources/trading.d.ts.map +1 -0
- package/dist/cjs/resources/trading.js +41 -0
- package/dist/cjs/resources/trading.js.map +1 -0
- package/dist/cjs/resources/transaction.d.ts +6 -9
- package/dist/cjs/resources/transaction.d.ts.map +1 -1
- package/dist/cjs/resources/transaction.js +10 -15
- package/dist/cjs/resources/transaction.js.map +1 -1
- package/dist/cjs/resources/webhooks.d.ts +46 -0
- package/dist/cjs/resources/webhooks.d.ts.map +1 -0
- package/dist/cjs/resources/webhooks.js +142 -0
- package/dist/cjs/resources/webhooks.js.map +1 -0
- package/dist/cjs/types/apikeys.d.ts +43 -0
- package/dist/cjs/types/apikeys.d.ts.map +1 -0
- package/dist/cjs/types/apikeys.js +3 -0
- package/dist/cjs/types/apikeys.js.map +1 -0
- package/dist/cjs/types/asset.d.ts +57 -0
- package/dist/cjs/types/asset.d.ts.map +1 -0
- package/dist/cjs/types/asset.js +3 -0
- package/dist/cjs/types/asset.js.map +1 -0
- package/dist/cjs/types/bank.d.ts +58 -0
- package/dist/cjs/types/bank.d.ts.map +1 -0
- package/dist/cjs/types/bank.js +3 -0
- package/dist/cjs/types/bank.js.map +1 -0
- package/dist/cjs/types/core.d.ts +32 -0
- package/dist/cjs/types/core.d.ts.map +1 -0
- package/dist/cjs/types/core.js +3 -0
- package/dist/cjs/types/core.js.map +1 -0
- package/dist/cjs/types/custody.d.ts +50 -0
- package/dist/cjs/types/custody.d.ts.map +1 -0
- package/dist/cjs/types/custody.js +3 -0
- package/dist/cjs/types/custody.js.map +1 -0
- package/dist/cjs/types/customer.d.ts +190 -0
- package/dist/cjs/types/customer.d.ts.map +1 -0
- package/dist/cjs/types/customer.js +3 -0
- package/dist/cjs/types/customer.js.map +1 -0
- package/dist/cjs/types/index.d.ts +78 -194
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/index.js +0 -1
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/types/staking.d.ts +88 -0
- package/dist/cjs/types/staking.d.ts.map +1 -0
- package/dist/cjs/types/staking.js +3 -0
- package/dist/cjs/types/staking.js.map +1 -0
- package/dist/cjs/types/trading.d.ts +51 -0
- package/dist/cjs/types/trading.d.ts.map +1 -0
- package/dist/cjs/types/trading.js +3 -0
- package/dist/cjs/types/trading.js.map +1 -0
- package/dist/cjs/types/transaction.d.ts +61 -0
- package/dist/cjs/types/transaction.d.ts.map +1 -0
- package/dist/cjs/types/transaction.js +3 -0
- package/dist/cjs/types/transaction.js.map +1 -0
- package/dist/cjs/types/webhooks.d.ts +55 -0
- package/dist/cjs/types/webhooks.d.ts.map +1 -0
- package/dist/cjs/types/webhooks.js +3 -0
- package/dist/cjs/types/webhooks.js.map +1 -0
- package/dist/cjs/utils.d.ts +21 -2
- package/dist/cjs/utils.d.ts.map +1 -1
- package/dist/cjs/utils.js +67 -4
- package/dist/cjs/utils.js.map +1 -1
- package/dist/cjs/version.d.ts +2 -0
- package/dist/cjs/version.d.ts.map +1 -0
- package/dist/cjs/version.js +6 -0
- package/dist/cjs/version.js.map +1 -0
- package/dist/esm/client.d.ts +20 -8
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +33 -12
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/constants.d.ts +256 -0
- package/dist/esm/constants.d.ts.map +1 -0
- package/dist/esm/constants.js +211 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/error.d.ts +17 -10
- package/dist/esm/error.d.ts.map +1 -1
- package/dist/esm/error.js +24 -6
- package/dist/esm/error.js.map +1 -1
- package/dist/esm/http.d.ts +13 -8
- package/dist/esm/http.d.ts.map +1 -1
- package/dist/esm/http.js +136 -45
- package/dist/esm/http.js.map +1 -1
- package/dist/esm/index.d.ts +14 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/resources/apikeys.d.ts +18 -0
- package/dist/esm/resources/apikeys.d.ts.map +1 -0
- package/dist/esm/resources/apikeys.js +27 -0
- package/dist/esm/resources/apikeys.js.map +1 -0
- package/dist/esm/resources/asset.d.ts +17 -5
- package/dist/esm/resources/asset.d.ts.map +1 -1
- package/dist/esm/resources/asset.js +17 -6
- package/dist/esm/resources/asset.js.map +1 -1
- package/dist/esm/resources/bank.d.ts +11 -6
- package/dist/esm/resources/bank.d.ts.map +1 -1
- package/dist/esm/resources/bank.js +18 -10
- package/dist/esm/resources/bank.js.map +1 -1
- package/dist/esm/resources/core.d.ts +12 -0
- package/dist/esm/resources/core.d.ts.map +1 -0
- package/dist/esm/resources/core.js +18 -0
- package/dist/esm/resources/core.js.map +1 -0
- package/dist/esm/resources/custody.d.ts +27 -0
- package/dist/esm/resources/custody.d.ts.map +1 -0
- package/dist/esm/resources/custody.js +34 -0
- package/dist/esm/resources/custody.js.map +1 -0
- package/dist/esm/resources/customer.d.ts +20 -0
- package/dist/esm/resources/customer.d.ts.map +1 -0
- package/dist/esm/resources/customer.js +34 -0
- package/dist/esm/resources/customer.js.map +1 -0
- package/dist/esm/resources/staking.d.ts +32 -0
- package/dist/esm/resources/staking.d.ts.map +1 -0
- package/dist/esm/resources/staking.js +65 -0
- package/dist/esm/resources/staking.js.map +1 -0
- package/dist/esm/resources/trading.d.ts +24 -0
- package/dist/esm/resources/trading.d.ts.map +1 -0
- package/dist/esm/resources/trading.js +37 -0
- package/dist/esm/resources/trading.js.map +1 -0
- package/dist/esm/resources/transaction.d.ts +6 -9
- package/dist/esm/resources/transaction.d.ts.map +1 -1
- package/dist/esm/resources/transaction.js +11 -16
- package/dist/esm/resources/transaction.js.map +1 -1
- package/dist/esm/resources/webhooks.d.ts +46 -0
- package/dist/esm/resources/webhooks.d.ts.map +1 -0
- package/dist/esm/resources/webhooks.js +138 -0
- package/dist/esm/resources/webhooks.js.map +1 -0
- package/dist/esm/types/apikeys.d.ts +43 -0
- package/dist/esm/types/apikeys.d.ts.map +1 -0
- package/dist/esm/types/apikeys.js +2 -0
- package/dist/esm/types/apikeys.js.map +1 -0
- package/dist/esm/types/asset.d.ts +57 -0
- package/dist/esm/types/asset.d.ts.map +1 -0
- package/dist/esm/types/asset.js +2 -0
- package/dist/esm/types/asset.js.map +1 -0
- package/dist/esm/types/bank.d.ts +58 -0
- package/dist/esm/types/bank.d.ts.map +1 -0
- package/dist/esm/types/bank.js +2 -0
- package/dist/esm/types/bank.js.map +1 -0
- package/dist/esm/types/core.d.ts +32 -0
- package/dist/esm/types/core.d.ts.map +1 -0
- package/dist/esm/types/core.js +2 -0
- package/dist/esm/types/core.js.map +1 -0
- package/dist/esm/types/custody.d.ts +50 -0
- package/dist/esm/types/custody.d.ts.map +1 -0
- package/dist/esm/types/custody.js +2 -0
- package/dist/esm/types/custody.js.map +1 -0
- package/dist/esm/types/customer.d.ts +190 -0
- package/dist/esm/types/customer.d.ts.map +1 -0
- package/dist/esm/types/customer.js +2 -0
- package/dist/esm/types/customer.js.map +1 -0
- package/dist/esm/types/index.d.ts +78 -194
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/types/index.js +0 -1
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/types/staking.d.ts +88 -0
- package/dist/esm/types/staking.d.ts.map +1 -0
- package/dist/esm/types/staking.js +2 -0
- package/dist/esm/types/staking.js.map +1 -0
- package/dist/esm/types/trading.d.ts +51 -0
- package/dist/esm/types/trading.d.ts.map +1 -0
- package/dist/esm/types/trading.js +2 -0
- package/dist/esm/types/trading.js.map +1 -0
- package/dist/esm/types/transaction.d.ts +61 -0
- package/dist/esm/types/transaction.d.ts.map +1 -0
- package/dist/esm/types/transaction.js +2 -0
- package/dist/esm/types/transaction.js.map +1 -0
- package/dist/esm/types/webhooks.d.ts +55 -0
- package/dist/esm/types/webhooks.d.ts.map +1 -0
- package/dist/esm/types/webhooks.js +2 -0
- package/dist/esm/types/webhooks.js.map +1 -0
- package/dist/esm/utils.d.ts +21 -2
- package/dist/esm/utils.d.ts.map +1 -1
- package/dist/esm/utils.js +62 -4
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/version.d.ts +2 -0
- package/dist/esm/version.d.ts.map +1 -0
- package/dist/esm/version.js +3 -0
- package/dist/esm/version.js.map +1 -0
- package/package.json +29 -12
- package/readme/concepts.md +128 -0
- package/readme/configuration.md +72 -0
- package/readme/errors.md +67 -0
- package/readme/installation.md +43 -0
- package/readme/media/activation.svg +58 -0
- package/readme/media/deposit-flow.svg +70 -0
- package/readme/media/order-buy.svg +43 -0
- package/readme/media/order-sell.svg +47 -0
- package/readme/media/purchase-flow.svg +61 -0
- package/readme/media/sale-flow.svg +61 -0
- package/readme/media/staking-position.svg +75 -0
- package/readme/media/transaction-lifecycle.svg +61 -0
- package/readme/media/webhook-delivery.svg +53 -0
- package/readme/media/withdrawal-flow.svg +64 -0
- package/readme/quick-start.md +87 -0
- package/readme/resource/apikeys.md +103 -0
- package/readme/resource/asset.md +121 -0
- package/readme/resource/bank.md +161 -0
- package/readme/resource/core.md +91 -0
- package/readme/resource/custody.md +166 -0
- package/readme/resource/customer.md +210 -0
- package/readme/resource/staking.md +281 -0
- package/readme/resource/trading.md +171 -0
- package/readme/resource/transaction.md +110 -0
- package/readme/resource/webhooks.md +309 -0
- package/src/client.ts +46 -0
- package/src/constants.ts +281 -0
- package/src/error.ts +36 -0
- package/src/http.ts +201 -0
- package/src/index.ts +111 -0
- package/src/resources/apikeys.ts +30 -0
- package/src/resources/asset.ts +28 -0
- package/src/resources/bank.ts +39 -0
- package/src/resources/core.ts +19 -0
- package/src/resources/custody.ts +37 -0
- package/src/resources/customer.ts +46 -0
- package/src/resources/staking.ts +88 -0
- package/src/resources/trading.ts +41 -0
- package/src/resources/transaction.ts +20 -0
- package/src/resources/webhooks.ts +169 -0
- package/src/types/apikeys.ts +35 -0
- package/src/types/asset.ts +59 -0
- package/src/types/bank.ts +60 -0
- package/src/types/core.ts +32 -0
- package/src/types/custody.ts +40 -0
- package/src/types/customer.ts +189 -0
- package/src/types/index.ts +215 -0
- package/src/types/staking.ts +87 -0
- package/src/types/trading.ts +56 -0
- package/src/types/transaction.ts +62 -0
- package/src/types/webhooks.ts +60 -0
- package/src/utils.ts +74 -0
- package/src/version.ts +2 -0
- package/dist/cjs/resources/order.d.ts +0 -17
- package/dist/cjs/resources/order.d.ts.map +0 -1
- package/dist/cjs/resources/order.js +0 -30
- package/dist/cjs/resources/order.js.map +0 -1
- package/dist/cjs/resources/stats.d.ts +0 -11
- package/dist/cjs/resources/stats.d.ts.map +0 -1
- package/dist/cjs/resources/stats.js +0 -18
- package/dist/cjs/resources/stats.js.map +0 -1
- package/dist/cjs/resources/user.d.ts +0 -22
- package/dist/cjs/resources/user.d.ts.map +0 -1
- package/dist/cjs/resources/user.js +0 -37
- package/dist/cjs/resources/user.js.map +0 -1
- package/dist/cjs/resources/wallet.d.ts +0 -11
- package/dist/cjs/resources/wallet.d.ts.map +0 -1
- package/dist/cjs/resources/wallet.js +0 -19
- package/dist/cjs/resources/wallet.js.map +0 -1
- package/dist/esm/resources/order.d.ts +0 -17
- package/dist/esm/resources/order.d.ts.map +0 -1
- package/dist/esm/resources/order.js +0 -26
- package/dist/esm/resources/order.js.map +0 -1
- package/dist/esm/resources/stats.d.ts +0 -11
- package/dist/esm/resources/stats.d.ts.map +0 -1
- package/dist/esm/resources/stats.js +0 -14
- package/dist/esm/resources/stats.js.map +0 -1
- package/dist/esm/resources/user.d.ts +0 -22
- package/dist/esm/resources/user.d.ts.map +0 -1
- package/dist/esm/resources/user.js +0 -33
- package/dist/esm/resources/user.js.map +0 -1
- package/dist/esm/resources/wallet.d.ts +0 -11
- package/dist/esm/resources/wallet.d.ts.map +0 -1
- package/dist/esm/resources/wallet.js +0 -15
- package/dist/esm/resources/wallet.js.map +0 -1
- package/dist/types/client.d.ts +0 -19
- package/dist/types/client.d.ts.map +0 -1
- package/dist/types/error.d.ts +0 -15
- package/dist/types/error.d.ts.map +0 -1
- package/dist/types/http.d.ts +0 -21
- package/dist/types/http.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/resources/asset.d.ts +0 -11
- package/dist/types/resources/asset.d.ts.map +0 -1
- package/dist/types/resources/bank.d.ts +0 -13
- package/dist/types/resources/bank.d.ts.map +0 -1
- package/dist/types/resources/order.d.ts +0 -17
- package/dist/types/resources/order.d.ts.map +0 -1
- package/dist/types/resources/stats.d.ts +0 -11
- package/dist/types/resources/stats.d.ts.map +0 -1
- package/dist/types/resources/transaction.d.ts +0 -15
- package/dist/types/resources/transaction.d.ts.map +0 -1
- package/dist/types/resources/user.d.ts +0 -22
- package/dist/types/resources/user.d.ts.map +0 -1
- package/dist/types/resources/wallet.d.ts +0 -11
- package/dist/types/resources/wallet.d.ts.map +0 -1
- package/dist/types/types/index.d.ts +0 -213
- package/dist/types/types/index.d.ts.map +0 -1
- package/dist/types/utils.d.ts +0 -7
- package/dist/types/utils.d.ts.map +0 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { HttpClient } from '../http.js';
|
|
2
|
+
import type { Order, OrderState, Page, TradingListParams, TradingOrderParams, UserRef } from '../types/index.js';
|
|
3
|
+
/** `/trading` — permissions `trading.write`, `trading.read`. Buy or sell crypto for a customer. */
|
|
4
|
+
export declare class TradingResource {
|
|
5
|
+
private readonly http;
|
|
6
|
+
constructor(http: HttpClient);
|
|
7
|
+
/** Buy crypto with EUR from the customer's bank account — `amount` in EUR (2 decimals max) */
|
|
8
|
+
buy(user: UserRef, params: TradingOrderParams): Promise<{
|
|
9
|
+
tunnel: string;
|
|
10
|
+
state: OrderState;
|
|
11
|
+
}>;
|
|
12
|
+
/** Sell crypto from the customer's custody — `amount` is the crypto quantity (string recommended) */
|
|
13
|
+
sell(user: UserRef, params: TradingOrderParams): Promise<{
|
|
14
|
+
tunnel: string;
|
|
15
|
+
state: OrderState;
|
|
16
|
+
}>;
|
|
17
|
+
/** One order by its uuid (the `tunnel` returned by `buy` / `sell`) or by model */
|
|
18
|
+
get(order: string | Order): Promise<Order>;
|
|
19
|
+
/** Orders of the organization, optionally filtered by customer, side and asset */
|
|
20
|
+
list(params?: TradingListParams): Promise<Page<Order>>;
|
|
21
|
+
/** `POST /trading` — the customer must be an `ENABLED` member of the organization (uuid or model, no email here) */
|
|
22
|
+
private order;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=trading.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trading.d.ts","sourceRoot":"","sources":["../../../src/resources/trading.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAa,UAAU,EAAE,IAAI,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAG3H,mGAAmG;AACnG,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,8FAA8F;IACxF,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE,CAAC;IAIpG,qGAAqG;IAC/F,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE,CAAC;IAIrG,kFAAkF;IAC5E,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAIhD,kFAAkF;IAC5E,IAAI,CAAC,MAAM,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAMhE,oHAAoH;YACtG,KAAK;CASpB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TradingResource = void 0;
|
|
4
|
+
const utils_js_1 = require("../utils.js");
|
|
5
|
+
/** `/trading` — permissions `trading.write`, `trading.read`. Buy or sell crypto for a customer. */
|
|
6
|
+
class TradingResource {
|
|
7
|
+
http;
|
|
8
|
+
constructor(http) {
|
|
9
|
+
this.http = http;
|
|
10
|
+
}
|
|
11
|
+
/** Buy crypto with EUR from the customer's bank account — `amount` in EUR (2 decimals max) */
|
|
12
|
+
async buy(user, params) {
|
|
13
|
+
return await this.order(user, params, 'BUY');
|
|
14
|
+
}
|
|
15
|
+
/** Sell crypto from the customer's custody — `amount` is the crypto quantity (string recommended) */
|
|
16
|
+
async sell(user, params) {
|
|
17
|
+
return await this.order(user, params, 'SELL');
|
|
18
|
+
}
|
|
19
|
+
/** One order by its uuid (the `tunnel` returned by `buy` / `sell`) or by model */
|
|
20
|
+
async get(order) {
|
|
21
|
+
return await this.http.get(`/trading/${(0, utils_js_1.pathSegment)((0, utils_js_1.idOf)(order, 'order'), 'order')}`);
|
|
22
|
+
}
|
|
23
|
+
/** Orders of the organization, optionally filtered by customer, side and asset */
|
|
24
|
+
async list(params = {}) {
|
|
25
|
+
const { user } = params;
|
|
26
|
+
// spread first: the query keeps the order of the params, `user` and `asset` are replaced in place (absent or null = no filter)
|
|
27
|
+
return await this.http.get('/trading/orders', { ...params, user: user === undefined || user === null ? undefined : (0, utils_js_1.resolveUuid)(user), asset: (0, utils_js_1.assetFilter)(params.asset) });
|
|
28
|
+
}
|
|
29
|
+
/** `POST /trading` — the customer must be an `ENABLED` member of the organization (uuid or model, no email here) */
|
|
30
|
+
async order(user, params, mode) {
|
|
31
|
+
return await this.http.post('/trading', {
|
|
32
|
+
user: (0, utils_js_1.resolveUuid)(user),
|
|
33
|
+
asset: (0, utils_js_1.assetId)(params.asset),
|
|
34
|
+
amount: (0, utils_js_1.amount)(params.amount),
|
|
35
|
+
mode,
|
|
36
|
+
reference: params.reference,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.TradingResource = TradingResource;
|
|
41
|
+
//# sourceMappingURL=trading.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trading.js","sourceRoot":"","sources":["../../../src/resources/trading.ts"],"names":[],"mappings":";;;AAEA,0CAA0F;AAE1F,mGAAmG;AACnG,MAAa,eAAe;IACG;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,8FAA8F;IAC9F,KAAK,CAAC,GAAG,CAAC,IAAa,EAAE,MAA0B;QACjD,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;IAC9C,CAAC;IAED,qGAAqG;IACrG,KAAK,CAAC,IAAI,CAAC,IAAa,EAAE,MAA0B;QAClD,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/C,CAAC;IAED,kFAAkF;IAClF,KAAK,CAAC,GAAG,CAAC,KAAqB;QAC7B,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,IAAA,sBAAW,EAAC,IAAA,eAAI,EAAC,KAAK,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;IACtF,CAAC;IAED,kFAAkF;IAClF,KAAK,CAAC,IAAI,CAAC,SAA4B,EAAE;QACvC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAA;QACvB,+HAA+H;QAC/H,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,sBAAW,EAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAA,sBAAW,EAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IAC3K,CAAC;IAED,oHAAoH;IAC5G,KAAK,CAAC,KAAK,CAAC,IAAa,EAAE,MAA0B,EAAE,IAAe;QAC5E,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACtC,IAAI,EAAE,IAAA,sBAAW,EAAC,IAAI,CAAC;YACvB,KAAK,EAAE,IAAA,kBAAO,EAAC,MAAM,CAAC,KAAK,CAAC;YAC5B,MAAM,EAAE,IAAA,iBAAM,EAAC,MAAM,CAAC,MAAM,CAAC;YAC7B,IAAI;YACJ,SAAS,EAAE,MAAM,CAAC,SAAS;SAC5B,CAAC,CAAA;IACJ,CAAC;CACF;AAnCD,0CAmCC"}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import type { HttpClient } from '../http.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Page, Transaction, TransactionListParams } from '../types/index.js';
|
|
3
|
+
/** `/transaction` — permission `transaction.read`. Unified journal of fiat and crypto movements, read-only. */
|
|
3
4
|
export declare class TransactionResource {
|
|
4
5
|
private readonly http;
|
|
5
6
|
constructor(http: HttpClient);
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/** Get a transaction by its ID */
|
|
11
|
-
get(txId: string): Promise<Transaction>;
|
|
12
|
-
/** Get transaction history for a user */
|
|
13
|
-
history(user: UserRef, filters?: TransactionHistoryFilter): Promise<TransactionHistoryItem[]>;
|
|
7
|
+
/** Transactions of the organization, optionally filtered — `limit` up to 100 on this route */
|
|
8
|
+
list(params?: TransactionListParams): Promise<Page<Transaction>>;
|
|
9
|
+
/** One transaction by uuid, by reference, or by model */
|
|
10
|
+
get(transaction: string | Transaction): Promise<Transaction>;
|
|
14
11
|
}
|
|
15
12
|
//# sourceMappingURL=transaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/resources/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/resources/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAGjF,+GAA+G;AAC/G,qBAAa,mBAAmB;IAClB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,8FAA8F;IACxF,IAAI,CAAC,MAAM,GAAE,qBAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAM1E,yDAAyD;IACnD,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;CAGnE"}
|
|
@@ -2,26 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TransactionResource = void 0;
|
|
4
4
|
const utils_js_1 = require("../utils.js");
|
|
5
|
+
/** `/transaction` — permission `transaction.read`. Unified journal of fiat and crypto movements, read-only. */
|
|
5
6
|
class TransactionResource {
|
|
7
|
+
http;
|
|
6
8
|
constructor(http) {
|
|
7
9
|
this.http = http;
|
|
8
10
|
}
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return this.http.
|
|
14
|
-
...params,
|
|
15
|
-
user: (0, utils_js_1.resolveUuid)(params.user),
|
|
16
|
-
}, true);
|
|
11
|
+
/** Transactions of the organization, optionally filtered — `limit` up to 100 on this route */
|
|
12
|
+
async list(params = {}) {
|
|
13
|
+
const { user } = params;
|
|
14
|
+
// spread first: the query keeps the order of the params, `user` and `asset` are replaced in place (absent or null = no filter)
|
|
15
|
+
return await this.http.get('/transaction', { ...params, user: user === undefined || user === null ? undefined : (0, utils_js_1.resolveUuid)(user), asset: (0, utils_js_1.assetFilter)(params.asset) });
|
|
17
16
|
}
|
|
18
|
-
/**
|
|
19
|
-
get(
|
|
20
|
-
return this.http.get(`/
|
|
21
|
-
}
|
|
22
|
-
/** Get transaction history for a user */
|
|
23
|
-
history(user, filters) {
|
|
24
|
-
return this.http.get(`/api/v3/txs/${(0, utils_js_1.resolveUuid)(user)}`, filters);
|
|
17
|
+
/** One transaction by uuid, by reference, or by model */
|
|
18
|
+
async get(transaction) {
|
|
19
|
+
return await this.http.get(`/transaction/${(0, utils_js_1.pathSegment)((0, utils_js_1.idOf)(transaction, 'transaction'), 'transaction')}`);
|
|
25
20
|
}
|
|
26
21
|
}
|
|
27
22
|
exports.TransactionResource = TransactionResource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../src/resources/transaction.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../src/resources/transaction.ts"],"names":[],"mappings":";;;AAEA,0CAAyE;AAEzE,+GAA+G;AAC/G,MAAa,mBAAmB;IACD;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,8FAA8F;IAC9F,KAAK,CAAC,IAAI,CAAC,SAAgC,EAAE;QAC3C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAA;QACvB,+HAA+H;QAC/H,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,sBAAW,EAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAA,sBAAW,EAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IACxK,CAAC;IAED,yDAAyD;IACzD,KAAK,CAAC,GAAG,CAAC,WAAiC;QACzC,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,IAAA,sBAAW,EAAC,IAAA,eAAI,EAAC,WAAW,EAAE,aAAa,CAAC,EAAE,aAAa,CAAC,EAAE,CAAC,CAAA;IAC5G,CAAC;CACF;AAdD,kDAcC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { HttpClient } from '../http.js';
|
|
2
|
+
import type { Created, DeliveryLog, Page, PageParams, Subscriber, VerifyInput, WebhookEvent, WebhookSubscriptions, WebhookType } from '../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* `/webhook`, `/webhooks` — permissions `webhooks.admin`, `webhooks.write`, `webhooks.read`, `webhook.read`.
|
|
5
|
+
* Wherever the API expects `{organization}`, the SDK sends the key's scope.
|
|
6
|
+
*/
|
|
7
|
+
export declare class WebhooksResource {
|
|
8
|
+
private readonly http;
|
|
9
|
+
constructor(http: HttpClient);
|
|
10
|
+
/** Activate the security (generates the HMAC secret) with the endpoint to deliver to — `https://` is added when the scheme is missing */
|
|
11
|
+
activate(params: {
|
|
12
|
+
endpoint: string;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
/** Change the delivery endpoint */
|
|
15
|
+
updateEndpoint(params: {
|
|
16
|
+
endpoint: string;
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
/** Generate a new secret — read it with `list()` */
|
|
19
|
+
regenerate(): Promise<void>;
|
|
20
|
+
/** The secret, the endpoint and the subscriptions of the organization */
|
|
21
|
+
list(params?: {
|
|
22
|
+
includeArchived?: boolean;
|
|
23
|
+
}): Promise<WebhookSubscriptions>;
|
|
24
|
+
/** Subscribe the organization to an event of the catalogue — by name (`WebhookEventName.CUSTODY_SENT`), by uuid, or as a `WebhookType` of the catalogue (its uuid is sent) */
|
|
25
|
+
subscribe(event: string | WebhookType): Promise<Created>;
|
|
26
|
+
/** Archive a subscription, by uuid or as the `Subscriber` of `list()` */
|
|
27
|
+
archive(subscriber: string | Subscriber): Promise<void>;
|
|
28
|
+
/** Reactivate an archived subscription, by uuid or as the `Subscriber` of `list()` */
|
|
29
|
+
reactivate(subscriber: string | Subscriber): Promise<void>;
|
|
30
|
+
/** Delivery attempts of a subscription, by uuid or as the `Subscriber` of `list()` */
|
|
31
|
+
logs(subscriber: string | Subscriber, params?: PageParams): Promise<Page<DeliveryLog>>;
|
|
32
|
+
/** The catalogue of events, all states */
|
|
33
|
+
catalog(): Promise<Page<WebhookType>>;
|
|
34
|
+
/** One event of the catalogue, by uuid or by model */
|
|
35
|
+
catalogItem(webhook: string | WebhookType): Promise<WebhookType>;
|
|
36
|
+
/**
|
|
37
|
+
* Verify a delivery received by your endpoint and return its envelope. Recomputes
|
|
38
|
+
* `HMAC_SHA256(secret, "<timestamp>.<rawBody>")` on the raw bytes, compares it with
|
|
39
|
+
* `X-BITGEN-Signature` in constant time, checks `X-BITGEN-Timestamp` against `tolerance`, then
|
|
40
|
+
* parses the JSON. Rejects with `BitgenError { status: 0, code }` — `missing_signature`,
|
|
41
|
+
* `invalid_signature`, `missing_timestamp`, `timestamp_expired`, `invalid_payload`.
|
|
42
|
+
*/
|
|
43
|
+
verify(input: VerifyInput): Promise<WebhookEvent>;
|
|
44
|
+
private organization;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=webhooks.d.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AAC,CAAC;IAIhG,0CAA0C;IACpC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAI3C,sDAAsD;IAChD,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAItE;;;;;;OAMG;IAEG,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAIvD,OAAO,CAAC,YAAY;CAGrB"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebhooksResource = void 0;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
const error_js_1 = require("../error.js");
|
|
6
|
+
const utils_js_1 = require("../utils.js");
|
|
7
|
+
/** Default freshness window of `verify`, in seconds */
|
|
8
|
+
const DEFAULT_TOLERANCE = 300;
|
|
9
|
+
/**
|
|
10
|
+
* `/webhook`, `/webhooks` — permissions `webhooks.admin`, `webhooks.write`, `webhooks.read`, `webhook.read`.
|
|
11
|
+
* Wherever the API expects `{organization}`, the SDK sends the key's scope.
|
|
12
|
+
*/
|
|
13
|
+
class WebhooksResource {
|
|
14
|
+
http;
|
|
15
|
+
constructor(http) {
|
|
16
|
+
this.http = http;
|
|
17
|
+
}
|
|
18
|
+
/** Activate the security (generates the HMAC secret) with the endpoint to deliver to — `https://` is added when the scheme is missing */
|
|
19
|
+
async activate(params) {
|
|
20
|
+
await this.http.post(`/webhook/security/${this.organization()}/activate`, { endpoint: params.endpoint });
|
|
21
|
+
}
|
|
22
|
+
/** Change the delivery endpoint */
|
|
23
|
+
async updateEndpoint(params) {
|
|
24
|
+
await this.http.patch(`/webhook/security/${this.organization()}`, { endpoint: params.endpoint });
|
|
25
|
+
}
|
|
26
|
+
/** Generate a new secret — read it with `list()` */
|
|
27
|
+
async regenerate() {
|
|
28
|
+
await this.http.patch(`/webhook/security/${this.organization()}/regenerate`);
|
|
29
|
+
}
|
|
30
|
+
/** The secret, the endpoint and the subscriptions of the organization */
|
|
31
|
+
async list(params = {}) {
|
|
32
|
+
return await this.http.get(`/webhooks/${this.organization()}`, { ...params });
|
|
33
|
+
}
|
|
34
|
+
/** Subscribe the organization to an event of the catalogue — by name (`WebhookEventName.CUSTODY_SENT`), by uuid, or as a `WebhookType` of the catalogue (its uuid is sent) */
|
|
35
|
+
async subscribe(event) {
|
|
36
|
+
return await this.http.post('/webhooks', { organization: this.http.scope, event: (0, utils_js_1.idOf)(event, 'event') });
|
|
37
|
+
}
|
|
38
|
+
/** Archive a subscription, by uuid or as the `Subscriber` of `list()` */
|
|
39
|
+
async archive(subscriber) {
|
|
40
|
+
await this.http.delete(`/webhooks/${(0, utils_js_1.pathSegment)((0, utils_js_1.idOf)(subscriber, 'subscriber'), 'subscriber')}`);
|
|
41
|
+
}
|
|
42
|
+
/** Reactivate an archived subscription, by uuid or as the `Subscriber` of `list()` */
|
|
43
|
+
async reactivate(subscriber) {
|
|
44
|
+
await this.http.post(`/webhooks/${(0, utils_js_1.pathSegment)((0, utils_js_1.idOf)(subscriber, 'subscriber'), 'subscriber')}`);
|
|
45
|
+
}
|
|
46
|
+
/** Delivery attempts of a subscription, by uuid or as the `Subscriber` of `list()` */
|
|
47
|
+
async logs(subscriber, params = {}) {
|
|
48
|
+
return await this.http.get(`/webhooks/${(0, utils_js_1.pathSegment)((0, utils_js_1.idOf)(subscriber, 'subscriber'), 'subscriber')}/logs`, { ...params });
|
|
49
|
+
}
|
|
50
|
+
/** The catalogue of events, all states */
|
|
51
|
+
async catalog() {
|
|
52
|
+
return await this.http.get('/webhook');
|
|
53
|
+
}
|
|
54
|
+
/** One event of the catalogue, by uuid or by model */
|
|
55
|
+
async catalogItem(webhook) {
|
|
56
|
+
return await this.http.get(`/webhook/${(0, utils_js_1.pathSegment)((0, utils_js_1.idOf)(webhook, 'webhook'), 'webhook')}`);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Verify a delivery received by your endpoint and return its envelope. Recomputes
|
|
60
|
+
* `HMAC_SHA256(secret, "<timestamp>.<rawBody>")` on the raw bytes, compares it with
|
|
61
|
+
* `X-BITGEN-Signature` in constant time, checks `X-BITGEN-Timestamp` against `tolerance`, then
|
|
62
|
+
* parses the JSON. Rejects with `BitgenError { status: 0, code }` — `missing_signature`,
|
|
63
|
+
* `invalid_signature`, `missing_timestamp`, `timestamp_expired`, `invalid_payload`.
|
|
64
|
+
*/
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- same rejection channel as every method, the work itself is synchronous
|
|
66
|
+
async verify(input) {
|
|
67
|
+
return verifyDelivery(input);
|
|
68
|
+
}
|
|
69
|
+
organization() {
|
|
70
|
+
return (0, utils_js_1.pathSegment)(this.http.scope, 'scope');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.WebhooksResource = WebhooksResource;
|
|
74
|
+
function verifyDelivery(input) {
|
|
75
|
+
if (typeof input.rawBody !== 'string' && !(input.rawBody instanceof Uint8Array)) {
|
|
76
|
+
throw new TypeError('rawBody must be the received bytes: a string or a Uint8Array (Buffer)');
|
|
77
|
+
}
|
|
78
|
+
if (typeof input.headers !== 'object' || input.headers === null) {
|
|
79
|
+
throw new TypeError('headers must be an object of the received headers');
|
|
80
|
+
}
|
|
81
|
+
if (typeof input.secret !== 'string' || input.secret === '') {
|
|
82
|
+
throw new TypeError('secret must be a non-empty string');
|
|
83
|
+
}
|
|
84
|
+
const tolerance = input.tolerance ?? DEFAULT_TOLERANCE;
|
|
85
|
+
if (typeof tolerance !== 'number' || !Number.isFinite(tolerance) || tolerance < 0) {
|
|
86
|
+
throw new TypeError('tolerance must be a number of seconds >= 0');
|
|
87
|
+
}
|
|
88
|
+
const signature = header(input.headers, 'x-bitgen-signature');
|
|
89
|
+
if (signature === undefined || signature === '') {
|
|
90
|
+
throw fail('missing_signature');
|
|
91
|
+
}
|
|
92
|
+
const timestamp = header(input.headers, 'x-bitgen-timestamp');
|
|
93
|
+
if (timestamp === undefined || timestamp === '') {
|
|
94
|
+
throw fail('missing_timestamp');
|
|
95
|
+
}
|
|
96
|
+
// Signature first: nothing else is trusted before it matches
|
|
97
|
+
const body = typeof input.rawBody === 'string' ? Buffer.from(input.rawBody, 'utf8') : Buffer.from(input.rawBody);
|
|
98
|
+
const expected = Buffer.from(`sha256=${(0, node_crypto_1.createHmac)('sha256', input.secret).update(`${timestamp}.`).update(body).digest('hex')}`);
|
|
99
|
+
const given = Buffer.from(signature.trim().toLowerCase());
|
|
100
|
+
if (given.length !== expected.length || !(0, node_crypto_1.timingSafeEqual)(given, expected)) {
|
|
101
|
+
throw fail('invalid_signature');
|
|
102
|
+
}
|
|
103
|
+
const issuedAt = Number(timestamp);
|
|
104
|
+
if (!Number.isFinite(issuedAt)) {
|
|
105
|
+
throw fail('missing_timestamp');
|
|
106
|
+
}
|
|
107
|
+
if (tolerance > 0 && Math.abs(Date.now() / 1000 - issuedAt) > tolerance) {
|
|
108
|
+
throw fail('timestamp_expired');
|
|
109
|
+
}
|
|
110
|
+
return parseEnvelope(body);
|
|
111
|
+
}
|
|
112
|
+
/** Case-insensitive header lookup; a multi-valued header keeps its first value */
|
|
113
|
+
function header(headers, name) {
|
|
114
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
115
|
+
if (key.toLowerCase() === name) {
|
|
116
|
+
return Array.isArray(value) ? value[0] : value;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
function parseEnvelope(body) {
|
|
122
|
+
let data;
|
|
123
|
+
try {
|
|
124
|
+
data = JSON.parse(body.toString('utf8'));
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
throw fail('invalid_payload');
|
|
128
|
+
}
|
|
129
|
+
if (typeof data !== 'object' || data === null ||
|
|
130
|
+
typeof data.delivery_id !== 'string' ||
|
|
131
|
+
typeof data.timestamp !== 'number' ||
|
|
132
|
+
typeof data.event !== 'string' ||
|
|
133
|
+
!('data' in data)) {
|
|
134
|
+
throw fail('invalid_payload');
|
|
135
|
+
}
|
|
136
|
+
return data;
|
|
137
|
+
}
|
|
138
|
+
/** Verification failure — no HTTP status, and never the secret in the message */
|
|
139
|
+
function fail(code) {
|
|
140
|
+
return new error_js_1.BitgenError(0, { error: true, message: code, code: 0 });
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=webhooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../../src/resources/webhooks.ts"],"names":[],"mappings":";;;AAAA,6CAAyD;AACzD,0CAAyC;AAazC,0CAA+C;AAE/C,uDAAuD;AACvD,MAAM,iBAAiB,GAAG,GAAG,CAAA;AAE7B;;;GAGG;AACH,MAAa,gBAAgB;IACE;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,yIAAyI;IACzI,KAAK,CAAC,QAAQ,CAAC,MAA4B;QACzC,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,qBAAqB,IAAI,CAAC,YAAY,EAAE,WAAW,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC1G,CAAC;IAED,mCAAmC;IACnC,KAAK,CAAC,cAAc,CAAC,MAA4B;QAC/C,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,qBAAqB,IAAI,CAAC,YAAY,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAA;IAClG,CAAC;IAED,oDAAoD;IACpD,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,qBAAqB,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,CAAA;IAC9E,CAAC;IAED,yEAAyE;IACzE,KAAK,CAAC,IAAI,CAAC,SAAwC,EAAE;QACnD,O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AAI,CAAC,EACjB,CAAC;QACD,MAAM,IAAI,CAAC,iBAAiB,CAAC,CAAA;IAC/B,CAAC;IACD,OAAO,IAAoB,CAAA;AAC7B,CAAC;AAED,iFAAiF;AACjF,SAAS,IAAI,CAAC,IAAY;IACxB,OAAO,IAAI,sBAAW,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAA;AACpE,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export type { ApikeyState } from '../constants.js';
|
|
2
|
+
import type { ApikeyState } from '../constants.js';
|
|
3
|
+
export interface Apikey {
|
|
4
|
+
uuid: string;
|
|
5
|
+
state: ApikeyState;
|
|
6
|
+
name: string;
|
|
7
|
+
permissions: string[];
|
|
8
|
+
expireAt: number;
|
|
9
|
+
createdAt: number;
|
|
10
|
+
organization: {
|
|
11
|
+
uuid: string;
|
|
12
|
+
state: string;
|
|
13
|
+
name: string;
|
|
14
|
+
hub: {
|
|
15
|
+
uuid: string;
|
|
16
|
+
state: string;
|
|
17
|
+
name: string;
|
|
18
|
+
options: Record<string, unknown>;
|
|
19
|
+
} | null;
|
|
20
|
+
owner: {
|
|
21
|
+
uuid: string;
|
|
22
|
+
login: string;
|
|
23
|
+
firstname: string;
|
|
24
|
+
lastname: string | null;
|
|
25
|
+
} | null;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** One call made with the key (`GET …/apikeys/{apikey}/logs`) */
|
|
29
|
+
export interface ApikeyLog {
|
|
30
|
+
date: number;
|
|
31
|
+
/** `"GET /custody/…"` */
|
|
32
|
+
path: string;
|
|
33
|
+
/** JSON of the inputs, PII masked */
|
|
34
|
+
payload: string;
|
|
35
|
+
status: number;
|
|
36
|
+
error: string | null;
|
|
37
|
+
}
|
|
38
|
+
export interface ApikeyListParams {
|
|
39
|
+
offset?: number;
|
|
40
|
+
limit?: number;
|
|
41
|
+
includeRevoked?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gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apikeys.js","sourceRoot":"","sources":["../../../src/types/apikeys.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { History } from './index.js';
|
|
2
|
+
export type { AssetState } from '../constants.js';
|
|
3
|
+
import type { AssetState } from '../constants.js';
|
|
4
|
+
export interface AssetTicker {
|
|
5
|
+
price: number;
|
|
6
|
+
marketcap: number;
|
|
7
|
+
rank: number;
|
|
8
|
+
percentChange24h: number;
|
|
9
|
+
}
|
|
10
|
+
export interface AssetFees {
|
|
11
|
+
/** Raw fee schedule of the gas provider, opaque */
|
|
12
|
+
low: unknown;
|
|
13
|
+
medium: unknown;
|
|
14
|
+
high: unknown;
|
|
15
|
+
computed: {
|
|
16
|
+
gas: string;
|
|
17
|
+
native: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface AssetNetworkType {
|
|
21
|
+
uuid: string;
|
|
22
|
+
code: string;
|
|
23
|
+
label: string;
|
|
24
|
+
/** Raw JSON, not parsed */
|
|
25
|
+
data: string;
|
|
26
|
+
}
|
|
27
|
+
export interface AssetNetwork {
|
|
28
|
+
uuid: string;
|
|
29
|
+
state: string;
|
|
30
|
+
caip2: string;
|
|
31
|
+
label: string;
|
|
32
|
+
gasBase: number;
|
|
33
|
+
/** Raw JSON, not parsed */
|
|
34
|
+
data: string;
|
|
35
|
+
type: AssetNetworkType;
|
|
36
|
+
}
|
|
37
|
+
export interface Asset {
|
|
38
|
+
uuid: string;
|
|
39
|
+
state: AssetState;
|
|
40
|
+
/** ISO code as stored by the API (`BTC`, `ETH` today) — compare case-insensitively */
|
|
41
|
+
iso: string;
|
|
42
|
+
label: string;
|
|
43
|
+
/** `''` for a native asset, never null */
|
|
44
|
+
contractAddress: string;
|
|
45
|
+
/** Decimals of the asset (default 18, max 24) */
|
|
46
|
+
baseUnit: number;
|
|
47
|
+
gasUnit: number;
|
|
48
|
+
logo: string | null;
|
|
49
|
+
/** Raw JSON, not parsed */
|
|
50
|
+
data: string;
|
|
51
|
+
fees: AssetFees;
|
|
52
|
+
ticker: AssetTicker;
|
|
53
|
+
/** EUR price */
|
|
54
|
+
history: History;
|
|
55
|
+
network: AssetNetwork;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=asset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset.d.ts","sourceRoot":"","sources":["../../../src/types/asset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEzC,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,gBAAgB,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,WAAW,SAAS;IACxB,mDAAmD;IACnD,GAAG,EAAE,OAAO,CAAA;IACZ,MAAM,EAAE,OAAO,CAAA;IACf,IAAI,EAAE,OAAO,CAAA;IACb,QAAQ,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAC1C;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,gBAAgB,CAAA;CACvB;AAED,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,UAAU,CAAA;IACjB,sFAAsF;IACtF,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,0CAA0C;IAC1C,eAAe,EAAE,MAAM,CAAA;IACvB,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,SAAS,CAAA;IACf,MAAM,EAAE,WAAW,CAAA;IACnB,gBAAgB;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,YAAY,CAAA;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset.js","sourceRoot":"","sources":["../../../src/types/asset.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Amount, History, UserRef } from './index.js';
|
|
2
|
+
export type { BankDirection } from '../constants.js';
|
|
3
|
+
import type { BankDirection } from '../constants.js';
|
|
4
|
+
/** EUR ledger of a customer — created on the first `GET /bank/{user}` */
|
|
5
|
+
export interface BankAccount {
|
|
6
|
+
uuid: string;
|
|
7
|
+
/** Wire transfer reference the customer must indicate (`BTGN` prefix) */
|
|
8
|
+
message: string;
|
|
9
|
+
iban: string | null;
|
|
10
|
+
bank: string | null;
|
|
11
|
+
bic: string | null;
|
|
12
|
+
/** EUR */
|
|
13
|
+
balance: number;
|
|
14
|
+
/** EUR balance curve, materialized by an hourly cron: `{}` until it has run for this account */
|
|
15
|
+
history: History | Record<string, never>;
|
|
16
|
+
/** EUR pending: incoming not credited yet / outgoing not confirmed yet */
|
|
17
|
+
pending: {
|
|
18
|
+
in: number;
|
|
19
|
+
out: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface BankOperation {
|
|
23
|
+
txId: string;
|
|
24
|
+
/** EUR */
|
|
25
|
+
amount: number;
|
|
26
|
+
/** One kind of operation — never the `ALL` of the filter */
|
|
27
|
+
direction: Exclude<BankDirection, typeof BankDirection.ALL>;
|
|
28
|
+
date: number;
|
|
29
|
+
info: string | null;
|
|
30
|
+
}
|
|
31
|
+
export interface BankOperationsParams {
|
|
32
|
+
/** Default `ALL` */
|
|
33
|
+
direction?: BankDirection;
|
|
34
|
+
/** Epoch seconds — `from` and `to` go together, otherwise ignored */
|
|
35
|
+
from?: number;
|
|
36
|
+
to?: number;
|
|
37
|
+
offset?: number;
|
|
38
|
+
limit?: number;
|
|
39
|
+
}
|
|
40
|
+
export interface BankWithdrawParams {
|
|
41
|
+
/** EUR, rounded to 2 decimals */
|
|
42
|
+
amount: Amount;
|
|
43
|
+
/** `iban` / `bank` / `bic` update the customer's bank details before the withdrawal */
|
|
44
|
+
iban?: string;
|
|
45
|
+
bank?: string;
|
|
46
|
+
bic?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface BankCreditParams {
|
|
49
|
+
amount: Amount;
|
|
50
|
+
currency?: 'EUR';
|
|
51
|
+
/** Target customer — or `message`, one of the two is required */
|
|
52
|
+
user?: UserRef;
|
|
53
|
+
/** Wire reference (`BTGN…`), alternative to `user` */
|
|
54
|
+
message?: string;
|
|
55
|
+
/** Idempotency key: replaying returns the same uuid */
|
|
56
|
+
reference?: string;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=bank.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bank.d.ts","sourceRoot":"","sources":["../../../src/types/bank.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,E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IACvF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,iEAAiE;IACjE,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bank.js","sourceRoot":"","sources":["../../../src/types/bank.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AssetInput, AssetRef } from './index.js';
|
|
2
|
+
export type { CoreType, CoreState } from '../constants.js';
|
|
3
|
+
import type { CoreType, CoreState } from '../constants.js';
|
|
4
|
+
/** One field of a connector's configuration schema — secrets live in the organization's configuration, never here */
|
|
5
|
+
export interface CoreConfigField {
|
|
6
|
+
name: string;
|
|
7
|
+
label: Record<string, string>;
|
|
8
|
+
data: {
|
|
9
|
+
type: string;
|
|
10
|
+
value: unknown;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/** Platform connector: bank (`RAMP`), exchange (`TRADING`), custodian (`CUSTODY`), staking provider… */
|
|
14
|
+
export interface Core {
|
|
15
|
+
uuid: string;
|
|
16
|
+
state: CoreState;
|
|
17
|
+
/** Connector identifier; for a `STAKING` core: `<provider>_<iso>` (`bitgen_eth`, `figment_sol`) */
|
|
18
|
+
name: string;
|
|
19
|
+
label: string;
|
|
20
|
+
type: CoreType;
|
|
21
|
+
/** Derived from the `name` suffix — null outside `STAKING` */
|
|
22
|
+
asset: AssetRef | null;
|
|
23
|
+
config: CoreConfigField[];
|
|
24
|
+
}
|
|
25
|
+
/** All optional, combinable — the list is not paginated */
|
|
26
|
+
export interface CoreListParams {
|
|
27
|
+
type?: CoreType;
|
|
28
|
+
/** Only the cores attached to this asset (the `STAKING` ones): uuid or ISO code, or an `Asset` / `AssetRef` model (its uuid is sent) */
|
|
29
|
+
asset?: AssetInput;
|
|
30
|
+
state?: CoreState;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../src/types/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEtD,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE1D,qHAAqH;AACrH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7B,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAA;CACvC;AAED,wGAAwG;AACxG,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,SAAS,CAAA;IAChB,mGAAmG;IACnG,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,QAAQ,CAAA;IACd,8DAA8D;IAC9D,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAA;IACtB,MAAM,EAAE,eAAe,EAAE,CAAA;CAC1B;AAED,2DAA2D;AAC3D,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,wIAAwI;IACxI,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/types/core.ts"],"names":[],"mappings":""}
|