@metamask/snaps-controllers 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 +36 -562
- package/dist/cjs/cronjob/CronjobController.js +294 -0
- package/dist/cjs/cronjob/CronjobController.js.map +1 -0
- package/dist/cjs/cronjob/index.js +20 -0
- package/dist/cjs/cronjob/index.js.map +1 -0
- package/dist/cjs/fsm.js +69 -0
- package/dist/cjs/fsm.js.map +1 -0
- package/dist/cjs/index.js +23 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/logging.js +15 -0
- package/dist/cjs/logging.js.map +1 -0
- package/dist/cjs/services/AbstractExecutionService.js +390 -0
- package/dist/cjs/services/AbstractExecutionService.js.map +1 -0
- package/dist/cjs/services/ExecutionService.js +7 -0
- package/dist/cjs/services/ExecutionService.js.map +1 -0
- package/dist/cjs/services/ProxyPostMessageStream.js +116 -0
- package/dist/cjs/services/ProxyPostMessageStream.js.map +1 -0
- package/dist/cjs/services/browser.js +32 -0
- package/dist/cjs/services/browser.js.map +1 -0
- package/dist/cjs/services/iframe/IframeExecutionService.js +54 -0
- package/dist/cjs/services/iframe/IframeExecutionService.js.map +1 -0
- package/dist/cjs/services/iframe/index.js +20 -0
- package/dist/cjs/services/iframe/index.js.map +1 -0
- package/dist/cjs/services/index.js +32 -0
- package/dist/cjs/services/index.js.map +1 -0
- package/dist/cjs/services/node/NodeProcessExecutionService.js +30 -0
- package/dist/cjs/services/node/NodeProcessExecutionService.js.map +1 -0
- package/dist/cjs/services/node/NodeThreadExecutionService.js +30 -0
- package/dist/cjs/services/node/NodeThreadExecutionService.js.map +1 -0
- package/dist/cjs/services/node/index.js +21 -0
- package/dist/cjs/services/node/index.js.map +1 -0
- package/dist/cjs/services/offscreen/OffscreenExecutionService.js +159 -0
- package/dist/cjs/services/offscreen/OffscreenExecutionService.js.map +1 -0
- package/dist/cjs/services/offscreen/index.js +20 -0
- package/dist/cjs/services/offscreen/index.js.map +1 -0
- package/dist/cjs/services/webworker/WebWorkerExecutionService.js +148 -0
- package/dist/cjs/services/webworker/WebWorkerExecutionService.js.map +1 -0
- package/dist/cjs/services/webworker/index.js +20 -0
- package/dist/cjs/services/webworker/index.js.map +1 -0
- package/dist/cjs/snaps/RequestQueue.js +63 -0
- package/dist/cjs/snaps/RequestQueue.js.map +1 -0
- package/dist/cjs/snaps/SnapController.js +1729 -0
- package/dist/cjs/snaps/SnapController.js.map +1 -0
- package/dist/cjs/snaps/Timer.js +117 -0
- package/dist/cjs/snaps/Timer.js.map +1 -0
- package/dist/cjs/snaps/endowments/cronjob.js +100 -0
- package/dist/cjs/snaps/endowments/cronjob.js.map +1 -0
- package/dist/cjs/snaps/endowments/enum.js +23 -0
- package/dist/cjs/snaps/endowments/enum.js.map +1 -0
- package/dist/cjs/snaps/endowments/ethereum-provider.js +43 -0
- package/dist/cjs/snaps/endowments/ethereum-provider.js.map +1 -0
- package/dist/cjs/snaps/endowments/index.js +88 -0
- package/dist/cjs/snaps/endowments/index.js.map +1 -0
- package/dist/cjs/snaps/endowments/lifecycle-hooks.js +37 -0
- package/dist/cjs/snaps/endowments/lifecycle-hooks.js.map +1 -0
- package/dist/cjs/snaps/endowments/name-lookup.js +106 -0
- package/dist/cjs/snaps/endowments/name-lookup.js.map +1 -0
- package/dist/cjs/snaps/endowments/network-access.js +44 -0
- package/dist/cjs/snaps/endowments/network-access.js.map +1 -0
- package/dist/cjs/snaps/endowments/rpc.js +99 -0
- package/dist/cjs/snaps/endowments/rpc.js.map +1 -0
- package/dist/cjs/snaps/endowments/transaction-insight.js +106 -0
- package/dist/cjs/snaps/endowments/transaction-insight.js.map +1 -0
- package/dist/cjs/snaps/endowments/web-assembly.js +42 -0
- package/dist/cjs/snaps/endowments/web-assembly.js.map +1 -0
- package/dist/cjs/snaps/index.js +25 -0
- package/dist/cjs/snaps/index.js.map +1 -0
- package/dist/cjs/snaps/location/http.js +106 -0
- package/dist/cjs/snaps/location/http.js.map +1 -0
- package/dist/cjs/snaps/location/index.js +23 -0
- package/dist/cjs/snaps/location/index.js.map +1 -0
- package/dist/cjs/snaps/location/local.js +93 -0
- package/dist/cjs/snaps/location/local.js.map +1 -0
- package/dist/cjs/snaps/location/location.js +34 -0
- package/dist/cjs/snaps/location/location.js.map +1 -0
- package/dist/cjs/snaps/location/npm.js +293 -0
- package/dist/cjs/snaps/location/npm.js.map +1 -0
- package/dist/cjs/snaps/permissions.js +61 -0
- package/dist/cjs/snaps/permissions.js.map +1 -0
- package/dist/cjs/snaps/registry/index.js +21 -0
- package/dist/cjs/snaps/registry/index.js.map +1 -0
- package/dist/cjs/snaps/registry/json.js +277 -0
- package/dist/cjs/snaps/registry/json.js.map +1 -0
- package/dist/cjs/snaps/registry/registry.js +18 -0
- package/dist/cjs/snaps/registry/registry.js.map +1 -0
- package/dist/cjs/snaps/selectors.js +13 -0
- package/dist/cjs/snaps/selectors.js.map +1 -0
- package/dist/cjs/utils.js +70 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/esm/cronjob/CronjobController.js +279 -0
- package/dist/esm/cronjob/CronjobController.js.map +1 -0
- package/dist/esm/cronjob/index.js +3 -0
- package/dist/esm/cronjob/index.js.map +1 -0
- package/dist/esm/fsm.js +70 -0
- package/dist/esm/fsm.js.map +1 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/logging.js +10 -0
- package/dist/esm/logging.js.map +1 -0
- package/dist/esm/services/AbstractExecutionService.js +373 -0
- package/dist/esm/services/AbstractExecutionService.js.map +1 -0
- package/dist/esm/services/ExecutionService.js +4 -0
- package/dist/esm/services/ExecutionService.js.map +1 -0
- package/dist/esm/services/ProxyPostMessageStream.js +109 -0
- package/dist/esm/services/ProxyPostMessageStream.js.map +1 -0
- package/dist/esm/services/browser.js +9 -0
- package/dist/esm/services/browser.js.map +1 -0
- package/dist/esm/services/iframe/IframeExecutionService.js +44 -0
- package/dist/esm/services/iframe/IframeExecutionService.js.map +1 -0
- package/dist/esm/services/iframe/index.js +3 -0
- package/dist/esm/services/iframe/index.js.map +1 -0
- package/dist/esm/services/index.js +9 -0
- package/dist/esm/services/index.js.map +1 -0
- package/dist/esm/services/node/NodeProcessExecutionService.js +20 -0
- package/dist/esm/services/node/NodeProcessExecutionService.js.map +1 -0
- package/dist/esm/services/node/NodeThreadExecutionService.js +21 -0
- package/dist/esm/services/node/NodeThreadExecutionService.js.map +1 -0
- package/dist/esm/services/node/index.js +4 -0
- package/dist/esm/services/node/index.js.map +1 -0
- package/dist/esm/services/offscreen/OffscreenExecutionService.js +149 -0
- package/dist/esm/services/offscreen/OffscreenExecutionService.js.map +1 -0
- package/dist/esm/services/offscreen/index.js +3 -0
- package/dist/esm/services/offscreen/index.js.map +1 -0
- package/dist/esm/services/webworker/WebWorkerExecutionService.js +130 -0
- package/dist/esm/services/webworker/WebWorkerExecutionService.js.map +1 -0
- package/dist/esm/services/webworker/index.js +3 -0
- package/dist/esm/services/webworker/index.js.map +1 -0
- package/dist/esm/snaps/RequestQueue.js +53 -0
- package/dist/esm/snaps/RequestQueue.js.map +1 -0
- package/dist/esm/snaps/SnapController.js +1708 -0
- package/dist/esm/snaps/SnapController.js.map +1 -0
- package/dist/esm/snaps/Timer.js +107 -0
- package/dist/esm/snaps/Timer.js.map +1 -0
- package/dist/esm/snaps/endowments/cronjob.js +99 -0
- package/dist/esm/snaps/endowments/cronjob.js.map +1 -0
- package/dist/esm/snaps/endowments/enum.js +13 -0
- package/dist/esm/snaps/endowments/enum.js.map +1 -0
- package/dist/esm/snaps/endowments/ethereum-provider.js +33 -0
- package/dist/esm/snaps/endowments/ethereum-provider.js.map +1 -0
- package/dist/esm/snaps/endowments/index.js +45 -0
- package/dist/esm/snaps/endowments/index.js.map +1 -0
- package/dist/esm/snaps/endowments/lifecycle-hooks.js +27 -0
- package/dist/esm/snaps/endowments/lifecycle-hooks.js.map +1 -0
- package/dist/esm/snaps/endowments/name-lookup.js +98 -0
- package/dist/esm/snaps/endowments/name-lookup.js.map +1 -0
- package/dist/esm/snaps/endowments/network-access.js +34 -0
- package/dist/esm/snaps/endowments/network-access.js.map +1 -0
- package/dist/esm/snaps/endowments/rpc.js +88 -0
- package/dist/esm/snaps/endowments/rpc.js.map +1 -0
- package/dist/esm/snaps/endowments/transaction-insight.js +99 -0
- package/dist/esm/snaps/endowments/transaction-insight.js.map +1 -0
- package/dist/esm/snaps/endowments/web-assembly.js +32 -0
- package/dist/esm/snaps/endowments/web-assembly.js.map +1 -0
- package/dist/esm/snaps/index.js +8 -0
- package/dist/esm/snaps/index.js.map +1 -0
- package/dist/{snaps → esm/snaps}/location/http.js +52 -31
- package/dist/esm/snaps/location/http.js.map +1 -0
- package/dist/esm/snaps/location/index.js +6 -0
- package/dist/esm/snaps/location/index.js.map +1 -0
- package/dist/esm/snaps/location/local.js +83 -0
- package/dist/esm/snaps/location/local.js.map +1 -0
- package/dist/esm/snaps/location/location.js +30 -0
- package/dist/esm/snaps/location/location.js.map +1 -0
- package/dist/{snaps → esm/snaps}/location/npm.js +143 -117
- package/dist/esm/snaps/location/npm.js.map +1 -0
- package/dist/esm/snaps/permissions.js +50 -0
- package/dist/esm/snaps/permissions.js.map +1 -0
- package/dist/esm/snaps/registry/index.js +4 -0
- package/dist/esm/snaps/registry/index.js.map +1 -0
- package/dist/esm/snaps/registry/json.js +267 -0
- package/dist/esm/snaps/registry/json.js.map +1 -0
- package/dist/esm/snaps/registry/registry.js +8 -0
- package/dist/esm/snaps/registry/registry.js.map +1 -0
- package/dist/esm/snaps/selectors.js +3 -0
- package/dist/esm/snaps/selectors.js.map +1 -0
- package/dist/{utils.js → esm/utils.js} +21 -30
- package/dist/esm/utils.js.map +1 -0
- package/dist/{cronjob → types/cronjob}/CronjobController.d.ts +12 -11
- package/dist/{fsm.d.ts → types/fsm.d.ts} +1 -1
- package/dist/{index.d.ts → types/index.d.ts} +0 -1
- package/dist/{services → types/services}/AbstractExecutionService.d.ts +4 -4
- package/dist/{services → types/services}/ExecutionService.d.ts +3 -3
- package/dist/{services/offscreen/OffscreenPostMessageStream.d.ts → types/services/ProxyPostMessageStream.d.ts} +10 -10
- package/dist/{services → types/services}/browser.d.ts +2 -0
- package/dist/{services → types/services}/iframe/IframeExecutionService.d.ts +3 -2
- package/dist/{services → types/services}/index.d.ts +2 -0
- package/dist/{services → types/services}/node/NodeProcessExecutionService.d.ts +4 -3
- package/dist/{services → types/services}/node/NodeThreadExecutionService.d.ts +3 -2
- package/dist/{services → types/services}/offscreen/OffscreenExecutionService.d.ts +4 -3
- package/dist/types/services/offscreen/index.d.ts +1 -0
- package/dist/types/services/webworker/WebWorkerExecutionService.d.ts +45 -0
- package/dist/types/services/webworker/index.d.ts +1 -0
- package/dist/{snaps → types/snaps}/SnapController.d.ts +78 -39
- package/dist/{snaps → types/snaps}/endowments/cronjob.d.ts +5 -3
- package/dist/{snaps → types/snaps}/endowments/enum.d.ts +3 -3
- package/dist/{snaps → types/snaps}/endowments/ethereum-provider.d.ts +2 -1
- package/dist/{snaps → types/snaps}/endowments/index.d.ts +23 -23
- package/dist/types/snaps/endowments/lifecycle-hooks.d.ts +15 -0
- package/dist/types/snaps/endowments/name-lookup.d.ts +38 -0
- package/dist/{snaps → types/snaps}/endowments/network-access.d.ts +2 -1
- package/dist/{snaps → types/snaps}/endowments/rpc.d.ts +5 -3
- package/dist/{snaps → types/snaps}/endowments/transaction-insight.d.ts +3 -2
- package/dist/{snaps → types/snaps}/endowments/web-assembly.d.ts +2 -1
- package/dist/{snaps → types/snaps}/index.d.ts +2 -0
- package/dist/{snaps → types/snaps}/location/http.d.ts +3 -2
- package/dist/{snaps → types/snaps}/location/local.d.ts +3 -3
- package/dist/{snaps → types/snaps}/location/location.d.ts +2 -2
- package/dist/types/snaps/location/npm.d.ts +49 -0
- package/dist/types/snaps/permissions.d.ts +16 -0
- package/dist/{snaps → types/snaps}/registry/json.d.ts +5 -4
- package/dist/{snaps → types/snaps}/registry/registry.d.ts +5 -5
- package/dist/types/snaps/selectors.d.ts +2 -0
- package/dist/{utils.d.ts → types/utils.d.ts} +14 -14
- package/package.json +55 -45
- package/dist/cronjob/CronjobController.js +0 -248
- package/dist/cronjob/CronjobController.js.map +0 -1
- package/dist/cronjob/index.js +0 -18
- package/dist/cronjob/index.js.map +0 -1
- package/dist/fsm.js +0 -75
- package/dist/fsm.js.map +0 -1
- package/dist/index.js +0 -22
- package/dist/index.js.map +0 -1
- package/dist/logging.js +0 -13
- package/dist/logging.js.map +0 -1
- package/dist/multichain/MultiChainController.d.ts +0 -137
- package/dist/multichain/MultiChainController.js +0 -339
- package/dist/multichain/MultiChainController.js.map +0 -1
- package/dist/multichain/index.d.ts +0 -3
- package/dist/multichain/index.js +0 -20
- package/dist/multichain/index.js.map +0 -1
- package/dist/multichain/matching.d.ts +0 -9
- package/dist/multichain/matching.js +0 -57
- package/dist/multichain/matching.js.map +0 -1
- package/dist/multichain/middleware.d.ts +0 -14
- package/dist/multichain/middleware.js +0 -42
- package/dist/multichain/middleware.js.map +0 -1
- package/dist/services/AbstractExecutionService.js +0 -318
- package/dist/services/AbstractExecutionService.js.map +0 -1
- package/dist/services/ExecutionService.js +0 -4
- package/dist/services/ExecutionService.js.map +0 -1
- package/dist/services/browser.js +0 -22
- package/dist/services/browser.js.map +0 -1
- package/dist/services/iframe/IframeExecutionService.js +0 -30
- package/dist/services/iframe/IframeExecutionService.js.map +0 -1
- package/dist/services/iframe/index.js +0 -18
- package/dist/services/iframe/index.js.map +0 -1
- package/dist/services/index.js +0 -22
- package/dist/services/index.js.map +0 -1
- package/dist/services/node/NodeProcessExecutionService.js +0 -18
- package/dist/services/node/NodeProcessExecutionService.js.map +0 -1
- package/dist/services/node/NodeThreadExecutionService.js +0 -19
- package/dist/services/node/NodeThreadExecutionService.js.map +0 -1
- package/dist/services/node/index.js +0 -19
- package/dist/services/node/index.js.map +0 -1
- package/dist/services/offscreen/OffscreenExecutionService.js +0 -100
- package/dist/services/offscreen/OffscreenExecutionService.js.map +0 -1
- package/dist/services/offscreen/OffscreenPostMessageStream.js +0 -66
- package/dist/services/offscreen/OffscreenPostMessageStream.js.map +0 -1
- package/dist/services/offscreen/index.d.ts +0 -2
- package/dist/services/offscreen/index.js +0 -19
- package/dist/services/offscreen/index.js.map +0 -1
- package/dist/snaps/RequestQueue.js +0 -44
- package/dist/snaps/RequestQueue.js.map +0 -1
- package/dist/snaps/SnapController.js +0 -1478
- package/dist/snaps/SnapController.js.map +0 -1
- package/dist/snaps/Timer.js +0 -86
- package/dist/snaps/Timer.js.map +0 -1
- package/dist/snaps/endowments/cronjob.js +0 -105
- package/dist/snaps/endowments/cronjob.js.map +0 -1
- package/dist/snaps/endowments/enum.js +0 -15
- package/dist/snaps/endowments/enum.js.map +0 -1
- package/dist/snaps/endowments/ethereum-provider.js +0 -32
- package/dist/snaps/endowments/ethereum-provider.js.map +0 -1
- package/dist/snaps/endowments/index.js +0 -60
- package/dist/snaps/endowments/index.js.map +0 -1
- package/dist/snaps/endowments/keyring.d.ts +0 -40
- package/dist/snaps/endowments/keyring.js +0 -103
- package/dist/snaps/endowments/keyring.js.map +0 -1
- package/dist/snaps/endowments/long-running.d.ts +0 -13
- package/dist/snaps/endowments/long-running.js +0 -29
- package/dist/snaps/endowments/long-running.js.map +0 -1
- package/dist/snaps/endowments/network-access.js +0 -30
- package/dist/snaps/endowments/network-access.js.map +0 -1
- package/dist/snaps/endowments/rpc.js +0 -92
- package/dist/snaps/endowments/rpc.js.map +0 -1
- package/dist/snaps/endowments/transaction-insight.js +0 -106
- package/dist/snaps/endowments/transaction-insight.js.map +0 -1
- package/dist/snaps/endowments/web-assembly.js +0 -31
- package/dist/snaps/endowments/web-assembly.js.map +0 -1
- package/dist/snaps/index.js +0 -21
- package/dist/snaps/index.js.map +0 -1
- package/dist/snaps/location/http.js.map +0 -1
- package/dist/snaps/location/index.js +0 -21
- package/dist/snaps/location/index.js.map +0 -1
- package/dist/snaps/location/local.js +0 -51
- package/dist/snaps/location/local.js.map +0 -1
- package/dist/snaps/location/location.js +0 -34
- package/dist/snaps/location/location.js.map +0 -1
- package/dist/snaps/location/npm.d.ts +0 -28
- package/dist/snaps/location/npm.js.map +0 -1
- package/dist/snaps/registry/index.js +0 -19
- package/dist/snaps/registry/index.js.map +0 -1
- package/dist/snaps/registry/json.js +0 -197
- package/dist/snaps/registry/json.js.map +0 -1
- package/dist/snaps/registry/registry.js +0 -11
- package/dist/snaps/registry/registry.js.map +0 -1
- package/dist/snaps/selectors.d.ts +0 -2
- package/dist/snaps/selectors.js +0 -6
- package/dist/snaps/selectors.js.map +0 -1
- package/dist/utils.js.map +0 -1
- /package/dist/{cronjob → types/cronjob}/index.d.ts +0 -0
- /package/dist/{logging.d.ts → types/logging.d.ts} +0 -0
- /package/dist/{services → types/services}/iframe/index.d.ts +0 -0
- /package/dist/{services → types/services}/node/index.d.ts +0 -0
- /package/dist/{snaps → types/snaps}/RequestQueue.d.ts +0 -0
- /package/dist/{snaps → types/snaps}/Timer.d.ts +0 -0
- /package/dist/{snaps → types/snaps}/location/index.d.ts +0 -0
- /package/dist/{snaps → types/snaps}/registry/index.d.ts +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { BasePostMessageStream } from '@metamask/post-message-stream';
|
|
2
|
+
import type { BasePostMessageStream } from '@metamask/post-message-stream';
|
|
3
3
|
import { Worker } from 'worker_threads';
|
|
4
|
-
import {
|
|
4
|
+
import type { Job } from '..';
|
|
5
|
+
import { AbstractExecutionService } from '..';
|
|
5
6
|
export declare class NodeThreadExecutionService extends AbstractExecutionService<Worker> {
|
|
6
7
|
protected initEnvStream(): Promise<{
|
|
7
8
|
worker: Worker;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { ExecutionServiceArgs, Job } from '../AbstractExecutionService';
|
|
2
|
+
import { AbstractExecutionService } from '../AbstractExecutionService';
|
|
3
|
+
import { ProxyPostMessageStream } from '../ProxyPostMessageStream';
|
|
3
4
|
declare type OffscreenExecutionEnvironmentServiceArgs = {
|
|
4
5
|
documentUrl: URL;
|
|
5
6
|
frameUrl: URL;
|
|
@@ -37,7 +38,7 @@ export declare class OffscreenExecutionService extends AbstractExecutionService<
|
|
|
37
38
|
*/
|
|
38
39
|
protected initEnvStream(jobId: string): Promise<{
|
|
39
40
|
worker: string;
|
|
40
|
-
stream:
|
|
41
|
+
stream: ProxyPostMessageStream;
|
|
41
42
|
}>;
|
|
42
43
|
/**
|
|
43
44
|
* Creates the offscreen document to be used as the execution environment.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './OffscreenExecutionService';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ExecutionServiceArgs, Job } from '../AbstractExecutionService';
|
|
2
|
+
import { AbstractExecutionService } from '../AbstractExecutionService';
|
|
3
|
+
import { ProxyPostMessageStream } from '../ProxyPostMessageStream';
|
|
4
|
+
declare type WebWorkerExecutionEnvironmentServiceArgs = {
|
|
5
|
+
documentUrl: URL;
|
|
6
|
+
} & ExecutionServiceArgs;
|
|
7
|
+
export declare const WORKER_POOL_ID = "snaps-worker-pool";
|
|
8
|
+
export declare class WebWorkerExecutionService extends AbstractExecutionService<string> {
|
|
9
|
+
#private;
|
|
10
|
+
/**
|
|
11
|
+
* Create a new webworker execution service.
|
|
12
|
+
*
|
|
13
|
+
* @param args - The constructor arguments.
|
|
14
|
+
* @param args.documentUrl - The URL of the worker pool document to use as the
|
|
15
|
+
* execution environment.
|
|
16
|
+
* @param args.messenger - The messenger to use for communication with the
|
|
17
|
+
* `SnapController`.
|
|
18
|
+
* @param args.setupSnapProvider - The function to use to set up the snap
|
|
19
|
+
* provider.
|
|
20
|
+
*/
|
|
21
|
+
constructor({ documentUrl, messenger, setupSnapProvider, }: WebWorkerExecutionEnvironmentServiceArgs);
|
|
22
|
+
/**
|
|
23
|
+
* Send a termination command to the worker pool document.
|
|
24
|
+
*
|
|
25
|
+
* @param job - The job to terminate.
|
|
26
|
+
*/
|
|
27
|
+
protected terminateJob(job: Job<string>): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Create a new stream for the specified job. This wraps the runtime stream
|
|
30
|
+
* in a stream specific to the job.
|
|
31
|
+
*
|
|
32
|
+
* @param jobId - The job ID.
|
|
33
|
+
*/
|
|
34
|
+
protected initEnvStream(jobId: string): Promise<{
|
|
35
|
+
worker: string;
|
|
36
|
+
stream: ProxyPostMessageStream;
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Creates the worker pool document to be used as the execution environment.
|
|
40
|
+
*
|
|
41
|
+
* If the document already exists, this does nothing.
|
|
42
|
+
*/
|
|
43
|
+
private createDocument;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './WebWorkerExecutionService';
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { AddApprovalRequest, UpdateRequestState } from '@metamask/approval-controller';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import type { AddApprovalRequest, UpdateRequestState } from '@metamask/approval-controller';
|
|
2
|
+
import type { RestrictedControllerMessenger } from '@metamask/base-controller';
|
|
3
|
+
import { BaseControllerV2 as BaseController } from '@metamask/base-controller';
|
|
4
|
+
import type { GetEndowments, GetPermissions, GetSubjectMetadata, GetSubjects, GrantPermissions, HasPermission, HasPermissions, RevokeAllPermissions, RevokePermissionForAllSubjects, RevokePermissions, UpdateCaveat } from '@metamask/permission-controller';
|
|
5
|
+
import type { BlockReason } from '@metamask/snaps-registry';
|
|
6
|
+
import type { InstallSnapsResult, PersistedSnap, RequestedSnapPermissions, Snap, SnapId, SnapRpcHook, SnapRpcHookArgs, StatusContext, StatusEvents, StatusStates, TruncatedSnap, ValidatedSnapId } from '@metamask/snaps-utils';
|
|
7
|
+
import { SnapStatusEvents } from '@metamask/snaps-utils';
|
|
8
|
+
import type { Json, NonEmptyArray } from '@metamask/utils';
|
|
9
|
+
import type { StateMachine } from '@xstate/fsm';
|
|
8
10
|
import type { Patch } from 'immer';
|
|
9
|
-
import { ExecuteSnapAction, ExecutionServiceEvents, HandleRpcRequestAction, SnapErrorJson, TerminateAllSnapsAction, TerminateSnapAction } from '../services';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
11
|
+
import type { ExecuteSnapAction, ExecutionServiceEvents, HandleRpcRequestAction, SnapErrorJson, TerminateAllSnapsAction, TerminateSnapAction } from '../services';
|
|
12
|
+
import type { SnapLocation } from './location';
|
|
13
|
+
import { detectSnapLocation } from './location';
|
|
14
|
+
import type { GetMetadata, GetResult, SnapsRegistryMetadata, Update } from './registry';
|
|
12
15
|
import { Timer } from './Timer';
|
|
13
16
|
export declare const controllerName = "SnapController";
|
|
14
17
|
export declare const SNAP_APPROVAL_INSTALL = "wallet_installSnap";
|
|
@@ -63,10 +66,10 @@ export declare type SnapError = {
|
|
|
63
66
|
data?: Json;
|
|
64
67
|
};
|
|
65
68
|
declare type CloseAllConnectionsFunction = (origin: string) => void;
|
|
66
|
-
declare type StoredSnaps = Record<
|
|
69
|
+
declare type StoredSnaps = Record<ValidatedSnapId, Snap>;
|
|
67
70
|
export declare type SnapControllerState = {
|
|
68
71
|
snaps: StoredSnaps;
|
|
69
|
-
snapStates: Record<
|
|
72
|
+
snapStates: Record<ValidatedSnapId, string | null>;
|
|
70
73
|
snapErrors: {
|
|
71
74
|
[internalID: string]: SnapError & {
|
|
72
75
|
internalID: string;
|
|
@@ -74,8 +77,8 @@ export declare type SnapControllerState = {
|
|
|
74
77
|
};
|
|
75
78
|
};
|
|
76
79
|
export declare type PersistedSnapControllerState = SnapControllerState & {
|
|
77
|
-
snaps: Record<
|
|
78
|
-
snapStates: Record<
|
|
80
|
+
snaps: Record<ValidatedSnapId, PersistedSnap>;
|
|
81
|
+
snapStates: Record<ValidatedSnapId, string>;
|
|
79
82
|
};
|
|
80
83
|
/**
|
|
81
84
|
* Gets the specified Snap from state.
|
|
@@ -166,7 +169,15 @@ export declare type GetRegistryMetadata = {
|
|
|
166
169
|
type: `${typeof controllerName}:getRegistryMetadata`;
|
|
167
170
|
handler: SnapController['getRegistryMetadata'];
|
|
168
171
|
};
|
|
169
|
-
export declare type
|
|
172
|
+
export declare type DisconnectOrigin = {
|
|
173
|
+
type: `${typeof controllerName}:disconnectOrigin`;
|
|
174
|
+
handler: SnapController['removeSnapFromSubject'];
|
|
175
|
+
};
|
|
176
|
+
export declare type RevokeDynamicPermissions = {
|
|
177
|
+
type: `${typeof controllerName}:revokeDynamicPermissions`;
|
|
178
|
+
handler: SnapController['revokeDynamicSnapPermissions'];
|
|
179
|
+
};
|
|
180
|
+
export declare type SnapControllerActions = ClearSnapState | GetSnap | GetSnapState | HandleSnapRequest | HasSnap | UpdateBlockedSnaps | UpdateSnapState | EnableSnap | DisableSnap | RemoveSnap | GetPermittedSnaps | InstallSnaps | RemoveSnapError | GetAllSnaps | IncrementActiveReferences | DecrementActiveReferences | GetRegistryMetadata | DisconnectOrigin | RevokeDynamicPermissions;
|
|
170
181
|
export declare type SnapStateChange = {
|
|
171
182
|
type: `${typeof controllerName}:stateChange`;
|
|
172
183
|
payload: [SnapControllerState, Patch[]];
|
|
@@ -229,9 +240,24 @@ export declare type SnapTerminated = {
|
|
|
229
240
|
type: `${typeof controllerName}:snapTerminated`;
|
|
230
241
|
payload: [snap: TruncatedSnap];
|
|
231
242
|
};
|
|
232
|
-
|
|
243
|
+
/**
|
|
244
|
+
* Emitted when a Snap is enabled by a user.
|
|
245
|
+
* This is not emitted by default when installing a snap.
|
|
246
|
+
*/
|
|
247
|
+
export declare type SnapEnabled = {
|
|
248
|
+
type: `${typeof controllerName}:snapEnabled`;
|
|
249
|
+
payload: [snap: TruncatedSnap];
|
|
250
|
+
};
|
|
251
|
+
/**
|
|
252
|
+
* Emitted when a Snap is disabled by a user.
|
|
253
|
+
*/
|
|
254
|
+
export declare type SnapDisabled = {
|
|
255
|
+
type: `${typeof controllerName}:snapDisabled`;
|
|
256
|
+
payload: [snap: TruncatedSnap];
|
|
257
|
+
};
|
|
258
|
+
export declare type SnapControllerEvents = SnapAdded | SnapBlocked | SnapInstalled | SnapRemoved | SnapStateChange | SnapUnblocked | SnapUpdated | SnapRolledback | SnapTerminated | SnapEnabled | SnapDisabled;
|
|
233
259
|
export declare type AllowedActions = GetEndowments | GetPermissions | GetSubjects | GetSubjectMetadata | HasPermission | HasPermissions | RevokePermissions | RevokeAllPermissions | RevokePermissionForAllSubjects | GrantPermissions | AddApprovalRequest | HandleRpcRequestAction | ExecuteSnapAction | TerminateAllSnapsAction | TerminateSnapAction | UpdateCaveat | UpdateRequestState | GetResult | GetMetadata | Update;
|
|
234
|
-
export declare type AllowedEvents = ExecutionServiceEvents;
|
|
260
|
+
export declare type AllowedEvents = ExecutionServiceEvents | SnapInstalled | SnapUpdated;
|
|
235
261
|
declare type SnapControllerMessenger = RestrictedControllerMessenger<typeof controllerName, SnapControllerActions | AllowedActions, SnapControllerEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
|
|
236
262
|
declare type FeatureFlags = {
|
|
237
263
|
/**
|
|
@@ -251,6 +277,10 @@ declare type SnapControllerArgs = {
|
|
|
251
277
|
* for a running snap.
|
|
252
278
|
*/
|
|
253
279
|
closeAllConnections: CloseAllConnectionsFunction;
|
|
280
|
+
/**
|
|
281
|
+
* A list of permissions that are allowed to be dynamic, meaning they can be revoked from the snap whenever.
|
|
282
|
+
*/
|
|
283
|
+
dynamicPermissions: string[];
|
|
254
284
|
/**
|
|
255
285
|
* The names of endowment permissions whose values are the names of JavaScript
|
|
256
286
|
* APIs that will be added to the snap execution environment at runtime.
|
|
@@ -305,7 +335,7 @@ declare type SnapControllerArgs = {
|
|
|
305
335
|
export declare class SnapController extends BaseController<string, SnapControllerState, SnapControllerMessenger> {
|
|
306
336
|
#private;
|
|
307
337
|
private readonly maxRequestTime;
|
|
308
|
-
constructor({ closeAllConnections, messenger, state, environmentEndowmentPermissions, excludedPermissions, idleTimeCheckInterval, maxIdleTime, maxRequestTime, fetchFunction, featureFlags, detectSnapLocation: detectSnapLocationFunction, }: SnapControllerArgs);
|
|
338
|
+
constructor({ closeAllConnections, messenger, state, dynamicPermissions, environmentEndowmentPermissions, excludedPermissions, idleTimeCheckInterval, maxIdleTime, maxRequestTime, fetchFunction, featureFlags, detectSnapLocation: detectSnapLocationFunction, }: SnapControllerArgs);
|
|
309
339
|
/**
|
|
310
340
|
* Checks all installed snaps against the block list and
|
|
311
341
|
* blocks/unblocks snaps as appropriate. See {@link SnapController.blockSnap}
|
|
@@ -321,21 +351,21 @@ export declare class SnapController extends BaseController<string, SnapControlle
|
|
|
321
351
|
*
|
|
322
352
|
* @param snapId - The id of the Snap to start.
|
|
323
353
|
*/
|
|
324
|
-
startSnap(snapId:
|
|
354
|
+
startSnap(snapId: ValidatedSnapId): Promise<void>;
|
|
325
355
|
/**
|
|
326
356
|
* Enables the given snap. A snap can only be started if it is enabled. A snap
|
|
327
357
|
* can only be enabled if it isn't blocked.
|
|
328
358
|
*
|
|
329
359
|
* @param snapId - The id of the Snap to enable.
|
|
330
360
|
*/
|
|
331
|
-
enableSnap(snapId:
|
|
361
|
+
enableSnap(snapId: ValidatedSnapId): void;
|
|
332
362
|
/**
|
|
333
363
|
* Disables the given snap. A snap can only be started if it is enabled.
|
|
334
364
|
*
|
|
335
365
|
* @param snapId - The id of the Snap to disable.
|
|
336
366
|
* @returns A promise that resolves once the snap has been disabled.
|
|
337
367
|
*/
|
|
338
|
-
disableSnap(snapId:
|
|
368
|
+
disableSnap(snapId: ValidatedSnapId): Promise<void>;
|
|
339
369
|
/**
|
|
340
370
|
* Stops the given snap, removes all hooks, closes all connections, and
|
|
341
371
|
* terminates its worker.
|
|
@@ -344,7 +374,7 @@ export declare class SnapController extends BaseController<string, SnapControlle
|
|
|
344
374
|
* @param statusEvent - The Snap status event that caused the snap to be
|
|
345
375
|
* stopped.
|
|
346
376
|
*/
|
|
347
|
-
stopSnap(snapId:
|
|
377
|
+
stopSnap(snapId: ValidatedSnapId, statusEvent?: SnapStatusEvents.Stop | SnapStatusEvents.Crash): Promise<void>;
|
|
348
378
|
/**
|
|
349
379
|
* Returns whether the given snap is running.
|
|
350
380
|
* Throws an error if the snap doesn't exist.
|
|
@@ -352,14 +382,14 @@ export declare class SnapController extends BaseController<string, SnapControlle
|
|
|
352
382
|
* @param snapId - The id of the Snap to check.
|
|
353
383
|
* @returns `true` if the snap is running, otherwise `false`.
|
|
354
384
|
*/
|
|
355
|
-
isRunning(snapId:
|
|
385
|
+
isRunning(snapId: ValidatedSnapId): boolean;
|
|
356
386
|
/**
|
|
357
387
|
* Returns whether the given snap has been added to state.
|
|
358
388
|
*
|
|
359
389
|
* @param snapId - The id of the Snap to check for.
|
|
360
390
|
* @returns `true` if the snap exists in the controller state, otherwise `false`.
|
|
361
391
|
*/
|
|
362
|
-
has(snapId:
|
|
392
|
+
has(snapId: ValidatedSnapId): boolean;
|
|
363
393
|
/**
|
|
364
394
|
* Gets the snap with the given id if it exists, including all data.
|
|
365
395
|
* This should not be used if the snap is to be serializable, as e.g.
|
|
@@ -379,7 +409,7 @@ export declare class SnapController extends BaseController<string, SnapControlle
|
|
|
379
409
|
* @param snapId - The id of the snap to get.
|
|
380
410
|
* @returns The entire snap object.
|
|
381
411
|
*/
|
|
382
|
-
getExpect(snapId:
|
|
412
|
+
getExpect(snapId: ValidatedSnapId): Snap;
|
|
383
413
|
/**
|
|
384
414
|
* Gets the snap with the given id if it exists, excluding any
|
|
385
415
|
* non-serializable or expensive-to-serialize data.
|
|
@@ -387,7 +417,7 @@ export declare class SnapController extends BaseController<string, SnapControlle
|
|
|
387
417
|
* @param snapId - The id of the Snap to get.
|
|
388
418
|
* @returns A truncated version of the snap state, that is less expensive to serialize.
|
|
389
419
|
*/
|
|
390
|
-
getTruncated(snapId:
|
|
420
|
+
getTruncated(snapId: ValidatedSnapId): TruncatedSnap | null;
|
|
391
421
|
/**
|
|
392
422
|
* Gets the snap with the given id, throw if it doesn't exist.
|
|
393
423
|
*
|
|
@@ -395,7 +425,7 @@ export declare class SnapController extends BaseController<string, SnapControlle
|
|
|
395
425
|
* @param snapId - The id of the snap to get.
|
|
396
426
|
* @returns A truncated version of the snap state, that is less expensive to serialize.
|
|
397
427
|
*/
|
|
398
|
-
getTruncatedExpect(snapId:
|
|
428
|
+
getTruncatedExpect(snapId: ValidatedSnapId): TruncatedSnap;
|
|
399
429
|
/**
|
|
400
430
|
* Updates the own state of the snap with the given id.
|
|
401
431
|
* This is distinct from the state MetaMask uses to manage snaps.
|
|
@@ -403,14 +433,14 @@ export declare class SnapController extends BaseController<string, SnapControlle
|
|
|
403
433
|
* @param snapId - The id of the Snap whose state should be updated.
|
|
404
434
|
* @param newSnapState - The new state of the snap.
|
|
405
435
|
*/
|
|
406
|
-
updateSnapState(snapId:
|
|
436
|
+
updateSnapState(snapId: ValidatedSnapId, newSnapState: string): Promise<void>;
|
|
407
437
|
/**
|
|
408
438
|
* Clears the state of the snap with the given id.
|
|
409
439
|
* This is distinct from the state MetaMask uses to manage snaps.
|
|
410
440
|
*
|
|
411
441
|
* @param snapId - The id of the Snap whose state should be cleared.
|
|
412
442
|
*/
|
|
413
|
-
clearSnapState(snapId:
|
|
443
|
+
clearSnapState(snapId: ValidatedSnapId): void;
|
|
414
444
|
/**
|
|
415
445
|
* Adds error from a snap to the SnapController state.
|
|
416
446
|
*
|
|
@@ -435,7 +465,7 @@ export declare class SnapController extends BaseController<string, SnapControlle
|
|
|
435
465
|
* @returns A promise that resolves with the decrypted snap state or null if no state exists.
|
|
436
466
|
* @throws If the snap state decryption fails.
|
|
437
467
|
*/
|
|
438
|
-
getSnapState(snapId:
|
|
468
|
+
getSnapState(snapId: ValidatedSnapId): Promise<Json>;
|
|
439
469
|
/**
|
|
440
470
|
* Completely clear the controller's state: delete all associated data,
|
|
441
471
|
* handlers, event listeners, and permissions; tear down all snap providers.
|
|
@@ -448,32 +478,41 @@ export declare class SnapController extends BaseController<string, SnapControlle
|
|
|
448
478
|
* @param snapId - The id of the Snap.
|
|
449
479
|
* @returns A promise that resolves once the snap has been removed.
|
|
450
480
|
*/
|
|
451
|
-
removeSnap(snapId:
|
|
481
|
+
removeSnap(snapId: ValidatedSnapId): Promise<void>;
|
|
452
482
|
/**
|
|
453
483
|
* Stops the given snaps, removes them from state, and clears all associated
|
|
454
484
|
* permissions, handlers, and listeners.
|
|
455
485
|
*
|
|
456
486
|
* @param snapIds - The ids of the Snaps.
|
|
457
487
|
*/
|
|
458
|
-
removeSnaps(snapIds:
|
|
488
|
+
removeSnaps(snapIds: ValidatedSnapId[]): Promise<void>;
|
|
489
|
+
/**
|
|
490
|
+
* Removes a snap's permission (caveat) from the specified subject.
|
|
491
|
+
*
|
|
492
|
+
* @param origin - The origin from which to remove the snap.
|
|
493
|
+
* @param snapId - The id of the snap to remove.
|
|
494
|
+
*/
|
|
495
|
+
removeSnapFromSubject(origin: string, snapId: ValidatedSnapId): void;
|
|
459
496
|
/**
|
|
460
|
-
*
|
|
497
|
+
* Checks if a list of permissions are dynamic and allowed to be revoked, if they are they will all be revoked.
|
|
461
498
|
*
|
|
462
499
|
* @param snapId - The snap ID.
|
|
500
|
+
* @param permissionNames - The names of the permissions.
|
|
501
|
+
* @throws If non-dynamic permissions are passed.
|
|
463
502
|
*/
|
|
464
|
-
|
|
503
|
+
revokeDynamicSnapPermissions(snapId: string, permissionNames: NonEmptyArray<string>): void;
|
|
465
504
|
/**
|
|
466
505
|
* Handles incrementing the activeReferences counter.
|
|
467
506
|
*
|
|
468
507
|
* @param snapId - The snap id of the snap that was referenced.
|
|
469
508
|
*/
|
|
470
|
-
incrementActiveReferences(snapId:
|
|
509
|
+
incrementActiveReferences(snapId: ValidatedSnapId): void;
|
|
471
510
|
/**
|
|
472
511
|
* Handles decrement the activeReferences counter.
|
|
473
512
|
*
|
|
474
513
|
* @param snapId - The snap id of the snap that was referenced..
|
|
475
514
|
*/
|
|
476
|
-
decrementActiveReferences(snapId:
|
|
515
|
+
decrementActiveReferences(snapId: ValidatedSnapId): void;
|
|
477
516
|
/**
|
|
478
517
|
* Gets all snaps in their truncated format.
|
|
479
518
|
*
|
|
@@ -535,7 +574,7 @@ export declare class SnapController extends BaseController<string, SnapControlle
|
|
|
535
574
|
* @returns The metadata for the given snap ID, or `null` if the snap is not
|
|
536
575
|
* verified.
|
|
537
576
|
*/
|
|
538
|
-
getRegistryMetadata(snapId:
|
|
577
|
+
getRegistryMetadata(snapId: ValidatedSnapId): Promise<SnapsRegistryMetadata | null>;
|
|
539
578
|
/**
|
|
540
579
|
* Initiates a request for the given snap's initial permissions.
|
|
541
580
|
* Must be called in order. See processRequestedSnap.
|
|
@@ -558,8 +597,8 @@ export declare class SnapController extends BaseController<string, SnapControlle
|
|
|
558
597
|
* @param options.request - The JSON-RPC request object.
|
|
559
598
|
* @returns The result of the JSON-RPC request.
|
|
560
599
|
*/
|
|
561
|
-
handleRequest({ snapId, origin, handler: handlerType, request, }: SnapRpcHookArgs & {
|
|
562
|
-
snapId:
|
|
600
|
+
handleRequest({ snapId, origin, handler: handlerType, request: rawRequest, }: SnapRpcHookArgs & {
|
|
601
|
+
snapId: ValidatedSnapId;
|
|
563
602
|
}): Promise<unknown>;
|
|
564
603
|
}
|
|
565
604
|
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { PermissionSpecificationBuilder,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { PermissionSpecificationBuilder, PermissionConstraint, Caveat, CaveatSpecificationConstraint } from '@metamask/permission-controller';
|
|
2
|
+
import { PermissionType } from '@metamask/permission-controller';
|
|
3
|
+
import type { CronjobSpecification } from '@metamask/snaps-utils';
|
|
4
|
+
import { SnapCaveatType } from '@metamask/snaps-utils';
|
|
5
|
+
import type { Json, NonEmptyArray } from '@metamask/utils';
|
|
4
6
|
import { SnapEndowments } from './enum';
|
|
5
7
|
declare const permissionName = SnapEndowments.Cronjob;
|
|
6
8
|
export declare const cronjobEndowmentBuilder: Readonly<{
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export declare enum SnapEndowments {
|
|
2
2
|
NetworkAccess = "endowment:network-access",
|
|
3
|
-
LongRunning = "endowment:long-running",
|
|
4
3
|
TransactionInsight = "endowment:transaction-insight",
|
|
5
|
-
Keyring = "endowment:keyring",
|
|
6
4
|
Cronjob = "endowment:cronjob",
|
|
7
5
|
EthereumProvider = "endowment:ethereum-provider",
|
|
8
6
|
Rpc = "endowment:rpc",
|
|
9
|
-
WebAssemblyAccess = "endowment:webassembly"
|
|
7
|
+
WebAssemblyAccess = "endowment:webassembly",
|
|
8
|
+
NameLookup = "endowment:name-lookup",
|
|
9
|
+
LifecycleHooks = "endowment:lifecycle-hooks"
|
|
10
10
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { PermissionSpecificationBuilder
|
|
1
|
+
import type { PermissionSpecificationBuilder } from '@metamask/permission-controller';
|
|
2
|
+
import { PermissionType } from '@metamask/permission-controller';
|
|
2
3
|
import { SnapEndowments } from './enum';
|
|
3
4
|
declare const permissionName = SnapEndowments.EthereumProvider;
|
|
4
5
|
export declare const ethereumProviderEndowmentBuilder: Readonly<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PermissionConstraint } from '@metamask/permission-controller';
|
|
1
|
+
import type { PermissionConstraint } from '@metamask/permission-controller';
|
|
2
2
|
import { HandlerType } from '@metamask/snaps-utils';
|
|
3
|
-
import { Json } from '@metamask/utils';
|
|
3
|
+
import type { Json } from '@metamask/utils';
|
|
4
4
|
export declare const endowmentPermissionBuilders: {
|
|
5
5
|
readonly "endowment:network-access": Readonly<{
|
|
6
6
|
readonly targetName: import("./enum").SnapEndowments.NetworkAccess;
|
|
@@ -11,15 +11,6 @@ export declare const endowmentPermissionBuilders: {
|
|
|
11
11
|
allowedCaveats: null;
|
|
12
12
|
}>;
|
|
13
13
|
}>;
|
|
14
|
-
readonly "endowment:long-running": Readonly<{
|
|
15
|
-
readonly targetName: import("./enum").SnapEndowments.LongRunning;
|
|
16
|
-
readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.Endowment, any, {
|
|
17
|
-
permissionType: import("@metamask/permission-controller").PermissionType.Endowment;
|
|
18
|
-
targetName: import("./enum").SnapEndowments.LongRunning;
|
|
19
|
-
endowmentGetter: (_options?: any) => undefined;
|
|
20
|
-
allowedCaveats: null;
|
|
21
|
-
}>;
|
|
22
|
-
}>;
|
|
23
14
|
readonly "endowment:transaction-insight": Readonly<{
|
|
24
15
|
readonly targetName: import("./enum").SnapEndowments.TransactionInsight;
|
|
25
16
|
readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.Endowment, any, {
|
|
@@ -30,17 +21,6 @@ export declare const endowmentPermissionBuilders: {
|
|
|
30
21
|
validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
|
|
31
22
|
}>;
|
|
32
23
|
}>;
|
|
33
|
-
readonly "endowment:keyring": Readonly<{
|
|
34
|
-
readonly targetName: import("./enum").SnapEndowments.Keyring;
|
|
35
|
-
readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.Endowment, {}, {
|
|
36
|
-
permissionType: import("@metamask/permission-controller").PermissionType.Endowment;
|
|
37
|
-
targetName: import("./enum").SnapEndowments.Keyring;
|
|
38
|
-
endowmentGetter: (_options?: any) => undefined;
|
|
39
|
-
allowedCaveats: readonly [string, ...string[]] | null;
|
|
40
|
-
validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
|
|
41
|
-
subjectTypes: readonly import("@metamask/permission-controller").SubjectType[];
|
|
42
|
-
}>;
|
|
43
|
-
}>;
|
|
44
24
|
readonly "endowment:cronjob": Readonly<{
|
|
45
25
|
readonly targetName: import("./enum").SnapEndowments.Cronjob;
|
|
46
26
|
readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.Endowment, any, {
|
|
@@ -79,15 +59,35 @@ export declare const endowmentPermissionBuilders: {
|
|
|
79
59
|
allowedCaveats: null;
|
|
80
60
|
}>;
|
|
81
61
|
}>;
|
|
62
|
+
readonly "endowment:name-lookup": Readonly<{
|
|
63
|
+
readonly targetName: import("./enum").SnapEndowments.NameLookup;
|
|
64
|
+
readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.Endowment, any, {
|
|
65
|
+
permissionType: import("@metamask/permission-controller").PermissionType.Endowment;
|
|
66
|
+
targetName: import("./enum").SnapEndowments.NameLookup;
|
|
67
|
+
endowmentGetter: (_options?: import("@metamask/permission-controller").EndowmentGetterParams | undefined) => undefined;
|
|
68
|
+
allowedCaveats: readonly [string, ...string[]] | null;
|
|
69
|
+
validator: import("@metamask/permission-controller").PermissionValidatorConstraint;
|
|
70
|
+
}>;
|
|
71
|
+
}>;
|
|
72
|
+
readonly "endowment:lifecycle-hooks": Readonly<{
|
|
73
|
+
readonly targetName: import("./enum").SnapEndowments.LifecycleHooks;
|
|
74
|
+
readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.Endowment, any, {
|
|
75
|
+
permissionType: import("@metamask/permission-controller").PermissionType.Endowment;
|
|
76
|
+
targetName: import("./enum").SnapEndowments.LifecycleHooks;
|
|
77
|
+
endowmentGetter: (_options?: import("@metamask/permission-controller").EndowmentGetterParams | undefined) => undefined;
|
|
78
|
+
allowedCaveats: readonly [string, ...string[]] | null;
|
|
79
|
+
}>;
|
|
80
|
+
}>;
|
|
82
81
|
};
|
|
83
82
|
export declare const endowmentCaveatSpecifications: {
|
|
83
|
+
chainIds: import("@metamask/permission-controller").CaveatSpecificationConstraint;
|
|
84
84
|
rpcOrigin: import("@metamask/permission-controller").CaveatSpecificationConstraint;
|
|
85
85
|
transactionOrigin: import("@metamask/permission-controller").CaveatSpecificationConstraint;
|
|
86
86
|
snapCronjob: import("@metamask/permission-controller").CaveatSpecificationConstraint;
|
|
87
|
-
snapKeyring: import("@metamask/permission-controller").CaveatSpecificationConstraint;
|
|
88
87
|
};
|
|
89
88
|
export declare const endowmentCaveatMappers: Record<string, (value: Json) => Pick<PermissionConstraint, 'caveats'>>;
|
|
90
89
|
export declare const handlerEndowments: Record<HandlerType, string>;
|
|
91
90
|
export * from './enum';
|
|
92
91
|
export { getRpcCaveatOrigins } from './rpc';
|
|
93
92
|
export { getTransactionOriginCaveat } from './transaction-insight';
|
|
93
|
+
export { getChainIdsCaveat } from './name-lookup';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PermissionSpecificationBuilder, EndowmentGetterParams } from '@metamask/permission-controller';
|
|
2
|
+
import { PermissionType } from '@metamask/permission-controller';
|
|
3
|
+
import type { NonEmptyArray } from '@metamask/utils';
|
|
4
|
+
import { SnapEndowments } from './enum';
|
|
5
|
+
declare const permissionName = SnapEndowments.LifecycleHooks;
|
|
6
|
+
export declare const lifecycleHooksEndowmentBuilder: Readonly<{
|
|
7
|
+
readonly targetName: SnapEndowments.LifecycleHooks;
|
|
8
|
+
readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.Endowment, any, {
|
|
9
|
+
permissionType: PermissionType.Endowment;
|
|
10
|
+
targetName: typeof permissionName;
|
|
11
|
+
endowmentGetter: (_options?: EndowmentGetterParams) => undefined;
|
|
12
|
+
allowedCaveats: Readonly<NonEmptyArray<string>> | null;
|
|
13
|
+
}>;
|
|
14
|
+
}>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { EndowmentGetterParams, PermissionSpecificationBuilder, PermissionValidatorConstraint, CaveatSpecificationConstraint, PermissionConstraint } from '@metamask/permission-controller';
|
|
2
|
+
import { PermissionType } from '@metamask/permission-controller';
|
|
3
|
+
import { SnapCaveatType } from '@metamask/snaps-utils';
|
|
4
|
+
import type { Json, NonEmptyArray } from '@metamask/utils';
|
|
5
|
+
import { SnapEndowments } from './enum';
|
|
6
|
+
declare const permissionName = SnapEndowments.NameLookup;
|
|
7
|
+
export declare const nameLookupEndowmentBuilder: Readonly<{
|
|
8
|
+
readonly targetName: SnapEndowments.NameLookup;
|
|
9
|
+
readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.Endowment, any, {
|
|
10
|
+
permissionType: PermissionType.Endowment;
|
|
11
|
+
targetName: typeof permissionName;
|
|
12
|
+
endowmentGetter: (_options?: EndowmentGetterParams) => undefined;
|
|
13
|
+
allowedCaveats: Readonly<NonEmptyArray<string>> | null;
|
|
14
|
+
validator: PermissionValidatorConstraint;
|
|
15
|
+
}>;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Map a raw value from the `initialPermissions` to a caveat specification.
|
|
19
|
+
* Note that this function does not do any validation, that's handled by the
|
|
20
|
+
* PermissionsController when the permission is requested.
|
|
21
|
+
*
|
|
22
|
+
* @param value - The raw value from the `initialPermissions`.
|
|
23
|
+
* @returns The caveat specification.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getNameLookupCaveatMapper(value: Json): Pick<PermissionConstraint, 'caveats'>;
|
|
26
|
+
/**
|
|
27
|
+
* Getter function to get the chainIds caveat from a permission.
|
|
28
|
+
*
|
|
29
|
+
* This does basic validation of the caveat, but does not validate the type or
|
|
30
|
+
* value of the namespaces object itself, as this is handled by the
|
|
31
|
+
* `PermissionsController` when the permission is requested.
|
|
32
|
+
*
|
|
33
|
+
* @param permission - The permission to get the `chainIds` caveat from.
|
|
34
|
+
* @returns An array of `chainIds` that the snap supports.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getChainIdsCaveat(permission?: PermissionConstraint): string[] | null;
|
|
37
|
+
export declare const nameLookupCaveatSpecifications: Record<SnapCaveatType.ChainIds, CaveatSpecificationConstraint>;
|
|
38
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { PermissionSpecificationBuilder
|
|
1
|
+
import type { PermissionSpecificationBuilder } from '@metamask/permission-controller';
|
|
2
|
+
import { PermissionType } from '@metamask/permission-controller';
|
|
2
3
|
import { SnapEndowments } from './enum';
|
|
3
4
|
declare const permissionName = SnapEndowments.NetworkAccess;
|
|
4
5
|
export declare const networkAccessEndowmentBuilder: Readonly<{
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { CaveatSpecificationConstraint, PermissionConstraint, PermissionSpecificationBuilder,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { CaveatSpecificationConstraint, PermissionConstraint, PermissionSpecificationBuilder, PermissionValidatorConstraint } from '@metamask/permission-controller';
|
|
2
|
+
import { PermissionType, SubjectType } from '@metamask/permission-controller';
|
|
3
|
+
import type { RpcOrigins } from '@metamask/snaps-utils';
|
|
4
|
+
import { SnapCaveatType } from '@metamask/snaps-utils';
|
|
5
|
+
import type { Json, NonEmptyArray } from '@metamask/utils';
|
|
4
6
|
import { SnapEndowments } from './enum';
|
|
5
7
|
declare const targetName = SnapEndowments.Rpc;
|
|
6
8
|
declare type RpcSpecificationBuilderOptions = {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { PermissionSpecificationBuilder,
|
|
1
|
+
import type { PermissionSpecificationBuilder, EndowmentGetterParams, PermissionValidatorConstraint, PermissionConstraint, CaveatSpecificationConstraint } from '@metamask/permission-controller';
|
|
2
|
+
import { PermissionType } from '@metamask/permission-controller';
|
|
2
3
|
import { SnapCaveatType } from '@metamask/snaps-utils';
|
|
3
|
-
import { Json, NonEmptyArray } from '@metamask/utils';
|
|
4
|
+
import type { Json, NonEmptyArray } from '@metamask/utils';
|
|
4
5
|
import { SnapEndowments } from './enum';
|
|
5
6
|
declare const permissionName = SnapEndowments.TransactionInsight;
|
|
6
7
|
export declare const transactionInsightEndowmentBuilder: Readonly<{
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { PermissionSpecificationBuilder
|
|
1
|
+
import type { PermissionSpecificationBuilder } from '@metamask/permission-controller';
|
|
2
|
+
import { PermissionType } from '@metamask/permission-controller';
|
|
2
3
|
import { SnapEndowments } from './enum';
|
|
3
4
|
declare const permissionName = SnapEndowments.WebAssemblyAccess;
|
|
4
5
|
export declare const webAssemblyEndowmentBuilder: Readonly<{
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { SnapManifest
|
|
2
|
-
import {
|
|
1
|
+
import type { SnapManifest } from '@metamask/snaps-utils';
|
|
2
|
+
import { VirtualFile } from '@metamask/snaps-utils';
|
|
3
|
+
import type { SnapLocation } from './location';
|
|
3
4
|
export interface HttpOptions {
|
|
4
5
|
/**
|
|
5
6
|
* @default fetch
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SnapManifest, VirtualFile } from '@metamask/snaps-utils';
|
|
2
|
-
import { HttpOptions } from './http';
|
|
3
|
-
import { SnapLocation } from './location';
|
|
1
|
+
import type { SnapManifest, VirtualFile } from '@metamask/snaps-utils';
|
|
2
|
+
import type { HttpOptions } from './http';
|
|
3
|
+
import type { SnapLocation } from './location';
|
|
4
4
|
export declare class LocalLocation implements SnapLocation {
|
|
5
5
|
#private;
|
|
6
6
|
constructor(url: URL, opts?: HttpOptions);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SnapManifest, VirtualFile } from '@metamask/snaps-utils';
|
|
2
|
-
import { NpmOptions } from './npm';
|
|
1
|
+
import type { SnapManifest, VirtualFile } from '@metamask/snaps-utils';
|
|
2
|
+
import type { NpmOptions } from './npm';
|
|
3
3
|
declare module '@metamask/snaps-utils' {
|
|
4
4
|
interface DataMap {
|
|
5
5
|
/**
|