@lukadriel/wave-sdk 0.0.0-stage → 0.1.0

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 (185) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +2 -0
  4. package/README.md +523 -2
  5. package/dist/client/wave-client-options.d.ts +29 -0
  6. package/dist/client/wave-client-options.d.ts.map +1 -0
  7. package/dist/client/wave-client-options.js +58 -0
  8. package/dist/client/wave-client-options.js.map +1 -0
  9. package/dist/client/wave-client.d.ts +47 -0
  10. package/dist/client/wave-client.d.ts.map +1 -0
  11. package/dist/client/wave-client.js +66 -0
  12. package/dist/client/wave-client.js.map +1 -0
  13. package/dist/core/auth/authentication.d.ts +8 -0
  14. package/dist/core/auth/authentication.d.ts.map +1 -0
  15. package/dist/core/auth/authentication.js +10 -0
  16. package/dist/core/auth/authentication.js.map +1 -0
  17. package/dist/core/auth/request-signer.d.ts +26 -0
  18. package/dist/core/auth/request-signer.d.ts.map +1 -0
  19. package/dist/core/auth/request-signer.js +39 -0
  20. package/dist/core/auth/request-signer.js.map +1 -0
  21. package/dist/core/errors/error-parser.d.ts +25 -0
  22. package/dist/core/errors/error-parser.d.ts.map +1 -0
  23. package/dist/core/errors/error-parser.js +198 -0
  24. package/dist/core/errors/error-parser.js.map +1 -0
  25. package/dist/core/errors/redact.d.ts +11 -0
  26. package/dist/core/errors/redact.d.ts.map +1 -0
  27. package/dist/core/errors/redact.js +20 -0
  28. package/dist/core/errors/redact.js.map +1 -0
  29. package/dist/core/errors/wave-api-error.d.ts +116 -0
  30. package/dist/core/errors/wave-api-error.d.ts.map +1 -0
  31. package/dist/core/errors/wave-api-error.js +114 -0
  32. package/dist/core/errors/wave-api-error.js.map +1 -0
  33. package/dist/core/errors/wave-error.d.ts +27 -0
  34. package/dist/core/errors/wave-error.d.ts.map +1 -0
  35. package/dist/core/errors/wave-error.js +22 -0
  36. package/dist/core/errors/wave-error.js.map +1 -0
  37. package/dist/core/errors/wave-network-error.d.ts +24 -0
  38. package/dist/core/errors/wave-network-error.d.ts.map +1 -0
  39. package/dist/core/errors/wave-network-error.js +24 -0
  40. package/dist/core/errors/wave-network-error.js.map +1 -0
  41. package/dist/core/errors/wave-webhook-verification-error.d.ts +18 -0
  42. package/dist/core/errors/wave-webhook-verification-error.d.ts.map +1 -0
  43. package/dist/core/errors/wave-webhook-verification-error.js +17 -0
  44. package/dist/core/errors/wave-webhook-verification-error.js.map +1 -0
  45. package/dist/core/http/fetch-transport.d.ts +23 -0
  46. package/dist/core/http/fetch-transport.d.ts.map +1 -0
  47. package/dist/core/http/fetch-transport.js +34 -0
  48. package/dist/core/http/fetch-transport.js.map +1 -0
  49. package/dist/core/http/http-client.d.ts +57 -0
  50. package/dist/core/http/http-client.d.ts.map +1 -0
  51. package/dist/core/http/http-client.js +254 -0
  52. package/dist/core/http/http-client.js.map +1 -0
  53. package/dist/core/http/http-request.d.ts +35 -0
  54. package/dist/core/http/http-request.d.ts.map +1 -0
  55. package/dist/core/http/http-request.js +2 -0
  56. package/dist/core/http/http-request.js.map +1 -0
  57. package/dist/core/http/http-response.d.ts +26 -0
  58. package/dist/core/http/http-response.d.ts.map +1 -0
  59. package/dist/core/http/http-response.js +23 -0
  60. package/dist/core/http/http-response.js.map +1 -0
  61. package/dist/core/http/query.d.ts +14 -0
  62. package/dist/core/http/query.d.ts.map +1 -0
  63. package/dist/core/http/query.js +23 -0
  64. package/dist/core/http/query.js.map +1 -0
  65. package/dist/core/http/transport.d.ts +44 -0
  66. package/dist/core/http/transport.d.ts.map +1 -0
  67. package/dist/core/http/transport.js +2 -0
  68. package/dist/core/http/transport.js.map +1 -0
  69. package/dist/core/idempotency/idempotency.d.ts +16 -0
  70. package/dist/core/idempotency/idempotency.d.ts.map +1 -0
  71. package/dist/core/idempotency/idempotency.js +27 -0
  72. package/dist/core/idempotency/idempotency.js.map +1 -0
  73. package/dist/core/retry/backoff.d.ts +18 -0
  74. package/dist/core/retry/backoff.d.ts.map +1 -0
  75. package/dist/core/retry/backoff.js +46 -0
  76. package/dist/core/retry/backoff.js.map +1 -0
  77. package/dist/core/retry/retry-policy.d.ts +43 -0
  78. package/dist/core/retry/retry-policy.d.ts.map +1 -0
  79. package/dist/core/retry/retry-policy.js +90 -0
  80. package/dist/core/retry/retry-policy.js.map +1 -0
  81. package/dist/core/types/common.d.ts +59 -0
  82. package/dist/core/types/common.d.ts.map +1 -0
  83. package/dist/core/types/common.js +2 -0
  84. package/dist/core/types/common.js.map +1 -0
  85. package/dist/core/types/configuration.d.ts +82 -0
  86. package/dist/core/types/configuration.d.ts.map +1 -0
  87. package/dist/core/types/configuration.js +2 -0
  88. package/dist/core/types/configuration.js.map +1 -0
  89. package/dist/core/types/json.d.ts +15 -0
  90. package/dist/core/types/json.d.ts.map +1 -0
  91. package/dist/core/types/json.js +2 -0
  92. package/dist/core/types/json.js.map +1 -0
  93. package/dist/index.d.ts +39 -0
  94. package/dist/index.d.ts.map +1 -0
  95. package/dist/index.js +24 -0
  96. package/dist/index.js.map +1 -0
  97. package/dist/resources/aggregated-merchants/aggregated-merchant-types.d.ts +82 -0
  98. package/dist/resources/aggregated-merchants/aggregated-merchant-types.d.ts.map +1 -0
  99. package/dist/resources/aggregated-merchants/aggregated-merchant-types.js +2 -0
  100. package/dist/resources/aggregated-merchants/aggregated-merchant-types.js.map +1 -0
  101. package/dist/resources/aggregated-merchants/aggregated-merchants.d.ts +67 -0
  102. package/dist/resources/aggregated-merchants/aggregated-merchants.d.ts.map +1 -0
  103. package/dist/resources/aggregated-merchants/aggregated-merchants.js +111 -0
  104. package/dist/resources/aggregated-merchants/aggregated-merchants.js.map +1 -0
  105. package/dist/resources/balance/balance-types.d.ts +18 -0
  106. package/dist/resources/balance/balance-types.d.ts.map +1 -0
  107. package/dist/resources/balance/balance-types.js +2 -0
  108. package/dist/resources/balance/balance-types.js.map +1 -0
  109. package/dist/resources/balance/balance.d.ts +20 -0
  110. package/dist/resources/balance/balance.d.ts.map +1 -0
  111. package/dist/resources/balance/balance.js +28 -0
  112. package/dist/resources/balance/balance.js.map +1 -0
  113. package/dist/resources/checkout/checkout-types.d.ts +96 -0
  114. package/dist/resources/checkout/checkout-types.d.ts.map +1 -0
  115. package/dist/resources/checkout/checkout-types.js +2 -0
  116. package/dist/resources/checkout/checkout-types.js.map +1 -0
  117. package/dist/resources/checkout/checkout.d.ts +66 -0
  118. package/dist/resources/checkout/checkout.d.ts.map +1 -0
  119. package/dist/resources/checkout/checkout.js +95 -0
  120. package/dist/resources/checkout/checkout.js.map +1 -0
  121. package/dist/resources/payout-batches/payout-batches.d.ts +31 -0
  122. package/dist/resources/payout-batches/payout-batches.d.ts.map +1 -0
  123. package/dist/resources/payout-batches/payout-batches.js +36 -0
  124. package/dist/resources/payout-batches/payout-batches.js.map +1 -0
  125. package/dist/resources/payouts/payout-types.d.ts +158 -0
  126. package/dist/resources/payouts/payout-types.d.ts.map +1 -0
  127. package/dist/resources/payouts/payout-types.js +2 -0
  128. package/dist/resources/payouts/payout-types.js.map +1 -0
  129. package/dist/resources/payouts/payouts.d.ts +63 -0
  130. package/dist/resources/payouts/payouts.d.ts.map +1 -0
  131. package/dist/resources/payouts/payouts.js +80 -0
  132. package/dist/resources/payouts/payouts.js.map +1 -0
  133. package/dist/resources/reconciliation/reconciliation-types.d.ts +86 -0
  134. package/dist/resources/reconciliation/reconciliation-types.d.ts.map +1 -0
  135. package/dist/resources/reconciliation/reconciliation-types.js +2 -0
  136. package/dist/resources/reconciliation/reconciliation-types.js.map +1 -0
  137. package/dist/resources/reconciliation/reconciliation.d.ts +41 -0
  138. package/dist/resources/reconciliation/reconciliation.d.ts.map +1 -0
  139. package/dist/resources/reconciliation/reconciliation.js +81 -0
  140. package/dist/resources/reconciliation/reconciliation.js.map +1 -0
  141. package/dist/resources/webhooks/webhook-types.d.ts +159 -0
  142. package/dist/resources/webhooks/webhook-types.d.ts.map +1 -0
  143. package/dist/resources/webhooks/webhook-types.js +36 -0
  144. package/dist/resources/webhooks/webhook-types.js.map +1 -0
  145. package/dist/resources/webhooks/webhook-verifier.d.ts +104 -0
  146. package/dist/resources/webhooks/webhook-verifier.d.ts.map +1 -0
  147. package/dist/resources/webhooks/webhook-verifier.js +188 -0
  148. package/dist/resources/webhooks/webhook-verifier.js.map +1 -0
  149. package/package.json +70 -4
  150. package/src/client/wave-client-options.ts +91 -0
  151. package/src/client/wave-client.ts +70 -0
  152. package/src/core/auth/authentication.ts +9 -0
  153. package/src/core/auth/request-signer.ts +42 -0
  154. package/src/core/errors/error-parser.ts +258 -0
  155. package/src/core/errors/redact.ts +20 -0
  156. package/src/core/errors/wave-api-error.ts +148 -0
  157. package/src/core/errors/wave-error.ts +32 -0
  158. package/src/core/errors/wave-network-error.ts +24 -0
  159. package/src/core/errors/wave-webhook-verification-error.ts +28 -0
  160. package/src/core/http/fetch-transport.ts +48 -0
  161. package/src/core/http/http-client.ts +352 -0
  162. package/src/core/http/http-request.ts +37 -0
  163. package/src/core/http/http-response.ts +37 -0
  164. package/src/core/http/query.ts +31 -0
  165. package/src/core/http/transport.ts +45 -0
  166. package/src/core/idempotency/idempotency.ts +31 -0
  167. package/src/core/retry/backoff.ts +61 -0
  168. package/src/core/retry/retry-policy.ts +106 -0
  169. package/src/core/types/common.ts +65 -0
  170. package/src/core/types/configuration.ts +85 -0
  171. package/src/core/types/json.ts +16 -0
  172. package/src/index.ts +146 -0
  173. package/src/resources/aggregated-merchants/aggregated-merchant-types.ts +87 -0
  174. package/src/resources/aggregated-merchants/aggregated-merchants.ts +171 -0
  175. package/src/resources/balance/balance-types.ts +19 -0
  176. package/src/resources/balance/balance.ts +39 -0
  177. package/src/resources/checkout/checkout-types.ts +102 -0
  178. package/src/resources/checkout/checkout.ts +144 -0
  179. package/src/resources/payout-batches/payout-batches.ts +58 -0
  180. package/src/resources/payouts/payout-types.ts +171 -0
  181. package/src/resources/payouts/payouts.ts +120 -0
  182. package/src/resources/reconciliation/reconciliation-types.ts +102 -0
  183. package/src/resources/reconciliation/reconciliation.ts +116 -0
  184. package/src/resources/webhooks/webhook-types.ts +222 -0
  185. package/src/resources/webhooks/webhook-verifier.ts +297 -0
