@bitgen/sdk 0.1.5 → 1.0.3

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.
Files changed (328) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +27 -106
  3. package/dist/cjs/client.d.ts +20 -8
  4. package/dist/cjs/client.d.ts.map +1 -1
  5. package/dist/cjs/client.js +33 -12
  6. package/dist/cjs/client.js.map +1 -1
  7. package/dist/cjs/constants.d.ts +256 -0
  8. package/dist/cjs/constants.d.ts.map +1 -0
  9. package/dist/cjs/constants.js +214 -0
  10. package/dist/cjs/constants.js.map +1 -0
  11. package/dist/cjs/error.d.ts +17 -10
  12. package/dist/cjs/error.d.ts.map +1 -1
  13. package/dist/cjs/error.js +25 -7
  14. package/dist/cjs/error.js.map +1 -1
  15. package/dist/cjs/http.d.ts +13 -8
  16. package/dist/cjs/http.d.ts.map +1 -1
  17. package/dist/cjs/http.js +135 -43
  18. package/dist/cjs/http.js.map +1 -1
  19. package/dist/cjs/index.d.ts +14 -1
  20. package/dist/cjs/index.d.ts.map +1 -1
  21. package/dist/cjs/index.js +30 -1
  22. package/dist/cjs/index.js.map +1 -1
  23. package/dist/cjs/resources/apikeys.d.ts +18 -0
  24. package/dist/cjs/resources/apikeys.d.ts.map +1 -0
  25. package/dist/cjs/resources/apikeys.js +31 -0
  26. package/dist/cjs/resources/apikeys.js.map +1 -0
  27. package/dist/cjs/resources/asset.d.ts +17 -5
  28. package/dist/cjs/resources/asset.d.ts.map +1 -1
  29. package/dist/cjs/resources/asset.js +17 -6
  30. package/dist/cjs/resources/asset.js.map +1 -1
  31. package/dist/cjs/resources/bank.d.ts +11 -6
  32. package/dist/cjs/resources/bank.d.ts.map +1 -1
  33. package/dist/cjs/resources/bank.js +17 -9
  34. package/dist/cjs/resources/bank.js.map +1 -1
  35. package/dist/cjs/resources/core.d.ts +12 -0
  36. package/dist/cjs/resources/core.d.ts.map +1 -0
  37. package/dist/cjs/resources/core.js +22 -0
  38. package/dist/cjs/resources/core.js.map +1 -0
  39. package/dist/cjs/resources/custody.d.ts +27 -0
  40. package/dist/cjs/resources/custody.d.ts.map +1 -0
  41. package/dist/cjs/resources/custody.js +38 -0
  42. package/dist/cjs/resources/custody.js.map +1 -0
  43. package/dist/cjs/resources/customer.d.ts +20 -0
  44. package/dist/cjs/resources/customer.d.ts.map +1 -0
  45. package/dist/cjs/resources/customer.js +38 -0
  46. package/dist/cjs/resources/customer.js.map +1 -0
  47. package/dist/cjs/resources/staking.d.ts +32 -0
  48. package/dist/cjs/resources/staking.d.ts.map +1 -0
  49. package/dist/cjs/resources/staking.js +69 -0
  50. package/dist/cjs/resources/staking.js.map +1 -0
  51. package/dist/cjs/resources/trading.d.ts +24 -0
  52. package/dist/cjs/resources/trading.d.ts.map +1 -0
  53. package/dist/cjs/resources/trading.js +41 -0
  54. package/dist/cjs/resources/trading.js.map +1 -0
  55. package/dist/cjs/resources/transaction.d.ts +6 -9
  56. package/dist/cjs/resources/transaction.d.ts.map +1 -1
  57. package/dist/cjs/resources/transaction.js +10 -15
  58. package/dist/cjs/resources/transaction.js.map +1 -1
  59. package/dist/cjs/resources/webhooks.d.ts +46 -0
  60. package/dist/cjs/resources/webhooks.d.ts.map +1 -0
  61. package/dist/cjs/resources/webhooks.js +142 -0
  62. package/dist/cjs/resources/webhooks.js.map +1 -0
  63. package/dist/cjs/types/apikeys.d.ts +43 -0
  64. package/dist/cjs/types/apikeys.d.ts.map +1 -0
  65. package/dist/cjs/types/apikeys.js +3 -0
  66. package/dist/cjs/types/apikeys.js.map +1 -0
  67. package/dist/cjs/types/asset.d.ts +57 -0
  68. package/dist/cjs/types/asset.d.ts.map +1 -0
  69. package/dist/cjs/types/asset.js +3 -0
  70. package/dist/cjs/types/asset.js.map +1 -0
  71. package/dist/cjs/types/bank.d.ts +58 -0
  72. package/dist/cjs/types/bank.d.ts.map +1 -0
  73. package/dist/cjs/types/bank.js +3 -0
  74. package/dist/cjs/types/bank.js.map +1 -0
  75. package/dist/cjs/types/core.d.ts +32 -0
  76. package/dist/cjs/types/core.d.ts.map +1 -0
  77. package/dist/cjs/types/core.js +3 -0
  78. package/dist/cjs/types/core.js.map +1 -0
  79. package/dist/cjs/types/custody.d.ts +50 -0
  80. package/dist/cjs/types/custody.d.ts.map +1 -0
  81. package/dist/cjs/types/custody.js +3 -0
  82. package/dist/cjs/types/custody.js.map +1 -0
  83. package/dist/cjs/types/customer.d.ts +190 -0
  84. package/dist/cjs/types/customer.d.ts.map +1 -0
  85. package/dist/cjs/types/customer.js +3 -0
  86. package/dist/cjs/types/customer.js.map +1 -0
  87. package/dist/cjs/types/index.d.ts +79 -194
  88. package/dist/cjs/types/index.d.ts.map +1 -1
  89. package/dist/cjs/types/index.js +0 -1
  90. package/dist/cjs/types/index.js.map +1 -1
  91. package/dist/cjs/types/staking.d.ts +88 -0
  92. package/dist/cjs/types/staking.d.ts.map +1 -0
  93. package/dist/cjs/types/staking.js +3 -0
  94. package/dist/cjs/types/staking.js.map +1 -0
  95. package/dist/cjs/types/trading.d.ts +51 -0
  96. package/dist/cjs/types/trading.d.ts.map +1 -0
  97. package/dist/cjs/types/trading.js +3 -0
  98. package/dist/cjs/types/trading.js.map +1 -0
  99. package/dist/cjs/types/transaction.d.ts +61 -0
  100. package/dist/cjs/types/transaction.d.ts.map +1 -0
  101. package/dist/cjs/types/transaction.js +3 -0
  102. package/dist/cjs/types/transaction.js.map +1 -0
  103. package/dist/cjs/types/webhooks.d.ts +55 -0
  104. package/dist/cjs/types/webhooks.d.ts.map +1 -0
  105. package/dist/cjs/types/webhooks.js +3 -0
  106. package/dist/cjs/types/webhooks.js.map +1 -0
  107. package/dist/cjs/utils.d.ts +21 -2
  108. package/dist/cjs/utils.d.ts.map +1 -1
  109. package/dist/cjs/utils.js +67 -4
  110. package/dist/cjs/utils.js.map +1 -1
  111. package/dist/cjs/version.d.ts +2 -0
  112. package/dist/cjs/version.d.ts.map +1 -0
  113. package/dist/cjs/version.js +6 -0
  114. package/dist/cjs/version.js.map +1 -0
  115. package/dist/esm/client.d.ts +20 -8
  116. package/dist/esm/client.d.ts.map +1 -1
  117. package/dist/esm/client.js +33 -12
  118. package/dist/esm/client.js.map +1 -1
  119. package/dist/esm/constants.d.ts +256 -0
  120. package/dist/esm/constants.d.ts.map +1 -0
  121. package/dist/esm/constants.js +211 -0
  122. package/dist/esm/constants.js.map +1 -0
  123. package/dist/esm/error.d.ts +17 -10
  124. package/dist/esm/error.d.ts.map +1 -1
  125. package/dist/esm/error.js +24 -6
  126. package/dist/esm/error.js.map +1 -1
  127. package/dist/esm/http.d.ts +13 -8
  128. package/dist/esm/http.d.ts.map +1 -1
  129. package/dist/esm/http.js +136 -44
  130. package/dist/esm/http.js.map +1 -1
  131. package/dist/esm/index.d.ts +14 -1
  132. package/dist/esm/index.d.ts.map +1 -1
  133. package/dist/esm/index.js +6 -0
  134. package/dist/esm/index.js.map +1 -1
  135. package/dist/esm/resources/apikeys.d.ts +18 -0
  136. package/dist/esm/resources/apikeys.d.ts.map +1 -0
  137. package/dist/esm/resources/apikeys.js +27 -0
  138. package/dist/esm/resources/apikeys.js.map +1 -0
  139. package/dist/esm/resources/asset.d.ts +17 -5
  140. package/dist/esm/resources/asset.d.ts.map +1 -1
  141. package/dist/esm/resources/asset.js +17 -6
  142. package/dist/esm/resources/asset.js.map +1 -1
  143. package/dist/esm/resources/bank.d.ts +11 -6
  144. package/dist/esm/resources/bank.d.ts.map +1 -1
  145. package/dist/esm/resources/bank.js +18 -10
  146. package/dist/esm/resources/bank.js.map +1 -1
  147. package/dist/esm/resources/core.d.ts +12 -0
  148. package/dist/esm/resources/core.d.ts.map +1 -0
  149. package/dist/esm/resources/core.js +18 -0
  150. package/dist/esm/resources/core.js.map +1 -0
  151. package/dist/esm/resources/custody.d.ts +27 -0
  152. package/dist/esm/resources/custody.d.ts.map +1 -0
  153. package/dist/esm/resources/custody.js +34 -0
  154. package/dist/esm/resources/custody.js.map +1 -0
  155. package/dist/esm/resources/customer.d.ts +20 -0
  156. package/dist/esm/resources/customer.d.ts.map +1 -0
  157. package/dist/esm/resources/customer.js +34 -0
  158. package/dist/esm/resources/customer.js.map +1 -0
  159. package/dist/esm/resources/staking.d.ts +32 -0
  160. package/dist/esm/resources/staking.d.ts.map +1 -0
  161. package/dist/esm/resources/staking.js +65 -0
  162. package/dist/esm/resources/staking.js.map +1 -0
  163. package/dist/esm/resources/trading.d.ts +24 -0
  164. package/dist/esm/resources/trading.d.ts.map +1 -0
  165. package/dist/esm/resources/trading.js +37 -0
  166. package/dist/esm/resources/trading.js.map +1 -0
  167. package/dist/esm/resources/transaction.d.ts +6 -9
  168. package/dist/esm/resources/transaction.d.ts.map +1 -1
  169. package/dist/esm/resources/transaction.js +11 -16
  170. package/dist/esm/resources/transaction.js.map +1 -1
  171. package/dist/esm/resources/webhooks.d.ts +46 -0
  172. package/dist/esm/resources/webhooks.d.ts.map +1 -0
  173. package/dist/esm/resources/webhooks.js +138 -0
  174. package/dist/esm/resources/webhooks.js.map +1 -0
  175. package/dist/esm/types/apikeys.d.ts +43 -0
  176. package/dist/esm/types/apikeys.d.ts.map +1 -0
  177. package/dist/esm/types/apikeys.js +2 -0
  178. package/dist/esm/types/apikeys.js.map +1 -0
  179. package/dist/esm/types/asset.d.ts +57 -0
  180. package/dist/esm/types/asset.d.ts.map +1 -0
  181. package/dist/esm/types/asset.js +2 -0
  182. package/dist/esm/types/asset.js.map +1 -0
  183. package/dist/esm/types/bank.d.ts +58 -0
  184. package/dist/esm/types/bank.d.ts.map +1 -0
  185. package/dist/esm/types/bank.js +2 -0
  186. package/dist/esm/types/bank.js.map +1 -0
  187. package/dist/esm/types/core.d.ts +32 -0
  188. package/dist/esm/types/core.d.ts.map +1 -0
  189. package/dist/esm/types/core.js +2 -0
  190. package/dist/esm/types/core.js.map +1 -0
  191. package/dist/esm/types/custody.d.ts +50 -0
  192. package/dist/esm/types/custody.d.ts.map +1 -0
  193. package/dist/esm/types/custody.js +2 -0
  194. package/dist/esm/types/custody.js.map +1 -0
  195. package/dist/esm/types/customer.d.ts +190 -0
  196. package/dist/esm/types/customer.d.ts.map +1 -0
  197. package/dist/esm/types/customer.js +2 -0
  198. package/dist/esm/types/customer.js.map +1 -0
  199. package/dist/esm/types/index.d.ts +79 -194
  200. package/dist/esm/types/index.d.ts.map +1 -1
  201. package/dist/esm/types/index.js +0 -1
  202. package/dist/esm/types/index.js.map +1 -1
  203. package/dist/esm/types/staking.d.ts +88 -0
  204. package/dist/esm/types/staking.d.ts.map +1 -0
  205. package/dist/esm/types/staking.js +2 -0
  206. package/dist/esm/types/staking.js.map +1 -0
  207. package/dist/esm/types/trading.d.ts +51 -0
  208. package/dist/esm/types/trading.d.ts.map +1 -0
  209. package/dist/esm/types/trading.js +2 -0
  210. package/dist/esm/types/trading.js.map +1 -0
  211. package/dist/esm/types/transaction.d.ts +61 -0
  212. package/dist/esm/types/transaction.d.ts.map +1 -0
  213. package/dist/esm/types/transaction.js +2 -0
  214. package/dist/esm/types/transaction.js.map +1 -0
  215. package/dist/esm/types/webhooks.d.ts +55 -0
  216. package/dist/esm/types/webhooks.d.ts.map +1 -0
  217. package/dist/esm/types/webhooks.js +2 -0
  218. package/dist/esm/types/webhooks.js.map +1 -0
  219. package/dist/esm/utils.d.ts +21 -2
  220. package/dist/esm/utils.d.ts.map +1 -1
  221. package/dist/esm/utils.js +62 -4
  222. package/dist/esm/utils.js.map +1 -1
  223. package/dist/esm/version.d.ts +2 -0
  224. package/dist/esm/version.d.ts.map +1 -0
  225. package/dist/esm/version.js +3 -0
  226. package/dist/esm/version.js.map +1 -0
  227. package/package.json +29 -12
  228. package/readme/concepts.md +104 -0
  229. package/readme/configuration.md +72 -0
  230. package/readme/errors.md +67 -0
  231. package/readme/installation.md +43 -0
  232. package/readme/quick-start.md +87 -0
  233. package/readme/resource/apikeys.md +103 -0
  234. package/readme/resource/asset.md +121 -0
  235. package/readme/resource/bank.md +156 -0
  236. package/readme/resource/core.md +91 -0
  237. package/readme/resource/custody.md +166 -0
  238. package/readme/resource/customer.md +208 -0
  239. package/readme/resource/staking.md +277 -0
  240. package/readme/resource/trading.md +166 -0
  241. package/readme/resource/transaction.md +106 -0
  242. package/readme/resource/webhooks.md +307 -0
  243. package/src/client.ts +46 -0
  244. package/src/constants.ts +281 -0
  245. package/src/error.ts +36 -0
  246. package/src/http.ts +201 -0
  247. package/src/index.ts +111 -0
  248. package/src/resources/apikeys.ts +30 -0
  249. package/src/resources/asset.ts +28 -0
  250. package/src/resources/bank.ts +39 -0
  251. package/src/resources/core.ts +19 -0
  252. package/src/resources/custody.ts +37 -0
  253. package/src/resources/customer.ts +46 -0
  254. package/src/resources/staking.ts +88 -0
  255. package/src/resources/trading.ts +41 -0
  256. package/src/resources/transaction.ts +20 -0
  257. package/src/resources/webhooks.ts +169 -0
  258. package/src/types/apikeys.ts +35 -0
  259. package/src/types/asset.ts +59 -0
  260. package/src/types/bank.ts +60 -0
  261. package/src/types/core.ts +32 -0
  262. package/src/types/custody.ts +40 -0
  263. package/src/types/customer.ts +189 -0
  264. package/src/types/index.ts +215 -0
  265. package/src/types/staking.ts +87 -0
  266. package/src/types/trading.ts +56 -0
  267. package/src/types/transaction.ts +62 -0
  268. package/src/types/webhooks.ts +60 -0
  269. package/src/utils.ts +74 -0
  270. package/src/version.ts +2 -0
  271. package/dist/cjs/resources/order.d.ts +0 -17
  272. package/dist/cjs/resources/order.d.ts.map +0 -1
  273. package/dist/cjs/resources/order.js +0 -30
  274. package/dist/cjs/resources/order.js.map +0 -1
  275. package/dist/cjs/resources/stats.d.ts +0 -11
  276. package/dist/cjs/resources/stats.d.ts.map +0 -1
  277. package/dist/cjs/resources/stats.js +0 -18
  278. package/dist/cjs/resources/stats.js.map +0 -1
  279. package/dist/cjs/resources/user.d.ts +0 -22
  280. package/dist/cjs/resources/user.d.ts.map +0 -1
  281. package/dist/cjs/resources/user.js +0 -37
  282. package/dist/cjs/resources/user.js.map +0 -1
  283. package/dist/cjs/resources/wallet.d.ts +0 -11
  284. package/dist/cjs/resources/wallet.d.ts.map +0 -1
  285. package/dist/cjs/resources/wallet.js +0 -19
  286. package/dist/cjs/resources/wallet.js.map +0 -1
  287. package/dist/esm/resources/order.d.ts +0 -17
  288. package/dist/esm/resources/order.d.ts.map +0 -1
  289. package/dist/esm/resources/order.js +0 -26
  290. package/dist/esm/resources/order.js.map +0 -1
  291. package/dist/esm/resources/stats.d.ts +0 -11
  292. package/dist/esm/resources/stats.d.ts.map +0 -1
  293. package/dist/esm/resources/stats.js +0 -14
  294. package/dist/esm/resources/stats.js.map +0 -1
  295. package/dist/esm/resources/user.d.ts +0 -22
  296. package/dist/esm/resources/user.d.ts.map +0 -1
  297. package/dist/esm/resources/user.js +0 -33
  298. package/dist/esm/resources/user.js.map +0 -1
  299. package/dist/esm/resources/wallet.d.ts +0 -11
  300. package/dist/esm/resources/wallet.d.ts.map +0 -1
  301. package/dist/esm/resources/wallet.js +0 -15
  302. package/dist/esm/resources/wallet.js.map +0 -1
  303. package/dist/types/client.d.ts +0 -19
  304. package/dist/types/client.d.ts.map +0 -1
  305. package/dist/types/error.d.ts +0 -15
  306. package/dist/types/error.d.ts.map +0 -1
  307. package/dist/types/http.d.ts +0 -21
  308. package/dist/types/http.d.ts.map +0 -1
  309. package/dist/types/index.d.ts +0 -4
  310. package/dist/types/index.d.ts.map +0 -1
  311. package/dist/types/resources/asset.d.ts +0 -11
  312. package/dist/types/resources/asset.d.ts.map +0 -1
  313. package/dist/types/resources/bank.d.ts +0 -13
  314. package/dist/types/resources/bank.d.ts.map +0 -1
  315. package/dist/types/resources/order.d.ts +0 -17
  316. package/dist/types/resources/order.d.ts.map +0 -1
  317. package/dist/types/resources/stats.d.ts +0 -11
  318. package/dist/types/resources/stats.d.ts.map +0 -1
  319. package/dist/types/resources/transaction.d.ts +0 -15
  320. package/dist/types/resources/transaction.d.ts.map +0 -1
  321. package/dist/types/resources/user.d.ts +0 -22
  322. package/dist/types/resources/user.d.ts.map +0 -1
  323. package/dist/types/resources/wallet.d.ts +0 -11
  324. package/dist/types/resources/wallet.d.ts.map +0 -1
  325. package/dist/types/types/index.d.ts +0 -212
  326. package/dist/types/types/index.d.ts.map +0 -1
  327. package/dist/types/utils.d.ts +0 -7
  328. package/dist/types/utils.d.ts.map +0 -1
