@spritz-finance/api-client 0.11.0 → 0.13.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 +31 -1
- package/dist/spritz-api-client.cjs +59 -59
- package/dist/spritz-api-client.d.ts +17031 -7282
- package/dist/spritz-api-client.mjs +59 -59
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -161,6 +161,21 @@ const { apiKey, userId, email } = await client.user.authorizeApiKeyWithOTP({
|
|
|
161
161
|
const userData = await client.user.getCurrentUser()
|
|
162
162
|
```
|
|
163
163
|
|
|
164
|
+
#### REST User Profile
|
|
165
|
+
|
|
166
|
+
`user.getMe()` returns the user profile from the REST API (`GET /v1/users/me`) as-is, typed as `UserProfile`. It includes the user's `verification` state and `capabilities`:
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
const me = await client.user.getMe()
|
|
170
|
+
|
|
171
|
+
me.verification.status // 'not_started' | 'verified' | 'failed' | 'disabled' | 'retry'
|
|
172
|
+
me.verification.country // e.g. 'US', or null
|
|
173
|
+
me.verification.requirement // outstanding requirement, if any ({ type, status, actionUrl?, retryable? })
|
|
174
|
+
me.capabilities // [{ product, method?, name, status, nextRequirement?, requirements }]
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
> **Note:** `getMe()` does not yet replace `getCurrentUser()`. The REST profile has no verification failure reason, reports verifications under review as `not_started`, and there is no REST equivalent of `retryFailedVerification()`.
|
|
178
|
+
|
|
164
179
|
### Identity Verification
|
|
165
180
|
|
|
166
181
|
All users must complete identity verification before using the platform. New users start with a verification status of `NotStarted`.
|
|
@@ -179,6 +194,21 @@ const verificationParams = await client.user.getVerificationParams()
|
|
|
179
194
|
// - verificationUrlExpiresAt: Expiration timestamp for the verification URL
|
|
180
195
|
```
|
|
181
196
|
|
|
197
|
+
#### Creating a Verification Session (REST)
|
|
198
|
+
|
|
199
|
+
`verification.createSession()` creates or resumes the user's verification session via the REST API (`POST /v1/users/me/verification-sessions/`) and returns the response as-is, typed as `VerificationSession`:
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
const { sessionId, provider, sessionToken, verificationUrl, verificationUrlExpiresAt } =
|
|
203
|
+
await client.verification.createSession()
|
|
204
|
+
|
|
205
|
+
// provider: 'persona' | 'plaid'
|
|
206
|
+
// sessionToken: embedded-flow token (Persona session token or Plaid Link token), or null
|
|
207
|
+
// verificationUrl: provider-hosted URL, or null
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Tokens and URLs may expire, so create the session just in time rather than caching it. The call throws a `ConflictError` (409) when verification is under review or unavailable, and an `InternalServerError` (503, with `retryAfter` in the error body) when the provider is temporarily unavailable.
|
|
211
|
+
|
|
182
212
|
#### Option 1: Verification URL
|
|
183
213
|
|
|
184
214
|
The simplest integration — redirect the user to the hosted verification flow:
|
|
@@ -980,7 +1010,7 @@ ACH onramp lets users convert USD from their bank account into USDC delivered to
|
|
|
980
1010
|
4. **Server:** find an active funding source and fetch limits with `client.fundingSource.getDepositLimits(id)`
|
|
981
1011
|
5. **Server:** prepare a quote with `client.deposit.prepare(...)`
|
|
982
1012
|
6. **Client:** show the quote and ACH authorization message to the user
|
|
983
|
-
7. **Server:** create the deposit with `client.deposit.create(
|
|
1013
|
+
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
|
|
984
1014
|
|
|
985
1015
|
Authorization is derived from the verified ACH funding source — no wallet signature is required.
|
|
986
1016
|
|