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.
- package/CHANGELOG.md +319 -0
- package/README.md +89 -133
- package/docs/README.md +52 -0
- package/docs/client-usage.md +489 -0
- package/docs/connect-access-token-screenshots/connect-access-token-pattern.png +0 -0
- package/docs/connect-access-token.md +207 -0
- package/docs/error.md +149 -0
- package/docs/faq.md +77 -0
- package/docs/fix-credentials.md +157 -0
- package/docs/flow-screenshots/realtime-validation.png +0 -0
- package/docs/headless.md +107 -0
- package/docs/interop-screenshots/Interop SDK Flow Legacy.png +0 -0
- package/docs/interop-screenshots/InteropSDKFlow.png +0 -0
- package/docs/interop.md +38 -0
- package/docs/migration-0.7-to-0.8.md +110 -0
- package/docs/quickstart-screenshots/employer-key-page.png +0 -0
- package/docs/quickstart.md +247 -0
- package/docs/sdk-flow.md +47 -0
- package/docs/theme.md +47 -0
- package/docs/two-factor.md +137 -0
- package/package.json +74 -78
- package/sdk-headless.js +2 -0
- package/sdk.js +1 -1
- package/.babelrc +0 -4
- package/.rgignore +0 -1
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Connect Access Token
|
|
2
|
+
|
|
3
|
+
This is an advanced security funcitonality intended for implementors who would like an extra layer of security on the stream connect sdk. This set-up is required if an implementor intends to use the Fix-Credentials capabilities of the stream connect sdk.
|
|
4
|
+
|
|
5
|
+
## Your Public Key vs Your Secret Key
|
|
6
|
+
If you have opted into using the connect access token for the stream connect sdk, then you will have been provided 2 keys in association to your sdk instance. One key will be made clear to be your `sdkToken` this is a public key not meant to be hidden. This key will go into the `sdkToken` key on your StreamConnect initialization object.
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
StreamConnect({
|
|
10
|
+
sdkToken: "Your-Sdk-Token"
|
|
11
|
+
})
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The other key you receive is a secret key not meant for public consumption.
|
|
15
|
+
|
|
16
|
+
**WARNING**
|
|
17
|
+
-----------
|
|
18
|
+
Never put your SDK secret key in a place were a user could potential see it. That means never put it in the StreamConnect initialization object.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## How to use your Secret Key
|
|
22
|
+
Your secret key is meant to be used to generate temporary tokens which you will then pass to your StreamConnect initialization object.
|
|
23
|
+
|
|
24
|
+
The pattern is as followed.
|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
1. Confirm that your secret key is stored on your application.
|
|
28
|
+
2. Make a POST request to https://app.tpastream.com/api/create-connect-token
|
|
29
|
+
* The Body should have `{"connect_access_key": "", "connect_secret_key": ""}`
|
|
30
|
+
3. You will recieve back a response with json data `"data": "some-super-long-jwt"`
|
|
31
|
+
4. Take the value from that response's data key and pump it up to your StreamConnect instance through `connectAccessToken`
|
|
32
|
+
|
|
33
|
+
Your init object should look like
|
|
34
|
+
```
|
|
35
|
+
StreamConnect({
|
|
36
|
+
"sdkToken": "<Your-Public-Access-Key>",
|
|
37
|
+
"connectAccessToken": "<some-super-long-jwt>"
|
|
38
|
+
})
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This JWT expires after 1 hour.
|
|
42
|
+
|
|
43
|
+
## Refreshing an expired token (0.8.1+)
|
|
44
|
+
|
|
45
|
+
Connect access tokens expire after 1 hour. When a member leaves your
|
|
46
|
+
SDK-hosting page open past that window and comes back to interact,
|
|
47
|
+
the next API call fails with a 422 and `error_code:
|
|
48
|
+
"expired_connect_token"`. The 0.8.1 SDK can recover transparently
|
|
49
|
+
**if** you wire a refresh hook — but the refresh has to go through
|
|
50
|
+
your server, because only your server holds the SDK secret key.
|
|
51
|
+
|
|
52
|
+
### Why this can't be automatic
|
|
53
|
+
|
|
54
|
+
The whole point of the connect access token is that the secret key
|
|
55
|
+
never reaches the browser. If the SDK could mint its own tokens, the
|
|
56
|
+
secret would have to be in JS code where any user with devtools could
|
|
57
|
+
read it. So the SDK can't refresh on its own — it can only ask your
|
|
58
|
+
server for a fresh token.
|
|
59
|
+
|
|
60
|
+
### Step 1: expose a refresh endpoint on your server
|
|
61
|
+
|
|
62
|
+
This endpoint does the same `POST` to `/api/create-connect-token`
|
|
63
|
+
that your original page-render did, returning the new JWT to the
|
|
64
|
+
browser. **Gate it with the same auth you use for the member's
|
|
65
|
+
session** — anyone who can call it can extend any member's SDK
|
|
66
|
+
session indefinitely.
|
|
67
|
+
|
|
68
|
+
**Flask:**
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from flask import jsonify, request
|
|
72
|
+
import requests
|
|
73
|
+
|
|
74
|
+
@app.route("/api/tpa-sdk-refresh-token", methods=["POST"])
|
|
75
|
+
@your_login_required
|
|
76
|
+
def tpa_sdk_refresh_token():
|
|
77
|
+
response = requests.post(
|
|
78
|
+
"https://app.tpastream.com/api/create-connect-token",
|
|
79
|
+
json={
|
|
80
|
+
"connect_access_key": app.config["TPA_SDK_PUBLIC_KEY"],
|
|
81
|
+
"connect_secret_key": app.config["TPA_SDK_SECRET_KEY"],
|
|
82
|
+
},
|
|
83
|
+
timeout=10,
|
|
84
|
+
)
|
|
85
|
+
response.raise_for_status()
|
|
86
|
+
return jsonify(token=response.json()["data"])
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Express:**
|
|
90
|
+
|
|
91
|
+
```js
|
|
92
|
+
app.post('/api/tpa-sdk-refresh-token', yourLoginRequired, async (req, res) => {
|
|
93
|
+
const r = await fetch('https://app.tpastream.com/api/create-connect-token', {
|
|
94
|
+
method: 'POST',
|
|
95
|
+
headers: { 'Content-Type': 'application/json' },
|
|
96
|
+
body: JSON.stringify({
|
|
97
|
+
connect_access_key: process.env.TPA_SDK_PUBLIC_KEY,
|
|
98
|
+
connect_secret_key: process.env.TPA_SDK_SECRET_KEY,
|
|
99
|
+
}),
|
|
100
|
+
});
|
|
101
|
+
if (!r.ok) return res.status(502).json({ error: 'refresh failed' });
|
|
102
|
+
const { data } = await r.json();
|
|
103
|
+
res.json({ token: data });
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**ASP.NET Core (C#):**
|
|
108
|
+
|
|
109
|
+
```csharp
|
|
110
|
+
[Authorize] // gate with your member-session auth
|
|
111
|
+
[HttpPost("api/tpa-sdk-refresh-token")]
|
|
112
|
+
public async Task<IActionResult> TpaSdkRefreshToken(
|
|
113
|
+
[FromServices] IHttpClientFactory clientFactory,
|
|
114
|
+
[FromServices] IConfiguration config)
|
|
115
|
+
{
|
|
116
|
+
var http = clientFactory.CreateClient();
|
|
117
|
+
var payload = new
|
|
118
|
+
{
|
|
119
|
+
connect_access_key = config["TpaSdk:PublicKey"],
|
|
120
|
+
connect_secret_key = config["TpaSdk:SecretKey"],
|
|
121
|
+
};
|
|
122
|
+
using var response = await http.PostAsJsonAsync(
|
|
123
|
+
"https://app.tpastream.com/api/create-connect-token", payload);
|
|
124
|
+
if (!response.IsSuccessStatusCode)
|
|
125
|
+
return StatusCode(502, new { error = "refresh failed" });
|
|
126
|
+
var doc = await response.Content.ReadFromJsonAsync<JsonElement>();
|
|
127
|
+
return Ok(new { token = doc.GetProperty("data").GetString() });
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
The pattern is the same in every backend: an authenticated POST that proxies to `app.tpastream.com/api/create-connect-token` with your stored secret + public keys. PHP, Ruby, Go, Java — same shape, swap the HTTP client for whatever's idiomatic.
|
|
132
|
+
|
|
133
|
+
### Step 2: wire `connectAccessTokenRefreshFn` on the SDK
|
|
134
|
+
|
|
135
|
+
```js
|
|
136
|
+
StreamConnect({
|
|
137
|
+
// ... your existing config ...
|
|
138
|
+
connectAccessToken: '<initial-token-from-page-render>',
|
|
139
|
+
connectAccessTokenRefreshFn: async () => {
|
|
140
|
+
const r = await fetch('/api/tpa-sdk-refresh-token', {
|
|
141
|
+
method: 'POST',
|
|
142
|
+
credentials: 'same-origin',
|
|
143
|
+
});
|
|
144
|
+
if (!r.ok) throw new Error(`refresh failed: ${r.status}`);
|
|
145
|
+
return (await r.json()).token;
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
When the SDK detects an expired token, it calls this function, swaps
|
|
151
|
+
the new value into its `X-Connect-Access-Token` header, and retries
|
|
152
|
+
the failed request — the member sees no error. Multiple parallel
|
|
153
|
+
failed requests share a single refresh attempt (stampede guard) so
|
|
154
|
+
your endpoint gets called once per expiry cycle, not once per request.
|
|
155
|
+
|
|
156
|
+
### Fallback: notification-only
|
|
157
|
+
|
|
158
|
+
If you can't add a refresh endpoint (legacy host, static site, etc.),
|
|
159
|
+
wire `onConnectAccessTokenExpired` instead. The SDK will surface the
|
|
160
|
+
expiry to your callback (and dispatch a
|
|
161
|
+
`tpastream-connect-token-expired` CustomEvent on `window`) so you can
|
|
162
|
+
prompt the member to reload:
|
|
163
|
+
|
|
164
|
+
```js
|
|
165
|
+
StreamConnect({
|
|
166
|
+
// ... your existing config ...
|
|
167
|
+
onConnectAccessTokenExpired: () => {
|
|
168
|
+
if (confirm('Your session has expired. Reload to continue?')) {
|
|
169
|
+
window.location.reload();
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
The reload triggers a fresh page render, which mints a fresh
|
|
176
|
+
`connectAccessToken` server-side. The trade-off versus the refresh
|
|
177
|
+
hook is that the member loses any in-progress credential entry.
|
|
178
|
+
|
|
179
|
+
## Mid-session token refresh (Patient Access API redirect)
|
|
180
|
+
|
|
181
|
+
After a Patient Access API redirect completes, `app.tpastream.com`
|
|
182
|
+
appends a fresh `?accessToken=...` query parameter to the return
|
|
183
|
+
URL. The 0.8 SDK reads it automatically on init and uses it for the
|
|
184
|
+
rest of the session, overriding any stale `connectAccessToken` baked
|
|
185
|
+
into the page. The token is stripped from the URL via
|
|
186
|
+
`history.replaceState` so it doesn't end up in the browser history
|
|
187
|
+
or address bar.
|
|
188
|
+
|
|
189
|
+
Note: `replaceState` runs after the SDK script loads, so any
|
|
190
|
+
resources or third-party scripts loaded by the host page *before*
|
|
191
|
+
the SDK runs (analytics beacons, ad pixels, anything in the `<head>`
|
|
192
|
+
that fires its own requests) can still see the original
|
|
193
|
+
token-bearing URL in the Referer header. If your host page loads
|
|
194
|
+
anything sensitive before the SDK, either move it after the SDK
|
|
195
|
+
script tag or strip the `accessToken` query param server-side
|
|
196
|
+
before serving the post-redirect page.
|
|
197
|
+
|
|
198
|
+
See [Client Usage > Redirect query
|
|
199
|
+
parameters](./client-usage.md#redirect-query-parameters-patient-access-api)
|
|
200
|
+
for the full mechanics.
|
|
201
|
+
|
|
202
|
+
## See also
|
|
203
|
+
|
|
204
|
+
* [Fix Credentials](./fix-credentials.md): the primary consumer of
|
|
205
|
+
`connectAccessToken`
|
|
206
|
+
* [Patient Access API (Interop)](./interop.md): the redirect flow
|
|
207
|
+
that drives the mid-session refresh above
|
package/docs/error.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Error Documentation
|
|
2
|
+
|
|
3
|
+
Errors are grouped by where they come from in the SDK lifecycle. Each
|
|
4
|
+
entry covers the message, the HTTP / SDK state it shows up in, and
|
|
5
|
+
what to do about it.
|
|
6
|
+
|
|
7
|
+
## Init-time configuration errors
|
|
8
|
+
|
|
9
|
+
### `init failed: el must be a CSS selector string`
|
|
10
|
+
|
|
11
|
+
The first argument to `StreamConnect({ el })` was undefined, missing,
|
|
12
|
+
or not a string. Pass a CSS selector that resolves to a single
|
|
13
|
+
element on the page (e.g. `'#react-hook'`).
|
|
14
|
+
|
|
15
|
+
### `init failed: element <selector> not found in DOM`
|
|
16
|
+
|
|
17
|
+
The selector passed in `el` doesn't match anything when the SDK tries
|
|
18
|
+
to mount. Either the element doesn't exist yet (load the SDK after
|
|
19
|
+
your container element renders), or the selector is wrong. The SDK
|
|
20
|
+
calls `handleInitErrors` with the error so your host page can log /
|
|
21
|
+
recover.
|
|
22
|
+
|
|
23
|
+
### `You are missing required parameters in user. We require [firstName, lastName, email].`
|
|
24
|
+
|
|
25
|
+
The `user` object passed to `StreamConnect({ user: ... })` is
|
|
26
|
+
missing one of the three required fields. Backend returns 422.
|
|
27
|
+
|
|
28
|
+
### `User is not a valid user for the easyenrollment sdk`
|
|
29
|
+
|
|
30
|
+
The email passed in `user.email` matches a TPAStream admin account.
|
|
31
|
+
Use a different email; admin accounts can't double as enrollment
|
|
32
|
+
users. For local testing the `+` alias trick works
|
|
33
|
+
(`youremail+sdktest@gmail.com`).
|
|
34
|
+
|
|
35
|
+
### `There was no APIKey Provided`
|
|
36
|
+
|
|
37
|
+
`sdkToken` / `apiToken` is missing from the init object. Both are the
|
|
38
|
+
same option (apiToken wins if both are set). Get the value from
|
|
39
|
+
TPAStream support.
|
|
40
|
+
|
|
41
|
+
### `This Token is not active`
|
|
42
|
+
|
|
43
|
+
`sdkToken` is valid but hasn't been activated yet (or has been
|
|
44
|
+
deactivated). Contact TPAStream support.
|
|
45
|
+
|
|
46
|
+
### `This is not a valid version for this endpoint`
|
|
47
|
+
|
|
48
|
+
The SDK version being loaded predates a server-side change. Pinned
|
|
49
|
+
CDN versions remain available indefinitely, so this is rare; usually
|
|
50
|
+
it indicates a bundle that's older than any pinned release.
|
|
51
|
+
|
|
52
|
+
## Connect Access Token errors
|
|
53
|
+
|
|
54
|
+
### `You must have a connect access token enabled and set to use fix-credentials functionality.`
|
|
55
|
+
|
|
56
|
+
The `fixCredentials: true` init option requires a
|
|
57
|
+
`connectAccessToken`. Mint one server-side via
|
|
58
|
+
`POST /api/create-connect-token` (see
|
|
59
|
+
[Connect Access Token](./connect-access-token.md)) and pass it to
|
|
60
|
+
`StreamConnect`.
|
|
61
|
+
|
|
62
|
+
### `You must include a redirect URL in your sdk-token config to enable interoperability`
|
|
63
|
+
|
|
64
|
+
The Patient Access API flow (`enablePatientAccessAPI: true`) needs a
|
|
65
|
+
redirect URL registered with your sdkToken so the carrier knows where
|
|
66
|
+
to send the user after they authenticate. Contact TPAStream support
|
|
67
|
+
to configure this on the sdkToken.
|
|
68
|
+
|
|
69
|
+
## SSE / real-time validation errors (0.8+)
|
|
70
|
+
|
|
71
|
+
These come from the `/v3/sdk/progress/<task_id>/stream` endpoint that
|
|
72
|
+
the 0.8 SDK uses for live validation updates. They are NOT shown to
|
|
73
|
+
the user directly. The SDK transitions the validation into a
|
|
74
|
+
recoverable state (`failure` or `pending_async`) and surfaces a copy
|
|
75
|
+
in the hero element.
|
|
76
|
+
|
|
77
|
+
| HTTP status | Detail message | Meaning | Recovery |
|
|
78
|
+
|---|---|---|---|
|
|
79
|
+
| 401 | `Missing token` | The SSE URL was hit without a `?token=` query param | Shouldn't happen via the SDK; if you proxy the URL yourself, forward the token |
|
|
80
|
+
| 401 | `Task token has expired` | JWT `exp` passed (10-minute TTL after dispatch) | Re-submit the credentials to get a fresh token |
|
|
81
|
+
| 401 | `Task not available` | The Redis `progress_task_owner` pointer expired (typically same TTL as token) | Same: re-submit |
|
|
82
|
+
| 403 | `Not your task` | The JWT and Redis pointer disagree on `user_id` | Token reuse across sessions; re-init the SDK |
|
|
83
|
+
| 422 | `Task token is invalid` | Bad signature, unknown algorithm, or malformed claims | Token was tampered with or minted by a different deploy |
|
|
84
|
+
| 422 | `Task token does not match requested task` | The token's `task_id` claim doesn't match the URL path | Token reuse against the wrong task; re-submit |
|
|
85
|
+
| 422 | `Task token audience mismatch` | `aud` claim isn't `sdk:sse:progress` | Token from a different service was forwarded |
|
|
86
|
+
| 422 | `Task token missing required claim: <name>` | Mint upstream produced a token missing one of `exp` / `iat` / `task_id` / `sub` | Backend bug; report it |
|
|
87
|
+
|
|
88
|
+
On any error the SDK transitions the active validation to
|
|
89
|
+
`pending_async` (visible in the hero / corner panel) and leaves the
|
|
90
|
+
wizard usable. The user can keep adding carriers; when they return
|
|
91
|
+
later the validation's true terminal state is reflected.
|
|
92
|
+
|
|
93
|
+
## Cred-submit + validation errors
|
|
94
|
+
|
|
95
|
+
### `Could not reach the carrier. Please try again.`
|
|
96
|
+
|
|
97
|
+
Generic transient error from the cred-submit POST. Often a brief
|
|
98
|
+
backend hiccup; user retry usually clears it. Surfaced in the inline
|
|
99
|
+
form error and via `handleFormErrors` so your host page can log.
|
|
100
|
+
|
|
101
|
+
### `Connection failed` / `<carrier-specific message>`
|
|
102
|
+
|
|
103
|
+
The carrier's Patient Access API redirect returned a `FAILURE` state.
|
|
104
|
+
The carrier-specific message is forwarded verbatim from the carrier's
|
|
105
|
+
response. Common causes: user denied consent on the carrier page,
|
|
106
|
+
carrier-side auth failure, expired authorization grant.
|
|
107
|
+
|
|
108
|
+
### `This carrier's connection is misconfigured. Please contact your administrator.`
|
|
109
|
+
|
|
110
|
+
The Patient Access API redirect couldn't begin because the carrier
|
|
111
|
+
has no `interoperability_authorization_url` configured on the backend
|
|
112
|
+
payer row. Not a customer-fixable problem; needs backend payer
|
|
113
|
+
config.
|
|
114
|
+
|
|
115
|
+
### `Connection check failed. Please try again.`
|
|
116
|
+
|
|
117
|
+
The `getInteropState` polling request rejected (network / auth /
|
|
118
|
+
server error). The SDK clears the interval, surfaces this message,
|
|
119
|
+
and lets the user retry the carrier auth from the start.
|
|
120
|
+
|
|
121
|
+
### `Unknown state of interop flow`
|
|
122
|
+
|
|
123
|
+
The interop polling endpoint returned a status the SDK doesn't know
|
|
124
|
+
how to handle. Indicates a backend-frontend version skew; report it.
|
|
125
|
+
|
|
126
|
+
## Form-validation errors
|
|
127
|
+
|
|
128
|
+
### `Required`
|
|
129
|
+
|
|
130
|
+
A required field on the credentials form is empty. Comes from the
|
|
131
|
+
Zod schema generated from the carrier's `onboard_form.schema`.
|
|
132
|
+
|
|
133
|
+
### `You must agree to the terms and services.`
|
|
134
|
+
|
|
135
|
+
The "I have read and agree to the Terms of Use" checkbox wasn't
|
|
136
|
+
ticked.
|
|
137
|
+
|
|
138
|
+
### `You must acknowledge that claims will be sent to the tenant.`
|
|
139
|
+
|
|
140
|
+
The tenant acknowledgement checkbox wasn't ticked.
|
|
141
|
+
|
|
142
|
+
## See also
|
|
143
|
+
|
|
144
|
+
* [Client Usage](./client-usage.md) for the full init option contract
|
|
145
|
+
and the `handleFormErrors` / `handleInitErrors` callback signatures
|
|
146
|
+
* [SDK Flow](./sdk-flow.md) for how the wizard recovers from each
|
|
147
|
+
error class
|
|
148
|
+
* [Two-Factor Authentication](./two-factor.md) for the MFA-specific
|
|
149
|
+
error states
|
package/docs/faq.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# FAQ
|
|
2
|
+
Here we attempt to address several of the common questions which might pop-up while an implementor is working with the StreamConnect SDK
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## What is a user in the configuration block?
|
|
6
|
+
A `user` is a TPAStream concept which consolidates all of the information of a given set of participant credentials. Underneath a user:
|
|
7
|
+
there are members which have credentials, unique-keys defined by an implementor to identify the user in the system, a unique email which acts as the default identifier of the participant, and a name.
|
|
8
|
+
|
|
9
|
+
An example of a TPAStream user is an implementor's Admin Credentials for TPAStream. However, these users are configured as policy holders.
|
|
10
|
+
|
|
11
|
+
Notes for users in the configuration block:
|
|
12
|
+
* A user cannot be an Admin within the TPAStream system.
|
|
13
|
+
* A user cannot be associated with 2 different SDK Tokens.
|
|
14
|
+
* A user must have a first and last name provided.
|
|
15
|
+
* A user must have a unique email.
|
|
16
|
+
|
|
17
|
+
For more information on configuration objects see our [Client Usage Docs](client-usage.md).
|
|
18
|
+
|
|
19
|
+
## How do I make test users for the SDK (A Useful Gmail Trick)?
|
|
20
|
+
When implementing the StreamConnect SDK it can be useful to use a test user object if you do not have access to provided user credentials.
|
|
21
|
+
|
|
22
|
+
We suggest that you use an email which does not currently have an account in TPAStream, however, if you have a gmail configured to the TPAStream Admin portal you can follow this pattern to create a new unique user in TPAStream that still will receive the same emails.
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
youremail@gmail.com -> youremail+testingsdk@gmail.com
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## I'd like to use React Native
|
|
29
|
+
|
|
30
|
+
Embed the SDK in a WebView via [`react-native-webview`](https://github.com/react-native-webview/react-native-webview) and ferry callbacks to the native shell via `postMessage`. The [Quickstart](./quickstart.md#react-native) has a full walkthrough, and the [SDK Hook docs](../sdk-hook/docs/README.md#recommended-webview-pattern-for-react-native) cover Patient Access API redirects and the SDK's complete callback surface.
|
|
31
|
+
|
|
32
|
+
The older `stream-connect-sdk-hook` npm package (v0.6.2) is deprecated. Existing integrations keep working but won't receive feature updates: no SSE-driven validation, no inline 2FA, no fix-credentials status badges, no PAA support. New integrations should use the WebView pattern.
|
|
33
|
+
|
|
34
|
+
## I'd like to create a more customized flow for how a user enters credentials and validation.
|
|
35
|
+
The default recommendation for customizing the SDK flow is to use the various sdk [Callbacks](client-usage.md#callbacks).
|
|
36
|
+
|
|
37
|
+
The SDK renders various steps with default templates which should be editted post render using JS and CSS. However, if you would like
|
|
38
|
+
to create more customized widgets it is possible to turn off the default rendering using the various `renderXStep` values within the
|
|
39
|
+
configuration.
|
|
40
|
+
|
|
41
|
+
If you are to turn of the default template rendering, the callbacks associated with each of those steps will provide functions and
|
|
42
|
+
objects in their parameters which will allow an implementor to mirror all of the functionality previously defined in the default
|
|
43
|
+
template.
|
|
44
|
+
|
|
45
|
+
Each of the provided information is present in the [Callbacks](client-usage.md#callbacks) docs.
|
|
46
|
+
|
|
47
|
+
## How do I use the data from the SDK?
|
|
48
|
+
The StreamConnect SDK is designed to take in carrier credentials, save them to the TPAStream sytem, and then validate the credentials.
|
|
49
|
+
If you are implementing the whole Stream Connect flow, including interfacing with the TPAStream API and using TPAStream webhooks, you will find the [doneEasyEnroll](client-usage.md#doneeasyenroll) callback to hold the main pieces of information you need.
|
|
50
|
+
|
|
51
|
+
There we define specifically a `policyHolder` which can be thought of as the carrier credentials that were just submitted.
|
|
52
|
+
This `policyHolder` will have:
|
|
53
|
+
* An `policy_holder_id` which is its unique identifier in TPAStream
|
|
54
|
+
* A `login_problem` which will define the state of the credentials. See [doneEasyEnroll](client-usage.md#doneeasyenroll)
|
|
55
|
+
* And a `payer_id` all of which can be useful when implementing the TPAStream Webhooks.
|
|
56
|
+
|
|
57
|
+
For implementing the TPAStream webhooks to get information on when a new claim is added to TPAStream or when the first crawl of the credentials is completed see our [Webhook Docs](https://developers.tpastream.com/en/latest/connect.html#webhooks)
|
|
58
|
+
|
|
59
|
+
## What is the tenant configuration block?
|
|
60
|
+
Within the TPAStream configuration examples as well as the [Client Usage Docs](client-usage.md) you might sometimes see
|
|
61
|
+
a `tenant` block defined within it. This specific configuraiton option is determined when your `sdkToken` is created.
|
|
62
|
+
|
|
63
|
+
This can almost always be left blank, unless you are an entity which is managing multiple different tenants within TPAStream.
|
|
64
|
+
If the latter is the case you will have been informed when your token was created.
|
|
65
|
+
|
|
66
|
+
## What is "vendor" within the various configuration blocks?
|
|
67
|
+
When configuring the SDK a user will see "`vendor`" within the configuration block of the `employer` object. This `vendor` value
|
|
68
|
+
will almost always be set to the value `"internal"`.
|
|
69
|
+
|
|
70
|
+
A Vendor in TPA Stream indicates which System of Record an identifier belongs to. If the identifier is the unique database ID from your
|
|
71
|
+
own in-house system, simply refer to it as "internal"
|
|
72
|
+
|
|
73
|
+
## I have a unique key for my participants, how can I associate those in TPAStream?
|
|
74
|
+
Using the `user` configuration object you can define `memberSystemKey`. This system key will be defined under the same vendor as the
|
|
75
|
+
employer block, since a member can only exist under 1 employer.
|
|
76
|
+
|
|
77
|
+
See our [Client Usage Docs](client-usage.md) for more information on the `user` object block.
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Fix Credentials
|
|
2
|
+
|
|
3
|
+
The fix-credentials view lets a returning user see and act on every
|
|
4
|
+
carrier they've connected: reconnect a broken login, finish a 2FA
|
|
5
|
+
challenge, or add a new carrier. The SDK enters this mode
|
|
6
|
+
automatically when a [Connect Access Token](./connect-access-token.md)
|
|
7
|
+
is supplied at init; no separate flag is required.
|
|
8
|
+
|
|
9
|
+
## Init options
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
StreamConnect({
|
|
13
|
+
el: '#react-hook',
|
|
14
|
+
apiToken: 'your-sdk-token',
|
|
15
|
+
connectAccessToken: '<minted server-side, see connect-access-token.md>',
|
|
16
|
+
// ... rest of init
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
* `connectAccessToken` (string) - presence of this token is the
|
|
21
|
+
signal for member-portal mode. See
|
|
22
|
+
[Connect Access Token](./connect-access-token.md) for how it's
|
|
23
|
+
minted and rotated.
|
|
24
|
+
|
|
25
|
+
> **Deprecated:** a `fixCredentials: true` init option used to opt
|
|
26
|
+
> into this view. It is no longer needed in 0.8 and is ignored
|
|
27
|
+
> (passing it logs a one-time console deprecation warning); behavior
|
|
28
|
+
> is now driven entirely by `connectAccessToken` presence, which was
|
|
29
|
+
> already a hard requirement.
|
|
30
|
+
|
|
31
|
+
## What the user sees
|
|
32
|
+
|
|
33
|
+
When a returning user opens the SDK in fix-credentials mode, the
|
|
34
|
+
first screen offers two paths: add a new carrier, or manage existing
|
|
35
|
+
ones.
|
|
36
|
+
|
|
37
|
+

|
|
38
|
+
|
|
39
|
+
The fix-credentials view lists every policy-holder the user has
|
|
40
|
+
connected. Each carrier renders as a tile with:
|
|
41
|
+
|
|
42
|
+
* The carrier logo and name
|
|
43
|
+
* A status badge (described below)
|
|
44
|
+
* "Last synced N min/hr/day ago" when there's a recent successful crawl
|
|
45
|
+
|
|
46
|
+
### Status badges
|
|
47
|
+
|
|
48
|
+
Each tile shows a status badge driven by the PH's `login_problem` and
|
|
49
|
+
the recency of the last successful crawl. The label space is two
|
|
50
|
+
coarse fallbacks plus a per-problem set:
|
|
51
|
+
|
|
52
|
+
| Badge text | When it fires |
|
|
53
|
+
|---|---|
|
|
54
|
+
| **Connected** | Severity is `ok`. That covers two cases: (a) `login_problem` is null, regardless of last-sync recency, and (b) `login_problem` is a warning-class value but a successful sync landed in the last 7 days, which downgrades the warning visually. See `severityFor` for the exact rule. |
|
|
55
|
+
| **Validating now** | A validation task is in flight against this PH. The tile pulses; the floating hero (top of the page) shows live progress. |
|
|
56
|
+
| **Action needed** | Severity is `warning` or `critical` but `login_problem` is null (we know something needs attention but the carrier didn't tell us what). |
|
|
57
|
+
| *Per-problem text* | Severity is `warning` or `critical` and `login_problem` is set. The badge uses the human label from `LOGIN_PROBLEM_LABELS` (e.g. `Invalid password`, `Locked account`, `Needs 2FA`, `Security question`) so the user knows what to fix before clicking. |
|
|
58
|
+
|
|
59
|
+
Severity classes (canonical sets in
|
|
60
|
+
[`assets/sdk/types.ts`](../assets/sdk/types.ts) `CRITICAL_LOGIN_PROBLEMS`
|
|
61
|
+
and `WARNING_LOGIN_PROBLEMS`):
|
|
62
|
+
|
|
63
|
+
- **`ok`**: no `login_problem`, OR a warning-class problem with a
|
|
64
|
+
successful sync in the last 7 days (the recent claim flow downgrades
|
|
65
|
+
the warning visually).
|
|
66
|
+
- **`warning`**: `login_problem` in `{incomplete, needs_two_factor,
|
|
67
|
+
sec_question, wrong_secondary, mfa_carrier, migrating}`. The carrier
|
|
68
|
+
is reachable, the user just has an outstanding action item.
|
|
69
|
+
- **`critical`**: `login_problem` in `{invalid, invalid_username_format,
|
|
70
|
+
locked, broken, invalid_interop_token}`. The carrier is unreachable
|
|
71
|
+
until the user reconnects.
|
|
72
|
+
|
|
73
|
+
The label and severity logic live in
|
|
74
|
+
[`assets/sdk/components/PayerImages.tsx`](../assets/sdk/components/PayerImages.tsx)
|
|
75
|
+
(`labelFor` / `severityFor` / `LOGIN_PROBLEM_LABELS`). Severity maps
|
|
76
|
+
to badge color via the `tpa-` theme tokens, so a customer-supplied
|
|
77
|
+
[`theme.primaryColor`](./theme.md) doesn't recolor the semantic
|
|
78
|
+
status states.
|
|
79
|
+
|
|
80
|
+
### Sort order
|
|
81
|
+
|
|
82
|
+
Tiles are sorted top-to-bottom by:
|
|
83
|
+
|
|
84
|
+
1. In-flight validations (the carrier the user just submitted)
|
|
85
|
+
2. Critical-broken PHs (Reconnect)
|
|
86
|
+
3. Warning PHs (Action needed)
|
|
87
|
+
4. Healthy PHs, most-recently-synced first
|
|
88
|
+
|
|
89
|
+
This puts the carriers that need attention at the top, with the
|
|
90
|
+
just-submitted one always visually pinned next to the hero.
|
|
91
|
+
|
|
92
|
+
### "Recently added" section
|
|
93
|
+
|
|
94
|
+
PHs created in the last 7 days are grouped into a "Recently added"
|
|
95
|
+
section above the main list, so the user can see what they just
|
|
96
|
+
connected without scrolling. The remaining carriers render under
|
|
97
|
+
"Your other carriers" (or "Your carriers" if there's no recent
|
|
98
|
+
section).
|
|
99
|
+
|
|
100
|
+
## Empty state
|
|
101
|
+
|
|
102
|
+
A user with no connected carriers sees:
|
|
103
|
+
|
|
104
|
+
> You haven't connected any carriers yet.
|
|
105
|
+
|
|
106
|
+
with a single "Your carriers" heading. Selecting a carrier from
|
|
107
|
+
choose-payer is still reachable via the "Add a new carrier" entry
|
|
108
|
+
point.
|
|
109
|
+
|
|
110
|
+
## Reconnecting a carrier
|
|
111
|
+
|
|
112
|
+
Clicking any tile with **Reconnect** or **Action needed** lands the
|
|
113
|
+
user on the credentials form for that carrier, pre-filled with the
|
|
114
|
+
username on file. The submit returns the user back to the
|
|
115
|
+
fix-credentials list with the new validation in flight (visible in
|
|
116
|
+
the hero + on the tile as "Validating now").
|
|
117
|
+
|
|
118
|
+
The wizard does NOT take over the screen during validation; multiple
|
|
119
|
+
validations can run in parallel and the user can keep navigating.
|
|
120
|
+
|
|
121
|
+
## Adding a new carrier from fix-credentials
|
|
122
|
+
|
|
123
|
+
Users in member-portal mode see an "Add a new carrier" entry
|
|
124
|
+
that drops them into the standard choose-payer flow (step 3). Submit
|
|
125
|
+
returns them to the choose-payer picker (step 3), NOT the
|
|
126
|
+
fix-credentials list, so they can chain another "Add a new carrier"
|
|
127
|
+
without an extra back-button trip. The freshly-added carrier shows up
|
|
128
|
+
in the picker's "already connected" markers via the user-refresh that
|
|
129
|
+
follows the submit.
|
|
130
|
+
|
|
131
|
+
To get back to the fix-credentials list itself the user uses the back
|
|
132
|
+
button or navigates back from choose-payer.
|
|
133
|
+
|
|
134
|
+
(Implementation note: the return-step logic at
|
|
135
|
+
[SDK.tsx](../assets/sdk/components/SDK.tsx) `returnStep` uses
|
|
136
|
+
`state.policyHolderId` to distinguish "reconnect existing" (PH set →
|
|
137
|
+
return to step 2, the fix-credentials list) from "add new" (PH null
|
|
138
|
+
→ return to step 3, the picker).)
|
|
139
|
+
|
|
140
|
+
## Hooks for custom rendering
|
|
141
|
+
|
|
142
|
+
* `doneFixCredentials` - fires once per render of the fix-credentials
|
|
143
|
+
view, after data loads. Useful for analytics or applying custom
|
|
144
|
+
styling.
|
|
145
|
+
* `doneSelectEnrollProcess` - fires when the legacy "Reconnect or Add
|
|
146
|
+
new" select screen renders. The 0.8 view collapses that selection
|
|
147
|
+
into the carrier-tile list, so this fires once at mount and is
|
|
148
|
+
primarily kept for back-compat.
|
|
149
|
+
|
|
150
|
+
## See also
|
|
151
|
+
|
|
152
|
+
* [Theme](./theme.md) for branding the SDK shell (the status badges
|
|
153
|
+
use semantic colors that aren't affected by `theme.primaryColor`)
|
|
154
|
+
* [Connect Access Token](./connect-access-token.md) for the security
|
|
155
|
+
setup member-portal mode requires
|
|
156
|
+
* [SDK Flow](./sdk-flow.md) for the broader step machine the
|
|
157
|
+
fix-credentials view plugs into
|
|
Binary file
|