@returningai/widget-sdk 1.4.0 → 1.4.2

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 ADDED
@@ -0,0 +1,104 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@returningai/widget-sdk` are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ---
9
+
10
+ ## [Security Notice — 2026-05-11] Refresh-token TTL change for Access Key Embed
11
+
12
+ **This is a server-side change. No SDK code update is required. Customers do
13
+ not need to publish a new build of their host pages — the change applies
14
+ automatically the next time their users load the widget.**
15
+
16
+ ### What changed
17
+
18
+ The ReturningAI widget auth backend (`/auth/serverless`) now issues
19
+ **0-second-TTL refresh tokens** for Access Key Embed sessions (any auth
20
+ request that includes a signed `embedToken` in the body). The SDK persists
21
+ the refresh token with an already-expired `refreshTokenExpiry`, so on the
22
+ next page load `loadFromStorage` wipes it and the SDK re-calls
23
+ `/auth/serverless` for fresh `embedToken` validation.
24
+
25
+ Public Embed sessions (auth via `data-*` identifier attributes only, no
26
+ `embedToken`) keep the original 7-day refresh window — their identity
27
+ arrives from the host page on every load anyway, so caching the refresh
28
+ token doesn't change the security model.
29
+
30
+ In addition, refresh tokens **issued before this date are now rejected** by
31
+ `/auth/refresh`. Users with stored refresh tokens older than the cutoff
32
+ will see a one-time `/auth/serverless` re-auth on their next page load.
33
+ This is transparent provided their host page still supplies `embed-token`
34
+ (Access Key Embed) or `data-email` / configured identifier attrs (Public
35
+ Embed) — which is the normal embed state.
36
+
37
+ ### Why
38
+
39
+ In the previous behavior, a host page that:
40
+
41
+ 1. Initially loaded with `embed-token` + `data-email` (auth succeeded,
42
+ 7-day refresh token stored), and
43
+ 2. Later loaded without those attributes (e.g., the `embed-token` attribute
44
+ was removed or rotated)
45
+
46
+ ...would still authenticate as the original user via the cached refresh
47
+ token until that token's 7-day TTL expired. This conflicted with the
48
+ Access Key Embed promise that **every page load re-validates the embed
49
+ token**. A revoked or expired `embedToken` should immediately end the
50
+ session — not survive for up to a week in the user's browser.
51
+
52
+ ### Visible behavior changes
53
+
54
+ | Scenario | Before | After |
55
+ |---|---|---|
56
+ | First load with `embed-token` (valid claims) | 200, stores 7-day refresh token | 200, stores already-expired refresh token |
57
+ | Subsequent loads with `embed-token` still present | Used cached refresh token via `/auth/refresh` | Re-validates via `/auth/serverless` every load |
58
+ | Subsequent loads after `embed-token` is removed/changed | Continued working for up to 7 days (gap) | Re-auth required; fails closed if no identity is present |
59
+ | Public Embed loads (`data-email` only) | Unchanged | Unchanged |
60
+ | Users mid-session (in-memory access token) | Unchanged | Unchanged until access token expires (~5 min) |
61
+
62
+ ### Action required
63
+
64
+ **For most customers: none.** The change is backward-compatible with all
65
+ documented embed patterns. Your existing `<script>` / custom-element
66
+ embeds keep working with their pinned SDK version.
67
+
68
+ **Possible visible effect:** existing logged-in users may see a single
69
+ re-auth round-trip on their next page load (≈50–150 ms latency added).
70
+ After that, normal behavior resumes.
71
+
72
+ **If you're using Access Key Embed:** confirm your token-mint endpoint
73
+ calls `issueEmbedTokenService(accessId, accessKey, { /* identifiers */ })`
74
+ so the JWT carries `userIdentifiers` as a signed claim. With a correctly
75
+ signed token, no `data-*` attributes are needed on the embed tag and
76
+ re-auth on every load is transparent.
77
+
78
+ ---
79
+
80
+ ## [1.4.0] — 2026-05-02
81
+
82
+ ### Added
83
+ - Bundled lottie-web (light build) loader instead of runtime CDN fetch.
84
+ Eliminates dependency on `cdnjs.cloudflare.com` at runtime — works
85
+ offline and behind corporate proxies.
86
+ - `AnimationItem.destroy()` cleanup on `disconnectedCallback` to fix a
87
+ memory leak when widgets are repeatedly mounted/unmounted.
88
+ - `data-rai-widget-root` attribute on the mount container for easier
89
+ selection in tests and external CSS.
90
+
91
+ ### Changed
92
+ - Environment URLs (`api-url`, `widget-url`, `domain-key`, `v2-api-url`)
93
+ are now optional. The SDK resolves them from `domain-key` when present
94
+ and defaults to production otherwise. Existing embeds that explicitly
95
+ pass these attributes continue to work without modification.
96
+
97
+ ---
98
+
99
+ ## [1.3.0] — Server-signed identity (Access Key Embed) + security hardening
100
+
101
+ Introduced Access Key Embed mode — JWT `embedToken` carries signed
102
+ `userIdentifiers` claims. Server trusts token claims over body-level
103
+ identifiers. SDK clears storage on every load when `embed-token` is
104
+ present, forcing fresh `/auth/serverless` validation.