stream-connect-sdk 0.8.0 → 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.
@@ -1,405 +1,489 @@
1
-
2
- # Client Usage
3
- We have decided that the best possible way to implement this SDK is a simple config pattern. A prospective user will communicate with us to receive an SDK sdkToken as well as employer system keys.
4
-
5
- A mock implementation might look something like the following:
6
-
7
- Using TPAStream as a CDN
8
- ```html
9
- <script src="https://app.tpastream.com/static/js/sdk.js"></script>
10
- <script>
11
- window.StreamConnect({
12
- el: '#react-hook', // CSS selector; the SDK renders under this element.
13
- employer: {
14
- systemKey: 'some-system-key',
15
- vendor: 'internal',
16
- name: 'some-employer-name'
17
- },
18
- user: {
19
- firstName: 'Joe',
20
- lastName: 'Sajor',
21
- email: 'some-email@place.com'
22
- },
23
- isDemo: false,
24
- sdkToken: 'VeryLegitKey',
25
- // Optional 0.8 additions:
26
- theme: { primaryColor: '#2563eb' },
27
- enablePatientAccessAPI: true,
28
- // Behavior toggles (defaults shown):
29
- realTimeVerification: true,
30
- renderChoosePayer: true,
31
- renderPayerForm: true,
32
- renderEndWidget: true,
33
- // Lifecycle callbacks:
34
- doneGetSDK: ({ user, payers, tenant, employer }) => {},
35
- doneChoosePayer: () => {},
36
- doneTermsOfService: () => {},
37
- doneCreatedForm: () => {},
38
- donePostCredentials: ({ params }) => {},
39
- doneRealTime: () => {},
40
- doneEasyEnroll: ({ employer, payer, tenant, policyHolder, user }) => {},
41
- donePopUp: () => {},
42
- handleFormErrors: (error, {response, request, config}) => {}
43
- })
44
- </script>
45
- ```
46
-
47
- As shown above the SDK is mounted by calling `window.StreamConnect({})` and passing in the desired parameters.
48
-
49
- As of SDK version 0.4.7 the CDN provider is versioned. Past versions remain available indefinitely.
50
- * The version is selected by the `src` attribute on your script tag.
51
- * `"https://app.tpastream.com/static/js/sdk.js"` -> Latest published version of the SDK.
52
- * `"https://app.tpastream.com/static/js/sdk-v-<VersionNumber>.js"` -> A specific version. Examples:
53
- * `"https://app.tpastream.com/static/js/sdk-v-0.8.0.js"` (current 0.8)
54
- * `"https://app.tpastream.com/static/js/sdk-v-0.7.7.js"` (last 0.7.x)
55
-
56
- NPM package
57
- ```javascript
58
-
59
- // Install with NPM
60
- npm i stream-connect-sdk
61
-
62
- import StreamConnect from 'stream-connect-sdk';
63
-
64
- StreamConnect({
65
- el: '#react-hook',
66
- isDemo: true
67
- });
68
- ```
69
-
70
- #### * Are required
71
-
72
- | Field | Description | Type | Example | Default |
73
- |-------------------------------|---------------------------------------------------------------------------------------------------------|---------|-------------------------------------------------------|-----------|
74
- | `el`* | A CSS selector for where you want the sdk to render: all items will render under this element | String | `el: '#react-hook'` | N\A |
75
- | `tenant` | The tenant configuration for this sdk instance. **Only needed if your token is configured to many tenants. Such a configuration will be made clear when TPAStream provides a token.** | Object | `tenant: {}` | `{}` |
76
- | `tenant.vendor` | The `code` for the specific vendor_tenant configured for this sdk-token. This is usually `internal` | String | `tenant: { vendor: 'internal' }` | `internal`|
77
- | `tenant.systemKey` | The unique systemKey configured for your selected tenant on the selected vendor. | String | `tenant: { systemKey: 'uniquekey' }` | N\A |
78
- | `employer`* | The employer configuration for this sdk instance. Employers will be created if they don't exist already | Object | `employer: {}` | N\A |
79
- | `employer.vendor`* | The `code` for the specific vendor your employer is configured to. | String | `employer: { vendor: 'internal' }` | `internal`|
80
- | `employer.systemKey`* | The unique systemKey configured for your selected employer on said vendor | String | `employer: { systemKey: 'ekey' }` | N\A |
81
- | `employer.name` | Name of the employer. *Only needed if the employer doesn't already exist* | String | `employer: { name: 'some-employer-name' }` | N\A |
82
- | `user`* | The user configuration. These are created automatically if they don't exist in our system. Think of users as employees going through and entering their payer credentials into our system. This is **not** an Implementors account on TPAStream (IE youremail@email.com). If you wish to set-up the SDK for the first time try using something like `youremail+testingsdk@email.com` in order to get the ball rolling. | Object | `user: {}` | N\A |
83
- | `user.firstName`* | The user's first name | String | `user: { firstName: 'Name' }` | N\A |
84
- | `user.lastName`* | The user's last name | String | `user: { lastName: 'name' }` | N\A |
85
- | `user.email`* | The user's email. | String | `user: { email: 'email@email.com' }` | N\A |
86
- | `user.memberSystemKey` | A unique key for an implementer to identify for their system. | String | `user: { memberSystemKey: 'some-key' }` | N\A |
87
- | `user.phoneNumber` | The user's phone number | String | `user: { phoneNumber: '000-000-0000' }` | N\A |
88
- | `user.dateOfBirth` | The user's date of birth | String | `user: { dateOfBirth: 'YYYY-MM-DD' }` | N\A |
89
- | `sdkToken`* | The SDK Token. This has to be configured before-hand. It isn't a secret. | String | `sdkToken: 'VeryLegitKey'` | N\A |
90
- | `apiToken`* | The SDK token. Same value as `sdkToken`; pass either. If both are set, `apiToken` wins. Not a secret. | String | `apiToken: 'VeryLegitKey'` | N\A |
91
- | `connectAccessToken` | A generated token if advanced security is enabled. See [Connect Access Token](./connect-access-token.md). 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 | `connectAccessToken: ''` | N\A |
92
- | `includePayerBlogs` | Enable optional payer updates blog on each enrollment form. Has some additional info about the payer. | Boolean | `includePayerBlogs: false` | `false` |
93
- | `theme` | Branding overrides applied as scoped CSS variables on the SDK root subtree. See [Theme](./theme.md). | Object | `theme: { primaryColor: '#2563eb' }` | `{}` |
94
- | `theme.primaryColor` | Hex color (e.g. `#2563eb`) used to recolor buttons, links, focus rings, and progress bars. Scoped to the SDK subtree; will not bleed into host-page CSS. | String | `theme: { primaryColor: '#2563eb' }` | (built-in indigo) |
95
- | `enablePatientAccessAPI` | **Default changed in 0.8 to `true`.** Enables Patient Access API payers (carriers that authenticate via a redirect to the carrier website rather than collecting credentials inline). With this flag on (the default), PAA-routed payers take the OAuth-popup branch; with it off, they fall through to the raw credentials form which exposes an `interoperability_refresh_token` field no real user can fill. See [Interop](./interop.md) and the [0.7→0.8 migration note](./migration-0.7-to-0.8.md#7-enablepatientaccessapi-default-flipped-to-true). | Boolean | `enablePatientAccessAPI: false` | `true` (was `false` in 0.7.x) |
96
- | `enablePatientAccessAPISinglePage` | Same as `enablePatientAccessAPI` but performs the redirect in the current tab instead of opening a new window. If true, takes precedence over `enablePatientAccessAPI`. | Boolean | `enablePatientAccessAPISinglePage: true` | `false` |
97
- | `enableInterop` | **Deprecated** alias for `enablePatientAccessAPI`. Still works indefinitely; using it logs a one-time console warning. | Boolean | `enableInterop: true` | `false` |
98
- | `enableInteropSinglePage` | **Deprecated** alias for `enablePatientAccessAPISinglePage`. Same behavior. | Boolean | `enableInteropSinglePage: true` | `false` |
99
- | `forceEndStep` | Skip directly to the end widget on load. Accepts the legacy boolean form (`true` -> end widget) and the explicit step-number form (`5` is the FinishedEasyEnroll step). The SDK also auto-applies this when the URL contains `?forceTPAStreamSdkEnd=1` (the flag is then stripped from the address bar). | Boolean \| Number | `forceEndStep: true` or `forceEndStep: 5` | `false` |
100
- | `entrySdkStateId` | Overrides the SDK-generated state id. Used to preserve SDK flow logs across a `webViewDelegation` round trip. Do not set otherwise. | String | `entrySdkStateId: 'somestateid'` | N\A |
101
- | `webViewDelegation` | Enables redirection delegation to a top-level webview hosting the SDK. The interop final redirect goes to `/patientaccessapi/sdk-interop-done-delegation/<string:sdk_state_id>/<int:ph_id>` for the host app to parse instead of `sdk_interop_done` or `window.location`. | Boolean | `webViewDelegation: true` | `false` |
102
- | `isDemo` | Tells the SDK not to work with real data; useful while iterating on styling. Demo mode cannot save or validate credentials. | Boolean | `isDemo: true` | `false` |
103
- | `realTimeVerification` | Enables credential-validation UI feedback. Default is `true` (unchanged since 0.7.7). The 0.8 SDK uses a Server-Sent Events stream instead of the 0.7 polling loop, and validation renders in the non-blocking hero + corner-panel UI rather than blocking the carrier picker. Pass `false` to submit and immediately advance with no validation UI. | Boolean | `realTimeVerification: true` | `true` |
104
- | `realtimeTimeout` | **Deprecated in 0.8.** Was the polling-loop timeout in 0.7.x. The 0.8 SDK uses SSE with a server-side stream deadline (~10 minutes) and no longer reads this option. Accepted for back-compat but has no effect. | Number | `realtimeTimeout: 600` | n/a |
105
- | `renderChoosePayer` | Render the built-in choose-payer widget. If `false`, the widget is omitted and you must drive payer selection from the `doneChoosePayer` callback. | Boolean | `renderChoosePayer: false` | `true` |
106
- | `renderPayerForm` | Render the built-in credentials form. If `false`, drive it from `doneCreatedForm`. | Boolean | `renderPayerForm: false` | `true` |
107
- | `renderEndWidget` | Render the built-in end widget. If `false`, drive it from `doneEasyEnroll`. | Boolean | `renderEndWidget: false` | `true` |
108
- | `userSchema` | **Changed in 0.8.** In 0.7.x this drove `react-jsonschema-form` UI-schema customization for the credentials form. `react-jsonschema-form` was removed in 0.8, so `userSchema` no longer affects rendering; the object is forwarded into the credential-submit payload for downstream consumers, and the SDK emits a one-time console warning when set. File an issue if you relied on UI-schema-driven extra fields. | Object | `userSchema: {}` | `{}` |
109
- | `fixCredentials` | **Deprecated in 0.8.** No longer needed: [fix-credentials mode](./fix-credentials.md) is now derived automatically from the presence of `connectAccessToken`. Accepted for back-compat and ignored; passing it logs a one-time console deprecation warning. | Boolean | `fixCredentials: true` | n/a |
110
- | `maxRetries` | **Deprecated in 0.8.** Was the retry count for the 0.7.x polling validation loop. The 0.8 SDK uses SSE with no client-side retry knob; this option is accepted for back-compat but has no effect. | Number | `maxRetries: 3` | n/a |
111
- | `_overrideBaseUrl` | Override the API base URL the SDK talks to. Used by the `/sdk-test` sandbox and integration tests; do not set in production. | String | `_overrideBaseUrl: 'https://stevedev.tpastream.com'` | (`app.tpastream.com`) |
112
-
113
- ## Redirect query parameters (Patient Access API)
114
-
115
- 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:
116
-
117
- * **`?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.
118
- * **`?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.
119
-
120
- 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.
121
-
122
- > **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).
123
-
124
- You do not need to handle these parameters yourself; this section documents them so that integrators who inspect the URL or rely on `popstate` events know what to expect.
125
-
126
- ## Callbacks
127
- The main way an implementor will be interacting and modifying the `stream-connect-js-sdk` is via our various callbacks placed at key flowpoints of the SDK. In these callbacks the implementors are recommended to use `JavaScript` to style the various widgets as well as handle any additional custom logic which they deem necessary. These callbacks also include various amounts of information which can be helpful when trying to integrate fully with the TPAStream system.
128
-
129
- ### `doneGetSDK`
130
- `doneGetSDK` is the first callback to be called in the SDK flow. It occurs when the system has finished its initial request to TPAStream systems.
131
-
132
- Data passed back -- These objects will have various information from the SDK. An Implementor might be concerned with any of the below.
133
- * `user`
134
- * `email` -- You should see that this email is the same as the one you set in configuration. The SDK can interface with a TPAStream user to create policy_holders via email and token.
135
- * `user_id` -- The unique identifier TPAStream uses for this user.
136
- * `policy_holders` -- This will list out all of the policy_holders associated with the user. You can think of these as the saved credentials per carrier. Data passed back here will be limited.
137
- * `payer_id` -- The ID for the specific payer these credentials exist for.
138
- * `id` and `policy_holder_id` -- The unique identifier TPAStream uses for this set of credentials. If you implement any of the *TPAStream Webhooks* you will find this info useful for association.
139
- * `tenant`
140
- * `id` and `tenant_id`
141
- * `name`
142
- * `terms_of_use_message` -- This is configured at the tenant level. It allows specific terms of service messages per tenant. If you implement a custom widget you might be concerned with this data.
143
- * `payers` -- List of Payers. If implementing a custom choose-payer widget (`renderChoosePayer` is `false`) an implementor should use this data in the `doneChoosePayer.choosePayer` callback.
144
- * `id` and `payer_id`
145
- * `logo_url`
146
- * `name`
147
- * `employer`
148
- * `id` and `employer_id`
149
- * `name`
150
- * `payers` -- The preferred payers to use on an employer. This can be configured in the TPAStream App.
151
- * `show_all_payers_in_easy_enroll` -- When set `true` all payers supported in TPAStream will render as options in the widget. `true` is the default for an employer generated by the SDK
152
- * `support_email_derived` -- Configured within the TPAStream App.
153
-
154
- Example Usage:
155
- ```javascript
156
- StreamConnect({
157
- el: '#react-hook',
158
- ...
159
- doneGetSDK: ({ user, payers, tenant, employer }) => {
160
- // Do something with this data
161
- },
162
- });
163
- ```
164
-
165
- ### `doneSelectEnrollProcess`
166
- `doneSelectEnrollProcess` is fired right after doneGetSDK when the SDK is in member-portal mode (a `connectAccessToken` was supplied at init). This is primarily meant for styling the two buttons.
167
-
168
- Example Usage:
169
- ```javascript
170
- StreamConnect({
171
- el: '#react-hook',
172
- ...
173
- doneSelectEnrollProcess: () => {
174
- // Do some styling
175
- },
176
- });
177
- ```
178
-
179
- ### `doneFixCredentials`
180
- `doneFixCredentials` is fired after the Fix Credentials card is clicked in the select-enroll flow. This only fires in member-portal mode (when a `connectAccessToken` was supplied at init).
181
-
182
- Example Usage:
183
- ```javascript
184
- StreamConnect({
185
- el: '#react-hook',
186
- ...
187
- doneFixCredentials: () => {
188
- // Do some styling
189
- },
190
- });
191
- ```
192
-
193
- ### `handleInitErrors`
194
- `handleInitErrors` is a callback which runs whenever there was a configuraiton error with the SDK. This configuration error will have a message attached to it explaining to an implementor what the problem with the configuration was. During this callback an implementor could add custom logic to handle custom messaging for the user who might be experiencing this error.
195
- Example Usage:
196
- ```javascript
197
- StreamConnect({
198
- el: '#react-hook',
199
- ...
200
- handleInitErrors: (error) => {
201
- // Do something with this data
202
- },
203
- });
204
- ```
205
-
206
- ### `doneChoosePayer`
207
- `doneChoosePayer` is the second callback to be called in the SDK flow. It occurs when the system has finished rendering the choose-payer widget. If the default widget is enabled then there are no parameters passed back into it. Instead implementors will be using this callback to style the default widget to their liking. This may take a little bit of effort depending on how your system looks and feels. It is best to worry about these changes while setting `isDemo` equal to `true` so that you can do so without worrying about creating data.
208
-
209
- If `renderChoosePayer: false` then this callback now passes back the params necessary for an implementor to create their own completely custom widget.
210
- * `choosePayer` -- This is a `javascript function`. Calling this will render the next widget. On a custom implementation you should have this as the select option.
211
- Accepted Properties below
212
- * `payer` -- This is an `object` value. This object should be from `doneGetSDK.streamPayers`
213
- * An example call would look like `choosePayer({ payer: streamPayers[some_choosen_index] })`
214
- * `usedPayers` -- This is a list of `payer_id`s. These ids are for payers which already have credentials associated to them.
215
- * `dropdown` -- If this value is `true` then the SDK will intend for a dropdown of all payers to be used. This value is the same as `doneGetSDK.employer.show_all_payers_in_easy_enroll`
216
- * `streamPayers` -- A list of all payers for this SDK instance based on employer. This will be the same as `doneGetSDK.streamPayers`
217
-
218
- Example Usage:
219
- ```javascript
220
- StreamConnect({
221
- el: '#react-hook',
222
- ...
223
- renderChoosePayer: false, // If this is true then there will be no data passed back to doneChoosePayer
224
- doneChoosePayer: ({ choosePayer, usedPayers, dropdown, streamPayers }) => {
225
- const selectPayer = (payerId) => {
226
- hideCustomWidget();
227
- choosePayer({ payer: streamPayers.find(p => p.id === payerId)});
228
- }
229
- /*
230
- Here this function would do some stuff to render your custom widget.
231
- selectPayer will be called when a payer is chosen by the user. That will in turn pass a payer ID back to the func.
232
- That will in turn pick a payer from streamPayers and pass it to choose payer. When choose payer is called. The
233
- Next SDK widget will render nested inside #react-hook
234
- */
235
- renderCustomWidget({ carriers: streamPayers, carriersWithCredentials: usedPayers, selectPayer: selectPayer })
236
- },
237
- });
238
- ```
239
-
240
- ### `doneCreatedForm`
241
- `doneCreatedForm` is the third callback to be called in the SDK flow. It occurs when the system finishes render the specific enrollment form for a carrier. This callback is purely used by the implementor for styling the form via JavaScript.
242
-
243
- If `renderPayerForm: false` then this callback now passes back the params necessary for an implementor to create their own completely custom widget.
244
- * `formJsonSchema` -- Provides a JS object which contains the configuration of the forms. Follows [Json Schema Form](https://github.com/json-schema-form) configuration.
245
- * Within this schema you will find all the security questions for a given payer as well as lots of other values and requirements.
246
- * `returnToChoosePayer` -- When called it will reset the `el` which the SDK is hooked into and re-render the ChoosePayer widget.
247
- * An example call would look like `returnToChoosePayer();`
248
- * `streamPayer` -- The carrier/payer object associated with the form and the credentials to be implemented.
249
- * `streamTenant` -- The tenant object the SDK and credentials it will be associated. This can be used to adjust text on your widget.
250
- * `tenantTerms` -- The custom terms of service configured by the Tenant.
251
- * `toggleTermsOfUse` -- renders the terms of use widget.
252
- * An example call would look like `toggleTermsOfUse();`
253
- * `validateCreds` -- Function which will submit the values of the form and then begin the realtime validation process.
254
- * `params` -- The values from the form to be submitted.
255
- * An example call would look like `validateCreds({ params: formValues });`
256
-
257
- Example Usage:
258
- ```javascript
259
- StreamConnect({
260
- el: '#react-hook',
261
- ...
262
- doneCreatedForm: ({ formJsonSchema, returnToChoosePayer, streamPayer, streamTenant, tenantTerms, toggleTermsOfUse, validateCreds}) => {},
263
- });
264
- ```
265
-
266
- ### `doneTermsOfService`
267
- `doneTermsOfService` Callback occurs when the user clicks on the TPAStream terms of service link. This callback is purely used by the implementor for styling the form via JavaScript.
268
-
269
- Example Usage:
270
- ```javascript
271
- StreamConnect({
272
- el: '#react-hook',
273
- ...
274
- doneTermsOfService: () => {
275
- // Do some styling
276
- },
277
- });
278
- ```
279
-
280
- ### `donePopUp`
281
- `donePopUp` Callback occurs when the user clicks on carrier pop-up. This callback is purely used by the implementor for styling the form via JavaScript.
282
-
283
- Example Usage:
284
- ```javascript
285
- StreamConnect({
286
- el: '#react-hook',
287
- ...
288
- donePopUp: () => {
289
- // Do some styling
290
- },
291
- });
292
- ```
293
-
294
- ### `donePostCredentials`
295
- `donePostCredentials` fires when the user submits the credentials form and the SDK is posting the new creds. The callback gives implementors a chance to intercept the post payload (for example to persist to your own backend) before the SDK moves on to the validation step.
296
-
297
- These values vary by carrier. Common fields:
298
- * `params`
299
- * `username`
300
- * `password`
301
- * `date_of_birth`
302
- * `termsAndServices` and `accept` -- The user accepted the terms of use
303
- * `payer_id`
304
- * `tenants_accept` -- (List) Whether or not the user accepted the tenants terms of use
305
- * `tenantAcknowledgement` -- Whether or not the user accepted the sending of their claims to the tenant.
306
- * `security_question_first` -- First security question answer
307
- * `security_question_first_choice`
308
- * `security_question_second`
309
- * `security_question_second_choice`
310
- * `security_question_third`
311
- * `security_question_third_choice`
312
-
313
- 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. Implementors do not need to handle the token themselves; the SDK uses it transparently. The token is audience-locked to `sdk:sse:progress`, valid for 10 minutes, and tied to the submitting user.
314
-
315
- Example Usage:
316
- ```javascript
317
- StreamConnect({
318
- el: '#react-hook',
319
- ...
320
- donePostCredentials: ({ params }) => {
321
- // Save the params to your system
322
- saveParams(params);
323
- },
324
- });
325
- ```
326
-
327
- ### `handleFormErrors`
328
- `handleFormErrors` Callback occurs when there was an issue submiting and saving the users credentials. While the SDK handles these errors and their presentation to the user, implementors might want additional info around these errors in order to better tune the SDK.
329
-
330
- This information can be obtuse. Its use may vary. Most implementors prefer to save this data in order to create info on what issues the users may have with saving.
331
- * `error`
332
- * `error_parts`
333
- * `response`
334
- * `request`
335
- * `config`
336
-
337
- Example Usage:
338
- ```javascript
339
- StreamConnect({
340
- el: '#react-hook',
341
- ...
342
- handleFormErrors: (error, {response, request, config}) => {
343
- // Save the params to your system
344
- console.log("Error Response -- Saving error to backend for logging purposes...");
345
- console.log(response);
346
- saveError(error);
347
- },
348
- });
349
- ```
350
-
351
- ### `doneRealTime`
352
- `doneRealTime` Callback occurs when the system finishes rendering the realtime-validation widget. If `realTimeVerification: false` this callback is never hit. This call back is purely for styling purposes.
353
-
354
- Example Usage:
355
- ```javascript
356
- StreamConnect({
357
- el: '#react-hook',
358
- ...
359
- doneRealTime: () => {
360
- // Do some styling
361
- },
362
- });
363
- ```
364
-
365
- ### `doneEasyEnroll`
366
- `doneEasyEnroll` This is the final callback of the SDK widget and it occurs when the system. There is a bunch of data dumped at the end which can be useful for an implementor when they are working the *TPAStream Webhooks*
367
-
368
- There are several properties passed back through this callback. Only a few may be applicable to an implementor.
369
- * `employer`
370
- * `payer`
371
- * `tenant`
372
- * `user`
373
- * `pending` -- The literal value the SDK is looking at to determine whether or not to show the pending page. If this is true the policyHolder is still pending.
374
- * `endingMessage` -- The specific ending message the SDK got from the backend to say to this user depending on their credentials status.
375
- * `policyHolder` -- The now saved policy_holder
376
- * `policy_holder_id`
377
- * `payer_id`
378
- * `login_correction_message` -- This will be null unless the `login_problem !== 'valid' || login_problem !== null`
379
- * `login_needs_correction` -- `true` or `false`. If `true` these credentials were found to be invalid via the realtime-validation engine.
380
- * `login_problem` -- This can be equal to any of the following below. Each has a different meaning around the credentials
381
- * `'valid'` -- The credentials are completely fine. Claims should start being collected shortly
382
- * `'invalid'` -- The crawl engine found that these credentials are not valid for the carrier. The user will be prompted to re-enter valid credentials into the SDK.
383
- * `'locked'` -- The crawl engine has identified that the carrier has locked this account for any number of reasons. This will require further action on the user's side in order to resolve.
384
- * `'broken'` -- The crawl engine has identified some issue with this credential's account. This usually requires the carriers to fix some issue on their site for progress to occure
385
- * `'needs_two_factor'` -- Support for two factor authentication for said payer is coming soon.
386
- * `'incomplete'` -- The crawl engine has identified that the registration for the user's credentials on the carrier site is incomplete. This will require action on the user's side to resolve.
387
- * `'inactive'` -- The user's account has been identified as inactive and thus will not be accessible to the crawler.
388
- * `'sec_question'` -- The user's security questions appear to be incorrect. The user will be prompted to re-enter valid credentials
389
- * `'wrong_secondary'` -- The user's account is configured to be using the wrong secondary method of authentication. This will prompt the user to update their account to use security questions.
390
- * `null` -- The crawl engine is still trying to confirm the status of these credentials. This may take up to 24 hours depending on the carrier's site uptime.
391
-
392
- If `renderEndWidget: true` then you will be given access to the following params as well.
393
- * `returnFlowFunction` This will restart the SDK engine or return the user to the payer form depending on if the credentials were valid or not.
394
- * An example call of this function looks like `returnFlowFunction()`
395
-
396
- Example Usage:
397
- ```javascript
398
- StreamConnect({
399
- el: '#react-hook',
400
- ...
401
- doneEasyEnroll: ({ employer, payer, tenant, policyHolder, user, returnFlowFunction }) => {
402
- // Do something with the data.
403
- },
404
- });
405
- ```
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
+ ```