@metamask/snaps-execution-environments 8.2.0 → 9.0.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 (31) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/common/BaseSnapExecutor.cjs +79 -61
  3. package/dist/common/BaseSnapExecutor.cjs.map +1 -1
  4. package/dist/common/BaseSnapExecutor.mjs +79 -61
  5. package/dist/common/BaseSnapExecutor.mjs.map +1 -1
  6. package/dist/common/endowments/crypto.cjs +5 -15
  7. package/dist/common/endowments/crypto.cjs.map +1 -1
  8. package/dist/common/endowments/crypto.d.cts +10 -4
  9. package/dist/common/endowments/crypto.d.cts.map +1 -1
  10. package/dist/common/endowments/crypto.d.mts +10 -4
  11. package/dist/common/endowments/crypto.d.mts.map +1 -1
  12. package/dist/common/endowments/crypto.mjs +5 -17
  13. package/dist/common/endowments/crypto.mjs.map +1 -1
  14. package/dist/common/endowments/network.cjs +39 -52
  15. package/dist/common/endowments/network.cjs.map +1 -1
  16. package/dist/common/endowments/network.mjs +39 -52
  17. package/dist/common/endowments/network.mjs.map +1 -1
  18. package/dist/proxy/ProxySnapExecutor.cjs +72 -69
  19. package/dist/proxy/ProxySnapExecutor.cjs.map +1 -1
  20. package/dist/proxy/ProxySnapExecutor.mjs +71 -68
  21. package/dist/proxy/ProxySnapExecutor.mjs.map +1 -1
  22. package/dist/webpack/iframe/bundle.js +1 -1
  23. package/dist/webpack/iframe/index.html +854 -406
  24. package/dist/webpack/node-process/bundle.js +1 -1
  25. package/dist/webpack/node-thread/bundle.js +1 -1
  26. package/dist/webpack/webview/index.html +855 -407
  27. package/dist/webview/WebViewExecutorStream.cjs +9 -22
  28. package/dist/webview/WebViewExecutorStream.cjs.map +1 -1
  29. package/dist/webview/WebViewExecutorStream.mjs +9 -22
  30. package/dist/webview/WebViewExecutorStream.mjs.map +1 -1
  31. package/package.json +7 -7
@@ -1,20 +1,11 @@
1
1
  "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var _WebViewExecutorStream_name, _WebViewExecutorStream_target, _WebViewExecutorStream_targetWindow;
14
2
  Object.defineProperty(exports, "__esModule", { value: true });
15
3
  exports.WebViewExecutorStream = void 0;
16
4
  const post_message_stream_1 = require("@metamask/post-message-stream");