package/README.md CHANGED
@@ -1,3 +1,524 @@
1
- # Temporary Holding Version
1
+ # @lukadriel/wave-sdk
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A unified, strictly typed TypeScript SDK for the [Wave Business APIs](https://docs.wave.com/business):
4
+ Payouts, Balance & Reconciliation, Checkout, Aggregated Merchants, and Webhooks.
5
+
6
+ - **Server-side only.** Uses your Wave Business API key; never bundle it into browser or mobile apps.
7
+ - **Zero runtime dependencies.** Native `fetch` transport and `node:crypto`.
8
+ - **Financial safety first.** Idempotency keys on documented mutations, retries only where the
9
+ operation is provably safe, and a fresh signature for every attempt.
10
+ - **Documentation-faithful types.** Amounts stay strings, field names match the API, and every
11
+ documented discrepancy is recorded in
12
+ [docs/documentation-gaps.md](https://github.com/lukadriel7/wave/blob/main/docs/documentation-gaps.md).
13
+
14
+ ## Requirements
15
+
16
+ | Runtime | Version |
17
+ | ------- | ------- |
18
+ | Node.js | >= 22 |
19
+ | Bun | >= 1.4 |
20
+
21
+ The package is ESM-only.
22
+
23
+ Wave does **not** document a sandbox or test environment, so the SDK does not invent one. The base
24
+ URL defaults to `https://api.wave.com` and can be changed with `baseUrl` for controlled test servers.
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ npm install @lukadriel/wave-sdk
30
+ ```
31
+
32
+ ## Quick start
33
+
34
+ ```ts
35
+ import { WaveClient } from '@lukadriel/wave-sdk';
36
+
37
+ const wave = new WaveClient({
38
+ apiKey: process.env.WAVE_API_KEY!,
39
+ signingSecret: process.env.WAVE_SIGNING_SECRET, // optional
40
+ });
41
+
42
+ const payout = await wave.payouts.create({
43
+ currency: 'XOF',
44
+ receive_amount: '5000',
45
+ name: 'John Doe',
46
+ mobile: '+2250700000000',
47
+ });
48
+ ```
49
+
50
+ ## Configuration
51
+
52
+ ```ts
53
+ import { WaveClient } from '@lukadriel/wave-sdk';
54
+
55
+ const wave = new WaveClient({
56
+ apiKey: process.env.WAVE_API_KEY!,
57
+ signingSecret: process.env.WAVE_SIGNING_SECRET, // enables Wave-Signature
58
+ baseUrl: 'https://api.wave.com', // default
59
+ timeoutMs: 30_000, // default
60
+ retry: { maxRetries: 2, baseDelayMs: 1000, maxDelayMs: 30_000, jitter: true },
61
+ transport: myTransport, // optional injectable WaveTransport
62
+ logger: { warn: (message, meta) => console.warn(message, meta) },
63
+ });
64
+ ```
65
+
66
+ | Option | Default | Description |
67
+ | --------------- | ---------------------- | ----------------------------------------------------------------- |
68
+ | `apiKey` | — | Required. Sent as `Authorization: Bearer <apiKey>`. |
69
+ | `signingSecret` | none | When set, every request includes `Wave-Signature`. |
70
+ | `baseUrl` | `https://api.wave.com` | Absolute `http(s)` URL; trailing slashes are normalized. |
71
+ | `timeoutMs` | `30000` | Per-request timeout. |
72
+ | `retry` | two retries | Retry policy, or `false` to disable. |
73
+ | `transport` | global `fetch` | Implement `WaveTransport` to plug in a custom HTTP stack. |
74
+ | `logger` | none | Receives request metadata only; never headers, bodies or secrets. |
75
+
76
+ Per-request overrides:
77
+
78
+ ```ts
79
+ await wave.balance.retrieve(undefined, {
80
+ timeoutMs: 5_000,
81
+ signal: abortController.signal,
82
+ retry: false,
83
+ idempotencyKey: 'order-2024-0001',
84
+ });
85
+ ```
86
+
87
+ ## Authentication
88
+
89
+ Wave authenticates requests with API keys bound to a single business wallet:
90
+
91
+ ```
92
+ Authorization: Bearer wave_sn_prod_...
93
+ ```
94
+
95
+ - Create and revoke keys in the [Wave Business Portal](https://business.wave.com/dev-portal).
96
+ - One key per wallet; scope keys to the APIs they need.
97
+ - Keep keys in a secrets manager or environment variables. Never commit them.
98
+ - The SDK never persists credentials, never logs them, and redacts them from error messages and
99
+ preserved response bodies.
100
+
101
+ ## Request signing
102
+
103
+ Request signing is optional and configured on the API key. When enabled, Wave requires this header
104
+ on every request:
105
+
106
+ ```
107
+ Wave-Signature: t={unix-seconds},v1={lowercase-hex-hmac-sha256}
108
+ ```
109
+
110
+ The signed payload is `timestamp + raw request body`. GET requests sign the timestamp alone.
111
+
112
+ ```ts
113
+ const wave = new WaveClient({
114
+ apiKey: process.env.WAVE_API_KEY!,
115
+ signingSecret: process.env.WAVE_SIGNING_SECRET!,
116
+ });
117
+ ```
118
+
119
+ Guarantees implemented by the SDK:
120
+
121
+ - The body is serialized **once**; those exact bytes are signed and transmitted.
122
+ - GET requests sign an empty body.
123
+ - A fresh timestamp is generated for every attempt, including retries.
124
+ - If no `signingSecret` is configured, no signature header is sent.
125
+
126
+ Wave rejects signatures older than 5 minutes or more than 30 seconds in the future, so keep the
127
+ server clock synchronized.
128
+
129
+ ## Idempotency
130
+
131
+ Wave requires an `Idempotency-Key` header for requests that modify data. Keys may be up to 255
132
+ characters; Wave recommends UUIDs.
133
+
134
+ The SDK generates a random v4 UUID per logical call when you do not supply one, and **reuses that
135
+ same key for every retry**:
136
+
137
+ ```ts
138
+ const payout = await wave.payouts.create(request);
139
+
140
+ // Or supply your own key. It is validated before any I/O happens.
141
+ await wave.payouts.create(request, { idempotencyKey: 'invoice-2024-0042' });
142
+ ```
143
+
144
+ | Operation | Auto idempotency key |
145
+ | ------------------------------------------ | ---------------------------------------------- |
146
+ | `payouts.create` | Yes |
147
+ | `payouts.reverse` | Yes |
148
+ | `payoutBatches.create` | Yes |
149
+ | `reconciliation.refund` | Yes |
150
+ | `checkout.refund` | Yes |
151
+ | `checkout.createSession` | No — Wave documents no key for this endpoint |
152
+ | `checkout.expire` | No — returns 409 when already complete/expired |
153
+ | `aggregatedMerchants.create/update/delete` | No |
154
+ | `payouts.verifyRecipient` | No — read-only verification |
155
+ | All GET operations | No key needed |
156
+
157
+ Rules to follow in your own system:
158
+
159
+ - Retry the **same** logical operation with the **same** key.
160
+ - Never reuse a key for a different transaction.
161
+ - Mark uncertain operations as pending, not failed, until you resolve them with the same key.
162
+ - A different key with an identical body creates a duplicate transaction.
163
+
164
+ ## Retries and rate limits
165
+
166
+ Default policy: two retries, exponential backoff starting at one second, full jitter, capped at 30
167
+ seconds. Retries happen only for:
168
+
169
+ - network failures and timeouts,
170
+ - HTTP 408, 429, and 5xx responses,
171
+
172
+ and only when the operation is documented as safe to retry. **Non-idempotent POSTs — checkout
173
+ session creation and aggregated merchant creation — are never retried automatically.** Wave also
174
+ documents HTTP 409 for expiring a completed session, so expiry is not auto-retried.
175
+
176
+ `Retry-After` is honoured when present (seconds or an HTTP date), although Wave's documentation does
177
+ not currently describe rate-limit headers or numeric quotas.
178
+
179
+ A per-request `retry` override on a non-idempotent operation is treated as an explicit assertion by
180
+ you that retrying is safe.
181
+
182
+ ## Error handling
183
+
184
+ ```ts
185
+ import {
186
+ WaveApiError,
187
+ WaveAuthenticationError,
188
+ WaveAuthorizationError,
189
+ WaveNotFoundError,
190
+ WaveValidationError,
191
+ WaveConflictError,
192
+ WaveRateLimitError,
193
+ WaveServerError,
194
+ WaveNetworkError,
195
+ WaveTimeoutError,
196
+ WaveAbortError,
197
+ WaveConfigurationError,
198
+ WaveWebhookVerificationError,
199
+ } from '@lukadriel/wave-sdk';
200
+ ```
201
+
202
+ ```
203
+ WaveError
204
+ ├── WaveApiError (statusCode, code, details, rawBody, responseHeaders)
205
+ │ ├── WaveAuthenticationError 401
206
+ │ ├── WaveAuthorizationError 403
207
+ │ ├── WaveNotFoundError 404
208
+ │ ├── WaveValidationError 400 / 422
209
+ │ ├── WaveConflictError 409
210
+ │ ├── WaveRateLimitError 429 (+ retryAfterSeconds)
211
+ │ └── WaveServerError 5xx
212
+ ├── WaveNetworkError
213
+ │ └── WaveTimeoutError
214
+ ├── WaveAbortError
215
+ ├── WaveConfigurationError
216
+ └── WaveWebhookVerificationError
217
+ ```
218
+
219
+ The parser accepts every documented error envelope:
220
+
221
+ - `{ "code", "message", "details" }` — the standard envelope,
222
+ - `{ "error", "message" }` — used by a payout example,
223
+ - `{ "error_code", "error_message" }` — used by aggregated merchants and payout failures.
224
+
225
+ Validation details are typed as `{ loc, msg, type?, ctx? }`.
226
+
227
+ A payout may also fail _after_ a successful HTTP response. Always inspect `payout.payout_error` for
228
+ `status === 'failed'`, including each payout inside a batch.
229
+
230
+ ## API
231
+
232
+ ### Payouts
233
+
234
+ ```ts
235
+ const payout = await wave.payouts.create({
236
+ currency: 'XOF',
237
+ receive_amount: '5000', // whole numbers only for payouts
238
+ name: 'John Doe',
239
+ mobile: '+2250700000000',
240
+ client_reference: 'order-2024-0001',
241
+ payment_reason: 'Order refund',
242
+ national_id: '1751197904376',
243
+ aggregated_merchant_id: 'am-7lks22ap113t4',
244
+ });
245
+
246
+ const samePayout = await wave.payouts.retrieve(payout.id);
247
+ const matches = await wave.payouts.search({ client_reference: 'order-2024-0001' });
248
+
249
+ // Returns nothing; Wave allows reversal within three days and the call is idempotent.
250
+ await wave.payouts.reverse(payout.id);
251
+ ```
252
+
253
+ Payout states: `processing`, `succeeded`, `failed`, `reversed`.
254
+
255
+ ### Payout batches
256
+
257
+ ```ts
258
+ const { id } = await wave.payoutBatches.create({
259
+ payouts: [
260
+ { currency: 'XOF', receive_amount: '1000', mobile: '+221555110219' },
261
+ { currency: 'XOF', receive_amount: '1200', mobile: '+221555110233' },
262
+ ],
263
+ });
264
+
265
+ const batch = await wave.payoutBatches.retrieve(id);
266
+ // batch.status: 'processing' | 'complete'
267
+ // Inspect each item's status/payout_error individually.
268
+ ```
269
+
270
+ Wave's endpoint list writes this path as `/v1/payouts-batch/:id`; the endpoint section and curl
271
+ example use `/v1/payout-batch/:id`. The SDK follows the latter.
272
+
273
+ ### Verify a recipient (restricted)
274
+
275
+ ```ts
276
+ const verification = await wave.payouts.verifyRecipient({
277
+ mobile: '+221761110010',
278
+ name: 'Alice Adams',
279
+ national_id: 'G4023458',
280
+ amount: '1000',
281
+ currency: 'XOF',
282
+ });
283
+
284
+ verification.within_limits; // boolean | null
285
+ verification.name_match; // 'MATCH' | 'NO_MATCH' | 'NAME_NOT_KNOWN' | null
286
+ verification.national_id_match; // 'MATCH' | 'NO_MATCH' | 'ID_NOT_KNOWN' | null | undefined
287
+ ```
288
+
289
+ This endpoint is disabled by default and enabled case by case for businesses with a documented
290
+ compliance justification. Without access it returns HTTP 403, surfaced as
291
+ `WaveAuthorizationError`. You do not need it to pay unregistered recipients.
292
+
293
+ ### Balance and reconciliation
294
+
295
+ ```ts
296
+ const balance = await wave.balance.retrieve({ include_subaccounts: true });
297
+
298
+ const page = await wave.reconciliation.listTransactions({
299
+ date: '2022-11-07',
300
+ include_subaccounts: true,
301
+ first: 1000,
302
+ });
303
+
304
+ for await (const transaction of wave.reconciliation.iterateTransactions({ date: '2022-11-07' })) {
305
+ console.log(transaction.transaction_id, transaction.amount, transaction.currency);
306
+ }
307
+
308
+ await wave.reconciliation.refund('T_VZSWJF5MMQ');
309
+ ```
310
+
311
+ Transactions are ordered oldest first and paginate when a day exceeds 1000 entries. Amounts, fees
312
+ and balances are strings.
313
+
314
+ ### Checkout
315
+
316
+ ```ts
317
+ const session = await wave.checkout.createSession({
318
+ amount: '1000',
319
+ currency: 'XOF',
320
+ error_url: 'https://example.com/error',
321
+ success_url: 'https://example.com/success',
322
+ client_reference: 'order-123',
323
+ restrict_payer_mobile: '+221761110010',
324
+ });
325
+
326
+ // Open this in the customer's browser; never inside an embedded webview.
327
+ console.log(session.wave_launch_url);
328
+
329
+ await wave.checkout.retrieve(session.id);
330
+ await wave.checkout.retrieveByTransactionId(session.transaction_id);
331
+ await wave.checkout.search({ client_reference: 'order-123' });
332
+ await wave.checkout.refund(session.id); // repeated refunds still return 200
333
+ await wave.checkout.expire(session.id); // 409 when already complete/expired
334
+ ```
335
+
336
+ Checkout states: `open`, `complete`, `expired`. Payment states: `processing`, `cancelled`,
337
+ `succeeded`.
338
+
339
+ `restrict_payer_mobile` was previously named `enforce_payer_mobile`; Wave documents the old name as
340
+ still accepted but deprecated, so the SDK uses the new name only.
341
+
342
+ ### Aggregated merchants
343
+
344
+ ```ts
345
+ for await (const merchant of wave.aggregatedMerchants.iterate()) {
346
+ console.log(merchant.id, merchant.name, merchant.is_locked);
347
+ }
348
+
349
+ const merchant = await wave.aggregatedMerchants.create({
350
+ name: 'Moustaphas Groceries',
351
+ business_type: 'other', // 'fintech' | 'other'
352
+ business_description: 'A grocery store in the heart of the city.',
353
+ business_registration_identifier: 'A-12234-M',
354
+ business_sector: 'retail',
355
+ website_url: 'https://groceries.example.com',
356
+ manager_name: 'Moustapha',
357
+ });
358
+
359
+ await wave.aggregatedMerchants.update(merchant.id, { ... });
360
+ await wave.aggregatedMerchants.delete(merchant.id); // 204, no body
361
+ ```
362
+
363
+ Fee structures are `one_percent`, `one_fifty_bps`, and `two_percent`. Locked merchants reject
364
+ updates with HTTP 403 (`record-locked`) but can still be deleted.
365
+
366
+ Wave's response table names a field `business_registration_id`, while its examples return
367
+ `business_registration_identifier`. The SDK types both as optional.
368
+
369
+ ## Webhooks
370
+
371
+ Wave registers webhooks through the Business Portal; there is no public webhook CRUD API. The SDK
372
+ provides verification and typed events.
373
+
374
+ ### Signing secret (recommended)
375
+
376
+ ```ts
377
+ import { constructWaveWebhookEvent, toKnownWebhookEvent } from '@lukadriel/wave-sdk';
378
+
379
+ // `rawBody` must be the exact bytes Wave sent. Do not parse and re-serialize first.
380
+ const event = constructWaveWebhookEvent({
381
+ rawBody,
382
+ signatureHeader: request.headers['wave-signature'],
383
+ secret: process.env.WAVE_WEBHOOK_SECRET!,
384
+ });
385
+
386
+ const known = toKnownWebhookEvent(event);
387
+ if (known?.type === 'checkout.session.completed') {
388
+ console.log(known.data.id, known.data.transaction_id);
389
+ }
390
+ ```
391
+
392
+ Verification details:
393
+
394
+ - HMAC-SHA256 over `timestamp + rawBody`, compared in constant time.
395
+ - Multiple `v1=` signatures are accepted, which supports Wave's secret-rotation flow.
396
+ - Timestamps older than 5 minutes are rejected by default (`toleranceSeconds` is configurable).
397
+ - Missing, malformed or mismatched headers raise `WaveWebhookVerificationError` with a `reason`.
398
+
399
+ ### Shared secret
400
+
401
+ ```ts
402
+ import { verifyWaveWebhookSharedSecret } from '@lukadriel/wave-sdk';
403
+
404
+ verifyWaveWebhookSharedSecret({
405
+ authorizationHeader: request.headers.authorization,
406
+ secret: process.env.WAVE_WEBHOOK_SECRET!,
407
+ });
408
+ ```
409
+
410
+ ### Event types
411
+
412
+ `checkout.session.completed`, `checkout.session.payment_failed`, `b2b.payment_received`,
413
+ `b2b.payment_failed`, `merchant.payment_received`, `remittance.delivered`, `remittance.reversed`,
414
+ `test.test_event`.
415
+
416
+ Every event has the shape `{ id, type, data }`. Use `id` for de-duplication: Wave may deliver the
417
+ same event more than once, and events may arrive out of order. Payload schemas for
418
+ `b2b.payment_failed`, `remittance.delivered`, `remittance.reversed` and `test.test_event` are not
419
+ published by Wave, so their `data` is typed as `unknown`.
420
+
421
+ ### Delivery expectations
422
+
423
+ - Respond with HTTP 2xx within 5 seconds, then process asynchronously.
424
+ - Wave retries for up to 3 days when the response is not 2xx.
425
+ - Events may be missed, duplicated, or delivered out of order.
426
+ - Whitelist Wave's published source IP ranges; see
427
+ [docs/security.md](https://github.com/lukadriel7/wave/blob/main/docs/security.md#webhook-source-ip-allowlist).
428
+
429
+ ## Production security recommendations
430
+
431
+ 1. **Server-side only.** Never expose the API key or signing secret to browsers or mobile apps.
432
+ 2. **Enable request signing** so a leaked API key alone cannot be used.
433
+ 3. **Enable API key IP allowlisting** in the Business Portal and use static egress IPs.
434
+ 4. **Use scoped keys**, one per wallet and API family; rotate keys regularly.
435
+ 5. **Verify webhooks** against raw bytes and keep the replay window small.
436
+ 6. **Deduplicate:** persist idempotency keys and webhook event IDs.
437
+ 7. **Treat unknown outcomes as pending** and resolve them with the same idempotency key or by
438
+ fetching the payout.
439
+ 8. **Avoid logging payloads and headers.** The SDK logger receives metadata only.
440
+ 9. **Keep clocks synchronized**; signature timestamps must be recent.
441
+
442
+ ## API coverage and documentation gaps
443
+
444
+ - [API coverage matrix](https://github.com/lukadriel7/wave/blob/main/docs/api-coverage.md)
445
+ - [Documentation discrepancies and gaps](https://github.com/lukadriel7/wave/blob/main/docs/documentation-gaps.md)
446
+ - [Security model](https://github.com/lukadriel7/wave/blob/main/docs/security.md)
447
+
448
+ ## TypeScript design
449
+
450
+ - Strict compiler settings, including `exactOptionalPropertyTypes` and `noUncheckedIndexedAccess`.
451
+ - No `any` in the public surface.
452
+ - Request and response models are separate.
453
+ - Documented field names are preserved (`receive_amount`, `client_reference`, `when_created`, …).
454
+ - Monetary amounts remain strings; nullable fields are `| null`, absent fields are optional.
455
+ - Literal unions model documented states and enums.
456
+
457
+ ## Examples
458
+
459
+ Runnable examples live in
460
+ [examples/](https://github.com/lukadriel7/wave/tree/main/examples):
461
+
462
+ ```bash
463
+ WAVE_API_KEY=... npx tsx examples/payout.ts
464
+ WAVE_API_KEY=... npx tsx examples/payout-batch.ts
465
+ WAVE_API_KEY=... npx tsx examples/balance-reconciliation.ts
466
+ WAVE_API_KEY=... npx tsx examples/checkout.ts
467
+ WAVE_API_KEY=... npx tsx examples/aggregated-merchants.ts
468
+ WAVE_WEBHOOK_SECRET=... npx tsx examples/webhook-verify.ts
469
+ ```
470
+
471
+ ## Development
472
+
473
+ ```bash
474
+ npm install
475
+ npm run typecheck
476
+ npm run lint
477
+ npm run format:check
478
+ npm test
479
+ npm run build
480
+ npm pack --dry-run
481
+ ```
482
+
483
+ Linting uses [Oxlint](https://oxc.rs/docs/guide/usage/linter) and formatting uses
484
+ [Oxfmt](https://oxc.rs/docs/guide/usage/formatter); see
485
+ [docs/tooling.md](https://github.com/lukadriel7/wave/blob/main/docs/tooling.md) for the
486
+ ESLint/Prettier mapping and known coverage gaps.
487
+
488
+ Bun compatibility is validated after a build:
489
+
490
+ ```bash
491
+ npm run build
492
+ npm run smoke:bun
493
+ ```
494
+
495
+ `npm pack` and `npm publish` run the `prepack` script, which rebuilds `dist/` so the tarball never
496
+ ships stale or missing JavaScript and declaration files. The tarball contains `dist/`, `src/` (needed
497
+ by the declaration maps), `README.md`, `CHANGELOG.md`, `LICENSE`, and `NOTICE` only.
498
+
499
+ ## Releasing
500
+
501
+ Releases are published manually by a maintainer who is authenticated to the `@lukadriel` npm scope.
502
+ CI validates the commit but does not publish.
503
+
504
+ 1. Bump the version: `npm version <patch|minor|major> --no-git-tag-version`.
505
+ 2. Move the `[Unreleased]` entries in [CHANGELOG.md](https://github.com/lukadriel7/wave/blob/main/CHANGELOG.md)
506
+ into a new `## [x.y.z] - YYYY-MM-DD` section and update the comparison links.
507
+ 3. Run the full gate:
508
+ `npm ci && npm run typecheck && npm run lint && npm run format:check && npm test`.
509
+ 4. Inspect the tarball with `npm pack --dry-run`: it must contain `dist/index.js`,
510
+ `dist/index.d.ts`, `package.json`, `README.md`, `CHANGELOG.md`, `LICENSE`, and `NOTICE`, and must
511
+ not contain `tests/`, `examples/`, `.env*`, or build configuration.
512
+ 5. Publish with `npm publish`. `prepublishOnly` re-runs typecheck, lint, and tests, then `prepack`
513
+ rebuilds `dist/`. The package is published publicly under the scope through
514
+ `publishConfig.access`.
515
+ 6. Push the commit and tag, then create a GitHub release whose notes mirror the new changelog
516
+ section.
517
+
518
+ The repository must be clean before tagging; never commit API keys, signing secrets, or `.env` files.
519
+
520
+ ## License
521
+
522
+ Apache License 2.0. See
523
+ [LICENSE](https://github.com/lukadriel7/wave/blob/main/LICENSE) and
524
+ [NOTICE](https://github.com/lukadriel7/wave/blob/main/NOTICE).
@@ -0,0 +1,29 @@
1
+ import type { WaveTransport } from '../core/http/transport.js';
2
+ import type { RetryOptions, WaveClientOptions, WaveLogger } from '../core/types/configuration.js';
3
+ /**
4
+ * Validated client configuration used internally.
5
+ */
6
+ export interface ResolvedClientOptions {
7
+ /** Normalized base URL without a trailing slash. */
8
+ readonly baseUrl: string;
9
+ /** Wave Business API key. */
10
+ readonly apiKey: string;
11
+ /** Optional signing secret. */
12
+ readonly signingSecret: string | undefined;
13
+ /** HTTP transport. */
14
+ readonly transport: WaveTransport;
15
+ /** Default request timeout in milliseconds. */
16
+ readonly timeoutMs: number;
17
+ /** Default retry policy, or `false` when disabled. */
18
+ readonly retry: RetryOptions | false;
19
+ /** Optional diagnostics logger. */
20
+ readonly logger: WaveLogger | undefined;
21
+ }
22
+ /**
23
+ * Validates and normalizes {@link WaveClientOptions}.
24
+ *
25
+ * @param options - Caller-provided client options.
26
+ * @returns Resolved configuration with defaults applied.
27
+ */
28
+ export declare function resolveClientOptions(options: WaveClientOptions): ResolvedClientOptions;
29
+ //# sourceMappingURL=wave-client-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wave-client-options.d.ts","sourceRoot":"","sources":["../../src/client/wave-client-options.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAElG;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,oDAAoD;IACpD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,6BAA6B;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+BAA+B;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,sBAAsB;IACtB,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;IAClC,+CAA+C;IAC/C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,sDAAsD;IACtD,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,KAAK,CAAC;IACrC,mCAAmC;IACnC,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,CAAC;CACzC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,GAAG,qBAAqB,CAuCtF"}
@@ -0,0 +1,58 @@
1
+ import { WaveConfigurationError } from '../core/errors/wave-error.js';
2
+ import { DEFAULT_BASE_URL, DEFAULT_TIMEOUT_MS } from '../core/http/http-client.js';
3
+ import { FetchTransport } from '../core/http/fetch-transport.js';
4
+ import { normalizeRetryOptions } from '../core/retry/retry-policy.js';
5
+ /**
6
+ * Validates and normalizes {@link WaveClientOptions}.
7
+ *
8
+ * @param options - Caller-provided client options.
9
+ * @returns Resolved configuration with defaults applied.
10
+ */
11
+ export function resolveClientOptions(options) {
12
+ if (typeof options !== 'object' || options === null) {
13
+ throw new WaveConfigurationError('WaveClient options are required.');
14
+ }
15
+ if (typeof options.apiKey !== 'string' || options.apiKey.trim().length === 0) {
16
+ throw new WaveConfigurationError('apiKey must be a non-empty string.');
17
+ }
18
+ if (options.signingSecret !== undefined &&
19
+ (typeof options.signingSecret !== 'string' || options.signingSecret.trim().length === 0)) {
20
+ throw new WaveConfigurationError('signingSecret must be a non-empty string when provided.');
21
+ }
22
+ const baseUrl = normalizeBaseUrl(options.baseUrl ?? DEFAULT_BASE_URL);
23
+ const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
24
+ if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
25
+ throw new WaveConfigurationError('timeoutMs must be a positive finite number.');
26
+ }
27
+ const retry = options.retry === false ? false : normalizeRetryOptions(options.retry ?? {});
28
+ const transport = options.transport ?? new FetchTransport();
29
+ if (typeof transport.send !== 'function') {
30
+ throw new WaveConfigurationError('transport must implement send(request).');
31
+ }
32
+ return {
33
+ baseUrl,
34
+ apiKey: options.apiKey,
35
+ signingSecret: options.signingSecret,
36
+ transport,
37
+ timeoutMs,
38
+ retry,
39
+ logger: options.logger,
40
+ };
41
+ }
42
+ function normalizeBaseUrl(value) {
43
+ let url;
44
+ try {
45
+ url = new URL(value);
46
+ }
47
+ catch {
48
+ throw new WaveConfigurationError('baseUrl must be a valid absolute URL.');
49
+ }
50
+ if (url.protocol !== 'https:' && url.protocol !== 'http:') {
51
+ throw new WaveConfigurationError('baseUrl must use the http or https scheme.');
52
+ }
53
+ if (url.search.length > 0 || url.hash.length > 0) {
54
+ throw new WaveConfigurationError('baseUrl must not contain a query string or fragment.');
55
+ }
56
+ return url.toString().replace(/\/+$/u, '');
57
+ }
58
+ //# sourceMappingURL=wave-client-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wave-client-options.js","sourceRoot":"","sources":["../../src/client/wave-client-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAuBtE;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA0B;IAC7D,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACpD,MAAM,IAAI,sBAAsB,CAAC,kCAAkC,CAAC,CAAC;IACvE,CAAC;IAED,IAAI,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7E,MAAM,IAAI,sBAAsB,CAAC,oCAAoC,CAAC,CAAC;IACzE,CAAC;IAED,IACE,OAAO,CAAC,aAAa,KAAK,SAAS;QACnC,CAAC,OAAO,OAAO,CAAC,aAAa,KAAK,QAAQ,IAAI,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,EACxF,CAAC;QACD,MAAM,IAAI,sBAAsB,CAAC,yDAAyD,CAAC,CAAC;IAC9F,CAAC;IAED,MAAM,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC,OAAO,IAAI,gBAAgB,CAAC,CAAC;IAEtE,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,kBAAkB,CAAC;IAC1D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,sBAAsB,CAAC,6CAA6C,CAAC,CAAC;IAClF,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,qBAAqB,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAC3F,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,cAAc,EAAE,CAAC;IAE5D,IAAI,OAAO,SAAS,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACzC,MAAM,IAAI,sBAAsB,CAAC,yCAAyC,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO;QACL,OAAO;QACP,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,SAAS;QACT,SAAS;QACT,KAAK;QACL,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAa;IACrC,IAAI,GAAQ,CAAC;IACb,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,sBAAsB,CAAC,uCAAuC,CAAC,CAAC;IAC5E,CAAC;IAED,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QAC1D,MAAM,IAAI,sBAAsB,CAAC,4CAA4C,CAAC,CAAC;IACjF,CAAC;IACD,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,sBAAsB,CAAC,sDAAsD,CAAC,CAAC;IAC3F,CAAC;IAED,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import { WaveConfigurationError } from '../core/errors/wave-error.js';\nimport { DEFAULT_BASE_URL, DEFAULT_TIMEOUT_MS } from '../core/http/http-client.js';\nimport { FetchTransport } from '../core/http/fetch-transport.js';\nimport type { WaveTransport } from '../core/http/transport.js';\nimport { normalizeRetryOptions } from '../core/retry/retry-policy.js';\nimport type { RetryOptions, WaveClientOptions, WaveLogger } from '../core/types/configuration.js';\n\n/**\n * Validated client configuration used internally.\n */\nexport interface ResolvedClientOptions {\n /** Normalized base URL without a trailing slash. */\n readonly baseUrl: string;\n /** Wave Business API key. */\n readonly apiKey: string;\n /** Optional signing secret. */\n readonly signingSecret: string | undefined;\n /** HTTP transport. */\n readonly transport: WaveTransport;\n /** Default request timeout in milliseconds. */\n readonly timeoutMs: number;\n /** Default retry policy, or `false` when disabled. */\n readonly retry: RetryOptions | false;\n /** Optional diagnostics logger. */\n readonly logger: WaveLogger | undefined;\n}\n\n/**\n * Validates and normalizes {@link WaveClientOptions}.\n *\n * @param options - Caller-provided client options.\n * @returns Resolved configuration with defaults applied.\n */\nexport function resolveClientOptions(options: WaveClientOptions): ResolvedClientOptions {\n if (typeof options !== 'object' || options === null) {\n throw new WaveConfigurationError('WaveClient options are required.');\n }\n\n if (typeof options.apiKey !== 'string' || options.apiKey.trim().length === 0) {\n throw new WaveConfigurationError('apiKey must be a non-empty string.');\n }\n\n if (\n options.signingSecret !== undefined &&\n (typeof options.signingSecret !== 'string' || options.signingSecret.trim().length === 0)\n ) {\n throw new WaveConfigurationError('signingSecret must be a non-empty string when provided.');\n }\n\n const baseUrl = normalizeBaseUrl(options.baseUrl ?? DEFAULT_BASE_URL);\n\n const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {\n throw new WaveConfigurationError('timeoutMs must be a positive finite number.');\n }\n\n const retry = options.retry === false ? false : normalizeRetryOptions(options.retry ?? {});\n const transport = options.transport ?? new FetchTransport();\n\n if (typeof transport.send !== 'function') {\n throw new WaveConfigurationError('transport must implement send(request).');\n }\n\n return {\n baseUrl,\n apiKey: options.apiKey,\n signingSecret: options.signingSecret,\n transport,\n timeoutMs,\n retry,\n logger: options.logger,\n };\n}\n\nfunction normalizeBaseUrl(value: string): string {\n let url: URL;\n try {\n url = new URL(value);\n } catch {\n throw new WaveConfigurationError('baseUrl must be a valid absolute URL.');\n }\n\n if (url.protocol !== 'https:' && url.protocol !== 'http:') {\n throw new WaveConfigurationError('baseUrl must use the http or https scheme.');\n }\n if (url.search.length > 0 || url.hash.length > 0) {\n throw new WaveConfigurationError('baseUrl must not contain a query string or fragment.');\n }\n\n return url.toString().replace(/\\/+$/u, '');\n}\n"]}
@@ -0,0 +1,47 @@
1
+ import type { WaveClientOptions } from '../core/types/configuration.js';
2
+ import { AggregatedMerchantsResource } from '../resources/aggregated-merchants/aggregated-merchants.js';
3
+ import { BalanceResource } from '../resources/balance/balance.js';
4
+ import { CheckoutResource } from '../resources/checkout/checkout.js';
5
+ import { PayoutBatchesResource } from '../resources/payout-batches/payout-batches.js';
6
+ import { PayoutsResource } from '../resources/payouts/payouts.js';
7
+ import { ReconciliationResource } from '../resources/reconciliation/reconciliation.js';
8
+ import { WaveWebhooks } from '../resources/webhooks/webhook-verifier.js';
9
+ /**
10
+ * Unified entry point for the Wave Business APIs.
11
+ *
12
+ * The client is intended for trusted server-side environments. It never persists credentials and
13
+ * never exposes them through errors or logs.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const wave = new WaveClient({ apiKey: process.env.WAVE_API_KEY! });
18
+ * const payout = await wave.payouts.create({
19
+ * currency: 'XOF',
20
+ * receive_amount: '5000',
21
+ * name: 'John Doe',
22
+ * mobile: '+2250700000000',
23
+ * });
24
+ * ```
25
+ */
26
+ export declare class WaveClient {
27
+ /** Payout API operations. */
28
+ readonly payouts: PayoutsResource;
29
+ /** Payout batch operations. */
30
+ readonly payoutBatches: PayoutBatchesResource;
31
+ /** Balance API operations. */
32
+ readonly balance: BalanceResource;
33
+ /** Transaction listing and refund operations. */
34
+ readonly reconciliation: ReconciliationResource;
35
+ /** Checkout API operations. */
36
+ readonly checkout: CheckoutResource;
37
+ /** Aggregated Merchants API operations. */
38
+ readonly aggregatedMerchants: AggregatedMerchantsResource;
39
+ /** Local webhook signature verification helpers; no HTTP calls are made. */
40
+ readonly webhooks: WaveWebhooks;
41
+ /**
42
+ * @param options - API credentials and transport configuration.
43
+ * @throws WaveConfigurationError when required options are missing or invalid.
44
+ */
45
+ constructor(options: WaveClientOptions);
46
+ }
47
+ //# sourceMappingURL=wave-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wave-client.d.ts","sourceRoot":"","sources":["../../src/client/wave-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,2DAA2D,CAAC;AACxG,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AAGzE;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,UAAU;IACrB,6BAA6B;IAC7B,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,+BAA+B;IAC/B,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAC;IAC9C,8BAA8B;IAC9B,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,iDAAiD;IACjD,QAAQ,CAAC,cAAc,EAAE,sBAAsB,CAAC;IAChD,+BAA+B;IAC/B,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,2CAA2C;IAC3C,QAAQ,CAAC,mBAAmB,EAAE,2BAA2B,CAAC;IAC1D,4EAA4E;IAC5E,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAEhC;;;OAGG;gBACS,OAAO,EAAE,iBAAiB;CAqBvC"}