stream-connect-sdk 0.8.5 → 0.8.7

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,170 @@ 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.7
8
+
9
+ ### axios removed
10
+
11
+ The SDK no longer depends on axios. Its requests now go through a
12
+ small built-in client (`assets/sdk/services/http.ts`) that wraps the
13
+ browser's `fetch`. axios brought about 26 transitive packages
14
+ (`form-data`, `follow-redirects` and others) and was the source of
15
+ nearly every advisory against the shipped bundle. The runtime
16
+ dependency tree drops from 57 packages to 30, and
17
+ `npm audit --omit=dev` still reports 0 vulnerabilities.
18
+
19
+ What is unchanged on the wire:
20
+
21
+ * Every header name: `X-TPAStream-Token`, `X-SDK-Version`,
22
+ `X-SDK-State-Id`, `X-Is-Demo`, `X-Connect-Access-Token`,
23
+ `X-Tenant-Label`, `X-Tenant-Key`, the per-request `X-SDK-Page-Path`,
24
+ and axios's `Accept: application/json, text/plain, */*`. The values
25
+ are unchanged too, with one exception: after a token refresh,
26
+ `X-Connect-Access-Token` carries the new token on every later
27
+ request (see the fix below).
28
+ * URLs and query strings. Parameters are encoded exactly as axios
29
+ 1.20.0 encoded them, and `undefined` or `null` parameters are left
30
+ out, as before.
31
+ * JSON bodies with `Content-Type: application/json`, and no body on
32
+ GET.
33
+ * No timeout, and cookies only on same-origin requests (axios's
34
+ `withCredentials: false` is fetch's `credentials: 'same-origin'`).
35
+ * The expired-token flow: one shared refresh, one replay, no loop,
36
+ and one `onConnectAccessTokenExpired` notification per expiry
37
+ cycle.
38
+
39
+ What an integrator can observe on the error object passed to
40
+ `handleFormErrors` (and to `doneGetSDK` when the first request fails):
41
+
42
+ * Unchanged: `message` (for example "Request failed with status code
43
+ 422", or "Network Error" when the server could not be reached),
44
+ `code` (`ERR_BAD_REQUEST`, `ERR_BAD_RESPONSE`, `ERR_NETWORK`),
45
+ `status`, `isAxiosError` (still `true`), `toJSON()`,
46
+ `response.status`, `response.statusText`, `response.data`, and
47
+ `response.headers` (a plain object with lower-cased names). A
48
+ network failure still has no `response`.
49
+ * Changed: `error.name` is `SdkHttpError` instead of `AxiosError`.
50
+ * Changed: `error.request` (and the `request` in `handleFormErrors`'
51
+ second argument) is a plain `{ method, url }` object instead of the
52
+ browser's `XMLHttpRequest`. It is still present for every request
53
+ that was sent.
54
+ * Changed: `error.config` keeps `method`, `url`, `baseURL`, `params`,
55
+ `headers` and `data` (the JSON string sent), but `headers` is a
56
+ plain object instead of an `AxiosHeaders` instance, and axios-only
57
+ fields such as `timeout`, `adapter` and `transformRequest` are gone.
58
+ * `error instanceof AxiosError` was already `false` for integrators,
59
+ because the SDK bundled its own copy of axios.
60
+
61
+ ### Fix: a refreshed connect token is used by later requests
62
+
63
+ When `connectAccessTokenRefreshFn` returned a new token, axios stored
64
+ it in a default header that the `connectAccessToken` passed to
65
+ `init()` overrode. Only the replayed request carried the new token,
66
+ and every later request went out with the original one. On a
67
+ long-lived page that meant a refresh on almost every request after
68
+ the first expiry. Later requests now carry the new token, as the
69
+ [connect token guide](./docs/connect-access-token.md) describes.
70
+
71
+ The server's `X-Set-Connect-Access-Token` response header is not part
72
+ of this fix for embedded widgets. The API does not expose that header
73
+ to other origins, so a cross-origin embed cannot read it, under 0.8.6
74
+ or 0.8.7. Only a page on the API's own origin can.
75
+
76
+ ### The fallback state id no longer uses `Math.random()`
77
+
78
+ The `X-SDK-State-Id` value comes from `crypto.randomUUID()`. Where
79
+ that is missing, the SDK now uses `crypto.getRandomValues()` instead
80
+ of `Math.random()`. Browsers on HTTPS pages are unaffected, because
81
+ they already took the `randomUUID` path.
82
+
83
+ ### Fix: no second refresh for a slow request
84
+
85
+ A request sent with the old token could come back expired after
86
+ another request's refresh had already finished. The SDK then called
87
+ `connectAccessTokenRefreshFn` a second time, minting a token that was
88
+ not needed. It now retries that request once with the token it
89
+ already holds. The other guarantees are unchanged: at most one retry
90
+ per request, no loop, one `onConnectAccessTokenExpired` notification
91
+ per expiry cycle, and parallel requests still share one refresh.
92
+
93
+ ## 0.8.6
94
+
95
+ ### Security: axios and dompurify upgraded
96
+
97
+ The SDK's two runtime dependencies with published advisories move to
98
+ their first patched versions:
99
+
100
+ * **axios** 1.16.1 -> 1.20.0 (and its `form-data` dependency 4.0.5 ->
101
+ 4.0.6). Closes the axios advisories affecting 1.0.0 - 1.19.0 and
102
+ GHSA-hmw2-7cc7-3qxx in `form-data`.
103
+ * **dompurify** 3.4.3 -> 3.4.17. Closes the advisories affecting
104
+ <= 3.4.15. DOMPurify sanitizes the Terms of Use modal and the payer
105
+ info articles before they render.
106
+
107
+ The package.json floors are now `axios ^1.20.0` and `dompurify
108
+ ^3.4.17`, so a host app that installs `stream-connect-sdk` no longer
109
+ pulls vulnerable nested copies into its own lockfile. The query
110
+ strings the SDK sends are unchanged: every query parameter is a flat
111
+ string or number, and axios 1.16.1 and 1.20.0 encode them
112
+ byte-for-byte the same.
113
+
114
+ ### Security: zod removed
115
+
116
+ `npm audit --omit=dev` reported a high advisory against zod 3.25.76
117
+ (GHSA-mrhx-c7xc-m3w5) whose only fix is zod 4. zod validated one
118
+ small form, the carrier credential form, so it is removed along with
119
+ `@hookform/resolvers` instead of being carried to a new major
120
+ version. A small built-in React Hook Form resolver
121
+ (`credentialsResolver.ts`) now applies the same rules: required and
122
+ optional text, password, date and select fields, boolean and numeric
123
+ fields, and the two consent checkboxes. Every error message the
124
+ member can see is unchanged. With zod gone, `npm audit --omit=dev`
125
+ reports 0 vulnerabilities. A plain `npm audit fix` also cleared the
126
+ build-time advisories in `@babel/core` and `postcss-selector-parser`,
127
+ so the full `npm audit` reports 0 as well.
128
+
129
+ ### Saved host-site logins are no longer offered on the carrier form
130
+
131
+ The SDK runs inside the customer's page, so the browser's password
132
+ manager treated the carrier form as a login for the customer's own
133
+ site. A customer reported a member's saved login for their site being
134
+ filled into the carrier username and password fields. The password
135
+ field asked for `autocomplete="current-password"` and the username
136
+ field for `autocomplete="username"`. Both, and every other text field
137
+ on the form, now render `autocomplete="off"` plus the opt-out
138
+ attributes 1Password, LastPass, Bitwarden and Dashlane read
139
+ (`data-1p-ignore`, `data-lpignore`, `data-bwignore`,
140
+ `data-form-type="other"`), the same pattern the carrier picker
141
+ already used. `new-password` is deliberately not used, because Chrome
142
+ would then offer to generate a password for an existing carrier
143
+ login. The one-time-code field in the 2FA prompt keeps
144
+ `autocomplete="one-time-code"`.
145
+
146
+ ### `X-SDK-Page-Path` is read per request
147
+
148
+ 0.8.5 read the hosting page's pathname once, when the widget mounted.
149
+ 0.8.6 reads it as each request is sent, so a single-page host that
150
+ routes the member to another view reports the page the widget is
151
+ actually on.
152
+
153
+ ### Fix: resubmitting during 2FA no longer sticks on "Connecting…"
154
+
155
+ A member who submitted the same credentials again while that
156
+ validation was still running (for example, waiting on the
157
+ verification-method picker) was left on "Connecting…" until a page
158
+ reload. The server hands back the running task's id instead of
159
+ starting a new one, and the SDK replaced its entry for that id with a
160
+ fresh `pending` one, dropping the method list. The progress stream
161
+ for that id stayed open, but the server sends a step only when the
162
+ step changes, so the picker or code prompt never came back.
163
+
164
+ Adding a validation whose id is still live now keeps its current
165
+ step, method list and messages, and takes only the new token, email
166
+ and carrier. An entry that has already ended (success, failure or
167
+ "still working on it") is replaced as before, so a new stream opens
168
+ for it. `npm test` now also runs the reducer's unit tests
169
+ (`npm run test:unit`, Node's built-in runner).
170
+
7
171
  ## 0.8.5
8
172
 
9
173
  ### Broken logins surface on the entry screen (TPA-6662)
package/README.md CHANGED
@@ -4,6 +4,14 @@
4
4
 
5
5
  ## Version
6
6
 
7
+ ### 0.8.7
8
+
9
+ 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.
10
+
11
+ ### 0.8.6
12
+
13
+ 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.
14
+
7
15
  ### 0.8.5
8
16
 
9
17
  The entry screen's "Manage your carriers" tile now carries an "X logins need attention" pill (red if any critical problem exists, amber otherwise, hidden at zero), so members in portal mode see broken logins without clicking in. The SDK also reports the hosting page's pathname (`X-SDK-Page-Path`) so fix-credentials emails can route members of SDK-only tenants back to the portal page that embeds the widget.
@@ -37,6 +45,55 @@ This SDK embeds the [EasyEnrollment platform](https://www.easyenrollment.net) in
37
45
  Latest highlights below. The full per-version changelog lives in
38
46
  [CHANGELOG.md](./CHANGELOG.md).
39
47
 
48
+ ### 0.8.7 highlights
49
+
50
+ * axios is removed. The SDK's HTTP client is now a small wrapper
51
+ around the browser's `fetch`, and the runtime dependency tree
52
+ shrinks from 57 packages to 30. `npm audit --omit=dev` still
53
+ reports no advisories.
54
+ * The requests the SDK sends are unchanged: same URLs, query strings,
55
+ headers and JSON bodies, no timeout, and cookies only on same-origin
56
+ requests, as before.
57
+ * Errors handed to `handleFormErrors` and `doneGetSDK` keep the fields
58
+ integrators read (`response.status`, `response.data`,
59
+ `response.headers`, `message`, `code`, `config`, `request`). The
60
+ error's `name` is now `SdkHttpError` instead of `AxiosError`, and
61
+ `request` is a small `{ method, url }` object instead of an
62
+ `XMLHttpRequest`. The full list is in the CHANGELOG.
63
+ * Fix: after `connectAccessTokenRefreshFn` returns a new connect
64
+ token, every later request now uses it. Before, when a
65
+ `connectAccessToken` was passed to `init()`, only the retried
66
+ request carried the new token, and later requests went out with the
67
+ original one.
68
+ * A slow request that comes back expired after another request's
69
+ refresh has finished is retried with the new token, instead of
70
+ calling `connectAccessTokenRefreshFn` a second time.
71
+
72
+ ### 0.8.6 highlights
73
+
74
+ * Fix: a member who submits the same credentials again while that
75
+ validation is still running keeps the 2FA method picker or code
76
+ prompt. Before, the widget stuck on "Connecting…" until the page was
77
+ reloaded.
78
+ * Dependency security upgrades: axios 1.20.0 and DOMPurify 3.4.17.
79
+ zod is removed; the carrier credential form is now checked by a
80
+ small built-in validator with the same rules and messages.
81
+ `npm audit --omit=dev` reports no advisories against the SDK's
82
+ runtime dependencies.
83
+ * `X-SDK-Page-Path` is read as each request is sent, not once at
84
+ mount, so a single-page host that changes route reports the page
85
+ the widget is actually on.
86
+ * The validation hero no longer sits flush against the step below it
87
+ when a member returns to the carrier picker or the fix-credentials
88
+ screen after a validation.
89
+ * New docs for the per-key embed origin allowlist: the
90
+ `origin_not_allowed` error and an FAQ entry. TPA Stream support
91
+ turns the allowlist on.
92
+ * The carrier username and password fields opt out of autofill.
93
+ Because the SDK runs inside the host's page, the browser used to
94
+ offer the login saved for the host site, and a customer reported a
95
+ member's host-site login being filled into the carrier form.
96
+
40
97
  ### 0.8.5 highlights
41
98
 
42
99
  * "X logins need attention" pill on the entry screen's Manage tile:
@@ -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.3.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,14 +29,18 @@ 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.3.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)
34
+ * `sdk-v-0.8.5.js` (0.8.5, pinned)
35
+ * `sdk-v-0.8.4.js` (0.8.4, pinned)
36
+ * `sdk-v-0.8.3.js` (0.8.3, pinned)
33
37
  * `sdk-v-0.8.2.js` (0.8.2, pinned)
34
38
  * `sdk-v-0.8.1.js` (0.8.1, pinned)
35
39
  * `sdk-v-0.8.0.js` (0.8.0, pinned)
36
40
  * `sdk-v-0.7.7.js` (last 0.7.x, pinned)
37
41
  * `sdk.js` (floating pointer to the latest release; updates automatically when a new version ships)
38
42
 
39
- 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.
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.
40
44
 
41
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.
42
46
 
package/docs/error.md CHANGED
@@ -66,6 +66,37 @@ redirect URL registered with your sdkToken so the carrier knows where
66
66
  to send the user after they authenticate. Contact TPAStream support
67
67
  to configure this on the sdkToken.
68
68
 
69
+ ## Embed origin errors
70
+
71
+ ### `origin_not_allowed`
72
+
73
+ The request was rejected with HTTP 403 and a JSON body like:
74
+
75
+ ```json
76
+ { "error_code": "origin_not_allowed", "docs_url": "..." }
77
+ ```
78
+
79
+ Your `sdkToken` has an embed origin allowlist, its mode is `enforce`,
80
+ and the page that made the request is not on the list. The browser's
81
+ `Origin` header (for example `https://staging.example.com`) did not
82
+ match any entry under the key's "Embed origins". The response still
83
+ carries the normal CORS headers, so the SDK can read it and hand the
84
+ error to `handleInitErrors`.
85
+
86
+ To fix it, either:
87
+
88
+ * Add the site's origin (scheme, host, and port if not the default) to
89
+ the key's embed origins. A wildcard such as `https://*.example.com`
90
+ covers subdomains. Local development origins like
91
+ `http://localhost:3000` must be listed too.
92
+ * Or switch the key's mode back to `report`, which lets the request
93
+ through and only logs it, while you finish the list.
94
+
95
+ Only TPAStream staff can change these settings, so contact TPAStream
96
+ support with the origins and mode you want. Requests with no `Origin` header, such as
97
+ server-to-server calls, are never affected. See
98
+ [Restricting which sites may embed your key](./faq.md#restricting-which-sites-may-embed-your-key).
99
+
69
100
  ## SSE / real-time validation errors (0.8+)
70
101
 
71
102
  These come from the `/v3/sdk/progress/<task_id>/stream` endpoint that
@@ -137,7 +168,8 @@ how to handle. Indicates a backend-frontend version skew; report it.
137
168
  ### `Required`
138
169
 
139
170
  A required field on the credentials form is empty. Comes from the
140
- Zod schema generated from the carrier's `onboard_form.schema`.
171
+ validation rules the SDK builds from the carrier's
172
+ `onboard_form.schema`.
141
173
 
142
174
  ### `You must agree to the terms and services.`
143
175
 
package/docs/faq.md CHANGED
@@ -74,4 +74,29 @@ own in-house system, simply refer to it as "internal"
74
74
  Using the `user` configuration object you can define `memberSystemKey`. This system key will be defined under the same vendor as the
75
75
  employer block, since a member can only exist under 1 employer.
76
76
 
77
- See our [Client Usage Docs](client-usage.md) for more information on the `user` object block.
77
+ See our [Client Usage Docs](client-usage.md) for more information on the `user` object block.
78
+
79
+ ## Restricting which sites may embed your key
80
+ By default an `sdkToken` works from any HTTPS page, because the token is public and ships in your page source.
81
+ You can optionally limit a key to your own sites. Only TPAStream staff can change these settings, so to turn this on, ask TPAStream support to enable it for your key and tell them the list of origins and the mode you want. Each key has two settings:
82
+
83
+ * **Embed origins**: a list of origins such as `https://benefits.example.com` or `https://*.example.com`.
84
+ * **Mode**: one of the three below.
85
+
86
+ | Mode | What happens to a request from a browser origin that is not on the list |
87
+ |---|---|
88
+ | `off` (default) | Nothing. The list is ignored and behavior is unchanged. |
89
+ | `report` | The request succeeds, and TPAStream logs it so you can see what would be blocked. |
90
+ | `enforce` | The request fails with HTTP 403 and `{"error_code": "origin_not_allowed", "docs_url": "..."}`. See [Error Documentation](./error.md#origin_not_allowed). |
91
+
92
+ The check uses the browser's `Origin` header on every SDK request that carries the key. Requests with no `Origin` header (server-to-server calls) are never affected, and neither are CORS preflight (`OPTIONS`) requests.
93
+
94
+ **Suggested rollout:**
95
+ 1. Leave the key on `off` while you collect every site that embeds the SDK, including staging and QA.
96
+ 2. Ask TPAStream support to enter those origins and switch the key to `report`. Run for about a week and ask TPAStream support for the logged origins that were not on the list.
97
+ 3. Ask support to add anything you missed, then switch to `enforce`.
98
+
99
+ Notes:
100
+ * A wildcard such as `https://*.example.com` matches subdomains (`https://benefits.example.com`). It never matches the bare `https://example.com`, so list the bare origin separately if you need it.
101
+ * Local development origins must be listed too, for example `http://localhost:3000`. Include the port.
102
+ * This restricts which websites can use a key from a browser. It does not protect a key used from a server, because server callers send no `Origin` header. For that, use server-side [connect access tokens](./connect-access-token.md).
@@ -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.3.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,13 +1,14 @@
1
1
  {
2
2
  "name": "stream-connect-sdk",
3
- "version": "0.8.5",
3
+ "version": "0.8.7",
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",
7
7
  "format": "biome check --write assets/",
8
8
  "test:lint": "biome check assets/",
9
9
  "test:types": "tsc --noEmit",
10
- "test": "npm run test:lint && npm run test:types",
10
+ "test:unit": "node --test --experimental-strip-types \"assets/**/*.test.ts\"",
11
+ "test": "npm run test:lint && npm run test:types && npm run test:unit",
11
12
  "screenshots": "node scripts/screenshots/capture.mjs",
12
13
  "screenshots:preview": "node scripts/screenshots/preview.mjs",
13
14
  "screenshots:upload": "node scripts/screenshots/upload.mjs"
@@ -41,14 +42,11 @@
41
42
  },
42
43
  "dependencies": {
43
44
  "@headlessui/react": "^2.2.0",
44
- "@hookform/resolvers": "^3.10.0",
45
- "axios": "^1.7.9",
46
- "dompurify": "^3.2.4",
45
+ "dompurify": "^3.4.17",
47
46
  "marked": "^15.0.7",
48
47
  "react": "^19.0.0",
49
48
  "react-dom": "^19.0.0",
50
- "react-hook-form": "^7.54.2",
51
- "zod": "^3.24.2"
49
+ "react-hook-form": "^7.54.2"
52
50
  },
53
51
  "bugs": {
54
52
  "url": "https://github.com/TPAStream/stream-connect-js-sdk/issues"