stream-connect-sdk 0.8.6 → 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,92 @@ 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
+
7
93
  ## 0.8.6
8
94
 
9
95
  ### Security: axios and dompurify upgraded
package/README.md CHANGED
@@ -4,6 +4,10 @@
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
+
7
11
  ### 0.8.6
8
12
 
9
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.
@@ -41,6 +45,30 @@ This SDK embeds the [EasyEnrollment platform](https://www.easyenrollment.net) in
41
45
  Latest highlights below. The full per-version changelog lives in
42
46
  [CHANGELOG.md](./CHANGELOG.md).
43
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
+
44
72
  ### 0.8.6 highlights
45
73
 
46
74
  * 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
 
@@ -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.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",
@@ -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",