stream-connect-sdk 0.8.6 → 0.8.8

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 CHANGED
@@ -4,6 +4,120 @@ All notable changes to the `stream-connect-sdk` npm package. The
4
4
  companion React Native hook (`stream-connect-sdk-hook`) is on its own
5
5
  release line; see [`sdk-hook/docs/README.md`](./sdk-hook/docs/README.md).
6
6
 
7
+ ## 0.8.8
8
+
9
+ ### A connect access token in the URL fragment
10
+
11
+ The SDK now also reads `accessToken` from the URL fragment
12
+ (`#accessToken=...`) and strips it with `history.replaceState`,
13
+ keeping the rest of the fragment, hash routes included. A fragment is
14
+ never sent to the host's web server, so it stays out of access logs.
15
+ The query-string form (`?accessToken=...`) still works and is still
16
+ stripped; when both are present the fragment wins.
17
+
18
+ The docs no longer say that `app.tpastream.com` adds `?accessToken=`
19
+ to the Patient Access API return URL. It does not. The session
20
+ continues on the `connectAccessToken` your page passes at init.
21
+
22
+ ### The credential submit sends the member email, not the user object
23
+
24
+ The add-carrier and fix-carrier submits (`POST` and `PUT
25
+ policy_holder_sdk/policy_holder`) sent `user`, the whole user object
26
+ with every policy holder on the member, although the server reads only
27
+ its email. They now send `user_email` in its place. The server already
28
+ accepts `user_email`, and the two-factor calls already send it. The
29
+ body no longer grows with the member's policy holders: with two
30
+ carriers it drops from about 2.2 KB to about 250 bytes.
31
+
32
+ No `init()` or callback change. `employer_id` and the credential
33
+ fields are sent as before.
34
+
35
+ ## 0.8.7
36
+
37
+ ### axios removed
38
+
39
+ The SDK no longer depends on axios. Its requests now go through a
40
+ small built-in client (`assets/sdk/services/http.ts`) that wraps the
41
+ browser's `fetch`. axios brought about 26 transitive packages
42
+ (`form-data`, `follow-redirects` and others) and was the source of
43
+ nearly every advisory against the shipped bundle. The runtime
44
+ dependency tree drops from 57 packages to 30, and
45
+ `npm audit --omit=dev` still reports 0 vulnerabilities.
46
+
47
+ What is unchanged on the wire:
48
+
49
+ * Every header name: `X-TPAStream-Token`, `X-SDK-Version`,
50
+ `X-SDK-State-Id`, `X-Is-Demo`, `X-Connect-Access-Token`,
51
+ `X-Tenant-Label`, `X-Tenant-Key`, the per-request `X-SDK-Page-Path`,
52
+ and axios's `Accept: application/json, text/plain, */*`. The values
53
+ are unchanged too, with one exception: after a token refresh,
54
+ `X-Connect-Access-Token` carries the new token on every later
55
+ request (see the fix below).
56
+ * URLs and query strings. Parameters are encoded exactly as axios
57
+ 1.20.0 encoded them, and `undefined` or `null` parameters are left
58
+ out, as before.
59
+ * JSON bodies with `Content-Type: application/json`, and no body on
60
+ GET.
61
+ * No timeout, and cookies only on same-origin requests (axios's
62
+ `withCredentials: false` is fetch's `credentials: 'same-origin'`).
63
+ * The expired-token flow: one shared refresh, one replay, no loop,
64
+ and one `onConnectAccessTokenExpired` notification per expiry
65
+ cycle.
66
+
67
+ What an integrator can observe on the error object passed to
68
+ `handleFormErrors` (and to `doneGetSDK` when the first request fails):
69
+
70
+ * Unchanged: `message` (for example "Request failed with status code
71
+ 422", or "Network Error" when the server could not be reached),
72
+ `code` (`ERR_BAD_REQUEST`, `ERR_BAD_RESPONSE`, `ERR_NETWORK`),
73
+ `status`, `isAxiosError` (still `true`), `toJSON()`,
74
+ `response.status`, `response.statusText`, `response.data`, and
75
+ `response.headers` (a plain object with lower-cased names). A
76
+ network failure still has no `response`.
77
+ * Changed: `error.name` is `SdkHttpError` instead of `AxiosError`.
78
+ * Changed: `error.request` (and the `request` in `handleFormErrors`'
79
+ second argument) is a plain `{ method, url }` object instead of the
80
+ browser's `XMLHttpRequest`. It is still present for every request
81
+ that was sent.
82
+ * Changed: `error.config` keeps `method`, `url`, `baseURL`, `params`,
83
+ `headers` and `data` (the JSON string sent), but `headers` is a
84
+ plain object instead of an `AxiosHeaders` instance, and axios-only
85
+ fields such as `timeout`, `adapter` and `transformRequest` are gone.
86
+ * `error instanceof AxiosError` was already `false` for integrators,
87
+ because the SDK bundled its own copy of axios.
88
+
89
+ ### Fix: a refreshed connect token is used by later requests
90
+
91
+ When `connectAccessTokenRefreshFn` returned a new token, axios stored
92
+ it in a default header that the `connectAccessToken` passed to
93
+ `init()` overrode. Only the replayed request carried the new token,
94
+ and every later request went out with the original one. On a
95
+ long-lived page that meant a refresh on almost every request after
96
+ the first expiry. Later requests now carry the new token, as the
97
+ [connect token guide](./docs/connect-access-token.md) describes.
98
+
99
+ The server's `X-Set-Connect-Access-Token` response header is not part
100
+ of this fix for embedded widgets. The API does not expose that header
101
+ to other origins, so a cross-origin embed cannot read it, under 0.8.6
102
+ or 0.8.7. Only a page on the API's own origin can.
103
+
104
+ ### The fallback state id no longer uses `Math.random()`
105
+
106
+ The `X-SDK-State-Id` value comes from `crypto.randomUUID()`. Where
107
+ that is missing, the SDK now uses `crypto.getRandomValues()` instead
108
+ of `Math.random()`. Browsers on HTTPS pages are unaffected, because
109
+ they already took the `randomUUID` path.
110
+
111
+ ### Fix: no second refresh for a slow request
112
+
113
+ A request sent with the old token could come back expired after
114
+ another request's refresh had already finished. The SDK then called
115
+ `connectAccessTokenRefreshFn` a second time, minting a token that was
116
+ not needed. It now retries that request once with the token it
117
+ already holds. The other guarantees are unchanged: at most one retry
118
+ per request, no loop, one `onConnectAccessTokenExpired` notification
119
+ per expiry cycle, and parallel requests still share one refresh.
120
+
7
121
  ## 0.8.6
8
122
 
9
123
  ### Security: axios and dompurify upgraded
package/README.md CHANGED
@@ -4,6 +4,16 @@
4
4
 
5
5
  ## Version
6
6
 
7
+ ### 0.8.8
8
+
9
+ The credential submit (add or fix a carrier) now sends the member's email as `user_email` instead of the whole user object, so the request no longer grows with each carrier the member has. No API change: the server already reads `user_email`.
10
+
11
+ The SDK also reads a connect access token from the URL fragment (`#accessToken=...`) and strips it from the address bar. A fragment never reaches the host's web server, so the token stays out of its access logs. The query-string form still works.
12
+
13
+ ### 0.8.7
14
+
15
+ Dependency release: axios is removed. The SDK now sends its requests with the browser's built-in `fetch`, which takes about 26 packages out of the SDK's runtime dependency tree. The requests, headers and query strings on the wire are unchanged. Errors passed to `handleFormErrors` and `doneGetSDK` keep `response.status`, `response.data`, `message`, `code` and `config`; see the [CHANGELOG](./CHANGELOG.md) for the few fields that changed. Fix: after a connect token refresh, later requests now carry the new token instead of the original one.
16
+
7
17
  ### 0.8.6
8
18
 
9
19
  Security release: axios is upgraded to 1.20.0 and DOMPurify to 3.4.17, and the zod dependency is removed, clearing every `npm audit --omit=dev` advisory against the SDK's runtime dependencies. No API or wire-format change. The `X-SDK-Page-Path` header is now read on each request instead of once at mount. The carrier credential form no longer invites the browser to fill in the login saved for the host site. Fix: a member who resubmits the same credentials while that validation is still running keeps the 2FA method picker or code prompt instead of sticking on "Connecting…" until a reload.
@@ -41,6 +51,42 @@ This SDK embeds the [EasyEnrollment platform](https://www.easyenrollment.net) in
41
51
  Latest highlights below. The full per-version changelog lives in
42
52
  [CHANGELOG.md](./CHANGELOG.md).
43
53
 
54
+ ### 0.8.8 highlights
55
+
56
+ * The credential submit (`POST` and `PUT policy_holder_sdk/policy_holder`)
57
+ sends `user_email` in place of the `user` object. The body no longer
58
+ carries every policy holder on the member, so it stays at a few
59
+ hundred bytes.
60
+ * No `init()` or callback change. The server already reads
61
+ `user_email`, and the two-factor calls already send it.
62
+ * A connect access token in the URL fragment (`#accessToken=...`) is
63
+ read and stripped, like the `?accessToken=...` query form. When both
64
+ are present, the fragment wins.
65
+
66
+ ### 0.8.7 highlights
67
+
68
+ * axios is removed. The SDK's HTTP client is now a small wrapper
69
+ around the browser's `fetch`, and the runtime dependency tree
70
+ shrinks from 57 packages to 30. `npm audit --omit=dev` still
71
+ reports no advisories.
72
+ * The requests the SDK sends are unchanged: same URLs, query strings,
73
+ headers and JSON bodies, no timeout, and cookies only on same-origin
74
+ requests, as before.
75
+ * Errors handed to `handleFormErrors` and `doneGetSDK` keep the fields
76
+ integrators read (`response.status`, `response.data`,
77
+ `response.headers`, `message`, `code`, `config`, `request`). The
78
+ error's `name` is now `SdkHttpError` instead of `AxiosError`, and
79
+ `request` is a small `{ method, url }` object instead of an
80
+ `XMLHttpRequest`. The full list is in the CHANGELOG.
81
+ * Fix: after `connectAccessTokenRefreshFn` returns a new connect
82
+ token, every later request now uses it. Before, when a
83
+ `connectAccessToken` was passed to `init()`, only the retried
84
+ request carried the new token, and later requests went out with the
85
+ original one.
86
+ * A slow request that comes back expired after another request's
87
+ refresh has finished is retried with the new token, instead of
88
+ calling `connectAccessTokenRefreshFn` a second time.
89
+
44
90
  ### 0.8.6 highlights
45
91
 
46
92
  * Fix: a member who submits the same credentials again while that
@@ -11,7 +11,7 @@ Mount the SDK by calling `StreamConnect({...})` with your config. The minimum yo
11
11
  ### Via CDN (vanilla HTML, server-rendered, Backbone, jQuery)
12
12
 
13
13
  ```html
14
- <script src="https://app.tpastream.com/static/js/sdk-v-0.8.6.js"></script>
14
+ <script src="https://app.tpastream.com/static/js/sdk-v-0.8.7.js"></script>
15
15
  <div id="sdk-hook"></div>
16
16
  <script>
17
17
  window.StreamConnect({
@@ -29,7 +29,8 @@ Mount the SDK by calling `StreamConnect({...})` with your config. The minimum yo
29
29
 
30
30
  These CDN forms are supported:
31
31
 
32
- * `sdk-v-0.8.6.js` (current 0.8.x, pinned)
32
+ * `sdk-v-0.8.7.js` (current 0.8.x, pinned)
33
+ * `sdk-v-0.8.6.js` (0.8.6, pinned)
33
34
  * `sdk-v-0.8.5.js` (0.8.5, pinned)
34
35
  * `sdk-v-0.8.4.js` (0.8.4, pinned)
35
36
  * `sdk-v-0.8.3.js` (0.8.3, pinned)
@@ -39,7 +40,7 @@ These CDN forms are supported:
39
40
  * `sdk-v-0.7.7.js` (last 0.7.x, pinned)
40
41
  * `sdk.js` (floating pointer to the latest release; updates automatically when a new version ships)
41
42
 
42
- If you pin, note that you do not pick up fixes automatically. 0.8.3 fixes a bug that made Medical Mutual and SimplePay Health impossible to connect, so pinned integrations on 0.8.0–0.8.2 should move up. 0.8.6 fixes the two-factor prompt disappearing when a member resubmits their credentials while the validation is still running, so pinned integrations on 0.8.0–0.8.5 should move up to 0.8.6.
43
+ If you pin, note that you do not pick up fixes automatically. 0.8.3 fixes a bug that made Medical Mutual and SimplePay Health impossible to connect, so pinned integrations on 0.8.0–0.8.2 should move up. 0.8.6 fixes the two-factor prompt disappearing when a member resubmits their credentials while the validation is still running, so pinned integrations on 0.8.0–0.8.5 should move up to 0.8.6 or later. 0.8.7 also stops a refreshed connect access token from being dropped after the first retried request.
43
44
 
44
45
  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.
45
46
 
@@ -146,7 +147,7 @@ A first-class React package with `peerDependencies` on `react` (no second React
146
147
  | `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` |
147
148
  | `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` |
148
149
  | `includePayerBlogs` | Enable optional payer-updates blog on each enrollment form. Shows additional info about the carrier. | Boolean | `false` |
149
- | `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 |
150
+ | `connectAccessToken` | Required if [Connect Access Token](./connect-access-token.md) advanced security is enabled. An `accessToken` on the page URL (fragment or query string), if present, overrides this option for that load and is stripped from the URL via `history.replaceState`; `app.tpastream.com` does not add one. See [Redirect query parameters](#redirect-query-parameters-patient-access-api). | String | unset |
150
151
  | `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 |
151
152
  | `renderChoosePayer` | Render the built-in choose-payer widget. If `false`, you drive payer selection from the `doneChoosePayer` callback. | Boolean | `true` |
152
153
  | `renderPayerForm` | Render the built-in credentials form. If `false`, drive it from `doneCreatedForm`. | Boolean | `true` |
@@ -198,12 +199,12 @@ Don't set these in production code.
198
199
 
199
200
  ## Redirect query parameters (Patient Access API)
200
201
 
201
- 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:
202
+ When the Patient Access API flow returns the user from a carrier site back to the page hosting the SDK, the SDK reads these parameters automatically on init:
202
203
 
203
- * **`?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.
204
+ * **`accessToken`**: `app.tpastream.com` does not put a connect access token on the return URL. The session continues on the `connectAccessToken` your page passed at init and the rolling `X-Set-Connect-Access-Token` header. If a URL does carry one, in the fragment (`#accessToken=...`, from 0.8.8) or the query string (`?accessToken=...`), the SDK uses it in place of `connectAccessToken` and strips it. The fragment wins when both are present.
204
205
  * **`?forceTPAStreamSdkEnd=1`**: set by the redirect URL the SDK constructs when `enablePatientAccessAPISinglePage` is `true`. Flags the OAuth return. As of 0.8.2 the SDK surfaces a self-dismissing "Connected" toast in the floating panel and lands the member on the carrier picker so they can add another carrier — it no longer forces the full-page end widget. (With `realTimeVerification: false` there's no panel, so it falls back to the end widget.) The explicit `forceEndStep` init option below is unaffected.
205
206
 
206
- 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.
207
+ 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 an access token cannot leak via history navigation or browser autofill.
207
208
 
208
209
  > **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).
209
210
 
@@ -178,22 +178,27 @@ hook is that the member loses any in-progress credential entry.
178
178
 
179
179
  ## Mid-session token refresh (Patient Access API redirect)
180
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.
181
+ `app.tpastream.com` does not put a connect access token on the URL
182
+ it returns the member to after a Patient Access API sign-in. A token
183
+ in a URL reaches the host's web server logs and any script that reads
184
+ the address, so the session continues on the `connectAccessToken`
185
+ your page passes at init, renewed by the rolling
186
+ `X-Set-Connect-Access-Token` header. The return is an ordinary load
187
+ of your page, so it gets the `connectAccessToken` your page passes on
188
+ every load.
189
+
190
+ The SDK still accepts a token on the URL, for integrations that put
191
+ one there themselves: `#accessToken=...` in the fragment (from 0.8.8;
192
+ a fragment is never sent to your web server) or `?accessToken=...` in
193
+ the query string. It uses that token in place of `connectAccessToken`
194
+ and strips it from the URL via `history.replaceState`.
188
195
 
189
196
  Note: `replaceState` runs after the SDK script loads, so any
190
197
  resources or third-party scripts loaded by the host page *before*
191
198
  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.
199
+ that fires its own requests) can still see a token-bearing URL. If
200
+ you put a token on the URL yourself, use the fragment, and load
201
+ anything that reads the address after the SDK script tag.
197
202
 
198
203
  See [Client Usage > Redirect query
199
204
  parameters](./client-usage.md#redirect-query-parameters-patient-access-api)
package/docs/interop.md CHANGED
@@ -23,7 +23,7 @@ The legacy alias `enableInteropSinglePage` is also still accepted with the same
23
23
 
24
24
  After the carrier redirect completes, the SDK reads two URL parameters automatically on load:
25
25
 
26
- * `?accessToken=...`: a fresh connect-access token minted by `app.tpastream.com`.
26
+ * `accessToken`: `app.tpastream.com` does not add one. If a return URL carries one, in the fragment (`#accessToken=...`, from 0.8.8) or the query string, the SDK uses it in place of `connectAccessToken`.
27
27
  * `?forceTPAStreamSdkEnd=1`: set in the single-page variant to flag the OAuth return. As of 0.8.2 the SDK shows a self-dismissing "Connected" toast in the floating panel and returns the member to the carrier picker (so they can add another carrier) rather than the full-page end widget. When `realTimeVerification: false` (no panel), it falls back to the end widget. The explicit `forceEndStep` init option is unaffected and still routes to the end widget.
28
28
 
29
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.
@@ -31,8 +31,7 @@ Both are stripped from the URL via `history.replaceState` so they cannot leak vi
31
31
  ## See also
32
32
 
33
33
  * [Connect Access Token](./connect-access-token.md): how the
34
- `?accessToken=` minting fits into the broader connect-token security
35
- model
34
+ connect access token reaches the session after a carrier return
36
35
  * [Fix Credentials](./fix-credentials.md): Patient Access API carriers
37
36
  show up in the same fix-credentials list with the same status badges
38
37
  as inline-credential carriers
@@ -19,7 +19,7 @@ Here is what the test htmlscript looks like.
19
19
  ```
20
20
 
21
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.6.js"></script>`. Pinned versions remain available indefinitely.
22
+ `<script src="https://app.tpastream.com/static/js/sdk-v-0.8.7.js"></script>`. Pinned versions remain available indefinitely.
23
23
 
24
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
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stream-connect-sdk",
3
- "version": "0.8.6",
3
+ "version": "0.8.8",
4
4
  "description": "A JavaScript SDK implementing TPAStream's Connect Platform",
5
5
  "scripts": {
6
6
  "build": "webpack --config webpack.prod-sdk.js --mode=production",
@@ -42,7 +42,6 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@headlessui/react": "^2.2.0",
45
- "axios": "^1.20.0",
46
45
  "dompurify": "^3.4.17",
47
46
  "marked": "^15.0.7",
48
47
  "react": "^19.0.0",