@cowprotocol/widget-lib 2.0.0 → 2.0.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/IframeCowEventEmitter.d.ts +10 -0
- package/IframeSafeSdkBridge.d.ts +8 -0
- package/cowSwapWidget.d.ts +18 -0
- package/flexibleConfig.d.ts +5 -0
- package/index.cjs +1 -0
- package/index.d.ts +7 -0
- package/index.js +217 -0
- package/package.json +19 -7
- package/resolveFlexibleConfigValues.d.ts +2 -0
- package/themeUtils.d.ts +2 -0
- package/types.d.ts +365 -0
- package/urlUtils.d.ts +4 -0
- package/widgetIframeTransport.d.ts +3 -0
- package/CHANGELOG.md +0 -447
- package/jest.config.ts +0 -10
- package/project.json +0 -51
- package/src/IframeCowEventEmitter.ts +0 -47
- package/src/IframeSafeSdkBridge.ts +0 -77
- package/src/cowSwapWidget.ts +0 -259
- package/src/flexibleConfig.ts +0 -39
- package/src/index.ts +0 -7
- package/src/resolveFlexibleConfigValues.ts +0 -14
- package/src/themeUtils.ts +0 -7
- package/src/types.ts +0 -458
- package/src/urlUtils.spec.ts +0 -88
- package/src/urlUtils.ts +0 -66
- package/src/widgetIframeTransport.ts +0 -5
- package/tsconfig.json +0 -22
- package/tsconfig.lib.json +0 -10
- package/tsconfig.spec.json +0 -9
package/CHANGELOG.md
DELETED
|
@@ -1,447 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## [2.0.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v1.3.0...widget-lib-v2.0.0) (2026-03-11)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
### ⚠ BREAKING CHANGES
|
|
7
|
-
|
|
8
|
-
* Remove support for Lens network ([#7128](https://github.com/cowprotocol/cowswap/issues/7128))
|
|
9
|
-
|
|
10
|
-
### ✨ Features
|
|
11
|
-
|
|
12
|
-
* remove support for Lens network ([#7128](https://github.com/cowprotocol/cowswap/issues/7128)) ([ffdd36d](https://github.com/cowprotocol/cowswap/commit/ffdd36db765eb1feb7fc675347de40b1e6df2bdd))
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
### 🔧 Miscellaneous
|
|
16
|
-
|
|
17
|
-
* **hotfix:** 2026-03-10 ([8c831f7](https://github.com/cowprotocol/cowswap/commit/8c831f70685c058f460d7a0fabbf2941163b9fba))
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
### Dependencies
|
|
21
|
-
|
|
22
|
-
* The following workspace dependencies were updated
|
|
23
|
-
* dependencies
|
|
24
|
-
* @cowprotocol/events bumped to 4.0.0
|
|
25
|
-
* @cowprotocol/iframe-transport bumped to 2.0.8
|
|
26
|
-
|
|
27
|
-
## [1.3.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v1.2.2...widget-lib-v1.3.0) (2026-03-10)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
### ✨ Features
|
|
31
|
-
|
|
32
|
-
* integrate non-evm sdk changes ([#7085](https://github.com/cowprotocol/cowswap/issues/7085)) ([674602e](https://github.com/cowprotocol/cowswap/commit/674602e19bd97197a98733da51cda186d256384e))
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
### 🐛 Bug Fixes
|
|
36
|
-
|
|
37
|
-
* use correct amounts to sign instead of afterSlippage ([#7022](https://github.com/cowprotocol/cowswap/issues/7022)) ([b1020c4](https://github.com/cowprotocol/cowswap/commit/b1020c44615b49c5f05f0a6dcf0d21b96b628846))
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
### 🔧 Miscellaneous
|
|
41
|
-
|
|
42
|
-
* **release:** 2026-03-04 ([5612b59](https://github.com/cowprotocol/cowswap/commit/5612b59d690f9081e62d9efc5ea80774428f0366))
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
### Dependencies
|
|
46
|
-
|
|
47
|
-
* The following workspace dependencies were updated
|
|
48
|
-
* dependencies
|
|
49
|
-
* @cowprotocol/events bumped to 3.4.0
|
|
50
|
-
* @cowprotocol/iframe-transport bumped to 2.0.7
|
|
51
|
-
|
|
52
|
-
## [1.2.2](https://github.com/cowprotocol/cowswap/compare/widget-lib-v1.2.1...widget-lib-v1.2.2) (2026-02-25)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
### 🔧 Miscellaneous
|
|
56
|
-
|
|
57
|
-
* main -> dev ([9c6611e](https://github.com/cowprotocol/cowswap/commit/9c6611e90a4b23e23f6aaadc513de3c6d7f3b562))
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
### Dependencies
|
|
61
|
-
|
|
62
|
-
* The following workspace dependencies were updated
|
|
63
|
-
* dependencies
|
|
64
|
-
* @cowprotocol/events bumped to 3.3.2
|
|
65
|
-
* @cowprotocol/iframe-transport bumped to 2.0.6
|
|
66
|
-
|
|
67
|
-
## [1.2.1](https://github.com/cowprotocol/cowswap/compare/widget-lib-v1.2.0...widget-lib-v1.2.1) (2026-02-24)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
### 🔧 Miscellaneous
|
|
71
|
-
|
|
72
|
-
* merge main into dev 23 02 ([#7062](https://github.com/cowprotocol/cowswap/issues/7062)) ([ac48c9c](https://github.com/cowprotocol/cowswap/commit/ac48c9c83284c6228ba71392edc1c1e0483b53ff))
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
### Dependencies
|
|
76
|
-
|
|
77
|
-
* The following workspace dependencies were updated
|
|
78
|
-
* dependencies
|
|
79
|
-
* @cowprotocol/events bumped to 3.3.1
|
|
80
|
-
* @cowprotocol/iframe-transport bumped to 2.0.5
|
|
81
|
-
|
|
82
|
-
## [1.2.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v1.1.2...widget-lib-v1.2.0) (2026-02-20)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
### ✨ Features
|
|
86
|
-
|
|
87
|
-
* **chains:** disable Lens and support deprecating networks ([#7028](https://github.com/cowprotocol/cowswap/issues/7028)) ([c12d6c2](https://github.com/cowprotocol/cowswap/commit/c12d6c21ad69258c587378add9da86d72ff755b2))
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
### Dependencies
|
|
91
|
-
|
|
92
|
-
* The following workspace dependencies were updated
|
|
93
|
-
* dependencies
|
|
94
|
-
* @cowprotocol/events bumped to 3.3.0
|
|
95
|
-
* @cowprotocol/iframe-transport bumped to 2.0.4
|
|
96
|
-
|
|
97
|
-
## [1.1.2](https://github.com/cowprotocol/cowswap/compare/widget-lib-v1.1.1...widget-lib-v1.1.2) (2026-02-13)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
### Dependencies
|
|
101
|
-
|
|
102
|
-
* The following workspace dependencies were updated
|
|
103
|
-
* dependencies
|
|
104
|
-
* @cowprotocol/events bumped to 3.2.0
|
|
105
|
-
* @cowprotocol/iframe-transport bumped to 2.0.3
|
|
106
|
-
|
|
107
|
-
## [1.1.1](https://github.com/cowprotocol/cowswap/compare/widget-lib-v1.1.0...widget-lib-v1.1.1) (2026-02-10)
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
### 🐛 Bug Fixes
|
|
111
|
-
|
|
112
|
-
* **widget-lib:** clean up code ([#6992](https://github.com/cowprotocol/cowswap/issues/6992)) ([39d9f97](https://github.com/cowprotocol/cowswap/commit/39d9f97966e0a80dbc6b1232676fd18333070e1a))
|
|
113
|
-
|
|
114
|
-
## [1.1.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v1.0.1...widget-lib-v1.1.0) (2026-02-05)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
### ✨ Features
|
|
118
|
-
|
|
119
|
-
* **trade:** upload appData to IPFS before signing ([#6922](https://github.com/cowprotocol/cowswap/issues/6922)) ([cb94104](https://github.com/cowprotocol/cowswap/commit/cb9410470c549bd5453a7933a0a224ba706ec2c2))
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
### 🔧 Miscellaneous
|
|
123
|
-
|
|
124
|
-
* update sdk ([a20814b](https://github.com/cowprotocol/cowswap/commit/a20814b7caf16f495cd0292d5f3469bc552e4d97))
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
### Dependencies
|
|
128
|
-
|
|
129
|
-
* The following workspace dependencies were updated
|
|
130
|
-
* dependencies
|
|
131
|
-
* @cowprotocol/events bumped to 3.1.0
|
|
132
|
-
* @cowprotocol/iframe-transport bumped to 2.0.2
|
|
133
|
-
|
|
134
|
-
## [1.0.1](https://github.com/cowprotocol/cowswap/compare/widget-lib-v1.0.0...widget-lib-v1.0.1) (2026-02-02)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
### Bug Fixes
|
|
138
|
-
|
|
139
|
-
* **protocol-fee:** support decimals in protocol fee ([#6948](https://github.com/cowprotocol/cowswap/issues/6948)) ([a572bbe](https://github.com/cowprotocol/cowswap/commit/a572bbe2899b0a48b2c0891922442a4420f6c3ef))
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
### Dependencies
|
|
143
|
-
|
|
144
|
-
* The following workspace dependencies were updated
|
|
145
|
-
* dependencies
|
|
146
|
-
* @cowprotocol/events bumped to 3.0.1
|
|
147
|
-
* @cowprotocol/iframe-transport bumped to 2.0.1
|
|
148
|
-
|
|
149
|
-
## [1.0.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.22.3...widget-lib-v1.0.0) (2026-01-28)
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
### ⚠ BREAKING CHANGES
|
|
153
|
-
|
|
154
|
-
* migrate from yarn to pnpm ([#6847](https://github.com/cowprotocol/cowswap/issues/6847))
|
|
155
|
-
|
|
156
|
-
### Features
|
|
157
|
-
|
|
158
|
-
* migrate from yarn to pnpm ([#6847](https://github.com/cowprotocol/cowswap/issues/6847)) ([1c5d115](https://github.com/cowprotocol/cowswap/commit/1c5d11516d0ddb997b0ebbb4eee4adcb491204a4))
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
### Dependencies
|
|
162
|
-
|
|
163
|
-
* The following workspace dependencies were updated
|
|
164
|
-
* dependencies
|
|
165
|
-
* @cowprotocol/events bumped to 3.0.0
|
|
166
|
-
* @cowprotocol/iframe-transport bumped to 2.0.0
|
|
167
|
-
|
|
168
|
-
## [0.22.3](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.22.2...widget-lib-v0.22.3) (2026-01-26)
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
### Dependencies
|
|
172
|
-
|
|
173
|
-
* The following workspace dependencies were updated
|
|
174
|
-
* dependencies
|
|
175
|
-
* @cowprotocol/iframe-transport bumped from ^1.1.1 to ^1.2.0
|
|
176
|
-
|
|
177
|
-
## [0.22.2](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.22.1...widget-lib-v0.22.2) (2026-01-26)
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
### Bug Fixes
|
|
181
|
-
|
|
182
|
-
* **widget-lib:** add compatibility with server rendering ([#6813](https://github.com/cowprotocol/cowswap/issues/6813)) ([76bd736](https://github.com/cowprotocol/cowswap/commit/76bd736f17d722f0a639542d4fcbd5e3f0be57b2))
|
|
183
|
-
|
|
184
|
-
## [0.22.1](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.22.0...widget-lib-v0.22.1) (2025-12-24)
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
### Dependencies
|
|
188
|
-
|
|
189
|
-
* The following workspace dependencies were updated
|
|
190
|
-
* dependencies
|
|
191
|
-
* @cowprotocol/events bumped from ^2.0.2 to ^2.1.0
|
|
192
|
-
|
|
193
|
-
## [0.22.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.21.1...widget-lib-v0.22.0) (2025-12-22)
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
### Features
|
|
197
|
-
|
|
198
|
-
* **widget:** option to disable bridging ([#6730](https://github.com/cowprotocol/cowswap/issues/6730)) ([7fc3949](https://github.com/cowprotocol/cowswap/commit/7fc3949f5d656709e3f812499870313cc3b41b9f))
|
|
199
|
-
|
|
200
|
-
## [0.21.1](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.21.0...widget-lib-v0.21.1) (2025-12-16)
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
### Dependencies
|
|
204
|
-
|
|
205
|
-
* The following workspace dependencies were updated
|
|
206
|
-
* dependencies
|
|
207
|
-
* @cowprotocol/events bumped from ^2.0.1 to ^2.0.2
|
|
208
|
-
|
|
209
|
-
## [0.21.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.20.0...widget-lib-v0.21.0) (2025-11-24)
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
### Features
|
|
213
|
-
|
|
214
|
-
* **internationalization:** add internationalization to CoW Swap ([#6198](https://github.com/cowprotocol/cowswap/issues/6198)) ([bec1e54](https://github.com/cowprotocol/cowswap/commit/bec1e54643d9b20a8b6517eae188993e364fed90))
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
### Dependencies
|
|
218
|
-
|
|
219
|
-
* The following workspace dependencies were updated
|
|
220
|
-
* dependencies
|
|
221
|
-
* @cowprotocol/events bumped from ^1.6.1 to ^2.0.1
|
|
222
|
-
|
|
223
|
-
## [0.20.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.19.2...widget-lib-v0.20.0) (2025-07-10)
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
### Features
|
|
227
|
-
|
|
228
|
-
* **trade:** slippage config for integrators ([#5906](https://github.com/cowprotocol/cowswap/issues/5906)) ([cbfa3b1](https://github.com/cowprotocol/cowswap/commit/cbfa3b142571df7bdf55919b8ae6df986017aeab))
|
|
229
|
-
|
|
230
|
-
## [0.19.2](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.19.1...widget-lib-v0.19.2) (2025-06-18)
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
### Bug Fixes
|
|
234
|
-
|
|
235
|
-
* make order progress bar UI more stable ([#5834](https://github.com/cowprotocol/cowswap/issues/5834)) ([80cebd1](https://github.com/cowprotocol/cowswap/commit/80cebd1104a0a2e30e12ce8a4b3d62c212559cec))
|
|
236
|
-
|
|
237
|
-
## [0.19.1](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.19.0...widget-lib-v0.19.1) (2025-05-19)
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
### Bug Fixes
|
|
241
|
-
|
|
242
|
-
* **dev-deps-update:** bump the dev-deps group with 76 updates ([#5663](https://github.com/cowprotocol/cowswap/issues/5663)) ([552b349](https://github.com/cowprotocol/cowswap/commit/552b349f53762a01ccf008e9a2083248424cbafa))
|
|
243
|
-
|
|
244
|
-
## [0.19.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.18.1...widget-lib-v0.19.0) (2025-03-27)
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
### Features
|
|
248
|
-
|
|
249
|
-
* **widget:** allow passing targetChainId for bridge ([#5523](https://github.com/cowprotocol/cowswap/issues/5523)) ([8572095](https://github.com/cowprotocol/cowswap/commit/85720957f2aaf1e8f67d745642f09bf3403ed8a5))
|
|
250
|
-
|
|
251
|
-
## [0.18.1](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.18.0...widget-lib-v0.18.1) (2025-02-05)
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
### Bug Fixes
|
|
255
|
-
|
|
256
|
-
* **safe-app:** remove approval+order placement bundling banner ([#5393](https://github.com/cowprotocol/cowswap/issues/5393)) ([571029d](https://github.com/cowprotocol/cowswap/commit/571029d11f7c2d1afe608f8dd3481c404e0efea0))
|
|
257
|
-
|
|
258
|
-
## [0.18.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.17.0...widget-lib-v0.18.0) (2024-12-03)
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
### Features
|
|
262
|
-
|
|
263
|
-
* **widget:** add maxHeight parameter for the widget ([#5127](https://github.com/cowprotocol/cowswap/issues/5127)) ([db8b509](https://github.com/cowprotocol/cowswap/commit/db8b509d2d46d1ef5e52a18347d20bbebe96dbbd))
|
|
264
|
-
|
|
265
|
-
## [0.17.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.16.0...widget-lib-v0.17.0) (2024-10-29)
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
### Features
|
|
269
|
-
|
|
270
|
-
* setup vampire attack widget ([#4950](https://github.com/cowprotocol/cowswap/issues/4950)) ([99c4c42](https://github.com/cowprotocol/cowswap/commit/99c4c42aec60a734a37926935be5dca6cd4cf11c))
|
|
271
|
-
|
|
272
|
-
## [0.16.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.15.0...widget-lib-v0.16.0) (2024-10-18)
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
### Features
|
|
276
|
-
|
|
277
|
-
* **widget:** deadline widget param ([#4991](https://github.com/cowprotocol/cowswap/issues/4991)) ([ce3b5b8](https://github.com/cowprotocol/cowswap/commit/ce3b5b8adb5cc95a5ca3097d5cf2d45b249748c2))
|
|
278
|
-
* **widget:** hide bridge info ([#4992](https://github.com/cowprotocol/cowswap/issues/4992)) ([9842afd](https://github.com/cowprotocol/cowswap/commit/9842afdb887497d235a01538663488b0b8852bb5))
|
|
279
|
-
* **widget:** hide orders table ([#4993](https://github.com/cowprotocol/cowswap/issues/4993)) ([681fb20](https://github.com/cowprotocol/cowswap/commit/681fb20dab0b4155d50ad7f32c7a48cb95e084a3))
|
|
280
|
-
|
|
281
|
-
## [0.15.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.14.1...widget-lib-v0.15.0) (2024-09-30)
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
### Features
|
|
285
|
-
|
|
286
|
-
* **hooks-store:** support iframe hook-dapps ([#4885](https://github.com/cowprotocol/cowswap/issues/4885)) ([5116f29](https://github.com/cowprotocol/cowswap/commit/5116f296a0e4866d0a51a806b7abe55e809d26e9))
|
|
287
|
-
|
|
288
|
-
## [0.14.1](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.14.0...widget-lib-v0.14.1) (2024-09-17)
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
### Bug Fixes
|
|
292
|
-
|
|
293
|
-
* **libs:** fix import error on multiple libs ([#4869](https://github.com/cowprotocol/cowswap/issues/4869)) ([8cfd70b](https://github.com/cowprotocol/cowswap/commit/8cfd70b6000a1a021b76ad1f924829cb42cb2bcd))
|
|
294
|
-
|
|
295
|
-
## [0.14.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.13.2...widget-lib-v0.14.0) (2024-08-27)
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
### Features
|
|
299
|
-
|
|
300
|
-
* **progress-bar-v2:** replace progress bar with v2 ([#4033](https://github.com/cowprotocol/cowswap/issues/4033)) ([e199bff](https://github.com/cowprotocol/cowswap/commit/e199bff492ad3f91df23be34a829ebe1f246444a))
|
|
301
|
-
|
|
302
|
-
## [0.13.2](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.13.1...widget-lib-v0.13.2) (2024-07-05)
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
### Bug Fixes
|
|
306
|
-
|
|
307
|
-
* **widget-lib:** exclude cow-sdk from the bundle ([#4681](https://github.com/cowprotocol/cowswap/issues/4681)) ([a2eaa3d](https://github.com/cowprotocol/cowswap/commit/a2eaa3d9198a4e5245a70b3a6c71a23337fd0ce8))
|
|
308
|
-
|
|
309
|
-
## [0.13.1](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.13.0...widget-lib-v0.13.1) (2024-07-04)
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
### Bug Fixes
|
|
313
|
-
|
|
314
|
-
* **widget:** always listen activation event ([#4670](https://github.com/cowprotocol/cowswap/issues/4670)) ([#4673](https://github.com/cowprotocol/cowswap/issues/4673)) ([a74244d](https://github.com/cowprotocol/cowswap/commit/a74244d3ec35f4b96b52b87f0be2e4f082a240e5))
|
|
315
|
-
|
|
316
|
-
## [0.13.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.12.0...widget-lib-v0.13.0) (2024-06-18)
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
### Features
|
|
320
|
-
|
|
321
|
-
* **widget:** use flexible config for partner fee ([#4546](https://github.com/cowprotocol/cowswap/issues/4546)) ([e23194a](https://github.com/cowprotocol/cowswap/commit/e23194acde8d97b8b4f852e73f4f59b33e65a8b8))
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
### Bug Fixes
|
|
325
|
-
|
|
326
|
-
* **widget:** allow using walletconnect in widget mobile ([#4522](https://github.com/cowprotocol/cowswap/issues/4522)) ([ff58638](https://github.com/cowprotocol/cowswap/commit/ff586381f673314cf5d847f4f52da2e9e4015bea))
|
|
327
|
-
|
|
328
|
-
## [0.12.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.11.0...widget-lib-v0.12.0) (2024-05-29)
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
### Features
|
|
332
|
-
|
|
333
|
-
* **arbitrum:** add arbitrum_one ([#4407](https://github.com/cowprotocol/cowswap/issues/4407)) ([166e33f](https://github.com/cowprotocol/cowswap/commit/166e33f3c494972738b154cf844584dd78e12c7d))
|
|
334
|
-
|
|
335
|
-
## [0.11.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.10.1...widget-lib-v0.11.0) (2024-05-01)
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
### Features
|
|
339
|
-
|
|
340
|
-
* allow to modify the label of the fee and its tooltip ([a5dd0ba](https://github.com/cowprotocol/cowswap/commit/a5dd0baf19e6831fc135dd6c089e66ea0edd14f4))
|
|
341
|
-
|
|
342
|
-
## [0.10.1](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.10.0...widget-lib-v0.10.1) (2024-04-23)
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
### Bug Fixes
|
|
346
|
-
|
|
347
|
-
* **widget:** ignore self-fired events in Safe sdk bridge ([#4271](https://github.com/cowprotocol/cowswap/issues/4271)) ([b11eab7](https://github.com/cowprotocol/cowswap/commit/b11eab7ad5dff65bee8ffa2be8aef2fa913af5f2))
|
|
348
|
-
|
|
349
|
-
## [0.10.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.9.0...widget-lib-v0.10.0) (2024-04-15)
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
### Features
|
|
353
|
-
|
|
354
|
-
* add option to define the base URL for the widget ([#3991](https://github.com/cowprotocol/cowswap/issues/3991)) ([6b70572](https://github.com/cowprotocol/cowswap/commit/6b7057239c137b6b80f8277fdda7d8b06a5b2ed0))
|
|
355
|
-
* Introduce partner fee ([#3913](https://github.com/cowprotocol/cowswap/issues/3913)) ([dbae7ed](https://github.com/cowprotocol/cowswap/commit/dbae7ed38b690b538d9fbd50e13d04bb199e3437))
|
|
356
|
-
* remove goerli ([#3735](https://github.com/cowprotocol/cowswap/issues/3735)) ([2eaae50](https://github.com/cowprotocol/cowswap/commit/2eaae5063f1623d03328e4c2a0fb49c7799ff0a3))
|
|
357
|
-
* up events lib version ([#4083](https://github.com/cowprotocol/cowswap/issues/4083)) ([02dbb0b](https://github.com/cowprotocol/cowswap/commit/02dbb0ba6f9f68a333a2fa2b78a961df4f301e36))
|
|
358
|
-
* update docs/learn.cow.fi URLs ([#3611](https://github.com/cowprotocol/cowswap/issues/3611)) ([af0ff6b](https://github.com/cowprotocol/cowswap/commit/af0ff6b71de422e43aab987287f780d26a17ac73))
|
|
359
|
-
* **widget:** add parametrization for sounds, images, and disabling/hiding features ([#3815](https://github.com/cowprotocol/cowswap/issues/3815)) ([4a6c461](https://github.com/cowprotocol/cowswap/commit/4a6c46133c98bdcffa5ebcfc66cde3bd85b23d9f))
|
|
360
|
-
* **widget:** create an iframe event emitter ([#3821](https://github.com/cowprotocol/cowswap/issues/3821)) ([d9d1f23](https://github.com/cowprotocol/cowswap/commit/d9d1f23c1bf90a277a0d559c019b9794e43d8162))
|
|
361
|
-
* **widget:** custom token lists in widget ([#3390](https://github.com/cowprotocol/cowswap/issues/3390)) ([7eabe06](https://github.com/cowprotocol/cowswap/commit/7eabe06d043703718d742809791eda555dff5058))
|
|
362
|
-
* **widget:** customize images ([#4159](https://github.com/cowprotocol/cowswap/issues/4159)) ([0b14b2b](https://github.com/cowprotocol/cowswap/commit/0b14b2b19279a1688f75dc4f2954b8c267e57c40))
|
|
363
|
-
* **widget:** emit post order events ([#3819](https://github.com/cowprotocol/cowswap/issues/3819)) ([0df62ec](https://github.com/cowprotocol/cowswap/commit/0df62ec3679da1841e07f85292a5de5faab74cab))
|
|
364
|
-
* **widget:** emit toast for posting orders ([#3837](https://github.com/cowprotocol/cowswap/issues/3837)) ([44749fc](https://github.com/cowprotocol/cowswap/commit/44749fc19a392bba0055c856b6990e354729f31a))
|
|
365
|
-
* **widget:** follow ups on issues raised ([#3840](https://github.com/cowprotocol/cowswap/issues/3840)) ([b1d621f](https://github.com/cowprotocol/cowswap/commit/b1d621f98fb1ec807b1ce5360e1f4d3d9cc50f4e))
|
|
366
|
-
* **widget:** implement all listeners and fix types ([#3817](https://github.com/cowprotocol/cowswap/issues/3817)) ([11a7226](https://github.com/cowprotocol/cowswap/commit/11a7226a5d3811139e784fe668ee2eebf2167a38))
|
|
367
|
-
* **widget:** improve JSON-RPC bridging between iFrame and provider ([#3824](https://github.com/cowprotocol/cowswap/issues/3824)) ([e9652e5](https://github.com/cowprotocol/cowswap/commit/e9652e5835d2c3ca0203349d4eae5b5874891cfc))
|
|
368
|
-
* **widget:** let the host app be the one connecting ([#3846](https://github.com/cowprotocol/cowswap/issues/3846)) ([05a3321](https://github.com/cowprotocol/cowswap/commit/05a3321ede220e7c07dc41df2f2f706028fc4afb))
|
|
369
|
-
* **widget:** misc to address issues and comments ([#3827](https://github.com/cowprotocol/cowswap/issues/3827)) ([ef83a5a](https://github.com/cowprotocol/cowswap/commit/ef83a5ad520d072ebf4f2cccde5fcfd0c1d88cd2))
|
|
370
|
-
* **widget:** optimise widget updates ([#3822](https://github.com/cowprotocol/cowswap/issues/3822)) ([d1a1e7d](https://github.com/cowprotocol/cowswap/commit/d1a1e7d05a1fed94dece9afbbc65f43af1a4f748))
|
|
371
|
-
* **widget:** option to hide safe banner ([#4175](https://github.com/cowprotocol/cowswap/issues/4175)) ([84108f4](https://github.com/cowprotocol/cowswap/commit/84108f4362333f8638d8da7c4ad4849d9f5a796c))
|
|
372
|
-
* **widget:** subscribe to cow events (from iframe) ([#3816](https://github.com/cowprotocol/cowswap/issues/3816)) ([c3b8104](https://github.com/cowprotocol/cowswap/commit/c3b810435a6e64b12d28aac12cf785eef52f6531))
|
|
373
|
-
* **widget:** use custom tokens as virtual list ([#4164](https://github.com/cowprotocol/cowswap/issues/4164)) ([8424a33](https://github.com/cowprotocol/cowswap/commit/8424a337f2ea2fd21cc3cb664d2f91facace00fb))
|
|
374
|
-
* **widget:** use theme colors from URL ([#4188](https://github.com/cowprotocol/cowswap/issues/4188)) ([1623b37](https://github.com/cowprotocol/cowswap/commit/1623b37a1b50499473cf82a7aa0dd8f73f63a415))
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
### Bug Fixes
|
|
378
|
-
|
|
379
|
-
* update widget-lib readme ([#4090](https://github.com/cowprotocol/cowswap/issues/4090)) ([014e321](https://github.com/cowprotocol/cowswap/commit/014e3210e4195c75a02f8a5e330b98d41a74149c))
|
|
380
|
-
* **widget:** call disconnect when destroying the widget ([#4181](https://github.com/cowprotocol/cowswap/issues/4181)) ([93a460a](https://github.com/cowprotocol/cowswap/commit/93a460a0082bc7039dea3cc5c376cc2038917966))
|
|
381
|
-
* **widget:** don't reset palette state while navigating ([#4239](https://github.com/cowprotocol/cowswap/issues/4239)) ([b963bc3](https://github.com/cowprotocol/cowswap/commit/b963bc32739084e729320c49c50f51e8aed86616))
|
|
382
|
-
* **widget:** simplify token lists config ([#3652](https://github.com/cowprotocol/cowswap/issues/3652)) ([08aacdb](https://github.com/cowprotocol/cowswap/commit/08aacdb09602f48408cfe132bb9e5440fd774063))
|
|
383
|
-
|
|
384
|
-
## [0.9.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.7.1...widget-lib-v0.9.0) (2024-04-11)
|
|
385
|
-
|
|
386
|
-
### Features
|
|
387
|
-
|
|
388
|
-
- **widget:** customize images ([#4159](https://github.com/cowprotocol/cowswap/issues/4159)) ([0b14b2b](https://github.com/cowprotocol/cowswap/commit/0b14b2b19279a1688f75dc4f2954b8c267e57c40))
|
|
389
|
-
- **widget:** option to hide safe banner ([#4175](https://github.com/cowprotocol/cowswap/issues/4175)) ([84108f4](https://github.com/cowprotocol/cowswap/commit/84108f4362333f8638d8da7c4ad4849d9f5a796c))
|
|
390
|
-
- **widget:** use custom tokens as virtual list ([#4164](https://github.com/cowprotocol/cowswap/issues/4164)) ([8424a33](https://github.com/cowprotocol/cowswap/commit/8424a337f2ea2fd21cc3cb664d2f91facace00fb))
|
|
391
|
-
- **widget:** use theme colors from URL ([#4188](https://github.com/cowprotocol/cowswap/issues/4188)) ([1623b37](https://github.com/cowprotocol/cowswap/commit/1623b37a1b50499473cf82a7aa0dd8f73f63a415))
|
|
392
|
-
|
|
393
|
-
### Bug Fixes
|
|
394
|
-
|
|
395
|
-
- **widget:** call disconnect when destroying the widget ([#4181](https://github.com/cowprotocol/cowswap/issues/4181)) ([93a460a](https://github.com/cowprotocol/cowswap/commit/93a460a0082bc7039dea3cc5c376cc2038917966))
|
|
396
|
-
|
|
397
|
-
## [0.7.1](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.7.0...widget-lib-v0.7.1) (2024-03-22)
|
|
398
|
-
|
|
399
|
-
### Bug Fixes
|
|
400
|
-
|
|
401
|
-
- update widget-lib readme ([#4090](https://github.com/cowprotocol/cowswap/issues/4090)) ([014e321](https://github.com/cowprotocol/cowswap/commit/014e3210e4195c75a02f8a5e330b98d41a74149c))
|
|
402
|
-
|
|
403
|
-
## [0.7.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.6.0...widget-lib-v0.7.0) (2024-03-22)
|
|
404
|
-
|
|
405
|
-
### Features
|
|
406
|
-
|
|
407
|
-
- up events lib version ([#4083](https://github.com/cowprotocol/cowswap/issues/4083)) ([02dbb0b](https://github.com/cowprotocol/cowswap/commit/02dbb0ba6f9f68a333a2fa2b78a961df4f301e36))
|
|
408
|
-
|
|
409
|
-
## [0.6.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.5.0...widget-lib-v0.6.0) (2024-03-12)
|
|
410
|
-
|
|
411
|
-
### Features
|
|
412
|
-
|
|
413
|
-
- add option to define the base URL for the widget ([#3991](https://github.com/cowprotocol/cowswap/issues/3991)) ([6b70572](https://github.com/cowprotocol/cowswap/commit/6b7057239c137b6b80f8277fdda7d8b06a5b2ed0))
|
|
414
|
-
- Introduce partner fee ([#3913](https://github.com/cowprotocol/cowswap/issues/3913)) ([dbae7ed](https://github.com/cowprotocol/cowswap/commit/dbae7ed38b690b538d9fbd50e13d04bb199e3437))
|
|
415
|
-
|
|
416
|
-
## [0.5.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.4.0...widget-lib-v0.5.0) (2024-02-22)
|
|
417
|
-
|
|
418
|
-
### Features
|
|
419
|
-
|
|
420
|
-
- **widget:** add parametrization for sounds, images, and disabling/hiding features ([#3815](https://github.com/cowprotocol/cowswap/issues/3815)) ([4a6c461](https://github.com/cowprotocol/cowswap/commit/4a6c46133c98bdcffa5ebcfc66cde3bd85b23d9f))
|
|
421
|
-
- **widget:** create an iframe event emitter ([#3821](https://github.com/cowprotocol/cowswap/issues/3821)) ([d9d1f23](https://github.com/cowprotocol/cowswap/commit/d9d1f23c1bf90a277a0d559c019b9794e43d8162))
|
|
422
|
-
- **widget:** emit post order events ([#3819](https://github.com/cowprotocol/cowswap/issues/3819)) ([0df62ec](https://github.com/cowprotocol/cowswap/commit/0df62ec3679da1841e07f85292a5de5faab74cab))
|
|
423
|
-
- **widget:** emit toast for posting orders ([#3837](https://github.com/cowprotocol/cowswap/issues/3837)) ([44749fc](https://github.com/cowprotocol/cowswap/commit/44749fc19a392bba0055c856b6990e354729f31a))
|
|
424
|
-
- **widget:** follow ups on issues raised ([#3840](https://github.com/cowprotocol/cowswap/issues/3840)) ([b1d621f](https://github.com/cowprotocol/cowswap/commit/b1d621f98fb1ec807b1ce5360e1f4d3d9cc50f4e))
|
|
425
|
-
- **widget:** implement all listeners and fix types ([#3817](https://github.com/cowprotocol/cowswap/issues/3817)) ([11a7226](https://github.com/cowprotocol/cowswap/commit/11a7226a5d3811139e784fe668ee2eebf2167a38))
|
|
426
|
-
- **widget:** improve JSON-RPC bridging between iFrame and provider ([#3824](https://github.com/cowprotocol/cowswap/issues/3824)) ([e9652e5](https://github.com/cowprotocol/cowswap/commit/e9652e5835d2c3ca0203349d4eae5b5874891cfc))
|
|
427
|
-
- **widget:** let the host app be the one connecting ([#3846](https://github.com/cowprotocol/cowswap/issues/3846)) ([05a3321](https://github.com/cowprotocol/cowswap/commit/05a3321ede220e7c07dc41df2f2f706028fc4afb))
|
|
428
|
-
- **widget:** misc to address issues and comments ([#3827](https://github.com/cowprotocol/cowswap/issues/3827)) ([ef83a5a](https://github.com/cowprotocol/cowswap/commit/ef83a5ad520d072ebf4f2cccde5fcfd0c1d88cd2))
|
|
429
|
-
- **widget:** optimise widget updates ([#3822](https://github.com/cowprotocol/cowswap/issues/3822)) ([d1a1e7d](https://github.com/cowprotocol/cowswap/commit/d1a1e7d05a1fed94dece9afbbc65f43af1a4f748))
|
|
430
|
-
- **widget:** subscribe to cow events (from iframe) ([#3816](https://github.com/cowprotocol/cowswap/issues/3816)) ([c3b8104](https://github.com/cowprotocol/cowswap/commit/c3b810435a6e64b12d28aac12cf785eef52f6531))
|
|
431
|
-
|
|
432
|
-
## [0.4.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.3.0...widget-lib-v0.4.0) (2024-02-01)
|
|
433
|
-
|
|
434
|
-
### Features
|
|
435
|
-
|
|
436
|
-
- remove goerli ([#3735](https://github.com/cowprotocol/cowswap/issues/3735)) ([2eaae50](https://github.com/cowprotocol/cowswap/commit/2eaae5063f1623d03328e4c2a0fb49c7799ff0a3))
|
|
437
|
-
|
|
438
|
-
## [0.3.0](https://github.com/cowprotocol/cowswap/compare/widget-lib-v0.2.1...widget-lib-v0.3.0) (2024-01-17)
|
|
439
|
-
|
|
440
|
-
### Features
|
|
441
|
-
|
|
442
|
-
- update docs/learn.cow.fi URLs ([#3611](https://github.com/cowprotocol/cowswap/issues/3611)) ([af0ff6b](https://github.com/cowprotocol/cowswap/commit/af0ff6b71de422e43aab987287f780d26a17ac73))
|
|
443
|
-
- **widget:** custom token lists in widget ([#3390](https://github.com/cowprotocol/cowswap/issues/3390)) ([7eabe06](https://github.com/cowprotocol/cowswap/commit/7eabe06d043703718d742809791eda555dff5058))
|
|
444
|
-
|
|
445
|
-
### Bug Fixes
|
|
446
|
-
|
|
447
|
-
- **widget:** simplify token lists config ([#3652](https://github.com/cowprotocol/cowswap/issues/3652)) ([08aacdb](https://github.com/cowprotocol/cowswap/commit/08aacdb09602f48408cfe132bb9e5440fd774063))
|
package/jest.config.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
displayName: 'widget-lib',
|
|
3
|
-
preset: '../../jest.preset.js',
|
|
4
|
-
transform: {
|
|
5
|
-
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
|
|
6
|
-
},
|
|
7
|
-
setupFilesAfterEnv: ['../../jest.setup.ts'],
|
|
8
|
-
moduleFileExtensions: ['ts', 'js', 'html'],
|
|
9
|
-
coverageDirectory: '../../../coverage/libs/widget-lib',
|
|
10
|
-
}
|
package/project.json
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "widget-lib",
|
|
3
|
-
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
-
"sourceRoot": "libs/widget-lib/src",
|
|
5
|
-
"projectType": "library",
|
|
6
|
-
"targets": {
|
|
7
|
-
"build": {
|
|
8
|
-
"executor": "@nx/js:tsc",
|
|
9
|
-
"outputs": ["{options.outputPath}"],
|
|
10
|
-
"options": {
|
|
11
|
-
"outputPath": "dist/libs/widget-lib",
|
|
12
|
-
"main": "libs/widget-lib/src/index.ts",
|
|
13
|
-
"tsConfig": "libs/widget-lib/tsconfig.lib.json",
|
|
14
|
-
"assets": ["libs/widget-lib/*.md"],
|
|
15
|
-
"updateBuildableProjectDepsInPackageJson": true,
|
|
16
|
-
"buildableProjectDepsInPackageJsonType": "dependencies"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"serve": {
|
|
20
|
-
"executor": "@nx/vite:dev-server",
|
|
21
|
-
"defaultConfiguration": "development",
|
|
22
|
-
"options": {
|
|
23
|
-
"buildTarget": "widget-lib:build",
|
|
24
|
-
"port": 3012
|
|
25
|
-
},
|
|
26
|
-
"configurations": {}
|
|
27
|
-
},
|
|
28
|
-
"lint": {
|
|
29
|
-
"executor": "@nx/eslint:lint",
|
|
30
|
-
"outputs": ["{options.outputFile}"],
|
|
31
|
-
"options": {
|
|
32
|
-
"lintFilePatterns": ["libs/widget-lib/**/*.ts"]
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"test": {
|
|
36
|
-
"executor": "@nx/jest:jest",
|
|
37
|
-
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
38
|
-
"options": {
|
|
39
|
-
"jestConfig": "libs/widget-lib/jest.config.ts",
|
|
40
|
-
"passWithNoTests": true
|
|
41
|
-
},
|
|
42
|
-
"configurations": {
|
|
43
|
-
"ci": {
|
|
44
|
-
"ci": true,
|
|
45
|
-
"codeCoverage": true
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
"tags": []
|
|
51
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SimpleCowEventEmitter,
|
|
3
|
-
CowWidgetEventListeners,
|
|
4
|
-
CowWidgetEvents,
|
|
5
|
-
CowWidgetEventPayloadMap,
|
|
6
|
-
} from '@cowprotocol/events'
|
|
7
|
-
|
|
8
|
-
import { WindowListener, WidgetMethodsEmit } from './types'
|
|
9
|
-
import { widgetIframeTransport } from './widgetIframeTransport'
|
|
10
|
-
|
|
11
|
-
export class IframeCowEventEmitter {
|
|
12
|
-
private eventEmitter = new SimpleCowEventEmitter<CowWidgetEventPayloadMap, CowWidgetEvents>()
|
|
13
|
-
private listeners: CowWidgetEventListeners = []
|
|
14
|
-
private widgetListener: WindowListener
|
|
15
|
-
|
|
16
|
-
constructor(
|
|
17
|
-
private contentWindow: Window,
|
|
18
|
-
listeners: CowWidgetEventListeners = [],
|
|
19
|
-
) {
|
|
20
|
-
// Subscribe listeners to local event emitter
|
|
21
|
-
this.updateListeners(listeners)
|
|
22
|
-
|
|
23
|
-
// Listen to iFrame, and forward to local event emitter
|
|
24
|
-
this.widgetListener = widgetIframeTransport.listenToMessageFromWindow(
|
|
25
|
-
this.contentWindow,
|
|
26
|
-
WidgetMethodsEmit.EMIT_COW_EVENT,
|
|
27
|
-
(cowEvent) => this.eventEmitter.emit(cowEvent.event, cowEvent.payload),
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public stopListeningIframe(): void {
|
|
32
|
-
widgetIframeTransport.stopListeningWindowListener(this.contentWindow, this.widgetListener)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public updateListeners(listeners?: CowWidgetEventListeners): void {
|
|
36
|
-
// Unsubscribe from previous listeners
|
|
37
|
-
for (const listener of this.listeners) {
|
|
38
|
-
this.eventEmitter.off(listener)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Subscribe to events
|
|
42
|
-
this.listeners = listeners || []
|
|
43
|
-
for (const listener of this.listeners) {
|
|
44
|
-
this.eventEmitter.on(listener)
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
export class IframeSafeSdkBridge {
|
|
2
|
-
forwardSdkMessage: (event: MessageEvent<unknown>) => void
|
|
3
|
-
|
|
4
|
-
constructor(
|
|
5
|
-
private appWindow: Window,
|
|
6
|
-
private iframeWidow: Window,
|
|
7
|
-
) {
|
|
8
|
-
this.forwardSdkMessage = (event: MessageEvent<unknown>) => {
|
|
9
|
-
if (!isSafeMessage(event.data)) {
|
|
10
|
-
return
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (typeof window !== 'undefined' && event.origin === window.location.origin) {
|
|
14
|
-
return
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (isSafeMessageRequest(event.data)) {
|
|
18
|
-
this.appWindow.parent.postMessage(event.data, '*')
|
|
19
|
-
} else if (isSafeMessageResponse(event.data)) {
|
|
20
|
-
this.iframeWidow.postMessage(event.data, '*')
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
this.startListening()
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
private startListening(): void {
|
|
28
|
-
this.appWindow.addEventListener('message', this.forwardSdkMessage)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public stopListening(): void {
|
|
32
|
-
this.appWindow.removeEventListener('message', this.forwardSdkMessage)
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function isSafeMessage(obj: unknown): obj is SafeMessage {
|
|
37
|
-
return typeof obj === 'object' && obj !== null && 'id' in obj && typeof obj.id === 'string'
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function isSafeMessageRequest(message: SafeMessage): message is SafeMessageRequest {
|
|
41
|
-
return (
|
|
42
|
-
'method' in message &&
|
|
43
|
-
typeof message.method === 'string' &&
|
|
44
|
-
'params' in message &&
|
|
45
|
-
'env' in message &&
|
|
46
|
-
typeof message.env === 'object' &&
|
|
47
|
-
message.env !== null &&
|
|
48
|
-
'sdkVersion' in message.env
|
|
49
|
-
)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function isSafeMessageResponse(message: SafeMessage): message is SafeMessageResponse {
|
|
53
|
-
return (
|
|
54
|
-
'success' in message &&
|
|
55
|
-
typeof message.success === 'boolean' &&
|
|
56
|
-
'version' in message &&
|
|
57
|
-
typeof message.version === 'string'
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
interface SafeMessage {
|
|
62
|
-
id: string
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
interface SafeMessageRequest extends SafeMessage {
|
|
66
|
-
method: string
|
|
67
|
-
params: unknown
|
|
68
|
-
env: {
|
|
69
|
-
sdkVersion: string
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
interface SafeMessageResponse extends SafeMessage {
|
|
74
|
-
id: string
|
|
75
|
-
success: boolean
|
|
76
|
-
version: string
|
|
77
|
-
}
|