17
5
  class WebViewExecutorStream extends post_message_stream_1.BasePostMessageStream {
6
+ #name;
7
+ #target;
8
+ #targetWindow;
18
9
  /**
19
10
  * A special post-message-stream to be used by the WebView executor.
20
11
  *
@@ -31,12 +22,9 @@ class WebViewExecutorStream extends post_message_stream_1.BasePostMessageStream
31
22
  */
32
23
  constructor({ name, target, targetWindow }) {
33
24
  super();
34
- _WebViewExecutorStream_name.set(this, void 0);
35
- _WebViewExecutorStream_target.set(this, void 0);
36
- _WebViewExecutorStream_targetWindow.set(this, void 0);
37
- __classPrivateFieldSet(this, _WebViewExecutorStream_name, name, "f");
38
- __classPrivateFieldSet(this, _WebViewExecutorStream_target, target, "f");
39
- __classPrivateFieldSet(this, _WebViewExecutorStream_targetWindow, targetWindow, "f");
25
+ this.#name = name;
26
+ this.#target = target;
27
+ this.#targetWindow = targetWindow;
40
28
  this._onMessage = this._onMessage.bind(this);
41
29
  // This method is already bound.
42
30
  // eslint-disable-next-line @typescript-eslint/unbound-method
@@ -48,8 +36,8 @@ class WebViewExecutorStream extends post_message_stream_1.BasePostMessageStream
48
36
  * Reference: https://github.com/react-native-webview/react-native-webview/blob/master/docs/Guide.md?plain=1#L471
49
37
  */
50
38
  _postMessage(data) {
51
- __classPrivateFieldGet(this, _WebViewExecutorStream_targetWindow, "f").postMessage(JSON.stringify({
52
- target: __classPrivateFieldGet(this, _WebViewExecutorStream_target, "f"),
39
+ this.#targetWindow.postMessage(JSON.stringify({
40
+ target: this.#target,
53
41
  data,
54
42
  }));
55
43
  }
@@ -63,7 +51,7 @@ class WebViewExecutorStream extends post_message_stream_1.BasePostMessageStream
63
51
  const message = JSON.parse(event.data);
64
52
  // Notice that we don't check targetWindow or targetOrigin here.
65
53
  // This doesn't seem possible to do in RN.
66
- if (!(0, post_message_stream_1.isValidStreamMessage)(message) || message.target !== __classPrivateFieldGet(this, _WebViewExecutorStream_name, "f")) {
54
+ if (!(0, post_message_stream_1.isValidStreamMessage)(message) || message.target !== this.#name) {
67
55
  return;
68
56
  }
69
57
  this._onData(message.data);
@@ -75,5 +63,4 @@ class WebViewExecutorStream extends post_message_stream_1.BasePostMessageStream
75
63
  }
76
64
  }
77
65
  exports.WebViewExecutorStream = WebViewExecutorStream;
78
- _WebViewExecutorStream_name = new WeakMap(), _WebViewExecutorStream_target = new WeakMap(), _WebViewExecutorStream_targetWindow = new WeakMap();
79
66
  //# sourceMappingURL=WebViewExecutorStream.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"WebViewExecutorStream.cjs","sourceRoot":"","sources":["../../src/webview/WebViewExecutorStream.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,uEAGuC;AAQvC,MAAa,qBAAsB,SAAQ,2CAAqB;IAO9D;;;;;;;;;;;;;OAaG;IAEH,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAA6B;QACnE,KAAK,EAAE,CAAC;QAtBD,8CAAM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","sourcesContent":["import type { PostMessageEvent } from '@metamask/post-message-stream';\nimport {\n BasePostMessageStream,\n isValidStreamMessage,\n} from '@metamask/post-message-stream';\n\ntype WebViewExecutorStreamArgs = {\n name: string;\n target: string;\n targetWindow: Window['ReactNativeWebView'];\n};\n\nexport class WebViewExecutorStream extends BasePostMessageStream {\n readonly #name;\n\n readonly #target;\n\n readonly #targetWindow;\n\n /**\n * A special post-message-stream to be used by the WebView executor.\n *\n * This stream is different in a few ways:\n * - It expects data to be base64 encoded\n * - It stringifies the data it posts\n * - It does less validation of origins\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. child:WebView\n * @param args.target - The name of the stream to exchange messages with. parent:rnside\n * @param args.targetWindow - The window object of the target stream.\n */\n\n constructor({ name, target, targetWindow }: WebViewExecutorStreamArgs) {\n super();\n\n this.#name = name;\n this.#target = target;\n this.#targetWindow = targetWindow;\n\n this._onMessage = this._onMessage.bind(this);\n\n // This method is already bound.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n window.addEventListener('message', this._onMessage as any, false);\n\n this._handshake();\n }\n\n /**\n * Webview needs to receive strings only on postMessage. That's the main difference between this and the original window post message stream.\n * Reference: https://github.com/react-native-webview/react-native-webview/blob/master/docs/Guide.md?plain=1#L471\n */\n\n protected _postMessage(data: unknown): void {\n this.#targetWindow.postMessage(\n JSON.stringify({\n target: this.#target,\n data,\n }),\n );\n }\n\n // TODO: Either fix this lint violation or explain why it's necessary to\n // ignore.\n // eslint-disable-next-line no-restricted-syntax\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 // This method is already bound.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n window.removeEventListener('message', this._onMessage as any, false);\n }\n}\n"]}
1
+ {"version":3,"file":"WebViewExecutorStream.cjs","sourceRoot":"","sources":["../../src/webview/WebViewExecutorStream.ts"],"names":[],"mappings":";;;AACA,uEAGuC;AAQvC,MAAa,qBAAsB,SAAQ,2CAAqB;IACrD,KAAK,CAAC;IAEN,OAAO,CAAC;IAER,aAAa,CAAC;IAEvB;;;;;;;;;;;;;OAaG;IAEH,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAA6B;QACnE,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAElC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE7C,gCAAgC;QAChC,6DAA6D;QAC7D,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,UAAiB,EAAE,KAAK,CAAC,CAAC;QAElE,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAED;;;OAGG;IAEO,YAAY,CAAC,IAAa;QAClC,IAAI,CAAC,aAAa,CAAC,WAAW,CAC5B,IAAI,CAAC,SAAS,CAAC;YACb,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,IAAI;SACL,CAAC,CACH,CAAC;IACJ,CAAC;IAED,wEAAwE;IACxE,WAAW;IACX,gDAAgD;IACxC,UAAU,CAAC,KAAuB;QACxC,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACnC,OAAO;QACT,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEvC,gEAAgE;QAChE,0CAA0C;QAC1C,IAAI,CAAC,IAAA,0CAAoB,EAAC,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;YACpE,OAAO;QACT,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,QAAQ;QACN,gCAAgC;QAChC,6DAA6D;QAC7D,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,UAAiB,EAAE,KAAK,CAAC,CAAC;IACvE,CAAC;CACF;AA5ED,sDA4EC","sourcesContent":["import type { PostMessageEvent } from '@metamask/post-message-stream';\nimport {\n BasePostMessageStream,\n isValidStreamMessage,\n} from '@metamask/post-message-stream';\n\ntype WebViewExecutorStreamArgs = {\n name: string;\n target: string;\n targetWindow: Window['ReactNativeWebView'];\n};\n\nexport class WebViewExecutorStream extends BasePostMessageStream {\n readonly #name;\n\n readonly #target;\n\n readonly #targetWindow;\n\n /**\n * A special post-message-stream to be used by the WebView executor.\n *\n * This stream is different in a few ways:\n * - It expects data to be base64 encoded\n * - It stringifies the data it posts\n * - It does less validation of origins\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. child:WebView\n * @param args.target - The name of the stream to exchange messages with. parent:rnside\n * @param args.targetWindow - The window object of the target stream.\n */\n\n constructor({ name, target, targetWindow }: WebViewExecutorStreamArgs) {\n super();\n\n this.#name = name;\n this.#target = target;\n this.#targetWindow = targetWindow;\n\n this._onMessage = this._onMessage.bind(this);\n\n // This method is already bound.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n window.addEventListener('message', this._onMessage as any, false);\n\n this._handshake();\n }\n\n /**\n * Webview needs to receive strings only on postMessage. That's the main difference between this and the original window post message stream.\n * Reference: https://github.com/react-native-webview/react-native-webview/blob/master/docs/Guide.md?plain=1#L471\n */\n\n protected _postMessage(data: unknown): void {\n this.#targetWindow.postMessage(\n JSON.stringify({\n target: this.#target,\n data,\n }),\n );\n }\n\n // TODO: Either fix this lint violation or explain why it's necessary to\n // ignore.\n // eslint-disable-next-line no-restricted-syntax\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 // This method is already bound.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n window.removeEventListener('message', this._onMessage as any, false);\n }\n}\n"]}
@@ -1,17 +1,8 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _WebViewExecutorStream_name, _WebViewExecutorStream_target, _WebViewExecutorStream_targetWindow;
13
1
  import { BasePostMessageStream, isValidStreamMessage } from "@metamask/post-message-stream";
14
2
  export class WebViewExecutorStream extends BasePostMessageStream {
3
+ #name;
4
+ #target;
5
+ #targetWindow;
15
6
  /**
16
7
  * A special post-message-stream to be used by the WebView executor.
17
8
  *
@@ -28,12 +19,9 @@ export class WebViewExecutorStream extends BasePostMessageStream {
28
19
  */
29
20
  constructor({ name, target, targetWindow }) {
30
21
  super();
31
- _WebViewExecutorStream_name.set(this, void 0);
32
- _WebViewExecutorStream_target.set(this, void 0);
33
- _WebViewExecutorStream_targetWindow.set(this, void 0);
34
- __classPrivateFieldSet(this, _WebViewExecutorStream_name, name, "f");
35
- __classPrivateFieldSet(this, _WebViewExecutorStream_target, target, "f");
36
- __classPrivateFieldSet(this, _WebViewExecutorStream_targetWindow, targetWindow, "f");
22
+ this.#name = name;
23
+ this.#target = target;
24
+ this.#targetWindow = targetWindow;
37
25
  this._onMessage = this._onMessage.bind(this);
38
26
  // This method is already bound.
39
27
  // eslint-disable-next-line @typescript-eslint/unbound-method
@@ -45,8 +33,8 @@ export class WebViewExecutorStream extends BasePostMessageStream {
45
33
  * Reference: https://github.com/react-native-webview/react-native-webview/blob/master/docs/Guide.md?plain=1#L471
46
34
  */
47
35
  _postMessage(data) {
48
- __classPrivateFieldGet(this, _WebViewExecutorStream_targetWindow, "f").postMessage(JSON.stringify({
49
- target: __classPrivateFieldGet(this, _WebViewExecutorStream_target, "f"),
36
+ this.#targetWindow.postMessage(JSON.stringify({
37
+ target: this.#target,
50
38
  data,
51
39
  }));
52
40
  }
@@ -60,7 +48,7 @@ export class WebViewExecutorStream extends BasePostMessageStream {
60
48
  const message = JSON.parse(event.data);
61
49
  // Notice that we don't check targetWindow or targetOrigin here.
62
50
  // This doesn't seem possible to do in RN.
63
- if (!isValidStreamMessage(message) || message.target !== __classPrivateFieldGet(this, _WebViewExecutorStream_name, "f")) {
51
+ if (!isValidStreamMessage(message) || message.target !== this.#name) {
64
52
  return;
65
53
  }
66
54
  this._onData(message.data);
@@ -71,5 +59,4 @@ export class WebViewExecutorStream extends BasePostMessageStream {
71
59
  window.removeEventListener('message', this._onMessage, false);
72
60
  }
73
61
  }
74
- _WebViewExecutorStream_name = new WeakMap(), _WebViewExecutorStream_target = new WeakMap(), _WebViewExecutorStream_targetWindow = new WeakMap();
75
62
  //# sourceMappingURL=WebViewExecutorStream.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"WebViewExecutorStream.mjs","sourceRoot":"","sources":["../../src/webview/WebViewExecutorStream.ts"],"names":[],"m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,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,QAAQ;QACN,gCAAgC;QAChC,6DAA6D;QAC7D,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,UAAiB,EAAE,KAAK,CAAC,CAAC;IACvE,CAAC;CACF","sourcesContent":["import type { PostMessageEvent } from '@metamask/post-message-stream';\nimport {\n BasePostMessageStream,\n isValidStreamMessage,\n} from '@metamask/post-message-stream';\n\ntype WebViewExecutorStreamArgs = {\n name: string;\n target: string;\n targetWindow: Window['ReactNativeWebView'];\n};\n\nexport class WebViewExecutorStream extends BasePostMessageStream {\n readonly #name;\n\n readonly #target;\n\n readonly #targetWindow;\n\n /**\n * A special post-message-stream to be used by the WebView executor.\n *\n * This stream is different in a few ways:\n * - It expects data to be base64 encoded\n * - It stringifies the data it posts\n * - It does less validation of origins\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. child:WebView\n * @param args.target - The name of the stream to exchange messages with. parent:rnside\n * @param args.targetWindow - The window object of the target stream.\n */\n\n constructor({ name, target, targetWindow }: WebViewExecutorStreamArgs) {\n super();\n\n this.#name = name;\n this.#target = target;\n this.#targetWindow = targetWindow;\n\n this._onMessage = this._onMessage.bind(this);\n\n // This method is already bound.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n window.addEventListener('message', this._onMessage as any, false);\n\n this._handshake();\n }\n\n /**\n * Webview needs to receive strings only on postMessage. That's the main difference between this and the original window post message stream.\n * Reference: https://github.com/react-native-webview/react-native-webview/blob/master/docs/Guide.md?plain=1#L471\n */\n\n protected _postMessage(data: unknown): void {\n this.#targetWindow.postMessage(\n JSON.stringify({\n target: this.#target,\n data,\n }),\n );\n }\n\n // TODO: Either fix this lint violation or explain why it's necessary to\n // ignore.\n // eslint-disable-next-line no-restricted-syntax\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 // This method is already bound.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n window.removeEventListener('message', this._onMessage as any, false);\n }\n}\n"]}
1
+ {"version":3,"file":"WebViewExecutorStream.mjs","sourceRoot":"","sources":["../../src/webview/WebViewExecutorStream.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACrB,sCAAsC;AAQvC,MAAM,OAAO,qBAAsB,SAAQ,qBAAqB;IACrD,KAAK,CAAC;IAEN,OAAO,CAAC;IAER,aAAa,CAAC;IAEvB;;;;;;;;;;;;;OAaG;IAEH,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAA6B;QACnE,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAElC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE7C,gCAAgC;QAChC,6DAA6D;QAC7D,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,UAAiB,EAAE,KAAK,CAAC,CAAC;QAElE,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAED;;;OAGG;IAEO,YAAY,CAAC,IAAa;QAClC,IAAI,CAAC,aAAa,CAAC,WAAW,CAC5B,IAAI,CAAC,SAAS,CAAC;YACb,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,IAAI;SACL,CAAC,CACH,CAAC;IACJ,CAAC;IAED,wEAAwE;IACxE,WAAW;IACX,gDAAgD;IACxC,UAAU,CAAC,KAAuB;QACxC,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACnC,OAAO;QACT,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEvC,gEAAgE;QAChE,0CAA0C;QAC1C,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;YACpE,OAAO;QACT,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,QAAQ;QACN,gCAAgC;QAChC,6DAA6D;QAC7D,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,UAAiB,EAAE,KAAK,CAAC,CAAC;IACvE,CAAC;CACF","sourcesContent":["import type { PostMessageEvent } from '@metamask/post-message-stream';\nimport {\n BasePostMessageStream,\n isValidStreamMessage,\n} from '@metamask/post-message-stream';\n\ntype WebViewExecutorStreamArgs = {\n name: string;\n target: string;\n targetWindow: Window['ReactNativeWebView'];\n};\n\nexport class WebViewExecutorStream extends BasePostMessageStream {\n readonly #name;\n\n readonly #target;\n\n readonly #targetWindow;\n\n /**\n * A special post-message-stream to be used by the WebView executor.\n *\n * This stream is different in a few ways:\n * - It expects data to be base64 encoded\n * - It stringifies the data it posts\n * - It does less validation of origins\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. child:WebView\n * @param args.target - The name of the stream to exchange messages with. parent:rnside\n * @param args.targetWindow - The window object of the target stream.\n */\n\n constructor({ name, target, targetWindow }: WebViewExecutorStreamArgs) {\n super();\n\n this.#name = name;\n this.#target = target;\n this.#targetWindow = targetWindow;\n\n this._onMessage = this._onMessage.bind(this);\n\n // This method is already bound.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n window.addEventListener('message', this._onMessage as any, false);\n\n this._handshake();\n }\n\n /**\n * Webview needs to receive strings only on postMessage. That's the main difference between this and the original window post message stream.\n * Reference: https://github.com/react-native-webview/react-native-webview/blob/master/docs/Guide.md?plain=1#L471\n */\n\n protected _postMessage(data: unknown): void {\n this.#targetWindow.postMessage(\n JSON.stringify({\n target: this.#target,\n data,\n }),\n );\n }\n\n // TODO: Either fix this lint violation or explain why it's necessary to\n // ignore.\n // eslint-disable-next-line no-restricted-syntax\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 // This method is already bound.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n window.removeEventListener('message', this._onMessage as any, false);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/snaps-execution-environments",
3
- "version": "8.2.0",
3
+ "version": "9.0.0",
4
4
  "description": "Snap sandbox environments for executing SES javascript",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -71,8 +71,8 @@
71
71
  "@metamask/post-message-stream": "^10.0.0",
72
72
  "@metamask/providers": "^22.1.0",
73
73
  "@metamask/rpc-errors": "^7.0.2",
74
- "@metamask/snaps-sdk": "^7.1.0",
75
- "@metamask/snaps-utils": "^9.4.0",
74
+ "@metamask/snaps-sdk": "^8.0.0",
75
+ "@metamask/snaps-utils": "^10.0.0",
76
76
  "@metamask/superstruct": "^3.2.1",
77
77
  "@metamask/utils": "^11.4.0",
78
78
  "readable-stream": "^3.6.2"
@@ -84,8 +84,8 @@
84
84
  "@lavamoat/lavatube": "^1.0.0",
85
85
  "@lavamoat/webpack": "^0.9.0-beta.0",
86
86
  "@metamask/auto-changelog": "^5.0.2",
87
- "@swc/core": "1.3.78",
88
- "@swc/jest": "^0.2.26",
87
+ "@swc/core": "1.11.31",
88
+ "@swc/jest": "^0.2.38",
89
89
  "@testing-library/dom": "^10.4.0",
90
90
  "@ts-bridge/cli": "^0.6.1",
91
91
  "@types/jest": "^27.5.1",
@@ -108,7 +108,7 @@
108
108
  "prettier": "^3.3.3",
109
109
  "rimraf": "^4.1.2",
110
110
  "serve-handler": "^6.1.5",
111
- "ses": "^1.12.0",
111
+ "ses": "^1.13.0",
112
112
  "stream-browserify": "^3.0.0",
113
113
  "terser": "^5.17.7",
114
114
  "ts-loader": "^9.5.2",
@@ -122,7 +122,7 @@
122
122
  "webpack-merge": "^5.9.0"
123
123
  },
124
124
  "engines": {
125
- "node": "^18.16 || >=20"
125
+ "node": "^20 || >=22"
126
126
  },
127
127
  "publishConfig": {
128
128
  "access": "public",