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,107 @@
1
+ # Headless mode — drive every step yourself
2
+
3
+ The default `stream-connect-sdk` bundle ships with a complete Plaid-Link-style UI: a stepped wizard, a choose-carrier tile grid, a credentials form, an end widget, and a floating validation hero / corner panel. For most integrators that's exactly what you want — drop in a `<div id="...">`, call `StreamConnect({ el, ...identity })`, done.
4
+
5
+ Some integrators want something different. They have a design system the SDK chrome doesn't match. They want the SDK invisible — just the data pipe — so they can render the carrier picker, the credentials form, and the end screen with their own components. The 0.8 SDK supports this in two pieces: the existing `renderXxx: false` callback contract, plus a separate **headless bundle** that ships without our stylesheet.
6
+
7
+ ## When to use the headless bundle
8
+
9
+ | Use headless when... | Use the default (styled) bundle when... |
10
+ |---|---|
11
+ | You drive every step (choose-carrier, credentials form, end screen) with your own React/Vue/whatever components and only need the SDK for the data flow. | You want the built-in widgets. The 50 KB of Tailwind output is a fair trade for "drop in and it works." |
12
+ | Your host page has its own styling system and our `tpa-*` utility classes are unwanted dead bytes. | You want a design that auto-themes from your brand color via `theme.primaryColor`. |
13
+ | You're shipping the SDK on a bandwidth-sensitive page (mobile, embedded). | You don't have a design team building custom UI for the connect flow. |
14
+ | You want full control over mobile / responsive behavior. | You're OK with the default layout. |
15
+
16
+ The headless bundle does NOT change the SDK's behavior — same auth, same SSE-driven validation, same 2FA flow, same backend contract. It only changes whether `tailwind.css` is bundled.
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install stream-connect-sdk@^0.8
22
+ ```
23
+
24
+ Both bundles ship in the same package; pick at import time:
25
+
26
+ ```js
27
+ // Styled (default) — built-in widgets render with their full chrome.
28
+ import StreamConnect from 'stream-connect-sdk';
29
+
30
+ // Headless — same StreamConnect function, no stylesheet bundled.
31
+ import StreamConnect from 'stream-connect-sdk/headless';
32
+ ```
33
+
34
+ ## Headless init recipe
35
+
36
+ ```js
37
+ import StreamConnect from 'stream-connect-sdk/headless';
38
+
39
+ StreamConnect({
40
+ el: '#sdk-mount',
41
+ apiToken: '...',
42
+ tenant: { systemKey: 'YOUR_TENANT_KEY', vendor: 'internal' },
43
+ employer: { systemKey: '...', vendor: 'internal', name: '...' },
44
+ user: { firstName: '...', lastName: '...', email: '...' },
45
+
46
+ // Skip the built-in renderers — your code handles the UI.
47
+ renderChoosePayer: false,
48
+ renderPayerForm: false,
49
+ renderEndWidget: false,
50
+
51
+ // Callbacks fire INSTEAD of the built-in widgets rendering.
52
+ doneChoosePayer: (payload) => {
53
+ // Render your own carrier picker. Call payload.choosePayer({ payer })
54
+ // to advance to the credentials step.
55
+ mountMyCarrierPicker(payload);
56
+ },
57
+ doneCreatedForm: (payload) => {
58
+ // Render your own credentials form. Call payload.validateCreds({ params })
59
+ // to submit. params must include payer_id + accept + tenants_accept;
60
+ // see assets/sdk/components/EnterCredentials.tsx for the canonical shape.
61
+ mountMyCredsForm(payload);
62
+ },
63
+ doneEasyEnroll: (payload) => {
64
+ // Final terminal event after validation completes. payload includes
65
+ // policyHolder, payer, employer, tenant, user, credentialsValid,
66
+ // endingMessage, pending.
67
+ mountMyEndScreen(payload);
68
+ }
69
+ });
70
+ ```
71
+
72
+ ## What's still mounted in headless mode
73
+
74
+ The SDK still mounts a React root at `el` because the renderXxx callbacks need a host React tree to live in. Two things render by default and are typically what customers want even in headless mode:
75
+
76
+ - **ActiveValidationsHero** — the inline 2FA prompt (method picker + code entry). When a validation needs 2FA, this card appears above your custom UI. It's the only way to gather the OTP from the user.
77
+ - **ActiveValidationsPanel** — the floating corner notification showing in-flight validations.
78
+
79
+ Both rely on the SDK's `tpa-*` utility classes. In the headless bundle those classes have no styles attached, so the elements render as unstyled divs and inputs. Two paths:
80
+
81
+ 1. **Style them yourself.** The hero is `.tpa-sdk-root > [data-tpa-hero]`; the panel is `[data-tpa-panel]`. Style with your own CSS to match your design system.
82
+ 2. **Hide them entirely** and provide your own 2FA UI. Subscribe to the same SSE stream the hero uses via... actually, this isn't currently exposed as a public API. If you need full 2FA control without the hero, file an issue — we'll plumb it.
83
+
84
+ The Terms-of-Use Dialog is mounted only when the user clicks "View Terms of Use" in your custom form (which calls `toggleTermsOfUse()` from the credentials callback payload). It uses the styled Dialog component; in headless mode it renders as an unstyled overlay. Style it via `.tpa-sdk-root [role="dialog"]` or pre-fetch the terms HTML yourself and render in your own modal.
85
+
86
+ ## What's NOT in the headless bundle
87
+
88
+ - `tailwind.css` (the entire utility-class stylesheet) — about 27 KiB minified.
89
+
90
+ That's it. Every component, every reducer, every API client, every type — all identical between bundles. The split is purely about whether the stylesheet is imported.
91
+
92
+ ## Migrating from the styled to the headless bundle
93
+
94
+ If you're already using the default styled bundle with `renderChoosePayer: false` etc., switching to headless is one import line:
95
+
96
+ ```diff
97
+ - import StreamConnect from 'stream-connect-sdk';
98
+ + import StreamConnect from 'stream-connect-sdk/headless';
99
+ ```
100
+
101
+ All your init options and callbacks keep working as-is. The only visual change is the SDK's chrome (hero, panel, dialog) lose their default styling — apply your own CSS or hide them per the section above.
102
+
103
+ ## See also
104
+
105
+ - [Client usage](./client-usage.md) — full options reference + the `renderChoosePayer` / `renderPayerForm` / `renderEndWidget` flags.
106
+ - [SDK flow](./sdk-flow.md) — the step machine you're driving callbacks for.
107
+ - [Two-factor authentication](./two-factor.md) — what the hero is rendering when a validation needs MFA.
@@ -0,0 +1,38 @@
1
+ # Patient Access API (Interop)
2
+
3
+ TPAStream supports carrier Patient Access APIs for SDK users. Instead of collecting carrier credentials inline, the user authenticates on the carrier's own website and TPAStream receives a 90-day access token that it uses to harvest the data. The init option that enables this flow is **`enablePatientAccessAPI`**.
4
+
5
+ > Renamed in 0.8. The option was originally called `enableInterop`; both names still work indefinitely. Passing `enableInterop` logs a one-time console deprecation warning but otherwise behaves identically. New integrations should use the canonical name.
6
+
7
+ ## Client Usage
8
+ When `enablePatientAccessAPI` is set and your tenant / token is configured within TPAStream as Patient Access API-compliant, the SDK exposes payers that authenticate via a redirect to the payer website instead of an inline credentials form.
9
+
10
+ Here's how the flow goes at a top level:
11
+
12
+ ![Patient Access API Flow](interop-screenshots/InteropSDKFlow.png)
13
+
14
+ As shown above, the user is sent to a new window on the payer's website, completes authentication there, and the SDK detects the connection back to TPAStream and continues normally.
15
+
16
+ ## Single-page variant
17
+
18
+ Pass **`enablePatientAccessAPISinglePage`** instead of (or in addition to) `enablePatientAccessAPI` to perform the redirect in the current tab rather than opening a new window. When both are set, single-page wins.
19
+
20
+ The legacy alias `enableInteropSinglePage` is also still accepted with the same deprecation-warning treatment.
21
+
22
+ ## Redirect query parameters
23
+
24
+ After the carrier redirect completes, the SDK reads two URL parameters automatically on load:
25
+
26
+ * `?accessToken=...`: a fresh connect-access token minted by `app.tpastream.com`.
27
+ * `?forceTPAStreamSdkEnd=1`: set in the single-page variant to tell the next load to skip straight to the end widget.
28
+
29
+ Both are stripped from the URL via `history.replaceState` so they cannot leak via browser history or autofill. See [Client Usage > Redirect query parameters](./client-usage.md#redirect-query-parameters-patient-access-api) for the full mechanics.
30
+
31
+ ## See also
32
+
33
+ * [Connect Access Token](./connect-access-token.md): how the
34
+ `?accessToken=` minting fits into the broader connect-token security
35
+ model
36
+ * [Fix Credentials](./fix-credentials.md): Patient Access API carriers
37
+ show up in the same fix-credentials list with the same status badges
38
+ as inline-credential carriers
@@ -0,0 +1,110 @@
1
+ # Migrating from 0.7.x to 0.8
2
+
3
+ The 0.8 release is **backward-compatible** with 0.7.x at the `init()` call site: every option supported in 0.7.7 keeps working, including the custom render props (`renderChoosePayer`, `renderPayerForm`, `renderEndWidget`), all `done*` callbacks, `theme` (new), `userSchema` (changed, see below), and the rest.
4
+
5
+ If you do nothing, the 0.8 SDK will run with your existing 0.7.x init object. The visible changes are the new default appearance and the SSE-backed validation UI. This document calls out the handful of cases where a no-op upgrade is *not* what you want.
6
+
7
+ ## What changed
8
+
9
+ ### Look and feel
10
+ - Polished default appearance: cards, generous whitespace, system-font stack, accessible focus rings. No host-page CSS required; the SDK is visually self-contained.
11
+ - New `theme.primaryColor` init option recolors buttons, links, focus rings, and progress bars. See [Theme](./theme.md).
12
+
13
+ ### Stack
14
+ - React 19, full TypeScript port.
15
+ - Tailwind utility classes with the `tpa-` prefix to avoid name collisions with host-page CSS. The reset and theme variables are scoped under `.tpa-sdk-root` so they only affect the SDK subtree; the utility classes themselves are global but prefixed, so they only apply where the prefixed class names appear in the DOM.
16
+ - Headless UI primitives for accessible Dialog and Combobox.
17
+ - React Hook Form + Zod for the carrier credential form.
18
+ - **Removed dependencies**: `@fortawesome/*`, `font-awesome`, `react-jsonschema-form`, `react-popup`, `react-select`, `react-highlight-words`, `query-string`, `@babel/polyfill`, `regenerator-runtime`.
19
+
20
+ ### Credential validation
21
+ - Server-Sent Events stream replaces polling. State transitions arrive as they happen instead of on a 5-second cadence.
22
+ - Backed by the new `/v3/sdk/progress/<task_id>/stream` endpoint. Auth is a short-lived task-scoped JWT (audience `sdk:sse:progress`, bound to the user + task, 10-minute TTL) returned in the credential-submit response as `task_token` and forwarded as a `?token=...` query param on the SSE subscription.
23
+ - Multiple validations can run in parallel; each owns its own SSE subscription.
24
+ - Validation now renders in a non-blocking hero element + corner panel rather than blocking the carrier picker.
25
+
26
+ ### `init()` options
27
+ - `realTimeVerification` default is unchanged from 0.7.7 (still `true`). The transport changed; the default did not.
28
+ - `enableInterop` -> `enablePatientAccessAPI`. Legacy name keeps working; using it logs a one-time console deprecation warning.
29
+ - `enableInteropSinglePage` -> `enablePatientAccessAPISinglePage`. Same deprecation treatment.
30
+ - **New**: `theme` / `theme.primaryColor`.
31
+ - **New**: `enablePatientAccessAPI`, `enablePatientAccessAPISinglePage`.
32
+
33
+ ## Things to double-check
34
+
35
+ ### 1. Drop the Bootstrap CSS link (optional)
36
+
37
+ The 0.7.x quickstart told integrators to load Bootstrap 4.3 in the host page. The 0.8 SDK does not require it; you can remove the `<link rel="stylesheet" href=".../bootstrap.min.css">` tag. Host pages that already load Bootstrap for their own reasons can keep doing so without conflict: SDK utility classes use the `tpa-` prefix so collisions with host CSS are by-construction unlikely, and the reset + theme variables are wrapped under `.tpa-sdk-root` so they only affect the SDK subtree. The utility classes themselves are global by construction (anywhere `.tpa-text-white` appears in the DOM, the rule applies), but the prefix is what prevents them from colliding with host CSS.
38
+
39
+ ### 2. `userSchema` no longer drives form rendering
40
+
41
+ In 0.7.x, `userSchema` was a [react-jsonschema-form](https://react-jsonschema-form.readthedocs.io/) UI-schema object that customized the credentials form layout. `react-jsonschema-form` was removed in 0.8 to cut bundle size.
42
+
43
+ `userSchema` is still accepted as an init option for back-compat:
44
+ - It is forwarded into the credential-submit payload (your backend can read it if you need to).
45
+ - It no longer affects the form's visual rendering.
46
+ - The SDK logs a one-time console warning if it sees a non-empty `userSchema`.
47
+
48
+ If you depended on UI-schema-driven extra fields in 0.7.x, please file an issue at https://github.com/TPAStream/stream-connect-js-sdk/issues so we can scope an alternative.
49
+
50
+ ### 3. `realTimeVerification` behavior is different
51
+
52
+ The default is still `true`. What changed:
53
+ - The transport is now SSE instead of a 5-second polling loop.
54
+ - The validation UI is now **non-blocking**. The user can continue interacting with the SDK while validation streams in the corner panel, rather than being held on a loading screen for up to 200 seconds.
55
+ - MFA prompts render in the floating validation hero (a card at the top of the SDK root), NOT inside the credentials form. After submit, the user is returned to the picker or fix-credentials list and the hero shows the method picker / code entry inline. The credentials form itself stays out of the MFA flow.
56
+
57
+ If you previously omitted `realTimeVerification` and relied on the blocking, polling-based behavior, you have two choices:
58
+ - **Recommended**: leave the default `true`. The non-blocking UI is the same fidelity of feedback, just nicer.
59
+ - **Preserve 0.7.x submit-and-trust**: pass `realTimeVerification: false` explicitly. The SDK will not display validation feedback or MFA prompts; submitted credentials are treated as accepted and the flow advances immediately.
60
+
61
+ ### 4. `realtimeTimeout` is a no-op
62
+
63
+ In 0.7.x this set the polling-loop timeout. In 0.8 the timeout is server-side (~10 minutes on the SSE stream) and `realtimeTimeout` is accepted but ignored. You can leave the option in place or remove it; either is fine.
64
+
65
+ ### 5. `fixCredentials` is deprecated
66
+
67
+ If your integration passes `fixCredentials: true` alongside a `connectAccessToken`, drop the `fixCredentials` line. The SDK now derives member-portal mode automatically from the presence of `connectAccessToken` (which was always a hard backend requirement for the fix-credentials endpoint, so the flag was redundant). The 0.8 SDK still accepts `fixCredentials` for back-compat and logs a one-time `console.warn` reminding you to remove it.
68
+
69
+ If you were passing `fixCredentials: true` *without* a `connectAccessToken`, the behavior has changed: 0.7.x surfaced a configuration error on init ("You must have a connect access token enabled..."); 0.8 drops that check and falls through to the standard choose-payer enrollment flow. The backend `/sdk-api/fix-credentials` endpoint still requires the token, so member-portal mode itself is unreachable without it, but the SDK won't error at init anymore. If your integration was relying on that error to surface a misconfiguration, set up a server-side check that `connectAccessToken` is non-empty before passing the init payload to the SDK.
70
+
71
+ ### 6. Rename `enableInterop` (no rush)
72
+
73
+ The legacy aliases keep working indefinitely; one-time console warning when set. Rename at your convenience:
74
+
75
+ | 0.7.x | 0.8 canonical |
76
+ |---|---|
77
+ | `enableInterop` | `enablePatientAccessAPI` |
78
+ | `enableInteropSinglePage` | `enablePatientAccessAPISinglePage` |
79
+
80
+ ### 7. `enablePatientAccessAPI` default flipped to `true`
81
+
82
+ **Behavior change**, opt-out only. In 0.7.x, Patient Access API routing was off by default; integrators had to pass `enableInterop: true` (or `enablePatientAccessAPI: true` in 0.8 canonical) to make PAA-routed payers like Anthem, UHC Interop, Kaiser Interop, and Empire BCBS API take the OAuth-popup branch. Without the flag, those payers fell through to rendering the raw `interoperability.OnBoard` schema, which exposes `interoperability_refresh_token` as a user-visible text input — meaningless to a real user since the OAuth callback is what populates that field server-side.
83
+
84
+ In 0.8 the default is `true`. If you weren't passing `enableInterop: true` / `enablePatientAccessAPI: true`, your PAA payers were almost certainly broken in 0.7.x (no user knows what to put in the refresh-token field) and start working in 0.8 with no action on your part.
85
+
86
+ If you deliberately want the legacy fallthrough behavior — e.g. you're doing custom PAA orchestration and want the SDK out of the way — pass `enablePatientAccessAPI: false` explicitly. The legacy `enableInterop: false` alias also continues to honor the opt-out.
87
+
88
+ `enablePatientAccessAPISinglePage` is unchanged at `false` by default. Single-page mode replaces the OAuth popup with a full host-page redirect; defaulting it on would silently lose host-page state for popup-flow customers, so customers explicitly opt in.
89
+
90
+ ### 8. Custom render props: data shapes unchanged
91
+
92
+ If you use `renderChoosePayer={false}` / `renderPayerForm={false}` / `renderEndWidget={false}` and drive those steps from `doneChoosePayer` / `doneCreatedForm` / `doneEasyEnroll`, the data passed into your callbacks is unchanged.
93
+
94
+ ## What you do NOT need to do
95
+
96
+ - You do not need to add a `theme` option. The default appearance applies automatically.
97
+ - You do not need to rename `apiToken` / `sdkToken`. Both still work.
98
+ - You do not need to install React or React-DOM. The SDK bundles its own React 19.
99
+ - You do not need to handle `task_token` yourself. The SDK uses it internally for the SSE subscription.
100
+ - You do not need to consume `?accessToken=...` or `?forceTPAStreamSdkEnd=1` URL parameters yourself. The SDK reads them on init and strips them via `history.replaceState`.
101
+
102
+ ## 0.7.x remains supported
103
+
104
+ If you are not ready to upgrade, the CDN keeps every pinned version available indefinitely. Pin to the last 0.7.x:
105
+
106
+ ```html
107
+ <script src="https://app.tpastream.com/static/js/sdk-v-0.7.7.js"></script>
108
+ ```
109
+
110
+ Open an issue if a 0.7.x bugfix backport is needed for a customer who cannot move yet.
@@ -0,0 +1,247 @@
1
+ # Quick Start
2
+ A guide to get an implementation up and running as quickly as possible. This guide
3
+ will not go into the deep customization of the SDK, but rather will look at getting
4
+ the SDK to be configured properly, to be able to submit credentials and validate them.
5
+
6
+ ## Step 1 -- Import the SDK
7
+ This guide will use a simple html document with the configuration of the StreamConnect SDK set in an html head script.
8
+ The html surrounding the SDK will not change throughout the guide.
9
+
10
+ Here is what the test htmlscript looks like.
11
+ ```html
12
+ <!DOCTYPE html>
13
+ <html>
14
+ <head>
15
+ <script src="https://app.tpastream.com/static/js/sdk.js"></script>
16
+ </head>
17
+ <body></body>
18
+ </html>
19
+ ```
20
+
21
+ `<script src="https://app.tpastream.com/static/js/sdk.js"></script>` in the head will bring down the latest version of the StreamConnect SDK. If you need to pin to a specific version, change the src to something like
22
+ `<script src="https://app.tpastream.com/static/js/sdk-v-0.8.1.js"></script>`. Pinned versions remain available indefinitely.
23
+
24
+ The 0.8 SDK is visually self-contained: it does not require Bootstrap, jQuery, FontAwesome, or any other host-page CSS. Host pages that already load Bootstrap can keep doing so without conflict. SDK styles use a `tpa-` class prefix to avoid name collisions with host CSS, and the reset/theme variables are wrapped under `.tpa-sdk-root` so they only affect the SDK subtree.
25
+
26
+ ## Step 2 -- Add element for SDK to hook to and init SDK
27
+ ```html
28
+ <!DOCTYPE html>
29
+ <html>
30
+ <head>
31
+ <script src="https://app.tpastream.com/static/js/sdk.js"></script>
32
+ <script>
33
+ window.StreamConnect({
34
+ el: '#sdk-hook',
35
+ isDemo: true,
36
+ })
37
+ </script>
38
+ </head>
39
+ <body>
40
+ <div id="sdk-hook"></div>
41
+ </body>
42
+ </html>
43
+ ```
44
+
45
+ The SDK will nest all of its elements beneath whatever div you target via a css selector in the `el` element. It is suggested
46
+ that an implementor starts the SDK init with `isDemo` set to true as shown above so that an implmenetor can see the initial SDK page.
47
+
48
+ *Demo mode is incapable of saving credentials or validating credentials.
49
+
50
+ If you then open up the above html in a browser you should see something close to the following.
51
+ ![Demo Init Page](https://tpastream-public.s3.amazonaws.com/sdk-docs/quickstart-screenshots/demo-init-page.png)
52
+
53
+ ## Step 3 -- Add sdk Token
54
+ ```html
55
+ <!DOCTYPE html>
56
+ <html>
57
+ <head>
58
+ <script src="https://app.tpastream.com/static/js/sdk.js"></script>
59
+ <script>
60
+ window.StreamConnect({
61
+ el: '#sdk-hook',
62
+ isDemo: false,
63
+ sdkToken: 'Your-SDK-Token-Here', // Same as apiToken: 'Your-SDK-Token-Here'
64
+ })
65
+ </script>
66
+ </head>
67
+ <body>
68
+ <div id="sdk-hook"></div>
69
+ </body>
70
+ </html>
71
+ ```
72
+
73
+ After setting the `sdkToken` you will see the following page on your html.
74
+ ![Init Error Page](https://tpastream-public.s3.amazonaws.com/sdk-docs/quickstart-screenshots/error-init-page.png)
75
+
76
+ That is ok! In order to initialize the SDK you will need to have quite a few more values. So for now it won't properly init.
77
+
78
+ If you go into the developer tools for your site, you can get several helpful errors from the various requests which the SDK
79
+ is generating. In this case the following init errors will likely provide `422` responses.
80
+
81
+ Example Error:
82
+ ```
83
+ You are missing required parameters in user. We require [firstName, lastName, email]. For more documentation on how the User Configuration works see https://github.com/TPAStream/stream-connect-js-sdk/blob/master/docs/client-usage.md#client-usage
84
+ ```
85
+
86
+ If you recieve a `404` error at this step it is possible that your `sdkToken` is not configured properly. Stick with the guide to see
87
+ if the error naturally resolves as you add the rest of the configuration.
88
+
89
+ ## Step 4 -- Add user configuration
90
+ ```html
91
+ <!DOCTYPE html>
92
+ <html>
93
+ <head>
94
+ <script src="https://app.tpastream.com/static/js/sdk.js"></script>
95
+ <script>
96
+ window.StreamConnect({
97
+ el: '#sdk-hook',
98
+ isDemo: false,
99
+ sdkToken: 'Your-SDK-Token-Here',
100
+ user: {
101
+ firstName: 'Testing',
102
+ lastName: 'User',
103
+ email: 'youremail+testingsdk@email.com'
104
+ },
105
+ })
106
+ </script>
107
+ </head>
108
+ <body>
109
+ <div id="sdk-hook"></div>
110
+ </body>
111
+ </html>
112
+ ```
113
+
114
+ An implementor can think of a user as a participant which has the credentials on whatever insurance carrier is being interacted with.
115
+ In order to save these members into our system we require a first name, last name, and an email. While eventually this data will
116
+ come from real user data on your site, while configurating the sdk we suggest you use test emails.
117
+
118
+ *Warning* If you have an Admin account on TPAStream you will not be able to use that account with the StreamConnect SDK. Instead use
119
+ a different email with your enrollment process. Or if you are using GMail, you can follow the pattern `youremail+testingsdk@gmail.com`.
120
+ This will allow you to set-up a new account in TPAStream which is separate from your current one, but also have the emails go to
121
+ your current email.
122
+
123
+ ## Step 5 -- Employer configuration
124
+ ```html
125
+ <!DOCTYPE html>
126
+ <html>
127
+ <head>
128
+ <script src="https://app.tpastream.com/static/js/sdk.js"></script>
129
+ <script>
130
+ window.StreamConnect({
131
+ el: '#sdk-hook',
132
+ isDemo: false,
133
+ sdkToken: 'Your-SDK-Token-Here',
134
+ user: {
135
+ firstName: 'Testing',
136
+ lastName: 'User',
137
+ email: 'youremail+testingsdk@email.com'
138
+ },
139
+ employer: {
140
+ name: 'testingEmployer', // Only provide this if your employer does not exist in TPAStream yet.
141
+ systemKey: 'testing-sdk',
142
+ vendor: 'internal', // This will almost always be internal
143
+ },
144
+ })
145
+ </script>
146
+ </head>
147
+ <body>
148
+ <div id="sdk-hook"></div>
149
+ </body>
150
+ </html>
151
+ ```
152
+
153
+ When implementing the SDK all carrier credentials will be nested under an employer in TPAStream. This block will define which
154
+ employer your are interested in.
155
+
156
+ To get the Key for an existing employer go to the [Employers Page](https://app.tpastream.com/d/employers) in the TPAStream Admin portal. From there search up the desired employer. Then enter the details page of said employer. From there open the **Support** tab.
157
+
158
+ You will see a screen similar to this:
159
+ ![Employer Key Page](https://tpastream-public.s3.amazonaws.com/webapp-docs/employers/employer-key-page.png)
160
+
161
+ The key field is labeled per-vendor — e.g. **Alegeus Key**, **OCA Key**, or simply **Key** depending on which integration the employer is attached to. Grab that value (in the screenshot it's `BBPGUIDE`) and put it into the `systemKey` config option in the employer object.
162
+
163
+
164
+ # Step 6 -- Init
165
+
166
+ Now that you have set up the configuration as follows you should be able to reload the page you set up before and init the SDK. From 0.8 onward the SDK ships with a polished default appearance, so you should see a usable enrollment widget without any host-page CSS work.
167
+
168
+ For brand-color matching see [Theme](./theme.md). For the per-callback contract and the full list of init options see [Client Usage](./client-usage.md). If you're coming from 0.7.x, the [Migration guide](./migration-0.7-to-0.8.md) calls out the handful of behaviors that changed.
169
+
170
+ ## Mobile (Android, iOS, React Native)
171
+
172
+ The SDK is web-first. The recommended mobile integration pattern is to embed the SDK page in a WebView and ferry callbacks to the native host via `postMessage` / message handlers. This gives the mobile app the polished 0.8 UI for free without a parallel native codebase.
173
+
174
+ ### React Native
175
+
176
+ [`react-native-webview`](https://github.com/react-native-webview/react-native-webview) is the standard library:
177
+
178
+ ```jsx
179
+ import { WebView } from 'react-native-webview';
180
+
181
+ export const ConnectScreen = ({ onComplete }) => {
182
+ const handleMessage = (event) => {
183
+ const message = JSON.parse(event.nativeEvent.data);
184
+ if (message.type === 'doneEasyEnroll') {
185
+ onComplete(message.data);
186
+ }
187
+ };
188
+
189
+ return (
190
+ <WebView
191
+ source={{ uri: 'https://your-backend.example.com/connect-sdk' }}
192
+ onMessage={handleMessage}
193
+ javaScriptEnabled
194
+ domStorageEnabled
195
+ originWhitelist={['*']}
196
+ />
197
+ );
198
+ };
199
+ ```
200
+
201
+ Your `/connect-sdk` page should host the standard SDK init from Step 5 above, plus a `postMessage` forwarder so terminal-state callbacks reach the native shell:
202
+
203
+ ```html
204
+ doneEasyEnroll: (data) => {
205
+ window.ReactNativeWebView?.postMessage(
206
+ JSON.stringify({ type: 'doneEasyEnroll', data })
207
+ );
208
+ }
209
+ ```
210
+
211
+ Full RN walkthrough including PAA-redirect handling is in [`sdk-hook/docs/README.md`](../sdk-hook/docs/README.md#recommended-webview-pattern-for-react-native).
212
+
213
+ > **Note on `stream-connect-sdk-hook`**: the separate headless hook package on npm (v0.6.x) is deprecated in favor of the WebView pattern above. Existing integrations keep working but won't receive feature updates. See the hook docs for the deprecation notice and migration guidance.
214
+
215
+ ### Android (Java)
216
+
217
+ ```java
218
+ public class ViewWeb extends Activity {
219
+ @Override
220
+ public void onCreate(Bundle savedInstanceState) {
221
+ super.onCreate(savedInstanceState);
222
+ setContentView(R.layout.content);
223
+ WebView webview = (WebView) findViewById(R.id.webView);
224
+ webview.getSettings().setJavaScriptEnabled(true);
225
+ webview.loadUrl("https://your-backend.example.com/connect-sdk");
226
+ }
227
+ }
228
+ ```
229
+
230
+ ### iOS (Swift / WKWebView)
231
+
232
+ ```swift
233
+ import UIKit
234
+ import WebKit
235
+
236
+ class ViewController: UIViewController, WKUIDelegate, WKNavigationDelegate {
237
+ @IBOutlet weak var webView: WKWebView!
238
+
239
+ override func viewDidLoad() {
240
+ super.viewDidLoad()
241
+ webView.uiDelegate = self
242
+ webView.navigationDelegate = self
243
+ let url = URL(string: "https://your-backend.example.com/connect-sdk")!
244
+ webView.load(URLRequest(url: url))
245
+ }
246
+ }
247
+ ```
@@ -0,0 +1,47 @@
1
+ # SDK Flow
2
+ ## Set-Up
3
+ The SDK will not render on the page until `StreamConnect` is called. Meaning that implementors can setup the page to go through various flows and have the SDK generate as part of a button click and or other method. The SDK will render beneath whatever element-hook the implementor attaches it to. As part of this the implementor should have setup all the necessary piping and configurations on a per-user basis. Once this configuration is complete and the SDK is called it shall render it's first widget `choose-payer`
4
+ ## Choose-Payer
5
+ This is the first widget to render on the page. It will appear as one of two forms. Either as a couple of images of payer logos or as a dropdown (Note: The dropdown can have the images appear as well if they are specifically configured on the employer OR there are credentials already existing for this user on said payer).
6
+
7
+ If the SDK is configured to demo mode you can see what each individual style will look like. Once the user clicks on one of these images or selects from the dropdown, the next widget renders: `enter-credentials`.
8
+
9
+ Here is what choose-payer might looks like (DISCLAIMER: All screenshots are configured in demo-mode and thus have incomplete data)
10
+ ![Choose Payer](https://tpastream-public.s3.amazonaws.com/sdk-docs/flow-screenshots/choose-payer.png)
11
+
12
+ The dropdown variant looks like this when the listbox is open:
13
+
14
+ ![Choose Payer (dropdown)](https://tpastream-public.s3.amazonaws.com/sdk-docs/flow-screenshots/choose-payer-dropdown.png)
15
+
16
+ ## Enter Credentials
17
+ The second widget to render on the page is the `enter-credentials` widget. This widget handles the form for the specific carrier site. This page will have fields for usernames, passwords, security questions, dates of birth, and terms of service acceptance.
18
+
19
+ The SDK will handle all the validation of the form. You can interface more thoroughly with the submit request via the `donePostCredentials` callback.
20
+
21
+ This widget is also home to some sub-widgets which have their own callbacks: `terms-of-service` and `pop-up`.
22
+
23
+ Here is what a form might look like
24
+ ![Enter Credentials](https://tpastream-public.s3.amazonaws.com/sdk-docs/flow-screenshots/enter-credentials.png)
25
+
26
+ ## Enter Credentials Sub-Widgets
27
+ #### Pop Up
28
+ This widget is accessed by clicking the question mark on the page. This pop-up has a link to the carrier site.
29
+ ![Pop Up](https://tpastream-public.s3.amazonaws.com/sdk-docs/flow-screenshots/pop-up.png)
30
+ #### Terms of Service
31
+ This widget contains the TPAStream terms of service
32
+ ![Terms of Service](https://tpastream-public.s3.amazonaws.com/sdk-docs/flow-screenshots/terms-of-service.png)
33
+
34
+ ## Real Time Validation
35
+
36
+ In 0.8 this is no longer a blocking intermediate widget. After the user submits credentials, the SDK opens a Server-Sent Events subscription to `/v3/sdk/progress/<task_id>/stream` and surfaces validation progress in a non-blocking hero element plus a corner-panel UI, while the rest of the flow remains interactive. Multiple validations can run in parallel; each one owns its own SSE subscription.
37
+
38
+ Auth on the SSE channel is a short-lived task-scoped JWT (audience `sdk:sse:progress`, bound to the user + validation task, 10-minute TTL) returned in the credential-submit response as `task_token`. The SDK forwards it as a `?token=...` query param on the SSE subscription; integrators do not need to handle the token directly.
39
+
40
+ State transitions arrive as they happen rather than on the 5-second polling cadence used in 0.7.x. The server-side stream has a hard ~10-minute deadline; if validation hasn't terminated by then the server emits a `timeout` event and closes the stream. The SDK transitions that validation to a `pending_async` state which keeps it visible in the hero / corner-panel UI (the wizard does NOT auto-advance to FinishedEasyEnroll). The user can keep using the SDK; when they return later, the next call to the backend will reflect whatever terminal state the validation reached.
41
+
42
+ `doneRealTime` still fires for back-compat. The `realtimeTimeout` init option is accepted but ignored (the timeout is now server-side).
43
+
44
+ ![Realtime Validation](https://tpastream-public.s3.amazonaws.com/sdk-docs/flow-screenshots/realtime-validation.png)
45
+
46
+ ## Done Easy Enroll
47
+ This final widget will display an ending message for the user and allow them to retry and or submit credentials depending on their end status.
package/docs/theme.md ADDED
@@ -0,0 +1,47 @@
1
+ # Theme
2
+
3
+ The 0.8 SDK ships with a polished default appearance: cards, generous whitespace, system-font stack, accessible focus rings. Most integrators do not need to write any CSS. For brand-color matching, the `theme` init option exposes a small set of overrides applied as scoped CSS variables on the SDK root subtree.
4
+
5
+ ## `theme.primaryColor`
6
+
7
+ Recolors the SDK's primary accent surfaces (buttons, links, focus rings, progress bars, selected-state highlights) to match your brand.
8
+
9
+ ```javascript
10
+ StreamConnect({
11
+ el: '#react-hook',
12
+ apiToken: 'VeryLegitKey',
13
+ // ... other options ...
14
+ theme: {
15
+ primaryColor: '#2563eb'
16
+ }
17
+ });
18
+ ```
19
+
20
+ Accepts a 6-digit hex color string (`#RRGGBB`) or a pre-formatted RGB triplet (`"37 99 235"`). The 3-digit shorthand `#RGB` is not supported. The SDK derives a small shade scale (50 / 100 / 200 / 300 / 500 / 600 / 700 / 800) from the value and binds it to CSS variables under `.tpa-sdk-root`. Two SDK instances on the same page with different `primaryColor` values render independently; the overrides are scoped, not global.
21
+
22
+ ### What it recolors
23
+
24
+ - Primary buttons (background + hover/active states)
25
+ - Links inside SDK widgets
26
+ - Focus rings on inputs, buttons, checkboxes
27
+ - Progress indicators and active-step markers
28
+ - Selected-state highlights (e.g., the chosen carrier tile)
29
+
30
+ ### What it does not recolor
31
+
32
+ - Carrier logos and Patient Access API payer tiles (these display the carrier's own branding)
33
+ - Error states (red), success states (green), and other semantic colors
34
+ - Body text, secondary text, card backgrounds, dividers
35
+ - Host-page content outside the SDK subtree
36
+
37
+ If you need to override a color the `primaryColor` knob does not touch, file an issue describing the use case; we would rather extend the theme API than have integrators target SDK internals with descendant CSS selectors that will break on the next release.
38
+
39
+ ## Scoping
40
+
41
+ All theme overrides are applied via CSS custom properties on the `.tpa-sdk-root` element the SDK mounts inside your `el` selector. They do not leak to any sibling or ancestor element on the host page.
42
+
43
+ The SDK's own Tailwind utility classes use the `tpa-` prefix to avoid name collisions with host-page CSS. The utility classes themselves are global (anywhere `.tpa-text-white` appears in the DOM, the rule applies), but the prefix means a host page that doesn't use `tpa-*` class names will never collide. The reset and theme variables are wrapped in `.tpa-sdk-root` so they only affect the SDK subtree.
44
+
45
+ ## What's coming
46
+
47
+ For more comprehensive branding (custom fonts, surface colors, dark mode, configurable border radius) we are gathering feedback. Open an issue at https://github.com/TPAStream/stream-connect-js-sdk/issues if you need controls beyond `primaryColor`.