@metamask/snaps-execution-environments 1.0.2 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -274
- package/dist/browserify/iframe/bundle.js +6 -4
- package/dist/browserify/iframe/index.html +7571 -7166
- package/dist/browserify/node-process/bundle.js +7577 -7168
- package/dist/browserify/node-thread/bundle.js +7577 -7168
- package/dist/browserify/offscreen/bundle.js +6 -9
- package/dist/browserify/offscreen/index.html +7571 -7166
- package/dist/browserify/worker-executor/bundle.js +12560 -0
- package/dist/browserify/worker-pool/bundle.js +7 -0
- package/dist/browserify/worker-pool/index.html +12555 -0
- package/dist/cjs/common/BaseSnapExecutor.js +420 -0
- package/dist/cjs/common/BaseSnapExecutor.js.map +1 -0
- package/dist/cjs/common/commands.js +81 -0
- package/dist/cjs/common/commands.js.map +1 -0
- package/dist/cjs/common/endowments/commonEndowmentFactory.js +147 -0
- package/dist/cjs/common/endowments/commonEndowmentFactory.js.map +1 -0
- package/dist/cjs/common/endowments/console.js +134 -0
- package/dist/cjs/common/endowments/console.js.map +1 -0
- package/dist/cjs/common/endowments/crypto.js +44 -0
- package/dist/cjs/common/endowments/crypto.js.map +1 -0
- package/dist/cjs/common/endowments/date.js +53 -0
- package/dist/cjs/common/endowments/date.js.map +1 -0
- package/dist/cjs/common/endowments/index.js +91 -0
- package/dist/cjs/common/endowments/index.js.map +1 -0
- package/dist/cjs/common/endowments/interval.js +61 -0
- package/dist/cjs/common/endowments/interval.js.map +1 -0
- package/dist/cjs/common/endowments/math.js +67 -0
- package/dist/cjs/common/endowments/math.js.map +1 -0
- package/dist/cjs/common/endowments/network.js +216 -0
- package/dist/cjs/common/endowments/network.js.map +1 -0
- package/dist/cjs/common/endowments/textDecoder.js +28 -0
- package/dist/cjs/common/endowments/textDecoder.js.map +1 -0
- package/dist/cjs/common/endowments/textEncoder.js +28 -0
- package/dist/cjs/common/endowments/textEncoder.js.map +1 -0
- package/dist/cjs/common/endowments/timeout.js +63 -0
- package/dist/cjs/common/endowments/timeout.js.map +1 -0
- package/dist/cjs/common/globalEvents.js +39 -0
- package/dist/cjs/common/globalEvents.js.map +1 -0
- package/dist/cjs/common/globalObject.js +53 -0
- package/dist/{common → cjs/common}/globalObject.js.map +1 -1
- package/dist/cjs/common/lockdown/lockdown-events.js +74 -0
- package/dist/cjs/common/lockdown/lockdown-events.js.map +1 -0
- package/dist/cjs/common/lockdown/lockdown-more.js +73 -0
- package/dist/cjs/common/lockdown/lockdown-more.js.map +1 -0
- package/dist/cjs/common/lockdown/lockdown.js +30 -0
- package/dist/cjs/common/lockdown/lockdown.js.map +1 -0
- package/dist/cjs/common/sortParams.js +26 -0
- package/dist/cjs/common/sortParams.js.map +1 -0
- package/dist/cjs/common/utils.js +141 -0
- package/dist/cjs/common/utils.js.map +1 -0
- package/dist/cjs/common/validation.js +118 -0
- package/dist/cjs/common/validation.js.map +1 -0
- package/dist/cjs/iframe/IFrameSnapExecutor.js +50 -0
- package/dist/cjs/iframe/IFrameSnapExecutor.js.map +1 -0
- package/dist/cjs/iframe/index.js +13 -0
- package/dist/cjs/iframe/index.js.map +1 -0
- package/dist/cjs/logging.js +15 -0
- package/dist/cjs/logging.js.map +1 -0
- package/dist/cjs/node-process/ChildProcessSnapExecutor.js +39 -0
- package/dist/cjs/node-process/ChildProcessSnapExecutor.js.map +1 -0
- package/dist/cjs/node-process/index.js +11 -0
- package/dist/cjs/node-process/index.js.map +1 -0
- package/dist/cjs/node-thread/ThreadSnapExecutor.js +39 -0
- package/dist/cjs/node-thread/ThreadSnapExecutor.js.map +1 -0
- package/dist/cjs/node-thread/index.js +11 -0
- package/dist/cjs/node-thread/index.js.map +1 -0
- package/dist/cjs/offscreen/OffscreenSnapExecutor.js +173 -0
- package/dist/cjs/offscreen/OffscreenSnapExecutor.js.map +1 -0
- package/dist/cjs/offscreen/index.js +19 -0
- package/dist/cjs/offscreen/index.js.map +1 -0
- package/dist/cjs/webworker/executor/WebWorkerSnapExecutor.js +45 -0
- package/dist/cjs/webworker/executor/WebWorkerSnapExecutor.js.map +1 -0
- package/dist/cjs/webworker/executor/index.js +13 -0
- package/dist/cjs/webworker/executor/index.js.map +1 -0
- package/dist/cjs/webworker/pool/WebWorkerPool.js +248 -0
- package/dist/cjs/webworker/pool/WebWorkerPool.js.map +1 -0
- package/dist/cjs/webworker/pool/index.js +13 -0
- package/dist/cjs/webworker/pool/index.js.map +1 -0
- package/dist/esm/common/BaseSnapExecutor.js +410 -0
- package/dist/esm/common/BaseSnapExecutor.js.map +1 -0
- package/dist/esm/common/commands.js +80 -0
- package/dist/esm/common/commands.js.map +1 -0
- package/dist/esm/common/endowments/commonEndowmentFactory.js +132 -0
- package/dist/esm/common/endowments/commonEndowmentFactory.js.map +1 -0
- package/dist/esm/common/endowments/console.js +116 -0
- package/dist/esm/common/endowments/console.js.map +1 -0
- package/dist/esm/common/endowments/crypto.js +26 -0
- package/dist/esm/common/endowments/crypto.js.map +1 -0
- package/dist/{common → esm/common}/endowments/date.js +20 -16
- package/dist/esm/common/endowments/date.js.map +1 -0
- package/dist/{common → esm/common}/endowments/index.js +34 -36
- package/dist/esm/common/endowments/index.js.map +1 -0
- package/dist/{common → esm/common}/endowments/interval.js +13 -12
- package/dist/esm/common/endowments/interval.js.map +1 -0
- package/dist/{common → esm/common}/endowments/math.js +21 -15
- package/dist/esm/common/endowments/math.js.map +1 -0
- package/dist/esm/common/endowments/network.js +206 -0
- package/dist/esm/common/endowments/network.js.map +1 -0
- package/dist/esm/common/endowments/textDecoder.js +18 -0
- package/dist/esm/common/endowments/textDecoder.js.map +1 -0
- package/dist/esm/common/endowments/textEncoder.js +18 -0
- package/dist/esm/common/endowments/textEncoder.js.map +1 -0
- package/dist/{common → esm/common}/endowments/timeout.js +14 -13
- package/dist/esm/common/endowments/timeout.js.map +1 -0
- package/dist/esm/common/globalEvents.js +35 -0
- package/dist/esm/common/globalEvents.js.map +1 -0
- package/dist/esm/common/globalObject.js +36 -0
- package/dist/esm/common/globalObject.js.map +1 -0
- package/dist/esm/common/lockdown/lockdown-events.js +66 -0
- package/dist/esm/common/lockdown/lockdown-events.js.map +1 -0
- package/dist/{common → esm/common}/lockdown/lockdown-more.js +15 -22
- package/dist/esm/common/lockdown/lockdown-more.js.map +1 -0
- package/dist/{common → esm/common}/lockdown/lockdown.js +6 -11
- package/dist/esm/common/lockdown/lockdown.js.map +1 -0
- package/dist/{common → esm/common}/sortParams.js +7 -13
- package/dist/esm/common/sortParams.js.map +1 -0
- package/dist/{common → esm/common}/utils.js +54 -56
- package/dist/esm/common/utils.js.map +1 -0
- package/dist/esm/common/validation.js +94 -0
- package/dist/esm/common/validation.js.map +1 -0
- package/dist/esm/iframe/IFrameSnapExecutor.js +35 -0
- package/dist/esm/iframe/IFrameSnapExecutor.js.map +1 -0
- package/dist/esm/iframe/index.js +9 -0
- package/dist/esm/iframe/index.js.map +1 -0
- package/dist/esm/logging.js +10 -0
- package/dist/esm/logging.js.map +1 -0
- package/dist/esm/node-process/ChildProcessSnapExecutor.js +24 -0
- package/dist/esm/node-process/ChildProcessSnapExecutor.js.map +1 -0
- package/dist/esm/node-process/index.js +7 -0
- package/dist/esm/node-process/index.js.map +1 -0
- package/dist/esm/node-thread/ThreadSnapExecutor.js +24 -0
- package/dist/esm/node-thread/ThreadSnapExecutor.js.map +1 -0
- package/dist/esm/node-thread/index.js +7 -0
- package/dist/esm/node-thread/index.js.map +1 -0
- package/dist/esm/offscreen/OffscreenSnapExecutor.js +176 -0
- package/dist/esm/offscreen/OffscreenSnapExecutor.js.map +1 -0
- package/dist/esm/offscreen/index.js +15 -0
- package/dist/esm/offscreen/index.js.map +1 -0
- package/dist/esm/webworker/executor/WebWorkerSnapExecutor.js +30 -0
- package/dist/esm/webworker/executor/WebWorkerSnapExecutor.js.map +1 -0
- package/dist/esm/webworker/executor/index.js +9 -0
- package/dist/esm/webworker/executor/index.js.map +1 -0
- package/dist/esm/webworker/pool/WebWorkerPool.js +245 -0
- package/dist/esm/webworker/pool/WebWorkerPool.js.map +1 -0
- package/dist/esm/webworker/pool/index.js +9 -0
- package/dist/esm/webworker/pool/index.js.map +1 -0
- package/dist/{common → types/common}/BaseSnapExecutor.d.ts +7 -7
- package/dist/{common → types/common}/commands.d.ts +2 -2
- package/dist/{common → types/common}/endowments/commonEndowmentFactory.d.ts +5 -1
- package/dist/types/common/endowments/console.d.ts +45 -0
- package/dist/{common → types/common}/endowments/crypto.d.ts +4 -0
- package/dist/{common → types/common}/endowments/index.d.ts +5 -3
- package/dist/{common → types/common}/globalEvents.d.ts +1 -0
- package/dist/{common → types/common}/sortParams.d.ts +1 -1
- package/dist/{common → types/common}/utils.d.ts +12 -4
- package/dist/{common → types/common}/validation.d.ts +26 -10
- package/dist/{iframe → types/iframe}/IFrameSnapExecutor.d.ts +1 -1
- package/dist/{offscreen → types/offscreen}/OffscreenSnapExecutor.d.ts +2 -1
- package/dist/types/webworker/executor/WebWorkerSnapExecutor.d.ts +13 -0
- package/dist/types/webworker/executor/index.d.ts +1 -0
- package/dist/types/webworker/pool/WebWorkerPool.d.ts +23 -0
- package/dist/types/webworker/pool/index.d.ts +1 -0
- package/package.json +57 -46
- package/dist/common/BaseSnapExecutor.js +0 -370
- package/dist/common/BaseSnapExecutor.js.map +0 -1
- package/dist/common/commands.js +0 -65
- package/dist/common/commands.js.map +0 -1
- package/dist/common/endowments/commonEndowmentFactory.js +0 -75
- package/dist/common/endowments/commonEndowmentFactory.js.map +0 -1
- package/dist/common/endowments/crypto.js +0 -28
- package/dist/common/endowments/crypto.js.map +0 -1
- package/dist/common/endowments/date.js.map +0 -1
- package/dist/common/endowments/index.js.map +0 -1
- package/dist/common/endowments/interval.js.map +0 -1
- package/dist/common/endowments/math.js.map +0 -1
- package/dist/common/endowments/network.js +0 -177
- package/dist/common/endowments/network.js.map +0 -1
- package/dist/common/endowments/textDecoder.js +0 -18
- package/dist/common/endowments/textDecoder.js.map +0 -1
- package/dist/common/endowments/textEncoder.js +0 -18
- package/dist/common/endowments/textEncoder.js.map +0 -1
- package/dist/common/endowments/timeout.js.map +0 -1
- package/dist/common/globalEvents.js +0 -47
- package/dist/common/globalEvents.js.map +0 -1
- package/dist/common/globalObject.js +0 -50
- package/dist/common/keyring.d.ts +0 -12
- package/dist/common/keyring.js +0 -42
- package/dist/common/keyring.js.map +0 -1
- package/dist/common/lockdown/lockdown-events.js +0 -60
- package/dist/common/lockdown/lockdown-events.js.map +0 -1
- package/dist/common/lockdown/lockdown-more.js.map +0 -1
- package/dist/common/lockdown/lockdown.js.map +0 -1
- package/dist/common/sortParams.js.map +0 -1
- package/dist/common/utils.js.map +0 -1
- package/dist/common/validation.js +0 -109
- package/dist/common/validation.js.map +0 -1
- package/dist/iframe/IFrameSnapExecutor.js +0 -42
- package/dist/iframe/IFrameSnapExecutor.js.map +0 -1
- package/dist/iframe/index.js +0 -10
- package/dist/iframe/index.js.map +0 -1
- package/dist/logging.js +0 -13
- package/dist/logging.js.map +0 -1
- package/dist/node-process/ChildProcessSnapExecutor.js +0 -30
- package/dist/node-process/ChildProcessSnapExecutor.js.map +0 -1
- package/dist/node-process/index.js +0 -8
- package/dist/node-process/index.js.map +0 -1
- package/dist/node-thread/ThreadSnapExecutor.js +0 -30
- package/dist/node-thread/ThreadSnapExecutor.js.map +0 -1
- package/dist/node-thread/index.js +0 -8
- package/dist/node-thread/index.js.map +0 -1
- package/dist/offscreen/OffscreenSnapExecutor.js +0 -104
- package/dist/offscreen/OffscreenSnapExecutor.js.map +0 -1
- package/dist/offscreen/index.js +0 -16
- package/dist/offscreen/index.js.map +0 -1
- package/dist/openrpc.json +0 -210
- /package/dist/{common → types/common}/endowments/date.d.ts +0 -0
- /package/dist/{common → types/common}/endowments/interval.d.ts +0 -0
- /package/dist/{common → types/common}/endowments/math.d.ts +0 -0
- /package/dist/{common → types/common}/endowments/network.d.ts +0 -0
- /package/dist/{common → types/common}/endowments/textDecoder.d.ts +0 -0
- /package/dist/{common → types/common}/endowments/textEncoder.d.ts +0 -0
- /package/dist/{common → types/common}/endowments/timeout.d.ts +0 -0
- /package/dist/{common → types/common}/globalObject.d.ts +0 -0
- /package/dist/{common → types/common}/lockdown/lockdown-events.d.ts +0 -0
- /package/dist/{common → types/common}/lockdown/lockdown-more.d.ts +0 -0
- /package/dist/{common → types/common}/lockdown/lockdown.d.ts +0 -0
- /package/dist/{iframe → types/iframe}/index.d.ts +0 -0
- /package/dist/{logging.d.ts → types/logging.d.ts} +0 -0
- /package/dist/{node-process → types/node-process}/ChildProcessSnapExecutor.d.ts +0 -0
- /package/dist/{node-process → types/node-process}/index.d.ts +0 -0
- /package/dist/{node-thread → types/node-thread}/ThreadSnapExecutor.d.ts +0 -0
- /package/dist/{node-thread → types/node-thread}/index.d.ts +0 -0
- /package/dist/{offscreen → types/offscreen}/index.d.ts +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { EndowmentFactoryOptions } from './commonEndowmentFactory';
|
|
2
|
+
export declare const consoleAttenuatedMethods: Set<string>;
|
|
3
|
+
/**
|
|
4
|
+
* A set of all the `console` values that will be passed to the snap. This has
|
|
5
|
+
* all the values that are available in both the browser and Node.js.
|
|
6
|
+
*/
|
|
7
|
+
export declare const consoleMethods: Set<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Create a a {@link console} object, with the same properties as the global
|
|
10
|
+
* {@link console} object, but with some methods replaced.
|
|
11
|
+
*
|
|
12
|
+
* @param options - Factory options used in construction of the endowment.
|
|
13
|
+
* @param options.snapId - The id of the snap that will interact with the endowment.
|
|
14
|
+
* @returns The {@link console} object with the replaced methods.
|
|
15
|
+
*/
|
|
16
|
+
declare function createConsole({ snapId }?: EndowmentFactoryOptions): {
|
|
17
|
+
console: {
|
|
18
|
+
error: {
|
|
19
|
+
(...data: any[]): void;
|
|
20
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
21
|
+
};
|
|
22
|
+
log: {
|
|
23
|
+
(...data: any[]): void;
|
|
24
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
25
|
+
};
|
|
26
|
+
warn: {
|
|
27
|
+
(...data: any[]): void;
|
|
28
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
29
|
+
};
|
|
30
|
+
debug: {
|
|
31
|
+
(...data: any[]): void;
|
|
32
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
33
|
+
};
|
|
34
|
+
info: {
|
|
35
|
+
(...data: any[]): void;
|
|
36
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
37
|
+
};
|
|
38
|
+
assert: (value: any, message?: string | undefined, ...optionalParams: any[]) => void;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
declare const endowmentModule: {
|
|
42
|
+
names: readonly ["console"];
|
|
43
|
+
factory: typeof createConsole;
|
|
44
|
+
};
|
|
45
|
+
export default endowmentModule;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { StreamProvider } from '@metamask/providers';
|
|
2
|
-
import { SnapsGlobalObject } from '@metamask/rpc-methods';
|
|
1
|
+
import type { StreamProvider } from '@metamask/providers';
|
|
2
|
+
import type { SnapsGlobalObject } from '@metamask/rpc-methods';
|
|
3
|
+
import type { SnapId } from '@metamask/snaps-utils';
|
|
3
4
|
/**
|
|
4
5
|
* Gets the endowments for a particular Snap. Some endowments, like `setTimeout`
|
|
5
6
|
* and `clearTimeout`, must be attenuated so that they can only affect behavior
|
|
@@ -9,10 +10,11 @@ import { SnapsGlobalObject } from '@metamask/rpc-methods';
|
|
|
9
10
|
*
|
|
10
11
|
* @param snap - The Snaps global API object.
|
|
11
12
|
* @param ethereum - The Snap's EIP-1193 provider object.
|
|
13
|
+
* @param snapId - The id of the snap that will use the created endowments.
|
|
12
14
|
* @param endowments - The list of endowments to provide to the snap.
|
|
13
15
|
* @returns An object containing the Snap's endowments.
|
|
14
16
|
*/
|
|
15
|
-
export declare function createEndowments(snap: SnapsGlobalObject, ethereum: StreamProvider, endowments?: string[]): {
|
|
17
|
+
export declare function createEndowments(snap: SnapsGlobalObject, ethereum: StreamProvider, snapId: SnapId, endowments?: string[]): {
|
|
16
18
|
endowments: Record<string, unknown>;
|
|
17
19
|
teardown: () => Promise<void>;
|
|
18
20
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { StreamProvider } from '@metamask/providers';
|
|
2
|
-
import { RequestArguments } from '@metamask/providers/dist/BaseProvider';
|
|
1
|
+
import type { StreamProvider } from '@metamask/providers';
|
|
2
|
+
import type { RequestArguments } from '@metamask/providers/dist/BaseProvider';
|
|
3
3
|
/**
|
|
4
4
|
* Takes an error that was thrown, determines if it is
|
|
5
5
|
* an error object. If it is then it will return that. Otherwise,
|
|
@@ -19,9 +19,9 @@ export declare function constructError(originalError: unknown): Error | undefine
|
|
|
19
19
|
* @param teardownRef.lastTeardown - Number of the last teardown.
|
|
20
20
|
* @returns New proxy promise.
|
|
21
21
|
*/
|
|
22
|
-
export declare function withTeardown<
|
|
22
|
+
export declare function withTeardown<Type>(originalPromise: Promise<Type>, teardownRef: {
|
|
23
23
|
lastTeardown: number;
|
|
24
|
-
}): Promise<
|
|
24
|
+
}): Promise<Type>;
|
|
25
25
|
/**
|
|
26
26
|
* Returns a Proxy that narrows down (attenuates) the fields available on
|
|
27
27
|
* the StreamProvider and replaces the request implementation.
|
|
@@ -31,6 +31,7 @@ export declare function withTeardown<T>(originalPromise: Promise<T>, teardownRef
|
|
|
31
31
|
* @returns Proxy to the StreamProvider instance.
|
|
32
32
|
*/
|
|
33
33
|
export declare function proxyStreamProvider(provider: StreamProvider, request: unknown): StreamProvider;
|
|
34
|
+
export declare const BLOCKED_RPC_METHODS: readonly string[];
|
|
34
35
|
/**
|
|
35
36
|
* Asserts the validity of request arguments for a snap outbound request using the `snap.request` API.
|
|
36
37
|
*
|
|
@@ -43,3 +44,10 @@ export declare function assertSnapOutboundRequest(args: RequestArguments): void;
|
|
|
43
44
|
* @param args - The arguments to validate.
|
|
44
45
|
*/
|
|
45
46
|
export declare function assertEthereumOutboundRequest(args: RequestArguments): void;
|
|
47
|
+
/**
|
|
48
|
+
* Gets a sanitized value to be used for passing to the underlying MetaMask provider.
|
|
49
|
+
*
|
|
50
|
+
* @param value - An unsanitized value from a snap.
|
|
51
|
+
* @returns A sanitized value ready to be passed to a MetaMask provider.
|
|
52
|
+
*/
|
|
53
|
+
export declare function sanitizeRequestArguments(value: unknown): RequestArguments;
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { HandlerType } from '@metamask/snaps-utils';
|
|
2
|
-
import { Json, JsonRpcSuccess } from '@metamask/utils';
|
|
3
|
-
import { Infer } from 'superstruct';
|
|
4
|
-
/**
|
|
5
|
-
* Validates a given snap export.
|
|
6
|
-
*
|
|
7
|
-
* @param type - The type of export expected.
|
|
8
|
-
* @param snapExport - The export itself.
|
|
9
|
-
* @returns True if the export matches the expected shape, false otherwise.
|
|
10
|
-
*/
|
|
11
|
-
export declare function validateExport(type: HandlerType, snapExport: unknown): boolean;
|
|
2
|
+
import type { Json, JsonRpcSuccess } from '@metamask/utils';
|
|
3
|
+
import type { Infer } from 'superstruct';
|
|
12
4
|
export declare const JsonRpcRequestWithoutIdStruct: import("superstruct").Struct<{
|
|
13
5
|
method: string;
|
|
14
6
|
jsonrpc: "2.0";
|
|
@@ -70,6 +62,30 @@ export declare type OnTransactionRequestArguments = Infer<typeof OnTransactionRe
|
|
|
70
62
|
* object.
|
|
71
63
|
*/
|
|
72
64
|
export declare function assertIsOnTransactionRequestArguments(value: unknown): asserts value is OnTransactionRequestArguments;
|
|
65
|
+
declare const baseNameLookupArgs: {
|
|
66
|
+
chainId: import("superstruct").Struct<string, null>;
|
|
67
|
+
};
|
|
68
|
+
export declare const OnNameLookupRequestArgumentsStruct: import("superstruct").Struct<{
|
|
69
|
+
chainId: string;
|
|
70
|
+
address: string;
|
|
71
|
+
} | {
|
|
72
|
+
chainId: string;
|
|
73
|
+
domain: string;
|
|
74
|
+
}, null>;
|
|
75
|
+
export declare type OnNameLookupRequestArguments = Infer<typeof OnNameLookupRequestArgumentsStruct>;
|
|
76
|
+
export declare type PossibleLookupRequestArgs = typeof baseNameLookupArgs & {
|
|
77
|
+
address?: string;
|
|
78
|
+
domain?: string;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Asserts that the given value is a valid {@link OnNameLookupRequestArguments}
|
|
82
|
+
* object.
|
|
83
|
+
*
|
|
84
|
+
* @param value - The value to validate.
|
|
85
|
+
* @throws If the value is not a valid {@link OnNameLookupRequestArguments}
|
|
86
|
+
* object.
|
|
87
|
+
*/
|
|
88
|
+
export declare function assertIsOnNameLookupRequestArguments(value: unknown): asserts value is OnNameLookupRequestArguments;
|
|
73
89
|
declare const OkResponseStruct: import("superstruct").Struct<{
|
|
74
90
|
id: string | number | null;
|
|
75
91
|
jsonrpc: "2.0";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BasePostMessageStream } from '@metamask/post-message-stream';
|
|
1
|
+
import type { BasePostMessageStream } from '@metamask/post-message-stream';
|
|
2
2
|
import { BaseSnapExecutor } from '../common/BaseSnapExecutor';
|
|
3
3
|
export declare class IFrameSnapExecutor extends BaseSnapExecutor {
|
|
4
4
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { BasePostMessageStream
|
|
1
|
+
import type { BasePostMessageStream } from '@metamask/post-message-stream';
|
|
2
|
+
import { WindowPostMessageStream } from '@metamask/post-message-stream';
|
|
2
3
|
declare type ExecutorJob = {
|
|
3
4
|
id: string;
|
|
4
5
|
window: Window;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BasePostMessageStream } from '@metamask/post-message-stream';
|
|
2
|
+
import { BaseSnapExecutor } from '../../common/BaseSnapExecutor';
|
|
3
|
+
export declare class WebWorkerSnapExecutor extends BaseSnapExecutor {
|
|
4
|
+
/**
|
|
5
|
+
* Initialize the WebWorkerSnapExecutor. This creates a post message stream
|
|
6
|
+
* from and to the parent window, for two-way communication with the iframe.
|
|
7
|
+
*
|
|
8
|
+
* @param stream - The stream to use for communication.
|
|
9
|
+
* @returns An instance of `WebWorkerSnapExecutor`, with the initialized post
|
|
10
|
+
* message streams.
|
|
11
|
+
*/
|
|
12
|
+
static initialize(stream?: BasePostMessageStream): WebWorkerSnapExecutor;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { BasePostMessageStream } from '@metamask/post-message-stream';
|
|
2
|
+
import { WebWorkerParentPostMessageStream } from '@metamask/post-message-stream';
|
|
3
|
+
declare type ExecutorJob = {
|
|
4
|
+
id: string;
|
|
5
|
+
worker: Worker;
|
|
6
|
+
stream: WebWorkerParentPostMessageStream;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* A snap executor using the WebWorker API.
|
|
10
|
+
*
|
|
11
|
+
* This is not a traditional snap executor, as it does not execute snaps itself.
|
|
12
|
+
* Instead, it creates a pool of webworkers for each snap execution, and sends
|
|
13
|
+
* the snap execution request to the webworker. The webworker is responsible for
|
|
14
|
+
* executing the snap.
|
|
15
|
+
*/
|
|
16
|
+
export declare class WebWorkerPool {
|
|
17
|
+
#private;
|
|
18
|
+
readonly pool: Worker[];
|
|
19
|
+
readonly jobs: Map<string, ExecutorJob>;
|
|
20
|
+
static initialize(stream?: BasePostMessageStream, url?: string, poolSize?: number): WebWorkerPool;
|
|
21
|
+
constructor(stream: BasePostMessageStream, url: string, poolSize?: number);
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-execution-environments",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Snap sandbox environments for executing SES javascript",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/MetaMask/snaps.git"
|
|
8
8
|
},
|
|
9
|
-
"
|
|
10
|
-
"
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"main": "./dist/cjs/index.js",
|
|
11
|
+
"module": "./dist/esm/index.js",
|
|
12
|
+
"types": "./dist/types/index.d.ts",
|
|
11
13
|
"files": [
|
|
12
|
-
"dist/"
|
|
14
|
+
"dist/cjs/**",
|
|
15
|
+
"dist/esm/**",
|
|
16
|
+
"dist/types/**",
|
|
17
|
+
"dist/browserify/**"
|
|
13
18
|
],
|
|
14
19
|
"scripts": {
|
|
15
20
|
"test": "rimraf coverage && jest && yarn test:browser && yarn posttest",
|
|
@@ -17,36 +22,38 @@
|
|
|
17
22
|
"test:browser": "wdio run wdio.config.ts",
|
|
18
23
|
"test:ci": "yarn test",
|
|
19
24
|
"test:watch": "jest --watch",
|
|
20
|
-
"lint:eslint": "eslint . --cache --ext js,ts",
|
|
21
|
-
"lint:misc": "prettier
|
|
25
|
+
"lint:eslint": "eslint . --cache --ext js,ts,jsx,tsx",
|
|
26
|
+
"lint:misc": "prettier --no-error-on-unmatched-pattern --loglevel warn \"**/*.json\" \"**/*.md\" \"**/*.html\" \"!CHANGELOG.md\" --ignore-path ./.prettierignore",
|
|
22
27
|
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
|
|
23
|
-
"lint:changelog": "
|
|
24
|
-
"lint": "yarn lint:eslint && yarn lint:misc --check",
|
|
25
|
-
"clean": "rimraf '*.tsbuildinfo' 'dist
|
|
28
|
+
"lint:changelog": "../../scripts/validate-changelog.sh @metamask/snaps-execution-environments",
|
|
29
|
+
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn lint:changelog && yarn lint:dependencies",
|
|
30
|
+
"clean": "rimraf '*.tsbuildinfo' 'dist' 'src/__GENERATED__/' 'coverage/*' '__test__/*'",
|
|
31
|
+
"build": "yarn build:source && yarn build:types",
|
|
32
|
+
"build:source": "yarn build:esm && yarn build:cjs",
|
|
33
|
+
"build:types": "tsc --project tsconfig.build.json",
|
|
34
|
+
"build:esm": "swc src --out-dir dist/esm --config-file ../../.swcrc.build.json --config module.type=es6",
|
|
35
|
+
"build:cjs": "swc src --out-dir dist/cjs --config-file ../../.swcrc.build.json --config module.type=commonjs",
|
|
26
36
|
"build:clean": "yarn clean && yarn build",
|
|
27
37
|
"build:post-tsc": "yarn build:lavamoat",
|
|
28
|
-
"build:tsc": "tsc --project tsconfig.build.json",
|
|
29
|
-
"build": "yarn build:tsc && yarn build:post-tsc",
|
|
30
|
-
"build:test": "yarn build:lavamoat",
|
|
31
38
|
"build:lavamoat": "lavamoat scripts/build.js --policy lavamoat/build-system/policy.json --policyOverride lavamoat/build-system/policy-override.json",
|
|
32
39
|
"build:lavamoat:policy": "yarn build:lavamoat --writeAutoPolicy && node scripts/build.js --writeAutoPolicy",
|
|
33
40
|
"auto-changelog-init": "auto-changelog init",
|
|
34
41
|
"prepare-manifest:preview": "../../scripts/prepare-preview-manifest.sh",
|
|
35
42
|
"publish:preview": "yarn npm publish --tag preview",
|
|
36
|
-
"
|
|
43
|
+
"lint:ci": "yarn lint",
|
|
44
|
+
"start": "node scripts/start.js",
|
|
45
|
+
"lint:dependencies": "depcheck"
|
|
37
46
|
},
|
|
38
47
|
"dependencies": {
|
|
39
48
|
"@metamask/object-multiplex": "^1.2.0",
|
|
40
|
-
"@metamask/post-message-stream": "^
|
|
41
|
-
"@metamask/providers": "^
|
|
42
|
-
"@metamask/rpc-methods": "^
|
|
43
|
-
"@metamask/snaps-utils": "^
|
|
44
|
-
"@metamask/utils": "^
|
|
49
|
+
"@metamask/post-message-stream": "^7.0.0",
|
|
50
|
+
"@metamask/providers": "^11.1.1",
|
|
51
|
+
"@metamask/rpc-methods": "^2.0.0",
|
|
52
|
+
"@metamask/snaps-utils": "^2.0.1",
|
|
53
|
+
"@metamask/utils": "^8.1.0",
|
|
45
54
|
"eth-rpc-errors": "^4.0.3",
|
|
46
55
|
"json-rpc-engine": "^6.1.0",
|
|
47
|
-
"
|
|
48
|
-
"ses": "^0.18.1",
|
|
49
|
-
"stream-browserify": "^3.0.0",
|
|
56
|
+
"nanoid": "^3.1.31",
|
|
50
57
|
"superstruct": "^1.0.3"
|
|
51
58
|
},
|
|
52
59
|
"devDependencies": {
|
|
@@ -55,61 +62,65 @@
|
|
|
55
62
|
"@babel/preset-typescript": "^7.20.12",
|
|
56
63
|
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
|
|
57
64
|
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
|
|
58
|
-
"@lavamoat/allow-scripts": "^2.
|
|
59
|
-
"@lavamoat/lavapack": "^5.
|
|
65
|
+
"@lavamoat/allow-scripts": "^2.5.1",
|
|
66
|
+
"@lavamoat/lavapack": "^5.4.1",
|
|
60
67
|
"@lavamoat/lavatube": "^0.2.3",
|
|
61
68
|
"@metamask/auto-changelog": "^3.1.0",
|
|
62
|
-
"@metamask/eslint-config": "^
|
|
63
|
-
"@metamask/eslint-config-jest": "^
|
|
64
|
-
"@metamask/eslint-config-nodejs": "^
|
|
65
|
-
"@metamask/eslint-config-typescript": "^
|
|
69
|
+
"@metamask/eslint-config": "^12.1.0",
|
|
70
|
+
"@metamask/eslint-config-jest": "^12.1.0",
|
|
71
|
+
"@metamask/eslint-config-nodejs": "^12.1.0",
|
|
72
|
+
"@metamask/eslint-config-typescript": "^12.1.0",
|
|
73
|
+
"@swc/cli": "^0.1.62",
|
|
74
|
+
"@swc/core": "1.3.78",
|
|
75
|
+
"@swc/jest": "^0.2.26",
|
|
76
|
+
"@types/express": "^4.17.17",
|
|
66
77
|
"@types/jest": "^27.5.1",
|
|
67
|
-
"@types/node": "
|
|
78
|
+
"@types/node": "18.14.2",
|
|
68
79
|
"@typescript-eslint/eslint-plugin": "^5.42.1",
|
|
69
80
|
"@typescript-eslint/parser": "^5.42.1",
|
|
70
|
-
"@wdio/browser-runner": "^8.
|
|
71
|
-
"@wdio/cli": "^8.
|
|
72
|
-
"@wdio/globals": "^8.
|
|
73
|
-
"@wdio/mocha-framework": "^8.
|
|
74
|
-
"@wdio/spec-reporter": "^8.
|
|
75
|
-
"@wdio/static-server-service": "^8.
|
|
76
|
-
"babel-loader": "^9.1.2",
|
|
81
|
+
"@wdio/browser-runner": "^8.15.9",
|
|
82
|
+
"@wdio/cli": "^8.15.9",
|
|
83
|
+
"@wdio/globals": "^8.15.9",
|
|
84
|
+
"@wdio/mocha-framework": "^8.15.9",
|
|
85
|
+
"@wdio/spec-reporter": "^8.15.7",
|
|
86
|
+
"@wdio/static-server-service": "^8.15.7",
|
|
77
87
|
"babel-plugin-tsconfig-paths-module-resolver": "^1.0.4",
|
|
78
88
|
"babelify": "^10.0.0",
|
|
79
89
|
"browserify": "^17.0.0",
|
|
80
|
-
"buffer": "^6.0.3",
|
|
81
90
|
"deepmerge": "^4.2.2",
|
|
91
|
+
"depcheck": "^1.4.5",
|
|
92
|
+
"esbuild": "^0.18.10",
|
|
82
93
|
"eslint": "^8.27.0",
|
|
83
94
|
"eslint-config-prettier": "^8.5.0",
|
|
84
95
|
"eslint-plugin-import": "^2.26.0",
|
|
85
96
|
"eslint-plugin-jest": "^27.1.5",
|
|
86
97
|
"eslint-plugin-jsdoc": "^39.6.2",
|
|
87
|
-
"eslint-plugin-
|
|
98
|
+
"eslint-plugin-n": "^15.7.0",
|
|
88
99
|
"eslint-plugin-prettier": "^4.2.1",
|
|
100
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
89
101
|
"expect-webdriverio": "^4.1.2",
|
|
102
|
+
"express": "^4.18.2",
|
|
90
103
|
"istanbul-lib-coverage": "^3.2.0",
|
|
91
104
|
"istanbul-lib-report": "^3.0.0",
|
|
92
105
|
"istanbul-reports": "^3.1.5",
|
|
93
106
|
"jest": "^29.0.2",
|
|
107
|
+
"jest-environment-node": "^29.5.0",
|
|
94
108
|
"jest-fetch-mock": "^3.0.3",
|
|
95
|
-
"lavamoat": "^7.
|
|
96
|
-
"lavamoat-browserify": "^15.
|
|
97
|
-
"memfs": "^3.4.13",
|
|
109
|
+
"lavamoat": "^7.3.1",
|
|
110
|
+
"lavamoat-browserify": "^15.9.1",
|
|
98
111
|
"prettier": "^2.7.1",
|
|
99
112
|
"prettier-plugin-packagejson": "^2.2.11",
|
|
100
|
-
"process": "^0.11.10",
|
|
101
113
|
"rimraf": "^4.1.2",
|
|
102
|
-
"
|
|
114
|
+
"serve-handler": "^6.1.5",
|
|
115
|
+
"ses": "^0.18.8",
|
|
103
116
|
"terser": "^5.17.7",
|
|
104
|
-
"ts-jest": "^29.0.0",
|
|
105
117
|
"ts-node": "^10.9.1",
|
|
106
|
-
"tsconfig-paths": "^4.1.2",
|
|
107
118
|
"typescript": "~4.8.4",
|
|
108
119
|
"vite": "^4.3.9",
|
|
109
120
|
"vite-tsconfig-paths": "^4.0.5",
|
|
110
121
|
"wdio-chromedriver-service": "^8.1.1",
|
|
111
|
-
"wdio-geckodriver-service": "^
|
|
112
|
-
"webdriverio": "^8.
|
|
122
|
+
"wdio-geckodriver-service": "^5.0.2",
|
|
123
|
+
"webdriverio": "^8.15.9",
|
|
113
124
|
"yargs": "^17.7.1"
|
|
114
125
|
},
|
|
115
126
|
"engines": {
|