@metamask/snaps-controllers 9.6.0 → 9.8.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +143 -1
  2. package/dist/services/node-js/NodeProcessExecutionService.mjs +3 -1
  3. package/dist/services/node-js/NodeProcessExecutionService.mjs.map +1 -1
  4. package/dist/services/node-js/NodeThreadExecutionService.mjs +3 -1
  5. package/dist/services/node-js/NodeThreadExecutionService.mjs.map +1 -1
  6. package/dist/services/offscreen/OffscreenExecutionService.d.cts +1 -1
  7. package/dist/services/offscreen/OffscreenExecutionService.d.mts +1 -1
  8. package/dist/services/webview/WebViewExecutionService.d.cts +1 -1
  9. package/dist/services/webview/WebViewExecutionService.d.mts +1 -1
  10. package/dist/services/webview/WebViewMessageStream.cjs.map +1 -1
  11. package/dist/services/webview/WebViewMessageStream.d.cts +1 -2
  12. package/dist/services/webview/WebViewMessageStream.d.cts.map +1 -1
  13. package/dist/services/webview/WebViewMessageStream.d.mts +1 -2
  14. package/dist/services/webview/WebViewMessageStream.d.mts.map +1 -1
  15. package/dist/services/webview/WebViewMessageStream.mjs.map +1 -1
  16. package/dist/services/webview/index.cjs +1 -0
  17. package/dist/services/webview/index.cjs.map +1 -1
  18. package/dist/services/webview/index.d.cts +1 -0
  19. package/dist/services/webview/index.d.cts.map +1 -1
  20. package/dist/services/webview/index.d.mts +1 -0
  21. package/dist/services/webview/index.d.mts.map +1 -1
  22. package/dist/services/webview/index.mjs +1 -0
  23. package/dist/services/webview/index.mjs.map +1 -1
  24. package/dist/snaps/SnapController.cjs +4 -2
  25. package/dist/snaps/SnapController.cjs.map +1 -1
  26. package/dist/snaps/SnapController.d.cts +1 -0
  27. package/dist/snaps/SnapController.d.cts.map +1 -1
  28. package/dist/snaps/SnapController.d.mts +1 -0
  29. package/dist/snaps/SnapController.d.mts.map +1 -1
  30. package/dist/snaps/SnapController.mjs +4 -2
  31. package/dist/snaps/SnapController.mjs.map +1 -1
  32. package/package.json +39 -24
package/CHANGELOG.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Changelog
2
+
2
3
  All notable changes to this project will be documented in this file.
3
4
 
4
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
@@ -6,11 +7,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
7
 
7
8
  ## [Unreleased]
8
9
 