@@ -0,0 +1,60 @@
1
+ export type { WebhookEventName, SubscriberState } from '../constants.js'
2
+ import type { WebhookEventName, SubscriberState } from '../constants.js'
3
+
4
+ /** An event of the catalogue (`GET /webhook`) */
5
+ export interface WebhookType {
6
+ uuid: string
7
+ state: SubscriberState
8
+ name: string
9
+ /** Raw JSON `{"fr": "…", "en": "…"}` */
10
+ label: string
11
+ /** Raw JSON */
12
+ data: string
13
+ }
14
+
15
+ /** A subscription of the organization to an event */
16
+ export interface Subscriber {
17
+ uuid: string
18
+ state: SubscriberState
19
+ updatedAt: number
20
+ webhook: WebhookType
21
+ }
22
+
23
+ /** `GET /webhooks/{organization}` — the HMAC secret, the endpoint and the subscriptions */
24
+ export interface WebhookSubscriptions {
25
+ secret: string
26
+ endpoint: string
27
+ items: Subscriber[]
28
+ }
29
+
30
+ /** One delivery attempt of a subscription (`GET /webhooks/{subscriber}/logs`) */
31
+ export interface DeliveryLog {
32
+ date: number
33
+ webhook: string
34
+ url: string
35
+ status: string
36
+ http_code: number | null
37
+ duration_ms: number | null
38
+ attempts: number
39
+ payload: Record<string, unknown>
40
+ error: string | null
41
+ }
42
+
43
+ /** Envelope delivered to the endpoint — `data` depends on the event */
44
+ export interface WebhookEvent {
45
+ delivery_id: string
46
+ timestamp: number
47
+ event: WebhookEventName
48
+ data: unknown
49
+ }
50
+
51
+ export interface VerifyInput {
52
+ /** The bytes received, never a re-serialized JSON */
53
+ rawBody: string | Uint8Array
54
+ /** Headers as received (Node `IncomingHttpHeaders`) — names are matched case-insensitively */
55
+ headers: Record<string, string | string[] | undefined>
56
+ /** The organization's secret, from `list().secret` */
57
+ secret: string
58
+ /** Seconds, default 300 — `0` disables the freshness check */
59
+ tolerance?: number
60
+ }
package/src/utils.ts ADDED
@@ -0,0 +1,74 @@
1
+ import type { Amount, AssetInput, UserRef } from './types/index.js'
2
+
3
+ /**
4
+ * Resolve a UserRef (uuid or email string, or a model carrying a `uuid`) to its string.
5
+ * Used by all resource methods that accept a user parameter.
6
+ */
7
+ export function resolveUuid(ref: UserRef): string {
8
+ const value = typeof ref === 'string' ? ref : ref?.uuid
9
+ if (typeof value !== 'string' || value.trim() === '') {
10
+ throw new TypeError('user must be a non-empty uuid or email, or a model with a non-empty uuid')
11
+ }
12
+ return value
13
+ }
14
+
15
+ /**
16
+ * The uuid of a reference given as a string (sent as is) or as a model carrying a `uuid` (an `Order`, a
17
+ * `StakingPosition`, an `Apikey`…). An empty string, or a model without one, is refused before any request.
18
+ */
19
+ export function idOf(ref: string | { uuid: string }, name: string): string {
20
+ const value = typeof ref === 'string' ? ref : ref?.uuid
21
+ if (typeof value !== 'string' || value.trim() === '') {
22
+ throw new TypeError(`${name} must be a non-empty string, or a model with a non-empty uuid`)
23
+ }
24
+ return value
25
+ }
26
+
27
+ /** An asset as given — a uuid or ISO code string as is, or the uuid of an `Asset` / `AssetRef` model; empty → `TypeError` before any request */
28
+ export function assetId(asset: AssetInput): string {
29
+ const value = typeof asset === 'string' ? asset : asset?.uuid
30
+ if (typeof value !== 'string' || value.trim() === '') {
31
+ throw new TypeError('asset must be a uuid or an ISO code, or a model with a non-empty uuid')
32
+ }
33
+ return value
34
+ }
35
+
36
+ /** An optional asset filter of a list: absent or `null` stays absent, otherwise `assetId` */
37
+ export function assetFilter(asset: AssetInput | null | undefined): string | undefined {
38
+ return asset === undefined || asset === null ? undefined : assetId(asset)
39
+ }
40
+
41
+ /** Validate and encode a value used as a path segment (`/asset/{asset}`, `/account/{user}`…) */
42
+ export function pathSegment(value: string, name: string): string {
43
+ if (typeof value !== 'string' || value.trim() === '') {
44
+ throw new TypeError(`${name} must be a non-empty string`)
45
+ }
46
+ // `.` and `..` are not encoded by encodeURIComponent and would be normalized away by the URL parser
47
+ if (value === '.' || value === '..') {
48
+ throw new TypeError(`${name} must not be "." or ".."`)
49
+ }
50
+ return encodeURIComponent(value)
51
+ }
52
+
53
+ /**
54
+ * Normalize an amount for the API, which always receives a string: a string is sent as is
55
+ * (trimmed), a finite number ≥ 0 is converted with `String(n)`. Numbers that `String()` writes
56
+ * in exponent notation (below 1e-6 or from 1e21) are refused: pass them as strings.
57
+ */
58
+ export function amount(value: Amount): string {
59
+ if (typeof value === 'string') {
60
+ const trimmed = value.trim()
61
+ if (trimmed === '') {
62
+ throw new TypeError('amount must be a non-empty string or a finite number >= 0')
63
+ }
64
+ return trimmed
65
+ }
66
+ if (typeof value !== 'number' || !Number.isFinite(value) || value < 0) {
67
+ throw new TypeError('amount must be a non-empty string or a finite number >= 0')
68
+ }
69
+ const text = String(value)
70
+ if (text.includes('e')) {
71
+ throw new TypeError(`amount ${text} would be sent in exponent notation: pass it as a decimal string`)
72
+ }
73
+ return text
74
+ }
package/src/version.ts ADDED
@@ -0,0 +1,2 @@
1
+ // Generated by scripts/prebuild.js from package.json — do not edit
2
+ export const VERSION = "1.0.3"
@@ -1,17 +0,0 @@
1
- import type { HttpClient } from '../http.js';
2
- import type { CreateOrderParams, CreatedOrder, Order, UserRef } from '../types/index.js';
3
- export declare class OrderResource {
4
- private readonly http;
5
- constructor(http: HttpClient);
6
- /**
7
- * Create a buy or sell order.
8
- * - BUY: amount is in EUR → delivers the target asset
9
- * - SELL: amount is in asset units → delivers EUR
10
- */
11
- create(params: CreateOrderParams): Promise<CreatedOrder>;
12
- /** Get the current status of an order by its tunnel ID */
13
- get(tunnel: string): Promise<Order>;
14
- /** Get full order history for a user */
15
- history(user: UserRef): Promise<Order[]>;
16
- }
17
- //# sourceMappingURL=order.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"order.d.ts","sourceRoot":"","sources":["../../../src/resources/order.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,KAAK,EACL,OAAO,EACR,MAAM,mBAAmB,CAAA;AAG1B,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;OAIG;IACH,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC;IAOxD,0DAA0D;IAC1D,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAInC,wCAAwC;IACxC,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;CAGzC"}
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OrderResource = void 0;
4
- const utils_js_1 = require("../utils.js");
5
- class OrderResource {
6
- constructor(http) {
7
- this.http = http;
8
- }
9
- /**
10
- * Create a buy or sell order.
11
- * - BUY: amount is in EUR → delivers the target asset
12
- * - SELL: amount is in asset units → delivers EUR
13
- */
14
- create(params) {
15
- return this.http.post('/api/v3/order', {
16
- ...params,
17
- user: (0, utils_js_1.resolveUuid)(params.user),
18
- });
19
- }
20
- /** Get the current status of an order by its tunnel ID */
21
- get(tunnel) {
22
- return this.http.get(`/api/v3/order/${tunnel}`);
23
- }
24
- /** Get full order history for a user */
25
- history(user) {
26
- return this.http.get(`/api/v3/orders/${(0, utils_js_1.resolveUuid)(user)}`);
27
- }
28
- }
29
- exports.OrderResource = OrderResource;
30
- //# sourceMappingURL=order.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"order.js","sourceRoot":"","sources":["../../../src/resources/order.ts"],"names":[],"mappings":";;;AAOA,0CAAyC;AAEzC,MAAa,aAAa;IACxB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;;OAIG;IACH,MAAM,CAAC,MAAyB;QAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAe,eAAe,EAAE;YACnD,GAAG,MAAM;YACT,IAAI,EAAE,IAAA,sBAAW,EAAC,MAAM,CAAC,IAAI,CAAC;SAC/B,CAAC,CAAA;IACJ,CAAC;IAED,0DAA0D;IAC1D,GAAG,CAAC,MAAc;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAQ,iBAAiB,MAAM,EAAE,CAAC,CAAA;IACxD,CAAC;IAED,wCAAwC;IACxC,OAAO,CAAC,IAAa;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAU,kBAAkB,IAAA,sBAAW,EAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACtE,CAAC;CACF;AAxBD,sCAwBC"}
@@ -1,11 +0,0 @@
1
- import type { HttpClient } from '../http.js';
2
- import type { HealthCheck, Stats } from '../types/index.js';
3
- export declare class StatsResource {
4
- private readonly http;
5
- constructor(http: HttpClient);
6
- /** Check API health */
7
- health(): Promise<HealthCheck>;
8
- /** Get service quotas (user slots, etc.) */
9
- quotas(): Promise<Stats>;
10
- }
11
- //# sourceMappingURL=stats.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../../src/resources/stats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE3D,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,uBAAuB;IACvB,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC;IAI9B,4CAA4C;IAC5C,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC;CAGzB"}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StatsResource = void 0;
4
- class StatsResource {
5
- constructor(http) {
6
- this.http = http;
7
- }
8
- /** Check API health */
9
- health() {
10
- return this.http.get('/health');
11
- }
12
- /** Get service quotas (user slots, etc.) */
13
- quotas() {
14
- return this.http.get('/api/v3/stats');
15
- }
16
- }
17
- exports.StatsResource = StatsResource;
18
- //# sourceMappingURL=stats.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stats.js","sourceRoot":"","sources":["../../../src/resources/stats.ts"],"names":[],"mappings":";;;AAGA,MAAa,aAAa;IACxB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,uBAAuB;IACvB,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAc,SAAS,CAAC,CAAA;IAC9C,CAAC;IAED,4CAA4C;IAC5C,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAQ,eAAe,CAAC,CAAA;IAC9C,CAAC;CACF;AAZD,sCAYC"}
@@ -1,22 +0,0 @@
1
- import type { HttpClient } from '../http.js';
2
- import type { CreateUserParams, UserDetail, UserList, UserListParams, UpdateUserParams, UserRef } from '../types/index.js';
3
- export declare class UserResource {
4
- private readonly http;
5
- constructor(http: HttpClient);
6
- /** Create a new user — returns their UUID */
7
- create(params: CreateUserParams): Promise<{
8
- uuid: string;
9
- }>;
10
- /** List all users (paginated) */
11
- list(params: UserListParams): Promise<UserList>;
12
- /** Get full user details (profile, wallets, bank) by UUID or User object */
13
- get(user: UserRef): Promise<UserDetail>;
14
- /** Update a user's profile — returns nothing on success (204) */
15
- update(user: UserRef, params: UpdateUserParams): Promise<void>;
16
- /**
17
- * Soft-disable a user account.
18
- * Data is retained — this is not a permanent deletion.
19
- */
20
- disable(user: UserRef): Promise<void>;
21
- }
22
- //# sourceMappingURL=user.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../src/resources/user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EACV,gBAAgB,EAChB,UAAU,EACV,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,OAAO,EACR,MAAM,mBAAmB,CAAA;AAG1B,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,6CAA6C;IAC7C,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAI3D,iCAAiC;IACjC,IAAI,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IAO/C,4EAA4E;IAC5E,GAAG,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;IAIvC,iEAAiE;IACjE,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9D;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAGtC"}
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UserResource = void 0;
4
- const utils_js_1 = require("../utils.js");
5
- class UserResource {
6
- constructor(http) {
7
- this.http = http;
8
- }
9
- /** Create a new user — returns their UUID */
10
- create(params) {
11
- return this.http.post('/api/v3/user', params);
12
- }
13
- /** List all users (paginated) */
14
- list(params) {
15
- return this.http.get('/api/v3/user', {
16
- offset: params.offset,
17
- limit: params.limit,
18
- });
19
- }
20
- /** Get full user details (profile, wallets, bank) by UUID or User object */
21
- get(user) {
22
- return this.http.get(`/api/v3/user/${(0, utils_js_1.resolveUuid)(user)}`);
23
- }
24
- /** Update a user's profile — returns nothing on success (204) */
25
- update(user, params) {
26
- return this.http.put(`/api/v3/user/${(0, utils_js_1.resolveUuid)(user)}`, params);
27
- }
28
- /**
29
- * Soft-disable a user account.
30
- * Data is retained — this is not a permanent deletion.
31
- */
32
- disable(user) {
33
- return this.http.delete(`/api/v3/user/${(0, utils_js_1.resolveUuid)(user)}`);
34
- }
35
- }
36
- exports.UserResource = UserResource;
37
- //# sourceMappingURL=user.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user.js","sourceRoot":"","sources":["../../../src/resources/user.ts"],"names":[],"mappings":";;;AASA,0CAAyC;AAEzC,MAAa,YAAY;IACvB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,6CAA6C;IAC7C,MAAM,CAAC,MAAwB;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAmB,cAAc,EAAE,MAAM,CAAC,CAAA;IACjE,CAAC;IAED,iCAAiC;IACjC,IAAI,CAAC,MAAsB;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAW,cAAc,EAAE;YAC7C,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC,CAAA;IACJ,CAAC;IAED,4EAA4E;IAC5E,GAAG,CAAC,IAAa;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAa,gBAAgB,IAAA,sBAAW,EAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACvE,CAAC;IAED,iEAAiE;IACjE,MAAM,CAAC,IAAa,EAAE,MAAwB;QAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAO,gBAAgB,IAAA,sBAAW,EAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;IACzE,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,IAAa;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAO,gBAAgB,IAAA,sBAAW,EAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACpE,CAAC;CACF;AAjCD,oCAiCC"}
@@ -1,11 +0,0 @@
1
- import type { HttpClient } from '../http.js';
2
- import type { Wallet, UserRef } from '../types/index.js';
3
- export declare class WalletResource {
4
- private readonly http;
5
- constructor(http: HttpClient);
6
- /** Get all wallets for a user */
7
- list(user: UserRef): Promise<Wallet[]>;
8
- /** Get a specific wallet by user and asset ISO code */
9
- get(user: UserRef, asset: string): Promise<Wallet>;
10
- }
11
- //# sourceMappingURL=wallet.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../src/resources/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAGxD,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,iCAAiC;IACjC,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAItC,uDAAuD;IACvD,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAGnD"}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WalletResource = void 0;
4
- const utils_js_1 = require("../utils.js");
5
- class WalletResource {
6
- constructor(http) {
7
- this.http = http;
8
- }
9
- /** Get all wallets for a user */
10
- list(user) {
11
- return this.http.get(`/api/v3/wallet/${(0, utils_js_1.resolveUuid)(user)}`);
12
- }
13
- /** Get a specific wallet by user and asset ISO code */
14
- get(user, asset) {
15
- return this.http.get(`/api/v3/wallet/${(0, utils_js_1.resolveUuid)(user)}/${asset}`);
16
- }
17
- }
18
- exports.WalletResource = WalletResource;
19
- //# sourceMappingURL=wallet.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../../src/resources/wallet.ts"],"names":[],"mappings":";;;AAEA,0CAAyC;AAEzC,MAAa,cAAc;IACzB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,iCAAiC;IACjC,IAAI,CAAC,IAAa;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAW,kBAAkB,IAAA,sBAAW,EAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACvE,CAAC;IAED,uDAAuD;IACvD,GAAG,CAAC,IAAa,EAAE,KAAa;QAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAS,kBAAkB,IAAA,sBAAW,EAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,CAAA;IAC9E,CAAC;CACF;AAZD,wCAYC"}
@@ -1,17 +0,0 @@
1
- import type { HttpClient } from '../http.js';
2
- import type { CreateOrderParams, CreatedOrder, Order, UserRef } from '../types/index.js';
3
- export declare class OrderResource {
4
- private readonly http;
5
- constructor(http: HttpClient);
6
- /**
7
- * Create a buy or sell order.
8
- * - BUY: amount is in EUR → delivers the target asset
9
- * - SELL: amount is in asset units → delivers EUR
10
- */
11
- create(params: CreateOrderParams): Promise<CreatedOrder>;
12
- /** Get the current status of an order by its tunnel ID */
13
- get(tunnel: string): Promise<Order>;
14
- /** Get full order history for a user */
15
- history(user: UserRef): Promise<Order[]>;
16
- }
17
- //# sourceMappingURL=order.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"order.d.ts","sourceRoot":"","sources":["../../../src/resources/order.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,KAAK,EACL,OAAO,EACR,MAAM,mBAAmB,CAAA;AAG1B,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;OAIG;IACH,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC;IAOxD,0DAA0D;IAC1D,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAInC,wCAAwC;IACxC,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;CAGzC"}
@@ -1,26 +0,0 @@
1
- import { resolveUuid } from '../utils.js';
2
- export class OrderResource {
3
- constructor(http) {
4
- this.http = http;
5
- }
6
- /**
7
- * Create a buy or sell order.
8
- * - BUY: amount is in EUR → delivers the target asset
9
- * - SELL: amount is in asset units → delivers EUR
10
- */
11
- create(params) {
12
- return this.http.post('/api/v3/order', {
13
- ...params,
14
- user: resolveUuid(params.user),
15
- });
16
- }
17
- /** Get the current status of an order by its tunnel ID */
18
- get(tunnel) {
19
- return this.http.get(`/api/v3/order/${tunnel}`);
20
- }
21
- /** Get full order history for a user */
22
- history(user) {
23
- return this.http.get(`/api/v3/orders/${resolveUuid(user)}`);
24
- }
25
- }
26
- //# sourceMappingURL=order.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"order.js","sourceRoot":"","sources":["../../../src/resources/order.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,MAAM,OAAO,aAAa;IACxB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;;OAIG;IACH,MAAM,CAAC,MAAyB;QAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAe,eAAe,EAAE;YACnD,GAAG,MAAM;YACT,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC;SAC/B,CAAC,CAAA;IACJ,CAAC;IAED,0DAA0D;IAC1D,GAAG,CAAC,MAAc;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAQ,iBAAiB,MAAM,EAAE,CAAC,CAAA;IACxD,CAAC;IAED,wCAAwC;IACxC,OAAO,CAAC,IAAa;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAU,kBAAkB,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACtE,CAAC;CACF"}
@@ -1,11 +0,0 @@
1
- import type { HttpClient } from '../http.js';
2
- import type { HealthCheck, Stats } from '../types/index.js';
3
- export declare class StatsResource {
4
- private readonly http;
5
- constructor(http: HttpClient);
6
- /** Check API health */
7
- health(): Promise<HealthCheck>;
8
- /** Get service quotas (user slots, etc.) */
9
- quotas(): Promise<Stats>;
10
- }
11
- //# sourceMappingURL=stats.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../../src/resources/stats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE3D,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,uBAAuB;IACvB,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC;IAI9B,4CAA4C;IAC5C,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC;CAGzB"}
@@ -1,14 +0,0 @@
1
- export class StatsResource {
2
- constructor(http) {
3
- this.http = http;
4
- }
5
- /** Check API health */
6
- health() {
7
- return this.http.get('/health');
8
- }
9
- /** Get service quotas (user slots, etc.) */
10
- quotas() {
11
- return this.http.get('/api/v3/stats');
12
- }
13
- }
14
- //# sourceMappingURL=stats.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stats.js","sourceRoot":"","sources":["../../../src/resources/stats.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,aAAa;IACxB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,uBAAuB;IACvB,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAc,SAAS,CAAC,CAAA;IAC9C,CAAC;IAED,4CAA4C;IAC5C,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAQ,eAAe,CAAC,CAAA;IAC9C,CAAC;CACF"}
@@ -1,22 +0,0 @@
1
- import type { HttpClient } from '../http.js';
2
- import type { CreateUserParams, UserDetail, UserList, UserListParams, UpdateUserParams, UserRef } from '../types/index.js';
3
- export declare class UserResource {
4
- private readonly http;
5
- constructor(http: HttpClient);
6
- /** Create a new user — returns their UUID */
7
- create(params: CreateUserParams): Promise<{
8
- uuid: string;
9
- }>;
10
- /** List all users (paginated) */
11
- list(params: UserListParams): Promise<UserList>;
12
- /** Get full user details (profile, wallets, bank) by UUID or User object */
13
- get(user: UserRef): Promise<UserDetail>;
14
- /** Update a user's profile — returns nothing on success (204) */
15
- update(user: UserRef, params: UpdateUserParams): Promise<void>;
16
- /**
17
- * Soft-disable a user account.
18
- * Data is retained — this is not a permanent deletion.
19
- */
20
- disable(user: UserRef): Promise<void>;
21
- }
22
- //# sourceMappingURL=user.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../src/resources/user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EACV,gBAAgB,EAChB,UAAU,EACV,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,OAAO,EACR,MAAM,mBAAmB,CAAA;AAG1B,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,6CAA6C;IAC7C,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAI3D,iCAAiC;IACjC,IAAI,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IAO/C,4EAA4E;IAC5E,GAAG,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;IAIvC,iEAAiE;IACjE,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9D;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAGtC"}
@@ -1,33 +0,0 @@
1
- import { resolveUuid } from '../utils.js';
2
- export class UserResource {
3
- constructor(http) {
4
- this.http = http;
5
- }
6
- /** Create a new user — returns their UUID */
7
- create(params) {
8
- return this.http.post('/api/v3/user', params);
9
- }
10
- /** List all users (paginated) */
11
- list(params) {
12
- return this.http.get('/api/v3/user', {
13
- offset: params.offset,
14
- limit: params.limit,
15
- });
16
- }
17
- /** Get full user details (profile, wallets, bank) by UUID or User object */
18
- get(user) {
19
- return this.http.get(`/api/v3/user/${resolveUuid(user)}`);
20
- }
21
- /** Update a user's profile — returns nothing on success (204) */
22
- update(user, params) {
23
- return this.http.put(`/api/v3/user/${resolveUuid(user)}`, params);
24
- }
25
- /**
26
- * Soft-disable a user account.
27
- * Data is retained — this is not a permanent deletion.
28
- */
29
- disable(user) {
30
- return this.http.delete(`/api/v3/user/${resolveUuid(user)}`);
31
- }
32
- }
33
- //# sourceMappingURL=user.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user.js","sourceRoot":"","sources":["../../../src/resources/user.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,MAAM,OAAO,YAAY;IACvB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,6CAA6C;IAC7C,MAAM,CAAC,MAAwB;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAmB,cAAc,EAAE,MAAM,CAAC,CAAA;IACjE,CAAC;IAED,iCAAiC;IACjC,IAAI,CAAC,MAAsB;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAW,cAAc,EAAE;YAC7C,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC,CAAA;IACJ,CAAC;IAED,4EAA4E;IAC5E,GAAG,CAAC,IAAa;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAa,gBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACvE,CAAC;IAED,iEAAiE;IACjE,MAAM,CAAC,IAAa,EAAE,MAAwB;QAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAO,gBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;IACzE,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,IAAa;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAO,gBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACpE,CAAC;CACF"}
@@ -1,11 +0,0 @@
1
- import type { HttpClient } from '../http.js';
2
- import type { Wallet, UserRef } from '../types/index.js';
3
- export declare class WalletResource {
4
- private readonly http;
5
- constructor(http: HttpClient);
6
- /** Get all wallets for a user */
7
- list(user: UserRef): Promise<Wallet[]>;
8
- /** Get a specific wallet by user and asset ISO code */
9
- get(user: UserRef, asset: string): Promise<Wallet>;
10
- }
11
- //# sourceMappingURL=wallet.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../src/resources/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAGxD,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,iCAAiC;IACjC,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAItC,uDAAuD;IACvD,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAGnD"}
@@ -1,15 +0,0 @@
1
- import { resolveUuid } from '../utils.js';
2
- export class WalletResource {
3
- constructor(http) {
4
- this.http = http;
5
- }
6
- /** Get all wallets for a user */
7
- list(user) {
8
- return this.http.get(`/api/v3/wallet/${resolveUuid(user)}`);
9
- }
10
- /** Get a specific wallet by user and asset ISO code */
11
- get(user, asset) {
12
- return this.http.get(`/api/v3/wallet/${resolveUuid(user)}/${asset}`);
13
- }
14
- }
15
- //# sourceMappingURL=wallet.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../../src/resources/wallet.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,MAAM,OAAO,cAAc;IACzB,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,iCAAiC;IACjC,IAAI,CAAC,IAAa;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAW,kBAAkB,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACvE,CAAC;IAED,uDAAuD;IACvD,GAAG,CAAC,IAAa,EAAE,KAAa;QAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAS,kBAAkB,WAAW,CAAC,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,CAAA;IAC9E,CAAC;CACF"}
@@ -1,19 +0,0 @@
1
- import { AssetResource } from './resources/asset.js';
2
- import { BankResource } from './resources/bank.js';
3
- import { OrderResource } from './resources/order.js';
4
- import { TransactionResource } from './resources/transaction.js';
5
- import { UserResource } from './resources/user.js';
6
- import { WalletResource } from './resources/wallet.js';
7
- import { StatsResource } from './resources/stats.js';
8
- import type { BitgenConfig } from './types/index.js';
9
- export declare class BitgenClient {
10
- readonly asset: AssetResource;
11
- readonly bank: BankResource;
12
- readonly order: OrderResource;
13
- readonly transaction: TransactionResource;
14
- readonly user: UserResource;
15
- readonly wallet: WalletResource;
16
- readonly stats: StatsResource;
17
- constructor(config: BitgenConfig);
18
- }
19
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAEpD,qBAAa,YAAY;IACvB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;IAC7B,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;IAC3B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;IAC7B,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAA;IACzC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;IAC/B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;gBAEjB,MAAM,EAAE,YAAY;CAWjC"}
@@ -1,15 +0,0 @@
1
- import type { BitgenErrorBody } from './types/index.js';
2
- export declare class BitgenError extends Error {
3
- /** HTTP status code */
4
- readonly status: number;
5
- /** BITGEN error code (from body) */
6
- readonly code: number;
7
- /** BITGEN service name (e.g. "order", "transaction") */
8
- readonly service: string;
9
- /** BITGEN module name (e.g. "create", "read") */
10
- readonly module: string;
11
- /** Raw error message from API */
12
- readonly apiMessage: string;
13
- constructor(status: number, body: BitgenErrorBody);
14
- }
15
- //# sourceMappingURL=error.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAEvD,qBAAa,WAAY,SAAQ,KAAK;IACpC,uBAAuB;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,wDAAwD;IACxD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,iDAAiD;IACjD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,iCAAiC;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;gBAEf,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe;CASlD"}
@@ -1,21 +0,0 @@
1
- import type { BitgenConfig } from './types/index.js';
2
- type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
3
- interface RequestOptions {
4
- method?: HttpMethod;
5
- body?: unknown;
6
- query?: Record<string, string | number | boolean | undefined>;
7
- /** Set to true for endpoints that return raw non-JSON errors (POST /tx) */
8
- rawErrors?: boolean;
9
- }
10
- export declare class HttpClient {
11
- private readonly baseUrl;
12
- private readonly headers;
13
- constructor(config: BitgenConfig);
14
- request<T>(path: string, options?: RequestOptions): Promise<T>;
15
- get<T>(path: string, query?: RequestOptions['query']): Promise<T>;
16
- post<T>(path: string, body: unknown, rawErrors?: boolean): Promise<T>;
17
- put<T>(path: string, body: unknown): Promise<T>;
18
- delete<T>(path: string): Promise<T>;
19
- }
20
- export {};
21
- //# sourceMappingURL=http.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAQpD,KAAK,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAA;AAEnD,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAA;IAC7D,2EAA2E;IAC3E,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwB;gBAEpC,MAAM,EAAE,YAAY;IAiB1B,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,CAAC,CAAC;IA6CxE,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAIjE,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,UAAQ,GAAG,OAAO,CAAC,CAAC,CAAC;IAInE,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAI/C,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;CAGpC"}
@@ -1,4 +0,0 @@
1
- export { BitgenClient } from './client.js';
2
- export { BitgenError } from './error.js';
3
- export type { BitgenConfig, BitgenEnv, UserRef, Asset, BankAccount, BankWithdrawResult, BankOperation, BankOperationDirection, BankOperationsFilter, OrderMode, OrderState, OrderStateBuy, OrderStateSell, CreateOrderParams, CreatedOrder, Order, OrderData, TransactionState, CreateTransactionParams, CreatedTransaction, Transaction, TransactionDirection, TransactionHistoryFilter, TransactionHistoryItem, IdentityState, UserState, CreateUserParams, UpdateUserParams, UserListParams, UserList, UserListMeta, User, UserDetail, UserAccount, UserAddress, UserIdentity, ActiveWallet, Wallet, WalletAsset, HealthCheck, Stats, UserQuota, } from './types/index.js';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,YAAY,EAEV,YAAY,EACZ,SAAS,EACT,OAAO,EAEP,KAAK,EAEL,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,sBAAsB,EACtB,oBAAoB,EAEpB,SAAS,EACT,UAAU,EACV,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,KAAK,EACL,SAAS,EAET,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,EAEtB,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EAEZ,MAAM,EACN,WAAW,EAEX,WAAW,EACX,KAAK,EACL,SAAS,GACV,MAAM,kBAAkB,CAAA"}