@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,169 @@
|
|
|
1
|
+
import { createHmac, timingSafeEqual } from 'node:crypto'
|
|
2
|
+
import { BitgenError } from '../error.js'
|
|
3
|
+
import type { HttpClient } from '../http.js'
|
|
4
|
+
import type {
|
|
5
|
+
Created,
|
|
6
|
+
DeliveryLog,
|
|
7
|
+
Page,
|
|
8
|
+
PageParams,
|
|
9
|
+
Subscriber,
|
|
10
|
+
VerifyInput,
|
|
11
|
+
WebhookEvent,
|
|
12
|
+
WebhookSubscriptions,
|
|
13
|
+
WebhookType,
|
|
14
|
+
} from '../types/index.js'
|
|
15
|
+
import { idOf, pathSegment } from '../utils.js'
|
|
16
|
+
|
|
17
|
+
/** Default freshness window of `verify`, in seconds */
|
|
18
|
+
const DEFAULT_TOLERANCE = 300
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* `/webhook`, `/webhooks` — permissions `webhooks.admin`, `webhooks.write`, `webhooks.read`, `webhook.read`.
|
|
22
|
+
* Wherever the API expects `{organization}`, the SDK sends the key's scope.
|
|
23
|
+
*/
|
|
24
|
+
export class WebhooksResource {
|
|
25
|
+
constructor(private readonly http: HttpClient) {}
|
|
26
|
+
|
|
27
|
+
/** Activate the security (generates the HMAC secret) with the endpoint to deliver to — `https://` is added when the scheme is missing */
|
|
28
|
+
async activate(params: { endpoint: string }): Promise<void> {
|
|
29
|
+
await this.http.post(`/webhook/security/${this.organization()}/activate`, { endpoint: params.endpoint })
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Change the delivery endpoint */
|
|
33
|
+
async updateEndpoint(params: { endpoint: string }): Promise<void> {
|
|
34
|
+
await this.http.patch(`/webhook/security/${this.organization()}`, { endpoint: params.endpoint })
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Generate a new secret — read it with `list()` */
|
|
38
|
+
async regenerate(): Promise<void> {
|
|
39
|
+
await this.http.patch(`/webhook/security/${this.organization()}/regenerate`)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The secret, the endpoint and the subscriptions of the organization */
|
|
43
|
+
async list(params: { includeArchived?: boolean } = {}): Promise<WebhookSubscriptions> {
|
|
44
|
+
return await this.http.get(`/webhooks/${this.organization()}`, { ...params })
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** 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) */
|
|
48
|
+
async subscribe(event: string | WebhookType): Promise<Created> {
|
|
49
|
+
return await this.http.post('/webhooks', { organization: this.http.scope, event: idOf(event, 'event') })
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Archive a subscription, by uuid or as the `Subscriber` of `list()` */
|
|
53
|
+
async archive(subscriber: string | Subscriber): Promise<void> {
|
|
54
|
+
await this.http.delete(`/webhooks/${pathSegment(idOf(subscriber, 'subscriber'), 'subscriber')}`)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Reactivate an archived subscription, by uuid or as the `Subscriber` of `list()` */
|
|
58
|
+
async reactivate(subscriber: string | Subscriber): Promise<void> {
|
|
59
|
+
await this.http.post(`/webhooks/${pathSegment(idOf(subscriber, 'subscriber'), 'subscriber')}`)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Delivery attempts of a subscription, by uuid or as the `Subscriber` of `list()` */
|
|
63
|
+
async logs(subscriber: string | Subscriber, params: PageParams = {}): Promise<Page<DeliveryLog>> {
|
|
64
|
+
return await this.http.get(`/webhooks/${pathSegment(idOf(subscriber, 'subscriber'), 'subscriber')}/logs`, { ...params })
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** The catalogue of events, all states */
|
|
68
|
+
async catalog(): Promise<Page<WebhookType>> {
|
|
69
|
+
return await this.http.get('/webhook')
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** One event of the catalogue, by uuid or by model */
|
|
73
|
+
async catalogItem(webhook: string | WebhookType): Promise<WebhookType> {
|
|
74
|
+
return await this.http.get(`/webhook/${pathSegment(idOf(webhook, 'webhook'), 'webhook')}`)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Verify a delivery received by your endpoint and return its envelope. Recomputes
|
|
79
|
+
* `HMAC_SHA256(secret, "<timestamp>.<rawBody>")` on the raw bytes, compares it with
|
|
80
|
+
* `X-BITGEN-Signature` in constant time, checks `X-BITGEN-Timestamp` against `tolerance`, then
|
|
81
|
+
* parses the JSON. Rejects with `BitgenError { status: 0, code }` — `missing_signature`,
|
|
82
|
+
* `invalid_signature`, `missing_timestamp`, `timestamp_expired`, `invalid_payload`.
|
|
83
|
+
*/
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- same rejection channel as every method, the work itself is synchronous
|
|
85
|
+
async verify(input: VerifyInput): Promise<WebhookEvent> {
|
|
86
|
+
return verifyDelivery(input)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private organization(): string {
|
|
90
|
+
return pathSegment(this.http.scope, 'scope')
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function verifyDelivery(input: VerifyInput): WebhookEvent {
|
|
95
|
+
if (typeof input.rawBody !== 'string' && !(input.rawBody instanceof Uint8Array)) {
|
|
96
|
+
throw new TypeError('rawBody must be the received bytes: a string or a Uint8Array (Buffer)')
|
|
97
|
+
}
|
|
98
|
+
if (typeof input.headers !== 'object' || input.headers === null) {
|
|
99
|
+
throw new TypeError('headers must be an object of the received headers')
|
|
100
|
+
}
|
|
101
|
+
if (typeof input.secret !== 'string' || input.secret === '') {
|
|
102
|
+
throw new TypeError('secret must be a non-empty string')
|
|
103
|
+
}
|
|
104
|
+
const tolerance = input.tolerance ?? DEFAULT_TOLERANCE
|
|
105
|
+
if (typeof tolerance !== 'number' || !Number.isFinite(tolerance) || tolerance < 0) {
|
|
106
|
+
throw new TypeError('tolerance must be a number of seconds >= 0')
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const signature = header(input.headers, 'x-bitgen-signature')
|
|
110
|
+
if (signature === undefined || signature === '') {
|
|
111
|
+
throw fail('missing_signature')
|
|
112
|
+
}
|
|
113
|
+
const timestamp = header(input.headers, 'x-bitgen-timestamp')
|
|
114
|
+
if (timestamp === undefined || timestamp === '') {
|
|
115
|
+
throw fail('missing_timestamp')
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Signature first: nothing else is trusted before it matches
|
|
119
|
+
const body = typeof input.rawBody === 'string' ? Buffer.from(input.rawBody, 'utf8') : Buffer.from(input.rawBody)
|
|
120
|
+
const expected = Buffer.from(`sha256=${createHmac('sha256', input.secret).update(`${timestamp}.`).update(body).digest('hex')}`)
|
|
121
|
+
const given = Buffer.from(signature.trim().toLowerCase())
|
|
122
|
+
if (given.length !== expected.length || !timingSafeEqual(given, expected)) {
|
|
123
|
+
throw fail('invalid_signature')
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const issuedAt = Number(timestamp)
|
|
127
|
+
if (!Number.isFinite(issuedAt)) {
|
|
128
|
+
throw fail('missing_timestamp')
|
|
129
|
+
}
|
|
130
|
+
if (tolerance > 0 && Math.abs(Date.now() / 1000 - issuedAt) > tolerance) {
|
|
131
|
+
throw fail('timestamp_expired')
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return parseEnvelope(body)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Case-insensitive header lookup; a multi-valued header keeps its first value */
|
|
138
|
+
function header(headers: VerifyInput['headers'], name: string): string | undefined {
|
|
139
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
140
|
+
if (key.toLowerCase() === name) {
|
|
141
|
+
return Array.isArray(value) ? value[0] : value
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return undefined
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function parseEnvelope(body: Buffer): WebhookEvent {
|
|
148
|
+
let data: unknown
|
|
149
|
+
try {
|
|
150
|
+
data = JSON.parse(body.toString('utf8'))
|
|
151
|
+
} catch {
|
|
152
|
+
throw fail('invalid_payload')
|
|
153
|
+
}
|
|
154
|
+
if (
|
|
155
|
+
typeof data !== 'object' || data === null ||
|
|
156
|
+
typeof (data as { delivery_id?: unknown }).delivery_id !== 'string' ||
|
|
157
|
+
typeof (data as { timestamp?: unknown }).timestamp !== 'number' ||
|
|
158
|
+
typeof (data as { event?: unknown }).event !== 'string' ||
|
|
159
|
+
!('data' in data)
|
|
160
|
+
) {
|
|
161
|
+
throw fail('invalid_payload')
|
|
162
|
+
}
|
|
163
|
+
return data as WebhookEvent
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Verification failure — no HTTP status, and never the secret in the message */
|
|
167
|
+
function fail(code: string): BitgenError {
|
|
168
|
+
return new BitgenError(0, { error: true, message: code, code: 0 })
|
|
169
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type { ApikeyState } from '../constants.js'
|
|
2
|
+
import type { ApikeyState } from '../constants.js'
|
|
3
|
+
|
|
4
|
+
export interface Apikey {
|
|
5
|
+
uuid: string
|
|
6
|
+
state: ApikeyState
|
|
7
|
+
name: string
|
|
8
|
+
permissions: string[]
|
|
9
|
+
expireAt: number
|
|
10
|
+
createdAt: number
|
|
11
|
+
organization: {
|
|
12
|
+
uuid: string
|
|
13
|
+
state: string
|
|
14
|
+
name: string
|
|
15
|
+
hub: { uuid: string, state: string, name: string, options: Record<string, unknown> } | null
|
|
16
|
+
owner: { uuid: string, login: string, firstname: string, lastname: string | null } | null
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** One call made with the key (`GET …/apikeys/{apikey}/logs`) */
|
|
21
|
+
export interface ApikeyLog {
|
|
22
|
+
date: number
|
|
23
|
+
/** `"GET /custody/…"` */
|
|
24
|
+
path: string
|
|
25
|
+
/** JSON of the inputs, PII masked */
|
|
26
|
+
payload: string
|
|
27
|
+
status: number
|
|
28
|
+
error: string | null
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface ApikeyListParams {
|
|
32
|
+
offset?: number
|
|
33
|
+
limit?: number
|
|
34
|
+
includeRevoked?: boolean
|
|
35
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { History } from './index.js'
|
|
2
|
+
|
|
3
|
+
export type { AssetState } from '../constants.js'
|
|
4
|
+
import type { AssetState } from '../constants.js'
|
|
5
|
+
|
|
6
|
+
export interface AssetTicker {
|
|
7
|
+
price: number
|
|
8
|
+
marketcap: number
|
|
9
|
+
rank: number
|
|
10
|
+
percentChange24h: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface AssetFees {
|
|
14
|
+
/** Raw fee schedule of the gas provider, opaque */
|
|
15
|
+
low: unknown
|
|
16
|
+
medium: unknown
|
|
17
|
+
high: unknown
|
|
18
|
+
computed: { gas: string, native: string }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface AssetNetworkType {
|
|
22
|
+
uuid: string
|
|
23
|
+
code: string
|
|
24
|
+
label: string
|
|
25
|
+
/** Raw JSON, not parsed */
|
|
26
|
+
data: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface AssetNetwork {
|
|
30
|
+
uuid: string
|
|
31
|
+
state: string
|
|
32
|
+
caip2: string
|
|
33
|
+
label: string
|
|
34
|
+
gasBase: number
|
|
35
|
+
/** Raw JSON, not parsed */
|
|
36
|
+
data: string
|
|
37
|
+
type: AssetNetworkType
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface Asset {
|
|
41
|
+
uuid: string
|
|
42
|
+
state: AssetState
|
|
43
|
+
/** ISO code as stored by the API (`BTC`, `ETH` today) — compare case-insensitively */
|
|
44
|
+
iso: string
|
|
45
|
+
label: string
|
|
46
|
+
/** `''` for a native asset, never null */
|
|
47
|
+
contractAddress: string
|
|
48
|
+
/** Decimals of the asset (default 18, max 24) */
|
|
49
|
+
baseUnit: number
|
|
50
|
+
gasUnit: number
|
|
51
|
+
logo: string | null
|
|
52
|
+
/** Raw JSON, not parsed */
|
|
53
|
+
data: string
|
|
54
|
+
fees: AssetFees
|
|
55
|
+
ticker: AssetTicker
|
|
56
|
+
/** EUR price */
|
|
57
|
+
history: History
|
|
58
|
+
network: AssetNetwork
|
|
59
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Amount, History, UserRef } from './index.js'
|
|
2
|
+
|
|
3
|
+
export type { BankDirection } from '../constants.js'
|
|
4
|
+
import type { BankDirection } from '../constants.js'
|
|
5
|
+
|
|
6
|
+
/** EUR ledger of a customer — created on the first `GET /bank/{user}` */
|
|
7
|
+
export interface BankAccount {
|
|
8
|
+
uuid: string
|
|
9
|
+
/** Wire transfer reference the customer must indicate (`BTGN` prefix) */
|
|
10
|
+
message: string
|
|
11
|
+
iban: string | null
|
|
12
|
+
bank: string | null
|
|
13
|
+
bic: string | null
|
|
14
|
+
/** EUR */
|
|
15
|
+
balance: number
|
|
16
|
+
/** EUR balance curve, materialized by an hourly cron: `{}` until it has run for this account */
|
|
17
|
+
history: History | Record<string, never>
|
|
18
|
+
/** EUR pending: incoming not credited yet / outgoing not confirmed yet */
|
|
19
|
+
pending: { in: number, 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
|
+
|
|
32
|
+
export interface BankOperationsParams {
|
|
33
|
+
/** Default `ALL` */
|
|
34
|
+
direction?: BankDirection
|
|
35
|
+
/** Epoch seconds — `from` and `to` go together, otherwise ignored */
|
|
36
|
+
from?: number
|
|
37
|
+
to?: number
|
|
38
|
+
offset?: number
|
|
39
|
+
limit?: number
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface BankWithdrawParams {
|
|
43
|
+
/** EUR, rounded to 2 decimals */
|
|
44
|
+
amount: Amount
|
|
45
|
+
/** `iban` / `bank` / `bic` update the customer's bank details before the withdrawal */
|
|
46
|
+
iban?: string
|
|
47
|
+
bank?: string
|
|
48
|
+
bic?: string
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface BankCreditParams {
|
|
52
|
+
amount: Amount
|
|
53
|
+
currency?: 'EUR'
|
|
54
|
+
/** Target customer — or `message`, one of the two is required */
|
|
55
|
+
user?: UserRef
|
|
56
|
+
/** Wire reference (`BTGN…`), alternative to `user` */
|
|
57
|
+
message?: string
|
|
58
|
+
/** Idempotency key: replaying returns the same uuid */
|
|
59
|
+
reference?: string
|
|
60
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AssetInput, AssetRef } from './index.js'
|
|
2
|
+
|
|
3
|
+
export type { CoreType, CoreState } from '../constants.js'
|
|
4
|
+
import type { CoreType, CoreState } from '../constants.js'
|
|
5
|
+
|
|
6
|
+
/** One field of a connector's configuration schema — secrets live in the organization's configuration, never here */
|
|
7
|
+
export interface CoreConfigField {
|
|
8
|
+
name: string
|
|
9
|
+
label: Record<string, string>
|
|
10
|
+
data: { type: string, 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
|
+
|
|
26
|
+
/** All optional, combinable — the list is not paginated */
|
|
27
|
+
export interface CoreListParams {
|
|
28
|
+
type?: CoreType
|
|
29
|
+
/** Only the cores attached to this asset (the `STAKING` ones): uuid or ISO code, or an `Asset` / `AssetRef` model (its uuid is sent) */
|
|
30
|
+
asset?: AssetInput
|
|
31
|
+
state?: CoreState
|
|
32
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Amount, AssetInput, AssetRef, History } from './index.js'
|
|
2
|
+
|
|
3
|
+
export type { WalletState, WalletType } from '../constants.js'
|
|
4
|
+
import type { WalletState, WalletType } from '../constants.js'
|
|
5
|
+
|
|
6
|
+
export interface Wallet {
|
|
7
|
+
uuid: string
|
|
8
|
+
state: WalletState
|
|
9
|
+
type: WalletType
|
|
10
|
+
/** Deposit address */
|
|
11
|
+
address: string | null
|
|
12
|
+
addressLegacy: string | null
|
|
13
|
+
/** Memo / tag (XRP, XLM…) */
|
|
14
|
+
tag: string | null
|
|
15
|
+
/** Exact quantity, as a string */
|
|
16
|
+
balance: string
|
|
17
|
+
/** EUR value curve — only on the unit read (`client.custody.wallet`), `{}` on a new wallet until it has been computed */
|
|
18
|
+
history?: History | Record<string, never>
|
|
19
|
+
asset: AssetRef
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** `{ uuid, type, history }` — or a flat `{ history }` at 0 while the customer has no custody */
|
|
23
|
+
export type CustodyPortfolio = { uuid: string, type: WalletType, history: History } | { history: History }
|
|
24
|
+
|
|
25
|
+
/** Exclusive forms — a person, or a platform — each field ≤ 255 characters (validated by the API); mixing them is a type error */
|
|
26
|
+
export type TravelRule =
|
|
27
|
+
| { firstname?: string, lastname?: string, address?: string, platform?: never }
|
|
28
|
+
| { platform: string, firstname?: never, lastname?: never, address?: never }
|
|
29
|
+
|
|
30
|
+
export interface CustodyWithdrawParams {
|
|
31
|
+
/** uuid or ISO code (`Asset.ETH`), or an `Asset` / `AssetRef` model — its uuid is sent */
|
|
32
|
+
asset: AssetInput
|
|
33
|
+
/** Prefer a string: up to 18 decimals, a JavaScript `number` loses precision beyond ~15 significant digits */
|
|
34
|
+
amount: Amount
|
|
35
|
+
targetAddress: string
|
|
36
|
+
targetTag?: string
|
|
37
|
+
/** ≤ 64 characters, unique per customer: replaying returns the same transaction */
|
|
38
|
+
idempotencyKey?: string
|
|
39
|
+
travelRule?: TravelRule
|
|
40
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
export type { Locale, CustomerState, IdentityState, IdentityMode, OrganizationCategory } from '../constants.js'
|
|
2
|
+
import type { Locale, CustomerState, IdentityState, IdentityMode, OrganizationCategory } from '../constants.js'
|
|
3
|
+
|
|
4
|
+
interface IdentityBase {
|
|
5
|
+
uuid: string
|
|
6
|
+
state: IdentityState
|
|
7
|
+
/** Steps: KYC `info`, `selfie`, `identity`, `residency` — KYB `info`, `kbis`, `status`, `domiciliation`, `rbe` */
|
|
8
|
+
data: {
|
|
9
|
+
steps: Record<string, { status: string, submittedAt: number | null }>
|
|
10
|
+
notifications: boolean
|
|
11
|
+
verificationUrl: string | null
|
|
12
|
+
hosted?: boolean
|
|
13
|
+
}
|
|
14
|
+
validatedAt: number | null
|
|
15
|
+
expiresAt: number | null
|
|
16
|
+
renewalNotifiedAt: number | null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** KYC file of an individual */
|
|
20
|
+
export interface KycIdentity extends IdentityBase {
|
|
21
|
+
mode: typeof IdentityMode.KYC
|
|
22
|
+
form: {
|
|
23
|
+
european_residency: unknown
|
|
24
|
+
ppe: unknown
|
|
25
|
+
ppp: unknown
|
|
26
|
+
source_income: string | null
|
|
27
|
+
net_income: string | null
|
|
28
|
+
experience: string | null
|
|
29
|
+
submittedAt: number | null
|
|
30
|
+
score: number
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** KYB file of a business */
|
|
35
|
+
export interface KybIdentity extends IdentityBase {
|
|
36
|
+
mode: typeof IdentityMode.KYB
|
|
37
|
+
form: {
|
|
38
|
+
activity: string | null
|
|
39
|
+
submittedAt: number | null
|
|
40
|
+
score: number
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** KYC or KYB file of a customer — narrow on `mode` to type `form` */
|
|
45
|
+
export type Identity = KycIdentity | KybIdentity
|
|
46
|
+
|
|
47
|
+
export interface CustomerAccount {
|
|
48
|
+
email: string
|
|
49
|
+
firstname: string
|
|
50
|
+
lastname: string | null
|
|
51
|
+
fin: string | null
|
|
52
|
+
birthdate: number | null
|
|
53
|
+
phoneNumber: number | null
|
|
54
|
+
phoneZone: string | null
|
|
55
|
+
address: { uuid: string, state: string, address: string } | null
|
|
56
|
+
referralCode: string
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface CustomerClient {
|
|
60
|
+
roles: string[]
|
|
61
|
+
hasTfa: boolean
|
|
62
|
+
hasPhishing: boolean
|
|
63
|
+
isValid: boolean
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface CustomerSetup {
|
|
67
|
+
theme: string
|
|
68
|
+
currency: 'EUR'
|
|
69
|
+
locale: string
|
|
70
|
+
/** Category chosen at signup (`OrganizationCategory.CUSTOMER`, `B2B`) — a string on the API's side: any other value stays as is */
|
|
71
|
+
choosenOrganization: OrganizationCategory | (string & {})
|
|
72
|
+
/** Activation email pending: the customer is invisible to bank / custody / trading / staking until they activate */
|
|
73
|
+
needActivation: boolean
|
|
74
|
+
notify: boolean
|
|
75
|
+
onboarding?: boolean
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Link between the customer and an organization */
|
|
79
|
+
export interface CollaboratorLink {
|
|
80
|
+
uuid: string
|
|
81
|
+
state: string
|
|
82
|
+
roles: string[]
|
|
83
|
+
/** Organization name */
|
|
84
|
+
organization: string
|
|
85
|
+
organizationUuid: string
|
|
86
|
+
manager: string | null
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Link where this user is the manager — empty for a customer */
|
|
90
|
+
export interface ManagerLink {
|
|
91
|
+
uuid: string
|
|
92
|
+
state: string
|
|
93
|
+
mandate: unknown
|
|
94
|
+
/** `d/m/Y` */
|
|
95
|
+
mandatedUntil: string | null
|
|
96
|
+
/** Email */
|
|
97
|
+
account: string | null
|
|
98
|
+
organizationUuid: string
|
|
99
|
+
roles: string[]
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Active compliance alert */
|
|
103
|
+
export interface CustomerAlert {
|
|
104
|
+
uuid: string
|
|
105
|
+
state: 'OPEN' | 'DECLARATED' | 'CONFIRMED'
|
|
106
|
+
severity: 'SUCCESS' | 'WARNING' | 'CRITICAL'
|
|
107
|
+
sources: Record<string, unknown>
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface CustomerBusiness {
|
|
111
|
+
identity: Identity
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Item of `GET /customer` */
|
|
115
|
+
export interface Customer {
|
|
116
|
+
uuid: string
|
|
117
|
+
state: CustomerState
|
|
118
|
+
isAvailable: boolean
|
|
119
|
+
createdAt: number
|
|
120
|
+
/** = email */
|
|
121
|
+
login: string
|
|
122
|
+
canLogin: boolean
|
|
123
|
+
account: CustomerAccount
|
|
124
|
+
client: CustomerClient
|
|
125
|
+
action: { setup: CustomerSetup }
|
|
126
|
+
identity: Identity
|
|
127
|
+
business: CustomerBusiness[]
|
|
128
|
+
collaborations: {
|
|
129
|
+
collaborator: CollaboratorLink[]
|
|
130
|
+
manager: ManagerLink[]
|
|
131
|
+
}
|
|
132
|
+
alert: CustomerAlert[]
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface AccountAddress {
|
|
136
|
+
uuid: string
|
|
137
|
+
address: string
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** `GET /account/{uuid}` — `account.address` is reduced to `{ uuid, address }` */
|
|
141
|
+
export interface Account {
|
|
142
|
+
uuid: string
|
|
143
|
+
identity: Identity
|
|
144
|
+
business: CustomerBusiness[]
|
|
145
|
+
account: Omit<CustomerAccount, 'address'> & { address: AccountAddress | null }
|
|
146
|
+
notifications: { login: boolean, newsletter: boolean }
|
|
147
|
+
setup: CustomerSetup
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// ─── Parameters ───────────────────────────────────────────────────────────────
|
|
151
|
+
|
|
152
|
+
export interface CreateCustomerParams {
|
|
153
|
+
account: {
|
|
154
|
+
email: string
|
|
155
|
+
firstname?: string
|
|
156
|
+
lastname?: string
|
|
157
|
+
/** Tax identification number, 100 characters max */
|
|
158
|
+
fin?: string
|
|
159
|
+
/**
|
|
160
|
+
* Default `true`: BITGEN emails the customer an activation link and the account stays `CREATED` (no financial
|
|
161
|
+
* route accepts it) until they activate. `false`: usable right away, BITGEN sends no email — for an organization
|
|
162
|
+
* that handles activation and notifications with its own system, or through webhooks.
|
|
163
|
+
*/
|
|
164
|
+
needActivation?: boolean
|
|
165
|
+
/** Default `true`: the customer receives BITGEN's emails (newsletter). `false`: none */
|
|
166
|
+
notify?: boolean
|
|
167
|
+
}
|
|
168
|
+
/** `manager` = uuid of the collaborator of the organization who follows this customer — the customer is created in the key's organization */
|
|
169
|
+
group: { manager: string }
|
|
170
|
+
/** Default `FR` */
|
|
171
|
+
locale?: Locale
|
|
172
|
+
/** Category, default `OrganizationCategory.CUSTOMER` — `B2B` also opens a KYB file */
|
|
173
|
+
organization?: OrganizationCategory
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export interface CustomerListParams {
|
|
177
|
+
offset?: number
|
|
178
|
+
limit?: number
|
|
179
|
+
includeClosed?: boolean
|
|
180
|
+
/** Only customers directly managed by this collaborator uuid */
|
|
181
|
+
manager?: string
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** The only settings a key may write (`PUT /account/{uuid}` in API mode) */
|
|
185
|
+
export interface UpdateCustomerParams {
|
|
186
|
+
theme?: string
|
|
187
|
+
locale?: Locale
|
|
188
|
+
notifications?: { login?: boolean, newsletter?: boolean }
|
|
189
|
+
}
|