@metamask/snaps-execution-environments 0.27.1 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/BaseSnapExecutor.d.ts +1 -1
- package/dist/common/BaseSnapExecutor.js +18 -5
- package/dist/common/BaseSnapExecutor.js.map +1 -1
- package/dist/common/endowments/commonEndowmentFactory.d.ts +19 -0
- package/dist/common/endowments/commonEndowmentFactory.js +69 -0
- package/dist/common/endowments/commonEndowmentFactory.js.map +1 -0
- package/dist/common/endowments/crypto.js +4 -1
- package/dist/common/endowments/crypto.js.map +1 -1
- package/dist/common/endowments/date.d.ts +15 -0
- package/dist/common/endowments/date.js +39 -0
- package/dist/common/endowments/date.js.map +1 -0
- package/dist/common/endowments/index.d.ts +1 -1
- package/dist/common/endowments/index.js +6 -6
- package/dist/common/endowments/index.js.map +1 -1
- package/dist/common/endowments/interval.js +7 -4
- package/dist/common/endowments/interval.js.map +1 -1
- package/dist/common/endowments/math.js +2 -2
- package/dist/common/endowments/math.js.map +1 -1
- package/dist/common/endowments/network.d.ts +1 -41
- package/dist/common/endowments/network.js +9 -207
- package/dist/common/endowments/network.js.map +1 -1
- package/dist/common/endowments/textDecoder.d.ts +10 -0
- package/dist/common/endowments/textDecoder.js +18 -0
- package/dist/common/endowments/textDecoder.js.map +1 -0
- package/dist/common/endowments/textEncoder.d.ts +10 -0
- package/dist/common/endowments/textEncoder.js +18 -0
- package/dist/common/endowments/textEncoder.js.map +1 -0
- package/dist/common/endowments/timeout.js +6 -4
- package/dist/common/endowments/timeout.js.map +1 -1
- package/dist/common/lockdown/lockdown-more.js +2 -1
- package/dist/common/lockdown/lockdown-more.js.map +1 -1
- package/dist/common/lockdown/lockdown.js +2 -1
- package/dist/common/lockdown/lockdown.js.map +1 -1
- package/dist/common/utils.d.ts +0 -16
- package/dist/common/utils.js +4 -43
- package/dist/common/utils.js.map +1 -1
- package/dist/common/validation.d.ts +8 -8
- package/dist/iframe/IFrameSnapExecutor.js +3 -2
- package/dist/iframe/IFrameSnapExecutor.js.map +1 -1
- package/dist/logging.d.ts +8 -0
- package/dist/logging.js +13 -0
- package/dist/logging.js.map +1 -0
- package/dist/node-process/ChildProcessSnapExecutor.js +3 -2
- package/dist/node-process/ChildProcessSnapExecutor.js.map +1 -1
- package/dist/node-thread/ThreadSnapExecutor.js +3 -2
- package/dist/node-thread/ThreadSnapExecutor.js.map +1 -1
- package/dist/offscreen/OffscreenSnapExecutor.d.ts +34 -0
- package/dist/offscreen/OffscreenSnapExecutor.js +104 -0
- package/dist/offscreen/OffscreenSnapExecutor.js.map +1 -0
- package/dist/offscreen/index.d.ts +1 -0
- package/dist/offscreen/index.js +15 -0
- package/dist/offscreen/index.js.map +1 -0
- package/dist/webpack/iframe/bundle.js +1750 -1
- package/dist/webpack/iframe/bundle.js.LICENSE.txt +0 -2
- package/dist/webpack/iframe/lockdown.umd.min.js +1 -1
- package/dist/webpack/node-process/bundle.js +23 -10
- package/dist/webpack/node-process/bundle.js.LICENSE.txt +0 -2
- package/dist/webpack/node-process/lockdown.umd.min.js +1 -1
- package/dist/webpack/node-thread/bundle.js +23 -10
- package/dist/webpack/node-thread/bundle.js.LICENSE.txt +0 -2
- package/dist/webpack/node-thread/lockdown.umd.min.js +1 -1
- package/dist/webpack/offscreen/bundle.js +1751 -0
- package/dist/webpack/offscreen/bundle.js.LICENSE.txt +25 -0
- package/dist/webpack/offscreen/index.html +11 -0
- package/dist/webpack/offscreen/lockdown.umd.min.js +1 -0
- package/package.json +19 -13
package/dist/common/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/common/utils.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,SAAgB,cAAc,CAAC,aAAsB;IACnD,IAAI,cAAiC,CAAC;IACtC,IAAI,aAAa,YAAY,KAAK,EAAE;QAClC,cAAc,GAAG,aAAa,CAAC;KAChC;SAAM,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE;QAC5C,cAAc,GAAG,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;QAC1C,qCAAqC;QACrC,OAAO,cAAc,CAAC,KAAK,CAAC;KAC7B;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAVD,wCAUC;AAED
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/common/utils.ts"],"names":[],"mappings":";;;AAAA,wCAAiC;AAEjC;;;;;;;GAOG;AACH,SAAgB,cAAc,CAAC,aAAsB;IACnD,IAAI,cAAiC,CAAC;IACtC,IAAI,aAAa,YAAY,KAAK,EAAE;QAClC,cAAc,GAAG,aAAa,CAAC;KAChC;SAAM,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE;QAC5C,cAAc,GAAG,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;QAC1C,qCAAqC;QACrC,OAAO,cAAc,CAAC,KAAK,CAAC;KAC7B;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAVD,wCAUC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,YAAY,CAChC,eAA2B,EAC3B,WAAqC;IAErC,MAAM,UAAU,GAAG,WAAW,CAAC,YAAY,CAAC;IAC5C,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACxC,eAAe;aACZ,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;YACd,IAAI,WAAW,CAAC,YAAY,KAAK,UAAU,EAAE;gBAC3C,OAAO,CAAC,KAAK,CAAC,CAAC;aAChB;iBAAM;gBACL,IAAA,aAAG,EACD,+EAA+E,CAChF,CAAC;aACH;QACH,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE;YAChB,IAAI,WAAW,CAAC,YAAY,KAAK,UAAU,EAAE;gBAC3C,MAAM,CAAC,MAAM,CAAC,CAAC;aAChB;iBAAM;gBACL,IAAA,aAAG,EACD,+EAA+E,CAChF,CAAC;aACH;QACH,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACL,CAAC;AA1BD,oCA0BC","sourcesContent":["import { log } from '../logging';\n\n/**\n * Takes an error that was thrown, determines if it is\n * an error object. If it is then it will return that. Otherwise,\n * an error object is created with the original error message.\n *\n * @param originalError - The error that was originally thrown.\n * @returns An error object.\n */\nexport function constructError(originalError: unknown) {\n let _originalError: Error | undefined;\n if (originalError instanceof Error) {\n _originalError = originalError;\n } else if (typeof originalError === 'string') {\n _originalError = new Error(originalError);\n // The stack is useless in this case.\n delete _originalError.stack;\n }\n return _originalError;\n}\n\n/**\n * Make proxy for Promise and handle the teardown process properly.\n * If the teardown is called in the meanwhile, Promise result will not be\n * exposed to the snap anymore and warning will be logged to the console.\n *\n * @param originalPromise - Original promise.\n * @param teardownRef - Reference containing teardown count.\n * @param teardownRef.lastTeardown - Number of the last teardown.\n * @returns New proxy promise.\n */\nexport async function withTeardown<T>(\n originalPromise: Promise<T>,\n teardownRef: { lastTeardown: number },\n): Promise<T> {\n const myTeardown = teardownRef.lastTeardown;\n return new Promise<T>((resolve, reject) => {\n originalPromise\n .then((value) => {\n if (teardownRef.lastTeardown === myTeardown) {\n resolve(value);\n } else {\n log(\n 'Late promise received after Snap finished execution. Promise will be dropped.',\n );\n }\n })\n .catch((reason) => {\n if (teardownRef.lastTeardown === myTeardown) {\n reject(reason);\n } else {\n log(\n 'Late promise received after Snap finished execution. Promise will be dropped.',\n );\n }\n });\n });\n}\n"]}
|
|
@@ -10,15 +10,15 @@ import { Infer } from 'superstruct';
|
|
|
10
10
|
*/
|
|
11
11
|
export declare function validateExport(type: HandlerType, snapExport: unknown): boolean;
|
|
12
12
|
export declare const JsonRpcRequestWithoutIdStruct: import("superstruct").Struct<{
|
|
13
|
-
jsonrpc: "2.0";
|
|
14
13
|
method: string;
|
|
14
|
+
jsonrpc: "2.0";
|
|
15
|
+
params?: Record<string, Json> | Json[] | undefined;
|
|
15
16
|
id?: string | number | null | undefined;
|
|
16
|
-
params?: Json[] | Record<string, Json> | undefined;
|
|
17
17
|
}, {
|
|
18
18
|
id: import("superstruct").Struct<string | number | null | undefined, null>;
|
|
19
|
-
|
|
19
|
+
params: import("superstruct").Struct<Record<string, Json> | Json[] | undefined, null>;
|
|
20
20
|
method: import("superstruct").Struct<string, null>;
|
|
21
|
-
|
|
21
|
+
jsonrpc: import("superstruct").Struct<"2.0", "2.0">;
|
|
22
22
|
}>;
|
|
23
23
|
export declare type JsonRpcRequestWithoutId = Infer<typeof JsonRpcRequestWithoutIdStruct>;
|
|
24
24
|
export declare const EndowmentStruct: import("superstruct").Struct<string, null>;
|
|
@@ -41,10 +41,10 @@ export declare const PingRequestArgumentsStruct: import("superstruct").Struct<un
|
|
|
41
41
|
export declare const TerminateRequestArgumentsStruct: import("superstruct").Struct<unknown[] | undefined, null>;
|
|
42
42
|
export declare const ExecuteSnapRequestArgumentsStruct: import("superstruct").Struct<[string, string, string[] | undefined], null>;
|
|
43
43
|
export declare const SnapRpcRequestArgumentsStruct: import("superstruct").Struct<[string, HandlerType, string, {
|
|
44
|
-
jsonrpc: "2.0";
|
|
45
44
|
method: string;
|
|
46
|
-
|
|
45
|
+
jsonrpc: "2.0";
|
|
47
46
|
params?: Record<string, Json> | undefined;
|
|
47
|
+
id?: string | number | null | undefined;
|
|
48
48
|
}], null>;
|
|
49
49
|
export declare type PingRequestArguments = Infer<typeof PingRequestArgumentsStruct>;
|
|
50
50
|
export declare type TerminateRequestArguments = Infer<typeof TerminateRequestArgumentsStruct>;
|
|
@@ -71,13 +71,13 @@ export declare type OnTransactionRequestArguments = Infer<typeof OnTransactionRe
|
|
|
71
71
|
*/
|
|
72
72
|
export declare function assertIsOnTransactionRequestArguments(value: unknown): asserts value is OnTransactionRequestArguments;
|
|
73
73
|
declare const OkResponseStruct: import("superstruct").Struct<{
|
|
74
|
-
jsonrpc: "2.0";
|
|
75
74
|
id: string | number | null;
|
|
75
|
+
jsonrpc: "2.0";
|
|
76
76
|
result: "OK";
|
|
77
77
|
}, {
|
|
78
78
|
result: import("superstruct").Struct<"OK", "OK">;
|
|
79
|
-
jsonrpc: import("superstruct").Struct<"2.0", "2.0">;
|
|
80
79
|
id: import("superstruct").Struct<string | number | null, null>;
|
|
80
|
+
jsonrpc: import("superstruct").Struct<"2.0", "2.0">;
|
|
81
81
|
}>;
|
|
82
82
|
declare const SnapRpcResponse: import("superstruct").Struct<{
|
|
83
83
|
id: string | number | null;
|
|
@@ -9,6 +9,7 @@ const post_message_stream_1 = require("@metamask/post-message-stream");
|
|
|
9
9
|
const snaps_utils_1 = require("@metamask/snaps-utils");
|
|
10
10
|
const pump_1 = __importDefault(require("pump"));
|
|
11
11
|
const BaseSnapExecutor_1 = require("../common/BaseSnapExecutor");
|
|
12
|
+
const logging_1 = require("../logging");
|
|
12
13
|
class IFrameSnapExecutor extends BaseSnapExecutor_1.BaseSnapExecutor {
|
|
13
14
|
/**
|
|
14
15
|
* Initialize the IFrameSnapExecutor. This creates a post message stream from
|
|
@@ -18,7 +19,7 @@ class IFrameSnapExecutor extends BaseSnapExecutor_1.BaseSnapExecutor {
|
|
|
18
19
|
* message streams.
|
|
19
20
|
*/
|
|
20
21
|
static initialize() {
|
|
21
|
-
|
|
22
|
+
(0, logging_1.log)('Worker: Connecting to parent.');
|
|
22
23
|
const parentStream = new post_message_stream_1.WindowPostMessageStream({
|
|
23
24
|
name: 'child',
|
|
24
25
|
target: 'parent',
|
|
@@ -28,7 +29,7 @@ class IFrameSnapExecutor extends BaseSnapExecutor_1.BaseSnapExecutor {
|
|
|
28
29
|
const mux = new object_multiplex_1.default();
|
|
29
30
|
(0, pump_1.default)(parentStream, mux, parentStream, (error) => {
|
|
30
31
|
if (error) {
|
|
31
|
-
|
|
32
|
+
(0, snaps_utils_1.logError)(`Parent stream failure, closing worker.`, error);
|
|
32
33
|
}
|
|
33
34
|
self.close();
|
|
34
35
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IFrameSnapExecutor.js","sourceRoot":"","sources":["../../src/iframe/IFrameSnapExecutor.ts"],"names":[],"mappings":";;;;;;AAAA,kFAAyD;AACzD,uEAAwE;AACxE,
|
|
1
|
+
{"version":3,"file":"IFrameSnapExecutor.js","sourceRoot":"","sources":["../../src/iframe/IFrameSnapExecutor.ts"],"names":[],"mappings":";;;;;;AAAA,kFAAyD;AACzD,uEAAwE;AACxE,uDAAoE;AACpE,gDAAwB;AAExB,iEAA8D;AAC9D,wCAAiC;AAEjC,MAAa,kBAAmB,SAAQ,mCAAgB;IACtD;;;;;;OAMG;IACH,MAAM,CAAC,UAAU;QACf,IAAA,aAAG,EAAC,+BAA+B,CAAC,CAAC;QAErC,MAAM,YAAY,GAAG,IAAI,6CAAuB,CAAC;YAC/C,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,QAAQ;YAChB,YAAY,EAAE,IAAI,CAAC,MAAM;YACzB,YAAY,EAAE,GAAG;SAClB,CAAC,CAAC;QAEH,MAAM,GAAG,GAAG,IAAI,0BAAe,EAAE,CAAC;QAClC,IAAA,cAAI,EAAC,YAAY,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE;YAC9C,IAAI,KAAK,EAAE;gBACT,IAAA,sBAAQ,EAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;aAC3D;YACD,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,MAAM,aAAa,GAAG,GAAG,CAAC,YAAY,CAAC,+BAAiB,CAAC,OAAO,CAAC,CAAC;QAClE,MAAM,SAAS,GAAG,GAAG,CAAC,YAAY,CAAC,+BAAiB,CAAC,QAAQ,CAAC,CAAC;QAE/D,OAAO,IAAI,kBAAkB,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAC1D,CAAC;CACF;AA/BD,gDA+BC","sourcesContent":["import ObjectMultiplex from '@metamask/object-multiplex';\nimport { WindowPostMessageStream } from '@metamask/post-message-stream';\nimport { logError, SNAP_STREAM_NAMES } from '@metamask/snaps-utils';\nimport pump from 'pump';\n\nimport { BaseSnapExecutor } from '../common/BaseSnapExecutor';\nimport { log } from '../logging';\n\nexport class IFrameSnapExecutor extends BaseSnapExecutor {\n /**\n * Initialize the IFrameSnapExecutor. This creates a post message stream from\n * and to the parent window, for two-way communication with the iframe.\n *\n * @returns An instance of `IFrameSnapExecutor`, with the initialized post\n * message streams.\n */\n static initialize() {\n log('Worker: Connecting to parent.');\n\n const parentStream = new WindowPostMessageStream({\n name: 'child',\n target: 'parent',\n targetWindow: self.parent,\n targetOrigin: '*',\n });\n\n const mux = new ObjectMultiplex();\n pump(parentStream, mux, parentStream, (error) => {\n if (error) {\n logError(`Parent stream failure, closing worker.`, error);\n }\n self.close();\n });\n\n const commandStream = mux.createStream(SNAP_STREAM_NAMES.COMMAND);\n const rpcStream = mux.createStream(SNAP_STREAM_NAMES.JSON_RPC);\n\n return new IFrameSnapExecutor(commandStream, rpcStream);\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="debug" />
|
|
2
|
+
/**
|
|
3
|
+
* A logging function specific to this package. The log messages don't show up
|
|
4
|
+
* by default, but they can be enabled by setting the environment variable:
|
|
5
|
+
* - `DEBUG=metamask:snaps:snaps-execution-environments`, or
|
|
6
|
+
* - `DEBUG=metamask:snaps:*` to enable all logs from `@metamask/snaps-*`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const log: import("debug").Debugger;
|
package/dist/logging.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.log = void 0;
|
|
4
|
+
const snaps_utils_1 = require("@metamask/snaps-utils");
|
|
5
|
+
const utils_1 = require("@metamask/utils");
|
|
6
|
+
/**
|
|
7
|
+
* A logging function specific to this package. The log messages don't show up
|
|
8
|
+
* by default, but they can be enabled by setting the environment variable:
|
|
9
|
+
* - `DEBUG=metamask:snaps:snaps-execution-environments`, or
|
|
10
|
+
* - `DEBUG=metamask:snaps:*` to enable all logs from `@metamask/snaps-*`.
|
|
11
|
+
*/
|
|
12
|
+
exports.log = (0, utils_1.createModuleLogger)(snaps_utils_1.snapsLogger, 'snaps-execution-environments');
|
|
13
|
+
//# sourceMappingURL=logging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AACpD,2CAAqD;AAErD;;;;;GAKG;AACU,QAAA,GAAG,GAAG,IAAA,0BAAkB,EACnC,yBAAW,EACX,8BAA8B,CAC/B,CAAC","sourcesContent":["import { snapsLogger } from '@metamask/snaps-utils';\nimport { createModuleLogger } from '@metamask/utils';\n\n/**\n * A logging function specific to this package. The log messages don't show up\n * by default, but they can be enabled by setting the environment variable:\n * - `DEBUG=metamask:snaps:snaps-execution-environments`, or\n * - `DEBUG=metamask:snaps:*` to enable all logs from `@metamask/snaps-*`.\n */\nexport const log = createModuleLogger(\n snapsLogger,\n 'snaps-execution-environments',\n);\n"]}
|
|
@@ -9,14 +9,15 @@ const post_message_stream_1 = require("@metamask/post-message-stream");
|
|
|
9
9
|
const snaps_utils_1 = require("@metamask/snaps-utils");
|
|
10
10
|
const pump_1 = __importDefault(require("pump"));
|
|
11
11
|
const BaseSnapExecutor_1 = require("../common/BaseSnapExecutor");
|
|
12
|
+
const logging_1 = require("../logging");
|
|
12
13
|
class ChildProcessSnapExecutor extends BaseSnapExecutor_1.BaseSnapExecutor {
|
|
13
14
|
static initialize() {
|
|
14
|
-
|
|
15
|
+
(0, logging_1.log)('Worker: Connecting to parent.');
|
|
15
16
|
const parentStream = new post_message_stream_1.ProcessMessageStream();
|
|
16
17
|
const mux = new object_multiplex_1.default();
|
|
17
18
|
(0, pump_1.default)(parentStream, mux, parentStream, (error) => {
|
|
18
19
|
if (error) {
|
|
19
|
-
|
|
20
|
+
(0, snaps_utils_1.logError)(`Parent stream failure, closing worker.`, error);
|
|
20
21
|
}
|
|
21
22
|
self.close();
|
|
22
23
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChildProcessSnapExecutor.js","sourceRoot":"","sources":["../../src/node-process/ChildProcessSnapExecutor.ts"],"names":[],"mappings":";;;;;;AAAA,kFAAyD;AACzD,uEAAqE;AACrE,
|
|
1
|
+
{"version":3,"file":"ChildProcessSnapExecutor.js","sourceRoot":"","sources":["../../src/node-process/ChildProcessSnapExecutor.ts"],"names":[],"mappings":";;;;;;AAAA,kFAAyD;AACzD,uEAAqE;AACrE,uDAAoE;AACpE,gDAAwB;AAExB,iEAA8D;AAC9D,wCAAiC;AAEjC,MAAa,wBAAyB,SAAQ,mCAAgB;IAC5D,MAAM,CAAC,UAAU;QACf,IAAA,aAAG,EAAC,+BAA+B,CAAC,CAAC;QAErC,MAAM,YAAY,GAAG,IAAI,0CAAoB,EAAE,CAAC;QAChD,MAAM,GAAG,GAAG,IAAI,0BAAe,EAAE,CAAC;QAClC,IAAA,cAAI,EAAC,YAAY,EAAE,GAAU,EAAE,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE;YACrD,IAAI,KAAK,EAAE;gBACT,IAAA,sBAAQ,EAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;aAC3D;YACD,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,MAAM,aAAa,GAAG,GAAG,CAAC,YAAY,CAAC,+BAAiB,CAAC,OAAO,CAAC,CAAC;QAClE,MAAM,SAAS,GAAG,GAAG,CAAC,YAAY,CAAC,+BAAiB,CAAC,QAAQ,CAAQ,CAAC;QACtE,OAAO,IAAI,wBAAwB,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAChE,CAAC;CACF;AAjBD,4DAiBC","sourcesContent":["import ObjectMultiplex from '@metamask/object-multiplex';\nimport { ProcessMessageStream } from '@metamask/post-message-stream';\nimport { logError, SNAP_STREAM_NAMES } from '@metamask/snaps-utils';\nimport pump from 'pump';\n\nimport { BaseSnapExecutor } from '../common/BaseSnapExecutor';\nimport { log } from '../logging';\n\nexport class ChildProcessSnapExecutor extends BaseSnapExecutor {\n static initialize() {\n log('Worker: Connecting to parent.');\n\n const parentStream = new ProcessMessageStream();\n const mux = new ObjectMultiplex();\n pump(parentStream, mux as any, parentStream, (error) => {\n if (error) {\n logError(`Parent stream failure, closing worker.`, error);\n }\n self.close();\n });\n\n const commandStream = mux.createStream(SNAP_STREAM_NAMES.COMMAND);\n const rpcStream = mux.createStream(SNAP_STREAM_NAMES.JSON_RPC) as any;\n return new ChildProcessSnapExecutor(commandStream, rpcStream);\n }\n}\n"]}
|
|
@@ -9,14 +9,15 @@ const post_message_stream_1 = require("@metamask/post-message-stream");
|
|
|
9
9
|
const snaps_utils_1 = require("@metamask/snaps-utils");
|
|
10
10
|
const pump_1 = __importDefault(require("pump"));
|
|
11
11
|
const BaseSnapExecutor_1 = require("../common/BaseSnapExecutor");
|
|
12
|
+
const logging_1 = require("../logging");
|
|
12
13
|
class ThreadSnapExecutor extends BaseSnapExecutor_1.BaseSnapExecutor {
|
|
13
14
|
static initialize() {
|
|
14
|
-
|
|
15
|
+
(0, logging_1.log)('Worker: Connecting to parent.');
|
|
15
16
|
const parentStream = new post_message_stream_1.ThreadMessageStream();
|
|
16
17
|
const mux = new object_multiplex_1.default();
|
|
17
18
|
(0, pump_1.default)(parentStream, mux, parentStream, (error) => {
|
|
18
19
|
if (error) {
|
|
19
|
-
|
|
20
|
+
(0, snaps_utils_1.logError)(`Parent stream failure, closing worker.`, error);
|
|
20
21
|
}
|
|
21
22
|
self.close();
|
|
22
23
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadSnapExecutor.js","sourceRoot":"","sources":["../../src/node-thread/ThreadSnapExecutor.ts"],"names":[],"mappings":";;;;;;AAAA,kFAAyD;AACzD,uEAAoE;AACpE,
|
|
1
|
+
{"version":3,"file":"ThreadSnapExecutor.js","sourceRoot":"","sources":["../../src/node-thread/ThreadSnapExecutor.ts"],"names":[],"mappings":";;;;;;AAAA,kFAAyD;AACzD,uEAAoE;AACpE,uDAAoE;AACpE,gDAAwB;AAExB,iEAA8D;AAC9D,wCAAiC;AAEjC,MAAa,kBAAmB,SAAQ,mCAAgB;IACtD,MAAM,CAAC,UAAU;QACf,IAAA,aAAG,EAAC,+BAA+B,CAAC,CAAC;QAErC,MAAM,YAAY,GAAG,IAAI,yCAAmB,EAAE,CAAC;QAC/C,MAAM,GAAG,GAAG,IAAI,0BAAe,EAAE,CAAC;QAClC,IAAA,cAAI,EAAC,YAAY,EAAE,GAAU,EAAE,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE;YACrD,IAAI,KAAK,EAAE;gBACT,IAAA,sBAAQ,EAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;aAC3D;YACD,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,MAAM,aAAa,GAAG,GAAG,CAAC,YAAY,CAAC,+BAAiB,CAAC,OAAO,CAAC,CAAC;QAClE,MAAM,SAAS,GAAG,GAAG,CAAC,YAAY,CAAC,+BAAiB,CAAC,QAAQ,CAAQ,CAAC;QACtE,OAAO,IAAI,kBAAkB,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAC1D,CAAC;CACF;AAjBD,gDAiBC","sourcesContent":["import ObjectMultiplex from '@metamask/object-multiplex';\nimport { ThreadMessageStream } from '@metamask/post-message-stream';\nimport { logError, SNAP_STREAM_NAMES } from '@metamask/snaps-utils';\nimport pump from 'pump';\n\nimport { BaseSnapExecutor } from '../common/BaseSnapExecutor';\nimport { log } from '../logging';\n\nexport class ThreadSnapExecutor extends BaseSnapExecutor {\n static initialize() {\n log('Worker: Connecting to parent.');\n\n const parentStream = new ThreadMessageStream();\n const mux = new ObjectMultiplex();\n pump(parentStream, mux as any, parentStream, (error) => {\n if (error) {\n logError(`Parent stream failure, closing worker.`, error);\n }\n self.close();\n });\n\n const commandStream = mux.createStream(SNAP_STREAM_NAMES.COMMAND);\n const rpcStream = mux.createStream(SNAP_STREAM_NAMES.JSON_RPC) as any;\n return new ThreadSnapExecutor(commandStream, rpcStream);\n }\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BasePostMessageStream, WindowPostMessageStream } from '@metamask/post-message-stream';
|
|
2
|
+
declare type ExecutorJob = {
|
|
3
|
+
id: string;
|
|
4
|
+
window: Window;
|
|
5
|
+
stream: WindowPostMessageStream;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A snap executor using the Offscreen Documents API.
|
|
9
|
+
*
|
|
10
|
+
* This is not a traditional snap executor, as it does not execute snaps itself.
|
|
11
|
+
* Instead, it creates an iframe window for each snap execution, and sends the
|
|
12
|
+
* snap execution request to the iframe window. The iframe window is responsible
|
|
13
|
+
* for executing the snap.
|
|
14
|
+
*
|
|
15
|
+
* Extensions can only have a single offscreen document, so this executor is
|
|
16
|
+
* persisted between snap executions. The offscreen snap executor essentially
|
|
17
|
+
* acts as a proxy between the extension and the iframe execution environment.
|
|
18
|
+
*
|
|
19
|
+
* @see https://developer.chrome.com/docs/extensions/reference/offscreen/
|
|
20
|
+
*/
|
|
21
|
+
export declare class OffscreenSnapExecutor {
|
|
22
|
+
#private;
|
|
23
|
+
readonly jobs: Record<string, ExecutorJob>;
|
|
24
|
+
/**
|
|
25
|
+
* Initialize the executor with the given stream. This is a wrapper around the
|
|
26
|
+
* constructor.
|
|
27
|
+
*
|
|
28
|
+
* @param stream - The stream to use for communication.
|
|
29
|
+
* @returns The initialized executor.
|
|
30
|
+
*/
|
|
31
|
+
static initialize(stream: BasePostMessageStream): OffscreenSnapExecutor;
|
|
32
|
+
constructor(stream: BasePostMessageStream);
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
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 _OffscreenSnapExecutor_instances, _OffscreenSnapExecutor_stream, _OffscreenSnapExecutor_onData, _OffscreenSnapExecutor_initializeJob, _OffscreenSnapExecutor_terminateJob;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.OffscreenSnapExecutor = void 0;
|
|
16
|
+
const post_message_stream_1 = require("@metamask/post-message-stream");
|
|
17
|
+
const snaps_utils_1 = require("@metamask/snaps-utils");
|
|
18
|
+
const utils_1 = require("@metamask/utils");
|
|
19
|
+
/**
|
|
20
|
+
* A snap executor using the Offscreen Documents API.
|
|
21
|
+
*
|
|
22
|
+
* This is not a traditional snap executor, as it does not execute snaps itself.
|
|
23
|
+
* Instead, it creates an iframe window for each snap execution, and sends the
|
|
24
|
+
* snap execution request to the iframe window. The iframe window is responsible
|
|
25
|
+
* for executing the snap.
|
|
26
|
+
*
|
|
27
|
+
* Extensions can only have a single offscreen document, so this executor is
|
|
28
|
+
* persisted between snap executions. The offscreen snap executor essentially
|
|
29
|
+
* acts as a proxy between the extension and the iframe execution environment.
|
|
30
|
+
*
|
|
31
|
+
* @see https://developer.chrome.com/docs/extensions/reference/offscreen/
|
|
32
|
+
*/
|
|
33
|
+
class OffscreenSnapExecutor {
|
|
34
|
+
constructor(stream) {
|
|
35
|
+
_OffscreenSnapExecutor_instances.add(this);
|
|
36
|
+
_OffscreenSnapExecutor_stream.set(this, void 0);
|
|
37
|
+
this.jobs = {};
|
|
38
|
+
__classPrivateFieldSet(this, _OffscreenSnapExecutor_stream, stream, "f");
|
|
39
|
+
__classPrivateFieldGet(this, _OffscreenSnapExecutor_stream, "f").on('data', __classPrivateFieldGet(this, _OffscreenSnapExecutor_instances, "m", _OffscreenSnapExecutor_onData).bind(this));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Initialize the executor with the given stream. This is a wrapper around the
|
|
43
|
+
* constructor.
|
|
44
|
+
*
|
|
45
|
+
* @param stream - The stream to use for communication.
|
|
46
|
+
* @returns The initialized executor.
|
|
47
|
+
*/
|
|
48
|
+
static initialize(stream) {
|
|
49
|
+
return new OffscreenSnapExecutor(stream);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.OffscreenSnapExecutor = OffscreenSnapExecutor;
|
|
53
|
+
_OffscreenSnapExecutor_stream = new WeakMap(), _OffscreenSnapExecutor_instances = new WeakSet(), _OffscreenSnapExecutor_onData = function _OffscreenSnapExecutor_onData(data) {
|
|
54
|
+
const { jobId, frameUrl, data: request } = data;
|
|
55
|
+
if (!this.jobs[jobId]) {
|
|
56
|
+
// This ensures that a job is initialized before it is used. To avoid
|
|
57
|
+
// code duplication, we call the `#onData` method again, which will
|
|
58
|
+
// run the rest of the logic after initialization.
|
|
59
|
+
__classPrivateFieldGet(this, _OffscreenSnapExecutor_instances, "m", _OffscreenSnapExecutor_initializeJob).call(this, jobId, frameUrl)
|
|
60
|
+
.then(() => {
|
|
61
|
+
__classPrivateFieldGet(this, _OffscreenSnapExecutor_instances, "m", _OffscreenSnapExecutor_onData).call(this, data);
|
|
62
|
+
})
|
|
63
|
+
.catch((error) => {
|
|
64
|
+
(0, snaps_utils_1.logError)('[Worker] Error initializing job:', error);
|
|
65
|
+
});
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
// This is a method specific to the `OffscreenSnapExecutor`, as the service
|
|
69
|
+
// itself does not have access to the iframes directly.
|
|
70
|
+
if (request.method === 'terminateJob') {
|
|
71
|
+
__classPrivateFieldGet(this, _OffscreenSnapExecutor_instances, "m", _OffscreenSnapExecutor_terminateJob).call(this, jobId);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this.jobs[jobId].stream.write(request);
|
|
75
|
+
}, _OffscreenSnapExecutor_initializeJob =
|
|
76
|
+
/**
|
|
77
|
+
* Create a new iframe and set up a stream to communicate with it.
|
|
78
|
+
*
|
|
79
|
+
* @param jobId - The job ID.
|
|
80
|
+
* @param frameUrl - The URL to load in the iframe.
|
|
81
|
+
*/
|
|
82
|
+
async function _OffscreenSnapExecutor_initializeJob(jobId, frameUrl) {
|
|
83
|
+
const window = await (0, snaps_utils_1.createWindow)(frameUrl, jobId);
|
|
84
|
+
const jobStream = new post_message_stream_1.WindowPostMessageStream({
|
|
85
|
+
name: 'parent',
|
|
86
|
+
target: 'child',
|
|
87
|
+
targetWindow: window,
|
|
88
|
+
targetOrigin: '*',
|
|
89
|
+
});
|
|
90
|
+
// Write messages from the iframe to the parent, wrapped with the job ID.
|
|
91
|
+
jobStream.on('data', (data) => {
|
|
92
|
+
__classPrivateFieldGet(this, _OffscreenSnapExecutor_stream, "f").write({ data, jobId });
|
|
93
|
+
});
|
|
94
|
+
this.jobs[jobId] = { id: jobId, window, stream: jobStream };
|
|
95
|
+
return this.jobs[jobId];
|
|
96
|
+
}, _OffscreenSnapExecutor_terminateJob = function _OffscreenSnapExecutor_terminateJob(jobId) {
|
|
97
|
+
(0, utils_1.assert)(this.jobs[jobId], `Job "${jobId}" not found.`);
|
|
98
|
+
const iframe = document.getElementById(jobId);
|
|
99
|
+
(0, utils_1.assert)(iframe, `Iframe with ID "${jobId}" not found.`);
|
|
100
|
+
iframe.remove();
|
|
101
|
+
this.jobs[jobId].stream.destroy();
|
|
102
|
+
delete this.jobs[jobId];
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=OffscreenSnapExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OffscreenSnapExecutor.js","sourceRoot":"","sources":["../../src/offscreen/OffscreenSnapExecutor.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n BasePostMessageStream,\n WindowPostMessageStream,\n} from '@metamask/post-message-stream';\nimport { createWindow, logError } from '@metamask/snaps-utils';\nimport { JsonRpcRequest, assert } from '@metamask/utils';\n\ntype ExecutorJob = {\n id: string;\n window: Window;\n stream: WindowPostMessageStream;\n};\n\n/**\n * A snap executor using the Offscreen Documents API.\n *\n * This is not a traditional snap executor, as it does not execute snaps itself.\n * Instead, it creates an iframe window for each snap execution, and sends the\n * snap execution request to the iframe window. The iframe window is responsible\n * for executing the snap.\n *\n * Extensions can only have a single offscreen document, so this executor is\n * persisted between snap executions. The offscreen snap executor essentially\n * acts as a proxy between the extension and the iframe execution environment.\n *\n * @see https://developer.chrome.com/docs/extensions/reference/offscreen/\n */\nexport class OffscreenSnapExecutor {\n readonly #stream: BasePostMessageStream;\n\n readonly jobs: Record<string, ExecutorJob> = {};\n\n /**\n * Initialize the executor with the given stream. This is a wrapper around the\n * constructor.\n *\n * @param stream - The stream to use for communication.\n * @returns The initialized executor.\n */\n static initialize(stream: BasePostMessageStream) {\n return new OffscreenSnapExecutor(stream);\n }\n\n constructor(stream: BasePostMessageStream) {\n this.#stream = stream;\n this.#stream.on('data', this.#onData.bind(this));\n }\n\n /**\n * Handle an incoming message from the `OffscreenExecutionService`. This\n * assumes that the message contains a `jobId` property, and a JSON-RPC\n * request in the `data` property.\n *\n * @param data - The message data.\n * @param data.data - The JSON-RPC request.\n * @param data.jobId - The job ID.\n * @param data.frameUrl - The URL to load in the iframe.\n */\n #onData(data: { data: JsonRpcRequest; jobId: string; frameUrl: string }) {\n const { jobId, frameUrl, data: request } = data;\n\n if (!this.jobs[jobId]) {\n // This ensures that a job is initialized before it is used. To avoid\n // code duplication, we call the `#onData` method again, which will\n // run the rest of the logic after initialization.\n this.#initializeJob(jobId, frameUrl)\n .then(() => {\n this.#onData(data);\n })\n .catch((error) => {\n logError('[Worker] Error initializing job:', error);\n });\n\n return;\n }\n\n // This is a method specific to the `OffscreenSnapExecutor`, as the service\n // itself does not have access to the iframes directly.\n if (request.method === 'terminateJob') {\n this.#terminateJob(jobId);\n return;\n }\n\n this.jobs[jobId].stream.write(request);\n }\n\n /**\n * Create a new iframe and set up a stream to communicate with it.\n *\n * @param jobId - The job ID.\n * @param frameUrl - The URL to load in the iframe.\n */\n async #initializeJob(jobId: string, frameUrl: string): Promise<ExecutorJob> {\n const window = await createWindow(frameUrl, jobId);\n const jobStream = new WindowPostMessageStream({\n name: 'parent',\n target: 'child',\n targetWindow: window,\n targetOrigin: '*',\n });\n\n // Write messages from the iframe to the parent, wrapped with the job ID.\n jobStream.on('data', (data) => {\n this.#stream.write({ data, jobId });\n });\n\n this.jobs[jobId] = { id: jobId, window, stream: jobStream };\n return this.jobs[jobId];\n }\n\n /**\n * Terminate the job with the given ID. This will close the iframe and delete\n * the job from the internal job map.\n *\n * @param jobId - The job ID.\n */\n #terminateJob(jobId: string) {\n assert(this.jobs[jobId], `Job \"${jobId}\" not found.`);\n\n const iframe = document.getElementById(jobId);\n assert(iframe, `Iframe with ID \"${jobId}\" not found.`);\n\n iframe.remove();\n this.jobs[jobId].stream.destroy();\n delete this.jobs[jobId];\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const post_message_stream_1 = require("@metamask/post-message-stream");
|
|
4
|
+
const lockdown_1 = require("../common/lockdown/lockdown");
|
|
5
|
+
const lockdown_more_1 = require("../common/lockdown/lockdown-more");
|
|
6
|
+
const OffscreenSnapExecutor_1 = require("./OffscreenSnapExecutor");
|
|
7
|
+
(0, lockdown_1.executeLockdown)();
|
|
8
|
+
(0, lockdown_more_1.executeLockdownMore)();
|
|
9
|
+
// The stream from the offscreen document to the execution service.
|
|
10
|
+
const parentStream = new post_message_stream_1.BrowserRuntimePostMessageStream({
|
|
11
|
+
name: 'child',
|
|
12
|
+
target: 'parent',
|
|
13
|
+
});
|
|
14
|
+
OffscreenSnapExecutor_1.OffscreenSnapExecutor.initialize(parentStream);
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/offscreen/index.ts"],"names":[],"mappings":";;AAAA,uEAAgF;AAEhF,0DAA8D;AAC9D,oEAAuE;AACvE,mEAAgE;AAEhE,IAAA,0BAAe,GAAE,CAAC;AAClB,IAAA,mCAAmB,GAAE,CAAC;AAEtB,mEAAmE;AACnE,MAAM,YAAY,GAAG,IAAI,qDAA+B,CAAC;IACvD,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,QAAQ;CACjB,CAAC,CAAC;AAEH,6CAAqB,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC","sourcesContent":["import { BrowserRuntimePostMessageStream } from '@metamask/post-message-stream';\n\nimport { executeLockdown } from '../common/lockdown/lockdown';\nimport { executeLockdownMore } from '../common/lockdown/lockdown-more';\nimport { OffscreenSnapExecutor } from './OffscreenSnapExecutor';\n\nexecuteLockdown();\nexecuteLockdownMore();\n\n// The stream from the offscreen document to the execution service.\nconst parentStream = new BrowserRuntimePostMessageStream({\n name: 'child',\n target: 'parent',\n});\n\nOffscreenSnapExecutor.initialize(parentStream);\n"]}
|