10
+ ## [9.8.0]
11
+
12
+ ### Added
13
+
14
+ - Export `WebViewMessageStream` and related types ([#2746](https://github.com/MetaMask/snaps/pull/2746))
15
+
16
+ ### Fixed
17
+
18
+ - Fix invalid `exports` field ([#2740](https://github.com/MetaMask/snaps/pull/2740))
19
+
20
+ ## [9.7.0]
21
+
22
+ ### Added
23
+
24
+ - Add `hideSnapBranding` flag for preinstalled Snaps ([#2713](https://github.com/MetaMask/snaps/pull/2713), [#2717](https://github.com/MetaMask/snaps/pull/2717))
25
+
26
+ ### Fixed
27
+
28
+ - Fix invalid types in type declaration in some cases ([#2714](https://github.com/MetaMask/snaps/pull/2714))
29
+
9
30
  ## [9.6.0]
31
+
10
32
  ### Added
33
+
11
34
  - Add `stopAllSnaps` function to `SnapController` ([#2674](https://github.com/MetaMask/snaps/pull/2674))
12
35
 
13
36
  ### Fixed
37
+
14
38
  - Fix ESM version of the package ([#2682](https://github.com/MetaMask/snaps/pull/2682))
15
39
  - This fixes the ESM version of the package to be fully compliant with the ESM
16
40
  standard.
@@ -18,22 +42,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
18
42
  - Bump other MetaMask dependencies ([#2703](https://github.com/MetaMask/snaps/pull/2703))
19
43
 
20
44
  ## [9.5.0]
45
+
21
46
  ### Added
47
+
22
48
  - Add `Selector` component ([#2645](https://github.com/MetaMask/snaps/pull/2645))
23
49
  - Add missing types for `getState` action & `stateChange` event ([#2655](https://github.com/MetaMask/snaps/pull/2655), [#2659](https://github.com/MetaMask/snaps/pull/2659))
24
50
 
25
51
  ### Fixed
52
+
26
53
  - Fix `fetch` binding under LavaMoat ([#2642](https://github.com/MetaMask/snaps/pull/2642))
27
54
 
28
55
  ## [9.4.0]
56
+
29
57
  ### Added
58
+
30
59
  - Add `RadioGroup` component ([#2592](https://github.com/MetaMask/snaps/pull/2592))
31
60
 
32
61
  ### Changed
62
+
33
63
  - Persist `severity` property in `SnapInsightsController` ([#2612](https://github.com/MetaMask/snaps/pull/2612))
34
64
 
35
65
  ## [9.3.1]
66
+
36
67
  ### Changed
68
+
37
69
  - Bump `@metamask/approval-controller` from `^7.0.0` to `^7.0.2` ([#2593](https://github.com/metamask/snaps/pull/2593))
38
70
  - Bump `@metamask/base-controller` from `^6.0.1` to `^6.0.2` ([#2593](https://github.com/metamask/snaps/pull/2593))
39
71
  - Bump `@metamask/json-rpc-engine` from `^9.0.0` to `^9.0.2` ([#2593](https://github.com/metamask/snaps/pull/2593))
@@ -43,11 +75,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
43
75
  - Bump `@metamask/snaps-utils` from `^7.8.0` to `^7.8.1` ([#2595](https://github.com/MetaMask/snaps/pull/2595))
44
76
 
45
77
  ## [9.3.0]
78
+
46
79
  ### Added
80
+
47
81
  - Add `snap_resolveInterface` RPC method to the `SnapInterfaceController` ([#2509](https://github.com/metamask/snaps/pull/2509))
48
82
  - Add `SnapInsightsController` ([#2555](https://github.com/metamask/snaps/pull/2555))
49
83
 
50
84
  ### Changed
85
+
51
86
  - Bump `@metamask/base-controller` from `^6.0.0` to `^6.0.1` ([#2445](https://github.com/MetaMask/snaps/pull/2445))
52
87
  - Bump `@metamask/permission-controller` from `^10.0.0` to `^10.0.1` ([#2445](https://github.com/MetaMask/snaps/pull/2445))
53
88
  - Bump `@metamask/rpc-errors` from `^6.2.1` to `^6.3.1` ([#2445](https://github.com/MetaMask/snaps/pull/2445))
@@ -59,6 +94,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
59
94
  - Bump peer dependency `@metamask/snaps-execution-environments` to `^6.6.1` ([#2589](https://github.com/MetaMask/snaps/pull/2589))
60
95
 
61
96
  ### Fixed
97
+
62
98
  - Handle initial connections for preinstalled Snaps ([#2591](https://github.com/MetaMask/snaps/pull/2591))
63
99
  - Account for revoked origins when calculating the difference in `initialConnections` ([#2535](https://github.com/metamask/snaps/pull/2535))
64
100
  - Fixes issue of revoking permissions that are already revoked.
@@ -67,71 +103,97 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
67
103
  - Prevent communication failures by enabling compliance with JSON-RPC extension message requirements.
68
104
 
69
105
  ## [9.2.0]
106
+
70
107
  ### Added
108
+
71
109
  - Add feature flag to disable Snap installation ([#2521](https://github.com/MetaMask/snaps/pull/2521))
72
110
 
73
111
  ## [9.1.0]
112
+
74
113
  ### Added
114
+
75
115
  - Add `Checkbox` component ([#2501](https://github.com/MetaMask/snaps/pull/2501))
76
116
  - Add `FileInput` component ([#2469](https://github.com/MetaMask/snaps/pull/2469))
77
117
  - Support additional components inside forms ([#2497](https://github.com/MetaMask/snaps/pull/2497))
78
118
 
79
119
  ## [9.0.0]
120
+
80
121
  ### Changed
122
+
81
123
  - **BREAKING:** Defer creation of offscreen document in `OffscreenExecutionService` ([#2473](https://github.com/MetaMask/snaps/pull/2473))
82
124
  - Update `onNameLookup` response to include `domainName` ([#2484](https://github.com/MetaMask/snaps/pull/2484))
83
125
  - Bump MetaMask dependencies ([#2460](https://github.com/MetaMask/snaps/pull/2460))
84
126
 
85
127
  ### Fixed
128
+
86
129
  - Properly decrypt legacy state blobs ([#2472](https://github.com/MetaMask/snaps/pull/2472))
87
130
 
88
131
  ## [8.4.0]
132
+
89
133
  ### Added
134
+
90
135
  - Add `hidden` flag for preinstalled Snaps ([#2463](https://github.com/MetaMask/snaps/pull/2463))
91
136
 
92
137
  ### Fixed
138
+
93
139
  - Use first Dropdown option as the default value ([#2465](https://github.com/MetaMask/snaps/pull/2465))
94
140
 
95
141
  ## [8.3.1]
142
+
96
143
  ### Fixed
144
+
97
145
  - Fix `react-native` export for tools that don't support `package.json` exports ([#2451](https://github.com/MetaMask/snaps/pull/2451))
98
146
 
99
147
  ## [8.3.0]
148
+
100
149
  ### Added
150
+
101
151
  - Add origin to lifecycle hooks ([#2441](https://github.com/MetaMask/snaps/pull/2441))
102
152
  - Lifecycle hooks can now use the `origin` parameter to determine the origin
103
153
  of the installation or update.
104
154
 
105
155
  ## [8.2.0]
156
+
106
157
  ### Added
158
+
107
159
  - Add `context` field to `snap_createInterface` ([#2413](https://github.com/MetaMask/snaps/pull/2413))
108
160
  - Add feature flag to disable platform ([#2434](https://github.com/MetaMask/snaps/pull/2434))
109
161
  - Add support for `Dropdown` component ([#2420](https://github.com/MetaMask/snaps/pull/2420))
110
162
  - Add `initialConnections` diff calculations needed for Snap update ([#2424](https://github.com/MetaMask/snaps/pull/2424))
111
163
 
112
164
  ### Fixed
165
+
113
166
  - Correctly merge caveats when using initial connections ([#2419](https://github.com/MetaMask/snaps/pull/2419))
114
167
 
115
168
  ## [8.1.1]
169
+
116
170
  ### Fixed
171
+
117
172
  - Re-instantiate preinstalled Snaps after clearing state ([#2393](https://github.com/MetaMask/snaps/pull/2393))
118
173
 
119
174
  ## [8.1.0]
175
+
120
176
  ### Added
177
+
121
178
  - Add JSX support for custom UI ([#2258](https://github.com/MetaMask/snaps/pull/2258))
122
179
 
123
180
  ### Changed
181
+
124
182
  - Bump `@metamask/approval-controller` from `6.0.1` to `6.0.2` ([#2380](https://github.com/MetaMask/snaps/pull/2380))
125
183
  - Bump `@metamask/base-controller` from `5.0.1` to `5.0.2` ([#2375](https://github.com/MetaMask/snaps/pull/2375))
126
184
 
127
185
  ### Fixed
186
+
128
187
  - Fix an issue where certain types of executors would be timed out too quickly ([#2389](https://github.com/MetaMask/snaps/pull/2389))
129
188
 
130
189
  ## [8.0.0]
190
+
131
191
  ### Changed
192
+
132
193
  - **BREAKING:** Move `maxInitTime` constructor argument from `SnapController` to `ExecutionService` ([#2348](https://github.com/MetaMask/snaps/pull/2348))
133
194
 
134
195
  ### Fixed
196
+
135
197
  - Increase max UI size limit from 250 KB to 10 MB ([#2342](https://github.com/MetaMask/snaps/pull/2342))
136
198
  - Consider caveats in permissions difference calculation ([#2345](https://github.com/MetaMask/snaps/pull/2345))
137
199
  - This fixes a bug where certain caveats would not be correctly applied when updating Snaps.
@@ -140,38 +202,53 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
140
202
  - Properly tear down partially initialized executors and improve stability when executor initialization fails ([#2348](https://github.com/MetaMask/snaps/pull/2348))
141
203
 
142
204
  ## [7.0.1]
205
+
143
206
  ### Fixed
207
+
144
208
  - Fix encryption key caching issues ([#2326](https://github.com/MetaMask/snaps/pull/2326))
145
209
 
146
210
  ## [7.0.0]
211
+
147
212
  ### Changed
213
+
148
214
  - **BREAKING:** Refactor encryption to enable caching ([#2316](https://github.com/MetaMask/snaps/pull/2316))
149
215
  - New required constructor arguments `encryptor` and `getMnemonic` have been added.
150
216
  - Include `initialConnections` in approval `requestState` ([#2322](https://github.com/MetaMask/snaps/pull/2322))
151
217
 
152
218
  ### Fixed
219
+
153
220
  - Delete unencrypted state when uninstalling a Snap ([#2311](https://github.com/MetaMask/snaps/pull/2311))
154
221
 
155
222
  ## [6.0.4]
223
+
156
224
  ### Changed
225
+
157
226
  - Bump MetaMask dependencies ([#2270](https://github.com/MetaMask/snaps/pull/2270))
158
227
 
159
228
  ## [6.0.3]
229
+
160
230
  ### Changed
231
+
161
232
  - Handle unavailable registry more gracefully ([#2256](https://github.com/MetaMask/snaps/pull/2256))
162
233
  - Bump `@metamask/snaps-registry` to `^3.0.1` ([#2255](https://github.com/MetaMask/snaps/pull/2255))
163
234
  - Bump `@metamask/json-rpc-engine` to `^7.3.3` ([#2247](https://github.com/MetaMask/snaps/pull/2247))
164
235
 
165
236
  ## [6.0.2]
237
+
166
238
  ### Changed
239
+
167
240
  - Improve timeout handling when the execution environment fails to load ([#2242](https://github.com/MetaMask/snaps/pull/2242))
168
241
 
169
242
  ## [6.0.1]
243
+
170
244
  ### Fixed
245
+
171
246
  - Fix minor build configuration problems ([#2220](https://github.com/MetaMask/snaps/pull/2220))
172
247
 
173
248
  ## [6.0.0]
249
+
174
250
  ### Changed
251
+
175
252
  - **BREAKING:** Update ESM build to be fully compliant with the ESM standard ([#2210](https://github.com/MetaMask/snaps/pull/2210))
176
253
  - **BREAKING:** Move Node.js exports to separate export ([#2210](https://github.com/MetaMask/snaps/pull/2210))
177
254
  - The default export is now browser-compatible.
@@ -179,20 +256,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
179
256
  - Bump `@metamask/rpc-errors` to `^6.2.1` ([#2209](https://github.com/MetaMask/snaps/pull/2209))
180
257
 
181
258
  ### Fixed
259
+
182
260
  - Add sizing limits for custom UI ([#2199](https://github.com/MetaMask/snaps/pull/2199))
183
261
 
184
262
  ## [5.0.1]
263
+
185
264
  ### Fixed
265
+
186
266
  - Fix issue installing non-allowlisted Snaps in allowlist mode ([#2196](https://github.com/MetaMask/snaps/pull/2196))
187
267
 
188
268
  ## [5.0.0]
269
+
189
270
  ### Added
271
+
190
272
  - Add support for dynamic user interfaces ([#1465](https://github.com/MetaMask/snaps/pull/1465), [#2126](https://github.com/MetaMask/snaps/pull/2126), [#2144](https://github.com/MetaMask/snaps/pull/2144), [#2152](https://github.com/MetaMask/snaps/pull/2152), [#2143](https://github.com/MetaMask/snaps/pull/2143))
191
273
  - Add support for Snap defined execution timeouts ([#2098](https://github.com/MetaMask/snaps/pull/2098))
192
274
  - A Snap can now define `maxRequestTime` to extend or shorten its execution timeout.
193
275
  - Add `WebViewExecutionService` for mobile execution ([#2005](https://github.com/MetaMask/snaps/pull/2005))
194
276
 
195
277
  ### Changed
278
+
196
279
  - Loosen allowlist requirements ([#1672](https://github.com/MetaMask/snaps/pull/1672))
197
280
  - Snaps with certain permissions can now be installed without being allowlisted.
198
281
  - Reintroduce `DecompressionStream` for improved installation performance ([#2110](https://github.com/MetaMask/snaps/pull/2110))
@@ -202,60 +285,79 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
202
285
  - Pass localized snap name to SubjectMetadataController ([#2157](https://github.com/MetaMask/snaps/pull/2157))
203
286
 
204
287
  ### Removed
288
+
205
289
  - **BREAKING:** Remove endowment permission specifications from this package ([#2155](https://github.com/MetaMask/snaps/pull/2155))
206
290
  - They can now be found in `snaps-rpc-methods`.
207
291
 
208
292
  ## [4.1.0]
293
+
209
294
  ### Added
295
+
210
296
  - Add support for signature insights ([#2074](https://github.com/MetaMask/snaps/pull/2074))
211
297
  - Add support for initial connections ([#2048](https://github.com/MetaMask/snaps/pull/2048))
212
298
  - Add support for preinstalled snaps ([#2008](https://github.com/MetaMask/snaps/pull/2008))
213
299
  - Add additional install events ([#2087](https://github.com/MetaMask/snaps/pull/2087))
214
300
 
215
301
  ### Changed
302
+
216
303
  - Bump several MetaMask dependencies ([#2086](https://github.com/MetaMask/snaps/pull/2086), [#2100](https://github.com/MetaMask/snaps/pull/2100))
217
304
 
218
305
  ## [4.0.0]
306
+
219
307
  ### Changed
308
+
220
309
  - **BREAKING:** Remove `:snapAdded` event ([#2073](https://github.com/MetaMask/snaps/pull/2073))
221
310
  - **BREAKING:** Remove `:snapRemoved` event ([#2076](https://github.com/MetaMask/snaps/pull/2076))
222
311
  - Populate subject metadata when snaps are added to state ([#2069](https://github.com/MetaMask/snaps/pull/2069))
223
312
 
224
313
  ## [3.6.0]
314
+
225
315
  ### Changed
316
+
226
317
  - Revert usage of `DecompressionStream` ([#2052](https://github.com/MetaMask/snaps/pull/2052))
227
318
  - Refactor `NpmLocation` class ([#2038](https://github.com/MetaMask/snaps/pull/2038))
228
319
  - Most logic is now located in `BaseNpmLocation`, making it easier to extend without duplication.
229
320
  - Bump several MetaMask dependencies ([#2053](https://github.com/MetaMask/snaps/pull/2053), [#2061](https://github.com/MetaMask/snaps/pull/2061), [#2064](https://github.com/MetaMask/snaps/pull/2064), [#2065](https://github.com/MetaMask/snaps/pull/2065), [#2067](https://github.com/MetaMask/snaps/pull/2067))
230
321
 
231
322
  ### Removed
323
+
232
324
  - Remove support for object-like syntax for cronjobs ([#2057](https://github.com/MetaMask/snaps/pull/2057))
233
325
  - Since this never worked in the first place we aren't marking it as breaking.
234
326
 
235
327
  ## [3.5.1]
328
+
236
329
  ### Changed
330
+
237
331
  - Improve `SnapController` constructor types ([#2023](https://github.com/MetaMask/snaps/pull/2023))
238
332
  - Bump `snaps-registry` ([#2020](https://github.com/MetaMask/snaps/pull/2020))
239
333
 
240
334
  ## [3.5.0]
335
+
241
336
  ### Changed
337
+
242
338
  - Reduce memory usage by removing source code and state from runtime ([#2009](https://github.com/MetaMask/snaps/pull/2009))
243
339
  - Improve base64 encoding/decoding speeds ([#1985](https://github.com/MetaMask/snaps/pull/1985))
244
340
  - Use `DecompressionStream` for NPM fetching when available ([#1971](https://github.com/MetaMask/snaps/pull/1971))
245
341
  - Bump several MetaMask dependencies ([#1989](https://github.com/MetaMask/snaps/pull/1989), [#1993](https://github.com/MetaMask/snaps/pull/1993), [#1987](https://github.com/MetaMask/snaps/pull/1987), [#1983](https://github.com/MetaMask/snaps/pull/1983))
246
342
 
247
343
  ### Fixed
344
+
248
345
  - Fix idle snap timeout for unused snap ([#2010](https://github.com/MetaMask/snaps/pull/2010))
249
346
 
250
347
  ## [3.4.1]
348
+
251
349
  ### Changed
350
+
252
351
  - Bump several MetaMask dependencies ([#1964](https://github.com/MetaMask/snaps/pull/1964), [#1961](https://github.com/MetaMask/snaps/pull/1961))
253
352
 
254
353
  ### Fixed
354
+
255
355
  - Fix a few issues with passing non-JSON-serializable values ([#1974](https://github.com/MetaMask/snaps/pull/1974))
256
356
 
257
357
  ## [3.4.0]
358
+
258
359
  ### Changed
360
+
259
361
  - Use `SubtleCrypto` for checksum calculation if available ([#1953](https://github.com/MetaMask/snaps/pull/1953))
260
362
  - This reduces the time of the checksum calculation by up to 95% in some
261
363
  environments.
@@ -264,32 +366,43 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
264
366
  - `@metamask/snaps-ui` packages.
265
367
 
266
368
  ### Fixed
369
+
267
370
  - Fix support for transaction insight Snaps returning `null` ([#1952](https://github.com/MetaMask/snaps/pull/1952))
268
371
 
269
372
  ## [3.3.0]
373
+
270
374
  ### Added
375
+
271
376
  - Add manifest localization functionality ([#1889](https://github.com/MetaMask/snaps/pull/1889))
272
377
  - Add support for unencrypted storage using `snap_manageState` ([#1902](https://github.com/MetaMask/snaps/pull/1902))
273
378
  - Add `OnHomePage` export ([#1896](https://github.com/MetaMask/snaps/pull/1896))
274
379
 
275
380
  ## [3.2.0]
381
+
276
382
  ### Added
383
+
277
384
  - Add support for links in custom UI and notifications ([#1814](https://github.com/MetaMask/snaps/pull/1814))
278
385
 
279
386
  ### Fixed
387
+
280
388
  - Fix an issue where snaps throwing a `SnapError` would be allowed to run for longer than expected ([#1897](https://github.com/MetaMask/snaps/pull/1897))
281
389
 
282
390
  ## [3.1.1]
391
+
283
392
  ### Fixed
393
+
284
394
  - Fix a few issues with allowlist version resolving ([#1888](https://github.com/MetaMask/snaps/pull/1888))
285
395
 
286
396
  ## [3.1.0]
397
+
287
398
  ### Added
399
+
288
400
  - Add static file API ([#1836](https://github.com/MetaMask/snaps/pull/1836))
289
401
  - This adds a `snap_getFile` method, which Snaps can use to load files.
290
402
  - Add `origin` parameter to `snapInstalled` and `snapUpdated` events ([#1867](https://github.com/MetaMask/snaps/pull/1867))
291
403
 
292
404
  ### Changed
405
+
293
406
  - Improve error handling ([#1841](https://github.com/MetaMask/snaps/pull/1841))
294
407
  - Snaps can now throw a `SnapError`, without causing the Snap to crash.
295
408
  - Bump `tar-stream` from `^2.2.0` to `^3.1.6` ([#1853](https://github.com/MetaMask/snaps/pull/1853))
@@ -297,77 +410,106 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
297
410
  - Remove snap errors from state ([#1837](https://github.com/MetaMask/snaps/pull/1837))
298
411
 
299
412
  ### Fixed
413
+
300
414
  - Try to match requested versions with an allowlisted version ([#1877](https://github.com/MetaMask/snaps/pull/1877))
301
415
  - Improve performance when installing snaps with a static version ([#1878](https://github.com/MetaMask/snaps/pull/1878))
302
416
  - Stop persisting snaps in the installing state ([#1876](https://github.com/MetaMask/snaps/pull/1876))
303
417
 
304
418
  ## [3.0.0]
419
+
305
420
  ### Added
421
+
306
422
  - Add keyring export and endowment ([#1787](https://github.com/MetaMask/snaps/pull/1787))
307
423
  - Add optional `allowedOrigins` field to `endowment:rpc` ([#1822](https://github.com/MetaMask/snaps/pull/1822))
308
424
  - This can be used to only accept certain origins in your Snap.
309
425
 
310
426
  ### Changed
427
+
311
428
  - **BREAKING:** Bump minimum Node.js version to `^18.16.0` ([#1741](https://github.com/MetaMask/snaps/pull/1741))
312
429
 
313
430
  ## [2.0.2]
431
+
314
432
  ### Added
433
+
315
434
  - Add `SnapController:snapUninstalled` event ([#1800](https://github.com/MetaMask/snaps/pull/1800))
316
435
 
317
436
  ### Fixed
437
+
318
438
  - Fix some issues with SnapController events ([#1800](https://github.com/MetaMask/snaps/pull/1800))
319
439
  - Fix an issue where cronjobs would continually be executed on init ([#1790](https://github.com/MetaMask/snaps/pull/1790))
320
440
 
321
441
  ## [2.0.1]
442
+
322
443
  ### Changed
444
+
323
445
  - Remove deprecated `endowment:long-running` ([#1751](https://github.com/MetaMask/snaps/pull/1751))
324
446
 
325
447
  ## [2.0.0]
448
+
326
449
  ### Changed
450
+
327
451
  - Initial stable release from main branch ([#1757](https://github.com/MetaMask/snaps/pull/1757))
328
452
 
329
453
  ## [0.39.0-flask.1]
454
+
330
455
  ### Added
456
+
331
457
  - Add `onNameLookup` export ([#1394](https://github.com/MetaMask/snaps/pull/1394))
332
458
 
333
459
  ### Changed
460
+
334
461
  - Remove `pump` ([#1730](https://github.com/MetaMask/snaps/pull/1730))
335
462
  - Bump `metamask/utils` and `metamask/snaps-registry` ([#1738](https://github.com/MetaMask/snaps/pull/1738))
336
463
 
337
464
  ### Fixed
465
+
338
466
  - Fix cronjob running on disabled snaps ([#1743](https://github.com/MetaMask/snaps/pull/1743))
339
467
 
340
468
  ## [0.38.3-flask.1]
469
+
341
470
  ### Changed
471
+
342
472
  - Bump `@metamask/post-message-stream` from 6.1.2 to 7.0.0 ([#1707](https://github.com/MetaMask/snaps/pull/1707), [#1724](https://github.com/MetaMask/snaps/pull/1724))
343
473
  - Bump `@metamask/utils` and `@metamask/snaps-registry` ([#1694](https://github.com/MetaMask/snaps/pull/1694))
344
474
 
345
475
  ### Fixed
476
+
346
477
  - Fix unpacking zero byte files from NPM ([#1708](https://github.com/MetaMask/snaps/pull/1708))
347
478
 
348
479
  ## [0.38.2-flask.1]
480
+
349
481
  ### Fixed
482
+
350
483
  - Remove unused dependencies ([#1680](https://github.com/MetaMask/snaps/pull/1680))
351
484
 
352
485
  ## [0.38.1-flask.1]
486
+
353
487
  ### Fixed
488
+
354
489
  - Fix parallel usage of registry ([#1669](https://github.com/MetaMask/snaps/pull/1669))
355
490
 
356
491
  ## [0.38.0-flask.1]
492
+
357
493
  ### Added
494
+
358
495
  - Add `onInstall` and `onUpdate` lifecycle hooks ([#1643](https://github.com/MetaMask/snaps/pull/1643))
359
496
 
360
497
  ### Changed
498
+
361
499
  - Make `updateBlockedSnaps` update the registry ([#1625](https://github.com/MetaMask/snaps/pull/1625))
362
500
  - Move source code and snap state back to controller state ([#1634](https://github.com/MetaMask/snaps/pull/1634))
363
501
 
364
502
  ## [0.37.2-flask.1]
503
+
365
504
  ### Changed
505
+
366
506
  - Release package independently ([#1600](https://github.com/MetaMask/snaps/pull/1600))
367
507
  - The version of the package no longer needs to match the version of all other
368
508
  MetaMask Snaps packages.
369
509
 
370
- [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@9.6.0...HEAD
510
+ [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@9.8.0...HEAD
511
+ [9.8.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@9.7.0...@metamask/snaps-controllers@9.8.0
512
+ [9.7.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@9.6.0...@metamask/snaps-controllers@9.7.0
371
513
  [9.6.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@9.5.0...@metamask/snaps-controllers@9.6.0
372
514
  [9.5.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@9.4.0...@metamask/snaps-controllers@9.5.0
373
515
  [9.4.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-controllers@9.3.1...@metamask/snaps-controllers@9.4.0
@@ -1,10 +1,12 @@
1
+ import { createRequire as $createRequire } from "module";
2
+ const $require = $createRequire(import.meta.url);
1
3
  import $metamaskpostmessagestream from "@metamask/post-message-stream";
2
4
  const { ProcessParentMessageStream } = $metamaskpostmessagestream;
3
5
  import { fork } from "child_process";
4
6
  import { AbstractExecutionService } from "../index.mjs";
5
7
  export class NodeProcessExecutionService extends AbstractExecutionService {
6
8
  async initEnvStream() {
7
- const worker = fork(require.resolve('@metamask/snaps-execution-environments/dist/browserify/node-process/bundle.js'), {
9
+ const worker = fork($require.resolve('@metamask/snaps-execution-environments/dist/browserify/node-process/bundle.js'), {
8
10
  stdio: 'pipe',
9
11
  });
10
12
  // Capturing `stdout` and `stderr` from the worker prevents the worker from
@@ -1 +1 @@
1
- {"version":3,"file":"NodeProcessExecutionService.mjs","sourceRoot":"","sources":["../../../src/services/node-js/NodeProcessExecutionService.ts"],"names":[],"mappings":";;AAGA,OAAO,EAAE,IAAI,EAAE,sBAAsB;AAGrC,OAAO,EAAE,wBAAwB,EAAE,qBAAW;AAE9C,MAAM,OAAO,2BAA4B,SAAQ,wBAAsC;IAC3E,KAAK,CAAC,aAAa;QAI3B,MAAM,MAAM,GAAG,IAAI,CACjB,OAAO,CAAC,OAAO,CACb,+EAA+E,CAChF,EACD;YACE,KAAK,EAAE,MAAM;SACd,CACF,CAAC;QAEF,2EAA2E;QAC3E,mEAAmE;QACnE,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YACjC,sCAAsC;YACtC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YACjC,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,IAAI,0BAA0B,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QACnE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7C,CAAC;IAES,YAAY,CAAC,UAA0C;QAC/D,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import type { BasePostMessageStream } from '@metamask/post-message-stream';\nimport { ProcessParentMessageStream } from '@metamask/post-message-stream';\nimport type { ChildProcess } from 'child_process';\nimport { fork } from 'child_process';\n\nimport type { TerminateJobArgs } from '..';\nimport { AbstractExecutionService } from '..';\n\nexport class NodeProcessExecutionService extends AbstractExecutionService<ChildProcess> {\n protected async initEnvStream(): Promise<{\n worker: ChildProcess;\n stream: BasePostMessageStream;\n }> {\n const worker = fork(\n require.resolve(\n '@metamask/snaps-execution-environments/dist/browserify/node-process/bundle.js',\n ),\n {\n stdio: 'pipe',\n },\n );\n\n // Capturing `stdout` and `stderr` from the worker prevents the worker from\n // writing to them directly, making it easier to capture them Jest.\n worker.stdout?.on('data', (data) => {\n // eslint-disable-next-line no-console\n console.log(data.toString());\n });\n\n worker.stderr?.on('data', (data) => {\n // eslint-disable-next-line no-console\n console.error(data.toString());\n });\n\n const stream = new ProcessParentMessageStream({ process: worker });\n return Promise.resolve({ worker, stream });\n }\n\n protected terminateJob(jobWrapper: TerminateJobArgs<ChildProcess>): void {\n jobWrapper.worker?.kill();\n }\n}\n"]}
1
+ {"version":3,"file":"NodeProcessExecutionService.mjs","sourceRoot":"","sources":["../../../src/services/node-js/NodeProcessExecutionService.ts"],"names":[],"mappings":";;;;AAGA,OAAO,EAAE,IAAI,EAAE,sBAAsB;AAGrC,OAAO,EAAE,wBAAwB,EAAE,qBAAW;AAE9C,MAAM,OAAO,2BAA4B,SAAQ,wBAAsC;IAC3E,KAAK,CAAC,aAAa;QAI3B,MAAM,MAAM,GAAG,IAAI,kBAEf,+EAA+E,GAEjF;YACE,KAAK,EAAE,MAAM;SACd,CACF,CAAC;QAEF,2EAA2E;QAC3E,mEAAmE;QACnE,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YACjC,sCAAsC;YACtC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YACjC,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,IAAI,0BAA0B,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QACnE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7C,CAAC;IAES,YAAY,CAAC,UAA0C;QAC/D,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import type { BasePostMessageStream } from '@metamask/post-message-stream';\nimport { ProcessParentMessageStream } from '@metamask/post-message-stream';\nimport type { ChildProcess } from 'child_process';\nimport { fork } from 'child_process';\n\nimport type { TerminateJobArgs } from '..';\nimport { AbstractExecutionService } from '..';\n\nexport class NodeProcessExecutionService extends AbstractExecutionService<ChildProcess> {\n protected async initEnvStream(): Promise<{\n worker: ChildProcess;\n stream: BasePostMessageStream;\n }> {\n const worker = fork(\n require.resolve(\n '@metamask/snaps-execution-environments/dist/browserify/node-process/bundle.js',\n ),\n {\n stdio: 'pipe',\n },\n );\n\n // Capturing `stdout` and `stderr` from the worker prevents the worker from\n // writing to them directly, making it easier to capture them Jest.\n worker.stdout?.on('data', (data) => {\n // eslint-disable-next-line no-console\n console.log(data.toString());\n });\n\n worker.stderr?.on('data', (data) => {\n // eslint-disable-next-line no-console\n console.error(data.toString());\n });\n\n const stream = new ProcessParentMessageStream({ process: worker });\n return Promise.resolve({ worker, stream });\n }\n\n protected terminateJob(jobWrapper: TerminateJobArgs<ChildProcess>): void {\n jobWrapper.worker?.kill();\n }\n}\n"]}
@@ -1,3 +1,5 @@
1
+ import { createRequire as $createRequire } from "module";
2
+ const $require = $createRequire(import.meta.url);
1
3
  import $metamaskpostmessagestream from "@metamask/post-message-stream";
2
4
  const { ThreadParentMessageStream } = $metamaskpostmessagestream;
3
5
  // eslint-disable-next-line @typescript-eslint/no-shadow
@@ -5,7 +7,7 @@ import { Worker } from "worker_threads";
5
7
  import { AbstractExecutionService } from "../index.mjs";
6
8
  export class NodeThreadExecutionService extends AbstractExecutionService {
7
9
  async initEnvStream() {
8
- const worker = new Worker(require.resolve('@metamask/snaps-execution-environments/dist/browserify/node-thread/bundle.js'), {
10
+ const worker = new Worker($require.resolve('@metamask/snaps-execution-environments/dist/browserify/node-thread/bundle.js'), {
9
11
  stdout: true,
10
12
  stderr: true,
11
13
  });
@@ -1 +1 @@
1
- {"version":3,"file":"NodeThreadExecutionService.mjs","sourceRoot":"","sources":["../../../src/services/node-js/NodeThreadExecutionService.ts"],"names":[],"mappings":";;AAEA,wDAAwD;AACxD,OAAO,EAAE,MAAM,EAAE,uBAAuB;AAGxC,OAAO,EAAE,wBAAwB,EAAE,qBAAW;AAE9C,MAAM,OAAO,0BAA2B,SAAQ,wBAAgC;IACpE,KAAK,CAAC,aAAa;QAI3B,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB,OAAO,CAAC,OAAO,CACb,8EAA8E,CAC/E,EACD;YACE,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,IAAI;SACb,CACF,CAAC;QAEF,2EAA2E;QAC3E,mEAAmE;QACnE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YAChC,sCAAsC;YACtC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YAChC,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,IAAI,yBAAyB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACjE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7C,CAAC;IAES,KAAK,CAAC,YAAY,CAC1B,UAAoC;QAEpC,MAAM,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC;IACvC,CAAC;CACF","sourcesContent":["import type { BasePostMessageStream } from '@metamask/post-message-stream';\nimport { ThreadParentMessageStream } from '@metamask/post-message-stream';\n// eslint-disable-next-line @typescript-eslint/no-shadow\nimport { Worker } from 'worker_threads';\n\nimport type { TerminateJobArgs } from '..';\nimport { AbstractExecutionService } from '..';\n\nexport class NodeThreadExecutionService extends AbstractExecutionService<Worker> {\n protected async initEnvStream(): Promise<{\n worker: Worker;\n stream: BasePostMessageStream;\n }> {\n const worker = new Worker(\n require.resolve(\n '@metamask/snaps-execution-environments/dist/browserify/node-thread/bundle.js',\n ),\n {\n stdout: true,\n stderr: true,\n },\n );\n\n // Capturing `stdout` and `stderr` from the worker prevents the worker from\n // writing to them directly, making it easier to capture them Jest.\n worker.stdout.on('data', (data) => {\n // eslint-disable-next-line no-console\n console.log(data.toString());\n });\n\n worker.stderr.on('data', (data) => {\n // eslint-disable-next-line no-console\n console.error(data.toString());\n });\n\n const stream = new ThreadParentMessageStream({ thread: worker });\n return Promise.resolve({ worker, stream });\n }\n\n protected async terminateJob(\n jobWrapper: TerminateJobArgs<Worker>,\n ): Promise<void> {\n await jobWrapper.worker?.terminate();\n }\n}\n"]}
1
+ {"version":3,"file":"NodeThreadExecutionService.mjs","sourceRoot":"","sources":["../../../src/services/node-js/NodeThreadExecutionService.ts"],"names":[],"mappings":";;;;AAEA,wDAAwD;AACxD,OAAO,EAAE,MAAM,EAAE,uBAAuB;AAGxC,OAAO,EAAE,wBAAwB,EAAE,qBAAW;AAE9C,MAAM,OAAO,0BAA2B,SAAQ,wBAAgC;IACpE,KAAK,CAAC,aAAa;QAI3B,MAAM,MAAM,GAAG,IAAI,MAAM,kBAErB,8EAA8E,GAEhF;YACE,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,IAAI;SACb,CACF,CAAC;QAEF,2EAA2E;QAC3E,mEAAmE;QACnE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YAChC,sCAAsC;YACtC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YAChC,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,IAAI,yBAAyB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACjE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7C,CAAC;IAES,KAAK,CAAC,YAAY,CAC1B,UAAoC;QAEpC,MAAM,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC;IACvC,CAAC;CACF","sourcesContent":["import type { BasePostMessageStream } from '@metamask/post-message-stream';\nimport { ThreadParentMessageStream } from '@metamask/post-message-stream';\n// eslint-disable-next-line @typescript-eslint/no-shadow\nimport { Worker } from 'worker_threads';\n\nimport type { TerminateJobArgs } from '..';\nimport { AbstractExecutionService } from '..';\n\nexport class NodeThreadExecutionService extends AbstractExecutionService<Worker> {\n protected async initEnvStream(): Promise<{\n worker: Worker;\n stream: BasePostMessageStream;\n }> {\n const worker = new Worker(\n require.resolve(\n '@metamask/snaps-execution-environments/dist/browserify/node-thread/bundle.js',\n ),\n {\n stdout: true,\n stderr: true,\n },\n );\n\n // Capturing `stdout` and `stderr` from the worker prevents the worker from\n // writing to them directly, making it easier to capture them Jest.\n worker.stdout.on('data', (data) => {\n // eslint-disable-next-line no-console\n console.log(data.toString());\n });\n\n worker.stderr.on('data', (data) => {\n // eslint-disable-next-line no-console\n console.error(data.toString());\n });\n\n const stream = new ThreadParentMessageStream({ thread: worker });\n return Promise.resolve({ worker, stream });\n }\n\n protected async terminateJob(\n jobWrapper: TerminateJobArgs<Worker>,\n ): Promise<void> {\n await jobWrapper.worker?.terminate();\n }\n}\n"]}
@@ -26,7 +26,7 @@ export declare class OffscreenExecutionService extends ProxyExecutionService {
26
26
  */
27
27
  protected initEnvStream(jobId: string): Promise<{
28
28
  worker: string;
29
- stream: import("..").ProxyPostMessageStream;
29
+ stream: import("../index.cjs").ProxyPostMessageStream;
30
30
  }>;
31
31
  }
32
32
  export {};
@@ -26,7 +26,7 @@ export declare class OffscreenExecutionService extends ProxyExecutionService {
26
26
  */
27
27
  protected initEnvStream(jobId: string): Promise<{
28
28
  worker: string;
29
- stream: import("..").ProxyPostMessageStream;
29
+ stream: import("../index.mjs").ProxyPostMessageStream;
30
30
  }>;
31
31
  }
32
32
  export {};
@@ -16,7 +16,7 @@ export declare class WebViewExecutionService extends ProxyExecutionService {
16
16
  */
17
17
  protected initEnvStream(jobId: string): Promise<{
18
18
  worker: string;
19
- stream: import("..").ProxyPostMessageStream;
19
+ stream: import("../index.cjs").ProxyPostMessageStream;
20
20
  }>;
21
21
  }
22
22
  //# sourceMappingURL=WebViewExecutionService.d.cts.map
@@ -16,7 +16,7 @@ export declare class WebViewExecutionService extends ProxyExecutionService {
16
16
  */
17
17
  protected initEnvStream(jobId: string): Promise<{
18
18
  worker: string;
19
- stream: import("..").ProxyPostMessageStream;
19
+ stream: import("../index.mjs").ProxyPostMessageStream;
20
20
  }>;
21
21
  }
22
22
  //# sourceMappingURL=WebViewExecutionService.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WebViewMessageStream.cjs","sourceRoot":"","sources":["../../../src/services/webview/WebViewMessageStream.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,uEAAsE;AACtE,uEAAgF;AAChF,uDAAiD;AACjD,2CAAuE;AAcvE;;GAEG;AAEH,MAAa,oBAAqB,SAAQ,2CAAqB;IAO7D;;;;;;;;OAQG;IACH,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAqB;QACzD,KAAK,EAAE,CAAC;QAhBV,6CAAM;QAEN,+CAAQ;QAER,gDAAuC;QAcrC,uBAAA,IAAI,8BAAS,IAAI,MAAA,CAAC;QAClB,uBAAA,IAAI,gCAAW,MAAM,MAAA,CAAC;QAEtB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE7C,0DAA0D;QAC1D,yFAAyF;QACzF,UAAU,EAAE;aACT,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;YAChB,uBAAA,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S,CAAC,CAAC;QACtB,gCAAgC;QAChC,6DAA6D;QAC7D,uBAAA,IAAI,qCAAS,CAAC,yBAAyB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC3D,CAAC;CACF;AA5ED,oDA4EC","sourcesContent":["import type { PostMessageEvent } from '@metamask/post-message-stream';\nimport { BasePostMessageStream } from '@metamask/post-message-stream';\nimport { isValidStreamMessage } from '@metamask/post-message-stream/dist/utils';\nimport { logError } from '@metamask/snaps-utils';\nimport { assert, bytesToBase64, stringToBytes } from '@metamask/utils';\n\nexport type WebViewInterface = {\n injectJavaScript(js: string): void;\n registerMessageListener(listener: (event: PostMessageEvent) => void): void;\n unregisterMessageListener(listener: (event: PostMessageEvent) => void): void;\n};\n\ntype WebViewStreamArgs = {\n name: string;\n target: string;\n getWebView: () => Promise<WebViewInterface>;\n};\n\n/**\n * A special postMessage stream used to interface with a WebView.\n */\n\nexport class WebViewMessageStream extends BasePostMessageStream {\n #name;\n\n #target;\n\n #webView: WebViewInterface | undefined;\n\n /**\n * Creates a stream for communicating with other streams inside a WebView.\n *\n * @param args - Options bag.\n * @param args.name - The name of the stream. Used to differentiate between\n * multiple streams sharing the same window object.\n * @param args.target - The name of the stream to exchange messages with.\n * @param args.getWebView - A asynchronous getter for the webview.\n */\n constructor({ name, target, getWebView }: WebViewStreamArgs) {\n super();\n\n this.#name = name;\n this.#target = target;\n\n this._onMessage = this._onMessage.bind(this);\n\n // This is a bit atypical from other post-message streams.\n // We have to wait for the WebView to fully load before we can continue using the stream.\n getWebView()\n .then((webView) => {\n this.#webView = webView;\n // This method is already bound.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n webView.registerMessageListener(this._onMessage);\n this._handshake();\n })\n .catch((error) => {\n logError(error);\n });\n }\n\n protected _postMessage(data: unknown): void {\n assert(this.#webView);\n const json = JSON.stringify({\n target: this.#target,\n data,\n });\n\n // To prevent XSS, we base64 encode the message before injecting it.\n // This adds significant performance overhead.\n // TODO: Should we use mobile native base64 here?\n const bytes = stringToBytes(json);\n const base64 = bytesToBase64(bytes);\n this.#webView.injectJavaScript(`window.postMessage('${base64}')`);\n }\n\n private _onMessage(event: PostMessageEvent): void {\n if (typeof event.data !== 'string') {\n return;\n }\n\n const message = JSON.parse(event.data);\n\n // Notice that we don't check targetWindow or targetOrigin here.\n // This doesn't seem possible to do in RN.\n if (!isValidStreamMessage(message) || message.target !== this.#name) {\n return;\n }\n\n this._onData(message.data);\n }\n\n _destroy() {\n assert(this.#webView);\n // This method is already bound.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.#webView.unregisterMessageListener(this._onMessage);\n }\n}\n"]}
1
+ {"version":3,"file":"WebViewMessageStream.cjs","sourceRoot":"","sources":["../../../src/services/webview/WebViewMessageStream.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,uEAAsE;AACtE,uEAAgF;AAChF,uDAAiD;AACjD,2CAAuE;AAcvE;;GAEG;AACH,MAAa,oBAAqB,SAAQ,2CAAqB;IAO7D;;;;;;;;OAQG;IACH,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAqB;QACzD,KAAK,EAAE,CAAC;QAhBV,6CAAM;QAEN,+CAAQ;QAER,gDAAuC;QAcrC,uBAAA,IAAI,8BAAS,IAAI,MAAA,CAAC;QAClB,uBAAA,IAAI,gCAAW,MAAM,MAAA,CAAC;QAEtB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE7C,0DAA0D;QAC1D,yFAAyF;QACzF,UAAU,EAAE;aACT,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;YAChB,uBAAA,IAAI,iCAAY,OAAO,MAAA,CAAC;YACxB,gCAAgC;YAChC,6DAA6D;YAC7D,OAAO,CAAC,uBAAuB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACjD,IAAI,CAAC,UAAU,EAAE,CAAC;QACpB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KA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asePostMessageStream } from '@metamask/post-message-stream';\nimport { isValidStreamMessage } from '@metamask/post-message-stream/dist/utils';\nimport { logError } from '@metamask/snaps-utils';\nimport { assert, bytesToBase64, stringToBytes } from '@metamask/utils';\n\nexport type WebViewInterface = {\n injectJavaScript(js: string): void;\n registerMessageListener(listener: (event: PostMessageEvent) => void): void;\n unregisterMessageListener(listener: (event: PostMessageEvent) => void): void;\n};\n\nexport type WebViewStreamArgs = {\n name: string;\n target: string;\n getWebView: () => Promise<WebViewInterface>;\n};\n\n/**\n * A special postMessage stream used to interface with a WebView.\n */\nexport class WebViewMessageStream extends BasePostMessageStream {\n #name;\n\n #target;\n\n #webView: WebViewInterface | undefined;\n\n /**\n * Creates a stream for communicating with other streams inside a WebView.\n *\n * @param args - Options bag.\n * @param args.name - The name of the stream. Used to differentiate between\n * multiple streams sharing the same window object.\n * @param args.target - The name of the stream to exchange messages with.\n * @param args.getWebView - A asynchronous getter for the webview.\n */\n constructor({ name, target, getWebView }: WebViewStreamArgs) {\n super();\n\n this.#name = name;\n this.#target = target;\n\n this._onMessage = this._onMessage.bind(this);\n\n // This is a bit atypical from other post-message streams.\n // We have to wait for the WebView to fully load before we can continue using the stream.\n getWebView()\n .then((webView) => {\n this.#webView = webView;\n // This method is already bound.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n webView.registerMessageListener(this._onMessage);\n this._handshake();\n })\n .catch((error) => {\n logError(error);\n });\n }\n\n protected _postMessage(data: unknown): void {\n assert(this.#webView);\n const json = JSON.stringify({\n target: this.#target,\n data,\n });\n\n // To prevent XSS, we base64 encode the message before injecting it.\n // This adds significant performance overhead.\n // TODO: Should we use mobile native base64 here?\n const bytes = stringToBytes(json);\n const base64 = bytesToBase64(bytes);\n this.#webView.injectJavaScript(`window.postMessage('${base64}')`);\n }\n\n private _onMessage(event: PostMessageEvent): void {\n if (typeof event.data !== 'string') {\n return;\n }\n\n const message = JSON.parse(event.data);\n\n // Notice that we don't check targetWindow or targetOrigin here.\n // This doesn't seem possible to do in RN.\n if (!isValidStreamMessage(message) || message.target !== this.#name) {\n return;\n }\n\n this._onData(message.data);\n }\n\n _destroy() {\n assert(this.#webView);\n // This method is already bound.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.#webView.unregisterMessageListener(this._onMessage);\n }\n}\n"]}
@@ -5,7 +5,7 @@ export type WebViewInterface = {
5
5
  registerMessageListener(listener: (event: PostMessageEvent) => void): void;
6
6
  unregisterMessageListener(listener: (event: PostMessageEvent) => void): void;
7
7
  };
8
- type WebViewStreamArgs = {
8
+ export type WebViewStreamArgs = {
9
9
  name: string;
10
10
  target: string;
11
11
  getWebView: () => Promise<WebViewInterface>;
@@ -29,5 +29,4 @@ export declare class WebViewMessageStream extends BasePostMessageStream {
29
29
  private _onMessage;
30
30
  _destroy(): void;
31
31
  }
32
- export {};
33
32
  //# sourceMappingURL=WebViewMessageStream.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WebViewMessageStream.d.cts","sourceRoot":"","sources":["../../../src/services/webview/WebViewMessageStream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,sCAAsC;AACtE,OAAO,EAAE,qBAAqB,EAAE,sCAAsC;AAKtE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,uBAAuB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GAAG,IAAI,CAAC;IAC3E,yBAAyB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GAAG,IAAI,CAAC;CAC9E,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC7C,CAAC;AAEF;;GAEG;AAEH,qBAAa,oBAAqB,SAAQ,qB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