@spritz-finance/api-client 0.11.0 → 0.12.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 +30 -0
- package/dist/spritz-api-client.cjs +14 -14
- package/dist/spritz-api-client.d.ts +17345 -7612
- package/dist/spritz-api-client.mjs +14 -14
- 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:
|