@spritz-finance/api-client 0.14.0 → 0.16.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.
- package/README.md +27 -0
- package/dist/spritz-api-client.cjs +68 -68
- package/dist/spritz-api-client.d.ts +645 -42
- package/dist/spritz-api-client.mjs +61 -61
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1015,9 +1015,36 @@ ACH onramp lets users convert USD from their bank account into USDC delivered to
|
|
|
1015
1015
|
5. **Server:** prepare a quote with `client.deposit.prepare(...)`
|
|
1016
1016
|
6. **Client:** show the quote and ACH authorization message to the user
|
|
1017
1017
|
7. **Server:** create the deposit with `client.deposit.create(input, { idempotencyKey })`; Spritz runs risk checks before initiating the ACH pull. Persist one unique key per deposit intent and reuse it verbatim on retries so a timed-out request replays the original response instead of authorizing a second debit
|
|
1018
|
+
8. **Server:** track the deposit with `client.deposit.get(depositId)`, or reconcile a backlog by paging `client.deposit.list({ limit, cursor })`
|
|
1019
|
+
|
|
1020
|
+
```typescript
|
|
1021
|
+
// Page the authenticated user's deposits, newest first
|
|
1022
|
+
const { data, hasMore, nextCursor } = await client.deposit.list({ limit: 25 })
|
|
1023
|
+
|
|
1024
|
+
if (hasMore && nextCursor) {
|
|
1025
|
+
const next = await client.deposit.list({ limit: 25, cursor: nextCursor })
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
// Read one deposit's ACH debit and crypto release state
|
|
1029
|
+
const deposit = await client.deposit.get('dep_01JV7Q8M4Y8K6N2Z5P3R1T9W0X')
|
|
1030
|
+
console.log(deposit.status, deposit.debitStatus, deposit.releaseStatus)
|
|
1031
|
+
```
|
|
1032
|
+
|
|
1033
|
+
`client.deposit.list()` is user-scoped, so an integrator-wide reconciliation iterates your own user roster and authorizes each user's read with `client.setApiKey(userApiKey)`. Webhooks are notifications, not the only record of deposits.
|
|
1018
1034
|
|
|
1019
1035
|
Authorization is derived from the verified ACH funding source — no wallet signature is required.
|
|
1020
1036
|
|
|
1037
|
+
**A backend `create` must send `clientIp`** — the public address your edge observed for the authorizing client, distinct from your backend's own address. The generated type marks it optional because the contract allows omitting it only for a direct client submission authenticated with a `submissionToken`, which this SDK does not send; a backend create without it fails at runtime, not at compile time.
|
|
1038
|
+
|
|
1039
|
+
```typescript
|
|
1040
|
+
const deposit = await client.deposit.create(
|
|
1041
|
+
{ preparationId: preparation.preparationId, clientIp: req.ip },
|
|
1042
|
+
{ idempotencyKey }
|
|
1043
|
+
)
|
|
1044
|
+
```
|
|
1045
|
+
|
|
1046
|
+
To move submission onto the customer's device, pass `clientNetwork: { ipAddresses: [req.ip] }` to `prepare` and forward the returned `submissionToken` to that client. The client then calls `POST /v1/deposits/direct` itself with `Authorization: Bearer ach_submit_...` as its only credential — no user API key, no integrator key, no HMAC headers — plus the `Idempotency-Key` header and a body of just `{ preparationId }`. This SDK signs every REST call with integrator HMAC, so that request should not go through it; see the [ACH Onramp Integration Guide](docs/ach-onramp-guide.md) for the full request.
|
|
1047
|
+
|
|
1021
1048
|
If risk checks block the create step, the API returns 409 before any ACH debit is pulled. Prepare a new quote before retrying; blocked create attempts consume the original `preparationId`.
|
|
1022
1049
|
|
|
1023
1050
|
For a complete walkthrough with code examples, request/response schemas, and deposit lifecycle documentation, see the **[ACH Onramp Integration Guide](docs/ach-onramp-guide.md)**.
|