stream-connect-sdk 0.7.7 → 0.8.1

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.
@@ -0,0 +1,489 @@
1
+ # Client Usage
2
+
3
+ > **Upgrading from 0.7?** See the [0.7 → 0.8 migration guide](./migration-0.7-to-0.8.md).
4
+
5
+ Mount the SDK by calling `StreamConnect({...})` with your config. The minimum you need is `el` (where to mount), `employer`, `user`, and `apiToken`. Everything else has sane defaults.
6
+
7
+ ![SDK default UI](https://tpastream-public.s3.amazonaws.com/sdk-docs/flow-screenshots/choose-payer.png)
8
+
9
+ ## Quickstart
10
+
11
+ ### Via CDN (vanilla HTML, server-rendered, Backbone, jQuery)
12
+
13
+ ```html
14
+ <script src="https://app.tpastream.com/static/js/sdk-v-0.8.1.js"></script>
15
+ <div id="sdk-hook"></div>
16
+ <script>
17
+ window.StreamConnect({
18
+ el: '#sdk-hook',
19
+ employer: { vendor: 'internal', systemKey: 'EMP-123' },
20
+ user: {
21
+ firstName: 'Joe',
22
+ lastName: 'Sample',
23
+ email: 'joe@example.com',
24
+ },
25
+ apiToken: 'YOUR-SDK-TOKEN',
26
+ });
27
+ </script>
28
+ ```
29
+
30
+ Three CDN forms are supported:
31
+
32
+ * `sdk-v-0.8.1.js` (current 0.8.x, pinned)
33
+ * `sdk-v-0.8.0.js` (0.8.0, pinned)
34
+ * `sdk-v-0.7.7.js` (last 0.7.x, pinned)
35
+ * `sdk.js` (floating pointer to the latest release; updates automatically when a new version ships)
36
+
37
+ Pinned versions stay available indefinitely. See [Migrating from 0.7 to 0.8](./migration-0.7-to-0.8.md) for the breaking-change story before flipping the floating pointer in production.
38
+
39
+ ### Via npm
40
+
41
+ ```bash
42
+ npm install stream-connect-sdk
43
+ ```
44
+
45
+ ```js
46
+ import StreamConnect from 'stream-connect-sdk';
47
+
48
+ StreamConnect({
49
+ el: '#sdk-hook',
50
+ employer: { vendor: 'internal', systemKey: 'EMP-123' },
51
+ user: { firstName: 'Joe', lastName: 'Sample', email: 'joe@example.com' },
52
+ apiToken: 'YOUR-SDK-TOKEN',
53
+ });
54
+ ```
55
+
56
+ If you only want to try the UI without wiring credentials, drop everything except `el` and add `isDemo: true`:
57
+
58
+ ```js
59
+ StreamConnect({ el: '#sdk-hook', isDemo: true });
60
+ ```
61
+
62
+ Demo mode renders the full UI against synthetic data; it cannot save or validate real credentials.
63
+
64
+ ### In a React app
65
+
66
+ The SDK is shaped as a self-contained widget (it brings its own React internally and mounts into a DOM element you give it), so the canonical React integration is a thin `useEffect` wrapper:
67
+
68
+ ```jsx
69
+ import { useEffect } from 'react';
70
+ import StreamConnect from 'stream-connect-sdk';
71
+
72
+ export function ConnectSDK({ employer, user, apiToken, ...opts }) {
73
+ useEffect(() => {
74
+ StreamConnect({
75
+ el: '#sdk-hook',
76
+ employer,
77
+ user,
78
+ apiToken,
79
+ ...opts,
80
+ });
81
+ }, []);
82
+ return <div id="sdk-hook" />;
83
+ }
84
+ ```
85
+
86
+ Then use it like any component:
87
+
88
+ ```jsx
89
+ <ConnectSDK
90
+ employer={{ vendor: 'internal', systemKey: 'EMP-123' }}
91
+ user={{ firstName: 'Joe', lastName: 'Sample', email: 'joe@example.com' }}
92
+ apiToken={process.env.NEXT_PUBLIC_TPASTREAM_SDK_TOKEN}
93
+ />
94
+ ```
95
+
96
+ A few things to know about this shape:
97
+
98
+ * The SDK mounts its own React tree inside the `<div>`. Host-app React contexts, error boundaries, and refs don't compose into the SDK subtree.
99
+ * Re-calling `StreamConnect()` against the same `el` unmounts the previous root cleanly (React 19 + WeakMap-backed root cache), so toggling identity props between renders is safe.
100
+ * For SSR (Next.js / Remix), the `useEffect` runs client-side only; no special guarding needed.
101
+
102
+ A first-class React package with `peerDependencies` on `react` (no second React tree, full composition) may follow in a future release.
103
+
104
+ ## Options reference
105
+
106
+ `*` in the tables below marks fields you must supply.
107
+
108
+ ### Required
109
+
110
+ | Field | Description | Type | Example |
111
+ |---|---|---|---|
112
+ | `el`* | A CSS selector for where you want the SDK to render. Everything renders under this element. | String | `el: '#sdk-hook'` |
113
+ | `apiToken`* | Your SDK token. Configured ahead of time by TPAStream; not a secret (safe to ship in browser code). | String | `apiToken: 'YOUR-SDK-TOKEN'` |
114
+ | `employer.vendor`* | The `code` for the vendor your employer is configured under. Usually `internal`. | String | `employer: { vendor: 'internal' }` |
115
+ | `employer.systemKey`* | Unique systemKey for your employer on the selected vendor. | String | `employer: { systemKey: 'EMP-123' }` |
116
+ | `employer.name` | Employer display name. Only required when the employer doesn't exist yet (the SDK auto-creates it). | String | `employer: { name: 'Acme Corp' }` |
117
+ | `user`* | The user (member) connecting. Auto-created if not already in our system. Think "the employee entering their carrier credentials," not a TPAStream-staff account. | Object | see below |
118
+ | `user.firstName`* | The user's first name. | String | `user: { firstName: 'Joe' }` |
119
+ | `user.lastName`* | The user's last name. | String | `user: { lastName: 'Sample' }` |
120
+ | `user.email`* | The user's email. | String | `user: { email: 'joe@example.com' }` |
121
+ | `user.memberSystemKey` | Your system's stable ID for this user. Lets you cross-reference back from TPAStream webhooks. | String | `user: { memberSystemKey: 'mem_42' }` |
122
+ | `user.phoneNumber` | The user's phone number. | String | `user: { phoneNumber: '555-555-5555' }` |
123
+ | `user.dateOfBirth` | The user's date of birth, `YYYY-MM-DD`. | String | `user: { dateOfBirth: '1985-04-12' }` |
124
+ | `tenant` | Only needed if your token is configured to multiple tenants. TPAStream will tell you when this applies. | Object | `tenant: { vendor: 'internal', systemKey: 'tenant-key' }` |
125
+
126
+ ### Theme
127
+
128
+ | Field | Description | Type | Default |
129
+ |---|---|---|---|
130
+ | `theme.primaryColor` | CSS color (hex, rgb, named) used to recolor buttons, links, focus rings, and progress bars. Scoped to the SDK subtree via `.tpa-sdk-root`; won't bleed into host-page CSS. See [Theme](./theme.md). | String | built-in indigo |
131
+
132
+ ### Behavior
133
+
134
+ | Field | Description | Type | Default |
135
+ |---|---|---|---|
136
+ | `isDemo` | Renders the SDK against synthetic data. Cannot save or validate real credentials. Useful while iterating on styling. | Boolean | `false` |
137
+ | `realTimeVerification` | Show the credential-validation UI after submit. The 0.8 SDK uses an SSE stream (replaces the 0.7 polling loop) and renders validation in a non-blocking hero plus corner panel rather than blocking the carrier picker. Pass `false` to submit and advance immediately with no validation UI. | Boolean | `true` |
138
+ | `enablePatientAccessAPI` | **Default flipped to `true` in 0.8.** PAA-routed payers (carriers that authenticate via redirect to the carrier's own site rather than collecting credentials inline) take the OAuth-popup branch. With this off, they fall through to a raw credentials form that exposes an `interoperability_refresh_token` field no real user can fill. See [Interop](./interop.md). | Boolean | `true` |
139
+ | `enablePatientAccessAPISinglePage` | Same as `enablePatientAccessAPI` but performs the redirect in the current tab instead of a new window. Takes precedence over `enablePatientAccessAPI` when `true`. | Boolean | `false` |
140
+ | `forceEndStep` | Skip directly to the end widget on load. Accepts the legacy boolean form (`true` → end widget) or an explicit step number (`5` is the `FinishedEasyEnroll` step). Auto-applied when the URL contains `?forceTPAStreamSdkEnd=1` (the flag is then stripped from the address bar). | Boolean or Number | `false` |
141
+ | `includePayerBlogs` | Enable optional payer-updates blog on each enrollment form. Shows additional info about the carrier. | Boolean | `false` |
142
+ | `connectAccessToken` | Required if [Connect Access Token](./connect-access-token.md) advanced security is enabled. The 0.8 SDK also accepts a fresh `?accessToken=...` on the URL after a Patient Access API redirect; if present, it overrides this option for that load and is stripped from the URL via `history.replaceState`. | String | unset |
143
+ | `connectAccessTokenRefreshFn` | Async function the SDK calls to mint a fresh `connectAccessToken` when the current one has expired (server returns `error_code: "expired_connect_token"`). When provided, expired-token responses trigger a transparent refresh + retry instead of bubbling up as a failed request. Without it, the SDK fires `onConnectAccessTokenExpired` and dispatches a `tpastream-connect-token-expired` window event so the host page can prompt the user. Connect tokens have a ~60-minute TTL, so long-lived pages benefit. | `() => Promise<string>` | unset |
144
+ | `renderChoosePayer` | Render the built-in choose-payer widget. If `false`, you drive payer selection from the `doneChoosePayer` callback. | Boolean | `true` |
145
+ | `renderPayerForm` | Render the built-in credentials form. If `false`, drive it from `doneCreatedForm`. | Boolean | `true` |
146
+ | `renderEndWidget` | Render the built-in end widget. If `false`, drive it from `doneEasyEnroll`. | Boolean | `true` |
147
+
148
+ ### Lifecycle callbacks
149
+
150
+ | Callback | Fires when |
151
+ |---|---|
152
+ | `doneGetSDK({ user, payers, tenant, employer })` | Initial SDK bootstrap completes. First callback in the flow. |
153
+ | `doneSelectEnrollProcess()` | The select-enroll cards finish rendering (member-portal mode only; requires `connectAccessToken`). |
154
+ | `doneFixCredentials()` | The user clicked the "Fix Credentials" card in member-portal mode. |
155
+ | `doneChoosePayer({ choosePayer, usedPayers, dropdown, streamPayers })` | The choose-payer widget renders. With `renderChoosePayer: false`, this passes the props you need to drive payer selection yourself. |
156
+ | `doneCreatedForm({ formJsonSchema, returnToChoosePayer, streamPayer, streamTenant, tenantTerms, toggleTermsOfUse, validateCreds })` | The credentials form renders. With `renderPayerForm: false`, drives a fully custom form. |
157
+ | `doneTermsOfService()` | The user clicked the TPAStream Terms of Service link. |
158
+ | `donePopUp()` | The user clicked the help (?) icon on the payer info card. |
159
+ | `donePostCredentials({ params })` | The user submitted credentials and the SDK is posting them. Use to mirror the payload into your own backend. |
160
+ | `doneRealTime()` | The realtime-validation widget rendered. Never fires when `realTimeVerification: false`. |
161
+ | `doneEasyEnroll({ employer, payer, tenant, policyHolder, user, returnFlowFunction })` | Final callback; the enrollment is saved (possibly pending validation). |
162
+ | `handleInitErrors(error)` | An init-configuration error happened before the SDK could mount. |
163
+ | `handleFormErrors(error, { response, request, config })` | Credential submit failed. The SDK shows the error to the user; this lets you log it. |
164
+ | `onConnectAccessTokenExpired()` | The `connectAccessToken` expired mid-session and either no `connectAccessTokenRefreshFn` was provided or the refresh attempt failed. Use to surface a "session expired, please reload" UI on the host page. Also dispatched as a `tpastream-connect-token-expired` window event for integrations that prefer a global listener. |
165
+
166
+ Each callback is documented in detail below.
167
+
168
+ ### Deprecated
169
+
170
+ These still work and will continue to indefinitely; the SDK logs a one-time console warning when it sees them. Migrate at your leisure.
171
+
172
+ | Field | Use instead | Notes |
173
+ |---|---|---|
174
+ | `sdkToken` | `apiToken` | Same value. If both are set, `apiToken` wins. |
175
+ | `enableInterop` | `enablePatientAccessAPI` | Renamed in 0.8. |
176
+ | `enableInteropSinglePage` | `enablePatientAccessAPISinglePage` | Renamed in 0.8. |
177
+ | `fixCredentials` | (remove) | Member-portal mode is now derived automatically from the presence of `connectAccessToken`; the flag is ignored. |
178
+ | `realtimeTimeout` | (remove) | Was the polling-loop timeout in 0.7.x. 0.8 uses SSE with a server-side stream deadline (~10 minutes). No-op. |
179
+ | `maxRetries` | (remove) | Was the polling-loop retry count. 0.8 has no client-side retry knob. No-op. |
180
+ | `userSchema` | (remove) | In 0.7.x this drove `react-jsonschema-form` UI-schema customization. `react-jsonschema-form` was replaced by React Hook Form + zod in 0.8, so `userSchema` no longer affects rendering. The object is forwarded into the credential-submit payload for downstream consumers. |
181
+
182
+ ### Internal / dev-only
183
+
184
+ Don't set these in production code.
185
+
186
+ | Field | What it's for |
187
+ |---|---|
188
+ | `_overrideBaseUrl` | Points the SDK at a different API host. Used by the `/sdk-test` sandbox on `stevedev.tpastream.com` and integration tests. |
189
+ | `webViewDelegation` | Enables redirection-delegation to a top-level WebView host. The interop final redirect goes to `/patientaccessapi/sdk-interop-done-delegation/<state>/<ph>` for the host app to parse instead of `sdk_interop_done` or `window.location`. |
190
+ | `entrySdkStateId` | Overrides the SDK-generated state id to preserve SDK flow logs across a `webViewDelegation` round trip. |
191
+
192
+ ## Redirect query parameters (Patient Access API)
193
+
194
+ When the Patient Access API flow returns the user from a carrier site back to the page hosting the SDK, the redirect URL can carry two query parameters that the 0.8 SDK reads automatically on init:
195
+
196
+ * **`?accessToken=...`**: a fresh connect-access token minted by `app.tpastream.com` after the carrier redirect completes. The SDK reads it on load, uses it for the remainder of the session, and (regardless of whether `connectAccessToken` was already set in the init object) takes the URL value as the freshest. The token is single-use.
197
+ * **`?forceTPAStreamSdkEnd=1`**: set by the redirect URL the SDK constructs when `enablePatientAccessAPISinglePage` is `true`. Tells this load to skip straight to the end widget instead of restarting at choose-payer.
198
+
199
+ Both parameters are stripped from the URL via `history.replaceState` after the SDK reads them. `replaceState` (not `pushState`) is used deliberately: the back button cannot restore the original URL, so the single-use access token cannot leak via history navigation or browser autofill.
200
+
201
+ > **Referrer caveat:** `replaceState` runs only after the SDK script has loaded and executed. Any resources, third-party scripts, or analytics beacons fetched *earlier* in the page lifecycle can still receive the token-bearing URL in the `Referer` header. For the full referrer-protection story (host-page `<meta name="referrer">` settings, CSP `Content-Security-Policy: referrer`, and the redirect-URL hygiene we recommend), see the Pre-SDK referrer caveat in [`connect-access-token.md`](./connect-access-token.md).
202
+
203
+ You don't need to handle these parameters yourself; this section documents them so integrators who inspect the URL or rely on `popstate` events know what to expect.
204
+
205
+ ## Lifecycle callbacks (in detail)
206
+
207
+ The main way an implementor interacts with the SDK is via callbacks fired at key flow points. See [SDK Flow](./sdk-flow.md) for a visual lifecycle diagram. Most callbacks pass useful data; some are pure styling hooks.
208
+
209
+ ### `doneGetSDK`
210
+
211
+ First callback in the SDK flow. Fires after the initial request to TPAStream completes.
212
+
213
+ Data passed back:
214
+
215
+ * `user`
216
+ * `email`: the same email you set in config.
217
+ * `user_id`: TPAStream's unique identifier for this user.
218
+ * `policy_holders`: all policy_holders already associated with the user (think "previously saved credentials per carrier"). Limited shape:
219
+ * `payer_id`
220
+ * `id` and `policy_holder_id`: same value, both surfaced for legacy reasons. Useful for matching webhook events back to the SDK session.
221
+ * `tenant`
222
+ * `id` and `tenant_id`
223
+ * `name`
224
+ * `terms_of_use_message`: configured at the tenant level. Use if you build a custom terms widget.
225
+ * `payers`: list of `{id, payer_id, logo_url, name}`. Use when `renderChoosePayer: false`.
226
+ * `employer`
227
+ * `id` and `employer_id`
228
+ * `name`
229
+ * `payers`: the preferred payers configured for this employer.
230
+ * `show_all_payers_in_easy_enroll`: when `true`, all payers TPAStream supports render as options. Default `true` for an employer the SDK auto-creates.
231
+ * `support_email_derived`: configured in the TPAStream app.
232
+
233
+ ```js
234
+ StreamConnect({
235
+ el: '#sdk-hook',
236
+ // ...
237
+ doneGetSDK: ({ user, payers, tenant, employer }) => {
238
+ // Mirror identity into analytics, etc.
239
+ },
240
+ });
241
+ ```
242
+
243
+ ### `doneSelectEnrollProcess`
244
+
245
+ Fires after `doneGetSDK` when the SDK is in member-portal mode (a `connectAccessToken` was supplied). Use for styling the two select-enroll cards.
246
+
247
+ ```js
248
+ StreamConnect({
249
+ el: '#sdk-hook',
250
+ // ...
251
+ doneSelectEnrollProcess: () => {
252
+ // Style the cards
253
+ },
254
+ });
255
+ ```
256
+
257
+ ### `doneFixCredentials`
258
+
259
+ Fires after the user clicks the Fix Credentials card in member-portal mode. Member-portal mode only.
260
+
261
+ ```js
262
+ StreamConnect({
263
+ el: '#sdk-hook',
264
+ // ...
265
+ doneFixCredentials: () => {
266
+ // Style the fix-credentials view
267
+ },
268
+ });
269
+ ```
270
+
271
+ ### `handleInitErrors`
272
+
273
+ Fires when the SDK can't initialize (missing `el`, missing required option, etc.). The error has a `message` you can surface to the user.
274
+
275
+ ```js
276
+ StreamConnect({
277
+ el: '#sdk-hook',
278
+ // ...
279
+ handleInitErrors: (error) => {
280
+ console.error('TPAStream SDK init failed:', error.message);
281
+ },
282
+ });
283
+ ```
284
+
285
+ ### `doneChoosePayer`
286
+
287
+ Second callback in the SDK flow. Fires when the choose-payer widget renders.
288
+
289
+ With `renderChoosePayer: true` (default), no parameters; use this callback purely for styling.
290
+
291
+ With `renderChoosePayer: false`, the callback receives the props you need to drive your own picker:
292
+
293
+ * `choosePayer({ payer })`: call this when the user picks a payer. The payer object should come from `streamPayers`. The SDK then renders the next step.
294
+ * `usedPayers`: list of `payer_id`s that already have credentials.
295
+ * `dropdown`: `true` if the SDK intends a full-payer dropdown (same as `employer.show_all_payers_in_easy_enroll` from `doneGetSDK`).
296
+ * `streamPayers`: full list of payers for this SDK instance.
297
+
298
+ ```js
299
+ StreamConnect({
300
+ el: '#sdk-hook',
301
+ // ...
302
+ renderChoosePayer: false,
303
+ doneChoosePayer: ({ choosePayer, usedPayers, dropdown, streamPayers }) => {
304
+ const onPick = (payerId) => {
305
+ const payer = streamPayers.find((p) => p.id === payerId);
306
+ choosePayer({ payer });
307
+ };
308
+ renderMyCustomPicker({
309
+ payers: streamPayers,
310
+ withCredentials: usedPayers,
311
+ onPick,
312
+ });
313
+ },
314
+ });
315
+ ```
316
+
317
+ ### `doneCreatedForm`
318
+
319
+ Third callback in the SDK flow. Fires when the credentials form renders for the chosen carrier.
320
+
321
+ With `renderPayerForm: true` (default), this is a pure styling hook (no useful parameters).
322
+
323
+ With `renderPayerForm: false`, you receive the props you need to drive a fully custom form:
324
+
325
+ * `formJsonSchema`: the JSON Schema for this carrier's credential form, including security questions and field requirements. Drive your own renderer from this shape. (In 0.7.x the SDK rendered this with `react-jsonschema-form`; that library was removed in 0.8, but the schema itself is unchanged and still emitted on this callback for custom integrations.)
326
+ * `returnToChoosePayer()`: reset to the carrier picker.
327
+ * `streamPayer`: the carrier object for this form.
328
+ * `streamTenant`: the tenant object. Useful for adjusting copy.
329
+ * `tenantTerms`: custom terms-of-service configured by the tenant.
330
+ * `toggleTermsOfUse()`: opens the Terms of Use overlay.
331
+ * `validateCreds({ params })`: submit the form. Triggers the realtime-validation path.
332
+
333
+ ```js
334
+ StreamConnect({
335
+ el: '#sdk-hook',
336
+ // ...
337
+ renderPayerForm: false,
338
+ doneCreatedForm: ({
339
+ formJsonSchema,
340
+ returnToChoosePayer,
341
+ streamPayer,
342
+ streamTenant,
343
+ tenantTerms,
344
+ toggleTermsOfUse,
345
+ validateCreds,
346
+ }) => {
347
+ // Render your form from formJsonSchema; on submit call validateCreds({ params }).
348
+ },
349
+ });
350
+ ```
351
+
352
+ ### `doneTermsOfService`
353
+
354
+ Fires when the user clicks the TPAStream Terms of Service link. Pure styling hook.
355
+
356
+ ```js
357
+ StreamConnect({
358
+ el: '#sdk-hook',
359
+ // ...
360
+ doneTermsOfService: () => {},
361
+ });
362
+ ```
363
+
364
+ ### `donePopUp`
365
+
366
+ Fires when the user clicks the help (?) icon on the payer info card to open the carrier-specific help drawer. Pure styling hook.
367
+
368
+ ```js
369
+ StreamConnect({
370
+ el: '#sdk-hook',
371
+ // ...
372
+ donePopUp: () => {},
373
+ });
374
+ ```
375
+
376
+ ### `donePostCredentials`
377
+
378
+ Fires when the user submits the credentials form and the SDK is posting them. Use to mirror the payload into your own backend before the SDK advances to validation.
379
+
380
+ Common payload fields (vary by carrier):
381
+
382
+ * `params`
383
+ * `username`
384
+ * `password`
385
+ * `date_of_birth`
386
+ * `termsAndServices` and `accept`: user accepted the TPAStream terms of use.
387
+ * `payer_id`
388
+ * `tenants_accept`: list of booleans, one per tenant the user accepted terms for.
389
+ * `tenantAcknowledgement`: user acknowledged the carrier-data-sharing notice.
390
+ * `security_question_first` / `security_question_first_choice`
391
+ * `security_question_second` / `security_question_second_choice`
392
+ * `security_question_third` / `security_question_third_choice`
393
+
394
+ In 0.8 the credential-submit response also includes a `task_token` (a short-lived task-scoped JWT bound to the validation task) that the SDK uses internally to subscribe to the `/v3/sdk/progress/<task_id>/stream` SSE channel. You don't need to handle the token; the SDK uses it transparently. The token is audience-locked to `sdk:sse:progress`, valid for 10 minutes, and tied to the submitting user.
395
+
396
+ ```js
397
+ StreamConnect({
398
+ el: '#sdk-hook',
399
+ // ...
400
+ donePostCredentials: ({ params }) => {
401
+ saveToYourBackend(params);
402
+ },
403
+ });
404
+ ```
405
+
406
+ ### `handleFormErrors`
407
+
408
+ Fires when the credential submit fails. The SDK already shows the error to the user; this callback lets you log or instrument it.
409
+
410
+ * `error`
411
+ * `error_parts`
412
+ * `response`
413
+ * `request`
414
+ * `config`
415
+
416
+ ```js
417
+ StreamConnect({
418
+ el: '#sdk-hook',
419
+ // ...
420
+ handleFormErrors: (error, { response, request, config }) => {
421
+ console.error('Credential submit failed', error, response);
422
+ sendToYourLogger(error);
423
+ },
424
+ });
425
+ ```
426
+
427
+ ### `doneRealTime`
428
+
429
+ Fires when the realtime-validation widget renders. Never fires when `realTimeVerification: false`. Pure styling hook.
430
+
431
+ ```js
432
+ StreamConnect({
433
+ el: '#sdk-hook',
434
+ // ...
435
+ doneRealTime: () => {},
436
+ });
437
+ ```
438
+
439
+ ### `doneEasyEnroll`
440
+
441
+ Final callback. Fires when enrollment is saved (possibly still pending validation).
442
+
443
+ Properties:
444
+
445
+ * `employer`
446
+ * `payer`
447
+ * `tenant`
448
+ * `user`
449
+ * `pending`: `true` if the policyHolder is still pending validation.
450
+ * `endingMessage`: backend-provided message tailored to the credential status.
451
+ * `policyHolder`: the saved policy_holder.
452
+ * `policy_holder_id`
453
+ * `payer_id`
454
+ * `login_correction_message`: only populated when `login_problem` is something other than `'valid'` or `null`.
455
+ * `login_needs_correction`: `true` if credentials were flagged invalid by realtime validation.
456
+ * `login_problem`: one of:
457
+ * `'valid'`: credentials are fine. Claims should start collecting shortly.
458
+ * `'invalid'`: the crawl engine confirmed bad credentials. The user will be prompted to re-enter them.
459
+ * `'locked'`: the carrier has locked this account. Requires user action on the carrier's site to resolve.
460
+ * `'broken'`: the crawl engine identified an issue requiring carrier-side fixes to make progress.
461
+ * `'needs_two_factor'`: the carrier requires 2FA on this login. The 0.8 SDK handles 2FA inline in the validation hero (method picker, code entry); customers who burn through 2FA prompts and reach a terminal failure end up here.
462
+ * `'incomplete'`: the user's carrier-site registration is incomplete. Requires user action to resolve.
463
+ * `'inactive'`: the account is inactive on the carrier site.
464
+ * `'sec_question'`: security-question answers were wrong. The user will be prompted to re-enter them.
465
+ * `'wrong_secondary'`: the account is configured with an unsupported secondary authentication method. The user will be prompted to switch the account to security questions.
466
+ * `null`: still being confirmed. Can take up to 24 hours depending on carrier-site uptime.
467
+
468
+ With `renderEndWidget: true` (default) you also get:
469
+
470
+ * `returnFlowFunction()`: restart the SDK or return to the payer form, depending on whether credentials were valid.
471
+
472
+ ```js
473
+ StreamConnect({
474
+ el: '#sdk-hook',
475
+ // ...
476
+ doneEasyEnroll: ({
477
+ employer,
478
+ payer,
479
+ tenant,
480
+ policyHolder,
481
+ user,
482
+ returnFlowFunction,
483
+ }) => {
484
+ if (policyHolder.login_problem === 'valid') {
485
+ analytics.track('enrollment_succeeded', { payer: payer.name });
486
+ }
487
+ },
488
+ });
489
+ ```