@returningai/widget-sdk 1.4.2 → 1.5.0
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 +84 -7
- package/README.md +476 -123
- package/dist/rai-widget.iife.js +1 -1
- package/dist/rai-widget.js +123 -6
- package/dist/types/BaseWidget.d.ts +9 -1
- package/dist/types/core/callback-registry.d.ts +15 -0
- package/dist/types/core/postmessage.d.ts +2 -2
- package/dist/types/index.d.ts +11 -7
- package/dist/types/jsx.d.ts +55 -0
- package/dist/types/types.d.ts +56 -0
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
+
## [1.5.0] — 2026-06-03
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Store and custom-store widgets can now register a host callback named
|
|
15
|
+
`callbackFieldOptions` to populate callback-backed purchase fields from the
|
|
16
|
+
customer's backend.
|
|
17
|
+
- Added per-widget callback registration APIs:
|
|
18
|
+
`widget.registerCallback(callbackName, callback)` and
|
|
19
|
+
`widget.lockCallbacks()`. Register callbacks on the specific widget element
|
|
20
|
+
so pages with multiple widgets can route each widget to its own handler.
|
|
21
|
+
- Added TypeScript exports for the store callback payload and result types,
|
|
22
|
+
including `StoreCallbackFieldOptionsPayload`,
|
|
23
|
+
`StoreCallbackFieldOptionsResult`, and
|
|
24
|
+
`ReturningAIStoreCallbackFieldOptionsCallback`.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- Store callback examples now call the customer's backend from the browser
|
|
29
|
+
callback and expect the backend to return `{ fieldOptions, signature }`.
|
|
30
|
+
Keep SDK access credentials on the backend; do not call ReturningAI's
|
|
31
|
+
callback-signature endpoint from browser code.
|
|
32
|
+
- Callback registration now supports both iframe mode and bundle mode.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
10
36
|
## [Security Notice — 2026-05-11] Refresh-token TTL change for Access Key Embed
|
|
11
37
|
|
|
12
38
|
**This is a server-side change. No SDK code update is required. Customers do
|
|
@@ -51,13 +77,13 @@ session — not survive for up to a week in the user's browser.
|
|
|
51
77
|
|
|
52
78
|
### Visible behavior changes
|
|
53
79
|
|
|
54
|
-
| Scenario
|
|
55
|
-
|
|
56
|
-
| First load with `embed-token` (valid claims)
|
|
57
|
-
| Subsequent loads with `embed-token` still present
|
|
58
|
-
| Subsequent loads after `embed-token` is removed/changed | Continued working for up to 7 days (gap)
|
|
59
|
-
| Public Embed loads (`data-email` only)
|
|
60
|
-
| Users mid-session (in-memory access token)
|
|
80
|
+
| Scenario | Before | After |
|
|
81
|
+
| ------------------------------------------------------- | --------------------------------------------- | -------------------------------------------------------- |
|
|
82
|
+
| First load with `embed-token` (valid claims) | 200, stores 7-day refresh token | 200, stores already-expired refresh token |
|
|
83
|
+
| Subsequent loads with `embed-token` still present | Used cached refresh token via `/auth/refresh` | Re-validates via `/auth/serverless` every load |
|
|
84
|
+
| 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 |
|
|
85
|
+
| Public Embed loads (`data-email` only) | Unchanged | Unchanged |
|
|
86
|
+
| Users mid-session (in-memory access token) | Unchanged | Unchanged until access token expires (~5 min) |
|
|
61
87
|
|
|
62
88
|
### Action required
|
|
63
89
|
|
|
@@ -77,9 +103,59 @@ re-auth on every load is transparent.
|
|
|
77
103
|
|
|
78
104
|
---
|
|
79
105
|
|
|
106
|
+
## [1.4.2] — 2026-05-20
|
|
107
|
+
|
|
108
|
+
### Added
|
|
109
|
+
|
|
110
|
+
- `attributeChangedCallback` on custom elements watches `embed-token` /
|
|
111
|
+
`data-embed-token` and reloads the widget when the token changes at
|
|
112
|
+
runtime (e.g. SPA re-renders a fresh token without a full page reload).
|
|
113
|
+
- User-identifier `data-*` attributes (e.g. `data-email`, `data-user-id`)
|
|
114
|
+
are now watched via `MutationObserver`. When any identifier value changes,
|
|
115
|
+
stored auth is cleared and the widget re-authenticates.
|
|
116
|
+
|
|
117
|
+
### Fixed
|
|
118
|
+
|
|
119
|
+
- Embed-token reload lifecycle: in-flight auth/mount work is cancelled when
|
|
120
|
+
identity changes mid-init, preventing stale sessions from mounting after a
|
|
121
|
+
token swap.
|
|
122
|
+
- Widget teardown on reload/disconnect now removes iframes, bundle mount
|
|
123
|
+
nodes, postMessage listeners, and sync timers — fixes duplicate widgets
|
|
124
|
+
and leaked listeners after repeated reloads.
|
|
125
|
+
- Error UI is cleared before relaunching after a successful re-auth.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## [1.4.1] — 2026-05-19
|
|
130
|
+
|
|
131
|
+
### Added
|
|
132
|
+
|
|
133
|
+
- Identity signature tracking: the SDK detects when `embed-token` or
|
|
134
|
+
`data-*` user identifiers change and triggers a full reload with cleared
|
|
135
|
+
storage.
|
|
136
|
+
- `/auth/refresh` requests now include the current `embedToken` and
|
|
137
|
+
`userIdentifiers` so the server can validate the refresh against the
|
|
138
|
+
active identity proof.
|
|
139
|
+
|
|
140
|
+
### Changed
|
|
141
|
+
|
|
142
|
+
- Auth storage keys are scoped per mount container
|
|
143
|
+
(`{prefix}-{widgetId}-{container}-auth`). Legacy keys are read once and
|
|
144
|
+
migrated automatically.
|
|
145
|
+
- `reload()` re-reads config, clears storage for both old and new identity,
|
|
146
|
+
and resets widget dimensions before re-init.
|
|
147
|
+
|
|
148
|
+
### Fixed
|
|
149
|
+
|
|
150
|
+
- Refresh failures (HTTP 400/401/403) fall back to `/auth/serverless`
|
|
151
|
+
re-auth instead of leaving the widget in a stuck authenticated state.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
80
155
|
## [1.4.0] — 2026-05-02
|
|
81
156
|
|
|
82
157
|
### Added
|
|
158
|
+
|
|
83
159
|
- Bundled lottie-web (light build) loader instead of runtime CDN fetch.
|
|
84
160
|
Eliminates dependency on `cdnjs.cloudflare.com` at runtime — works
|
|
85
161
|
offline and behind corporate proxies.
|
|
@@ -89,6 +165,7 @@ re-auth on every load is transparent.
|
|
|
89
165
|
selection in tests and external CSS.
|
|
90
166
|
|
|
91
167
|
### Changed
|
|
168
|
+
|
|
92
169
|
- Environment URLs (`api-url`, `widget-url`, `domain-key`, `v2-api-url`)
|
|
93
170
|
are now optional. The SDK resolves them from `domain-key` when present
|
|
94
171
|
and defaults to production otherwise. Existing embeds that explicitly
|