@metamask/snaps-controllers 9.3.1 → 9.4.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/CHANGELOG.md +9 -1
- package/dist/{chunk-3T6W5VI2.mjs → chunk-3WEWHK2I.mjs} +7 -3
- package/dist/chunk-3WEWHK2I.mjs.map +1 -0
- package/dist/{chunk-QYQLJCPR.js → chunk-5O4O4BI5.js} +2 -1
- package/dist/chunk-5O4O4BI5.js.map +1 -0
- package/dist/{chunk-23PVLQFV.mjs → chunk-CJY2LYEL.mjs} +2 -2
- package/dist/{chunk-H7TB7I6Z.js → chunk-EVKVZUYY.js} +7 -3
- package/dist/chunk-EVKVZUYY.js.map +1 -0
- package/dist/{chunk-JLIW4CNS.js → chunk-OJBUUQ5D.js} +7 -7
- package/dist/{chunk-G245VWEY.mjs → chunk-UMVUXQ3B.mjs} +2 -1
- package/dist/chunk-UMVUXQ3B.mjs.map +1 -0
- package/dist/cronjob/CronjobController.js +3 -3
- package/dist/cronjob/CronjobController.mjs +3 -3
- package/dist/cronjob/index.js +3 -3
- package/dist/cronjob/index.mjs +3 -3
- package/dist/index.js +4 -4
- package/dist/index.mjs +3 -3
- package/dist/insights/SnapInsightsController.js +2 -2
- package/dist/insights/SnapInsightsController.mjs +1 -1
- package/dist/insights/index.js +2 -2
- package/dist/insights/index.mjs +1 -1
- package/dist/interface/SnapInterfaceController.js +3 -3
- package/dist/interface/SnapInterfaceController.mjs +2 -2
- package/dist/interface/index.js +3 -3
- package/dist/interface/index.mjs +2 -2
- package/dist/interface/utils.js +2 -2
- package/dist/interface/utils.mjs +1 -1
- package/dist/node.js +4 -4
- package/dist/node.mjs +3 -3
- package/dist/react-native.js +4 -4
- package/dist/react-native.mjs +3 -3
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/cronjob/CronjobController.d.ts +7 -7
- package/dist/types/insights/SnapInsightsController.d.ts +8 -7
- package/dist/types/interface/SnapInterfaceController.d.ts +12 -12
- package/dist/types/services/AbstractExecutionService.d.ts +5 -5
- package/dist/types/services/ExecutionService.d.ts +16 -16
- package/dist/types/services/ProxyPostMessageStream.d.ts +2 -2
- package/dist/types/services/iframe/IframeExecutionService.d.ts +1 -1
- package/dist/types/services/offscreen/OffscreenExecutionService.d.ts +1 -1
- package/dist/types/services/proxy/ProxyExecutionService.d.ts +1 -1
- package/dist/types/services/webview/WebViewExecutionService.d.ts +1 -1
- package/dist/types/services/webview/WebViewMessageStream.d.ts +2 -2
- package/dist/types/services/webworker/WebWorkerExecutionService.d.ts +1 -1
- package/dist/types/snaps/SnapController.d.ts +46 -46
- package/dist/types/snaps/Timer.d.ts +1 -1
- package/dist/types/snaps/location/location.d.ts +1 -1
- package/dist/types/snaps/location/npm.d.ts +1 -1
- package/dist/types/snaps/registry/json.d.ts +10 -10
- package/dist/types/snaps/registry/registry.d.ts +5 -5
- package/dist/types/types/controllers.d.ts +8 -8
- package/dist/types/types/encryptor.d.ts +5 -5
- package/dist/types/utils.d.ts +13 -6
- package/package.json +5 -5
- package/dist/chunk-3T6W5VI2.mjs.map +0 -1
- package/dist/chunk-G245VWEY.mjs.map +0 -1
- package/dist/chunk-H7TB7I6Z.js.map +0 -1
- package/dist/chunk-QYQLJCPR.js.map +0 -1
- /package/dist/{chunk-23PVLQFV.mjs.map → chunk-CJY2LYEL.mjs.map} +0 -0
- /package/dist/{chunk-JLIW4CNS.js.map → chunk-OJBUUQ5D.js.map} +0 -0
|
@@ -5,26 +5,26 @@ import type { SnapId } from '@metamask/snaps-sdk';
|
|
|
5
5
|
import type { CronjobSpecification } from '@metamask/snaps-utils';
|
|
6
6
|
import type { GetAllSnaps, HandleSnapRequest, SnapDisabled, SnapEnabled, SnapInstalled, SnapUninstalled, SnapUpdated } from '..';
|
|
7
7
|
import { Timer } from '../snaps/Timer';
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
8
|
+
export type CronjobControllerActions = GetAllSnaps | HandleSnapRequest | GetPermissions;
|
|
9
|
+
export type CronjobControllerEvents = SnapInstalled | SnapUninstalled | SnapUpdated | SnapEnabled | SnapDisabled;
|
|
10
|
+
export type CronjobControllerMessenger = RestrictedControllerMessenger<'CronjobController', CronjobControllerActions, CronjobControllerEvents, CronjobControllerActions['type'], CronjobControllerEvents['type']>;
|
|
11
11
|
export declare const DAILY_TIMEOUT: number;
|
|
12
|
-
export
|
|
12
|
+
export type CronjobControllerArgs = {
|
|
13
13
|
messenger: CronjobControllerMessenger;
|
|
14
14
|
/**
|
|
15
15
|
* Persisted state that will be used for rehydration.
|
|
16
16
|
*/
|
|
17
17
|
state?: CronjobControllerState;
|
|
18
18
|
};
|
|
19
|
-
export
|
|
19
|
+
export type Cronjob = {
|
|
20
20
|
timer?: Timer;
|
|
21
21
|
id: string;
|
|
22
22
|
snapId: SnapId;
|
|
23
23
|
} & CronjobSpecification;
|
|
24
|
-
export
|
|
24
|
+
export type StoredJobInformation = {
|
|
25
25
|
lastRun: number;
|
|
26
26
|
};
|
|
27
|
-
export
|
|
27
|
+
export type CronjobControllerState = {
|
|
28
28
|
jobs: Record<string, StoredJobInformation>;
|
|
29
29
|
};
|
|
30
30
|
declare const controllerName = "CronjobController";
|
|
@@ -6,20 +6,21 @@ import type { DeleteInterface } from '../interface';
|
|
|
6
6
|
import type { GetAllSnaps, HandleSnapRequest } from '../snaps';
|
|
7
7
|
import type { TransactionControllerUnapprovedTransactionAddedEvent, SignatureStateChange, TransactionControllerTransactionStatusUpdatedEvent } from '../types';
|
|
8
8
|
declare const controllerName = "SnapInsightsController";
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
9
|
+
export type SnapInsightsControllerAllowedActions = HandleSnapRequest | GetAllSnaps | GetPermissions | DeleteInterface;
|
|
10
|
+
export type SnapInsightsControllerActions = never;
|
|
11
|
+
export type SnapInsightsControllerAllowedEvents = TransactionControllerUnapprovedTransactionAddedEvent | TransactionControllerTransactionStatusUpdatedEvent | SignatureStateChange;
|
|
12
|
+
export type SnapInsightsControllerMessenger = RestrictedControllerMessenger<typeof controllerName, SnapInsightsControllerActions | SnapInsightsControllerAllowedActions, SnapInsightsControllerAllowedEvents, SnapInsightsControllerAllowedActions['type'], SnapInsightsControllerAllowedEvents['type']>;
|
|
13
|
+
export type SnapInsight = {
|
|
14
14
|
snapId: SnapId;
|
|
15
15
|
interfaceId?: string | null;
|
|
16
16
|
error?: string;
|
|
17
17
|
loading: boolean;
|
|
18
|
+
severity?: string;
|
|
18
19
|
};
|
|
19
|
-
export
|
|
20
|
+
export type SnapInsightsControllerState = {
|
|
20
21
|
insights: Record<string, Record<SnapId, SnapInsight>>;
|
|
21
22
|
};
|
|
22
|
-
export
|
|
23
|
+
export type SnapInsightsControllerArgs = {
|
|
23
24
|
messenger: SnapInsightsControllerMessenger;
|
|
24
25
|
state?: SnapInsightsControllerState;
|
|
25
26
|
};
|
|
@@ -6,43 +6,43 @@ import type { InterfaceState, SnapId, ComponentOrElement, InterfaceContext } fro
|
|
|
6
6
|
import type { JSXElement } from '@metamask/snaps-sdk/jsx';
|
|
7
7
|
import type { Json } from '@metamask/utils';
|
|
8
8
|
declare const controllerName = "SnapInterfaceController";
|
|
9
|
-
export
|
|
9
|
+
export type CreateInterface = {
|
|
10
10
|
type: `${typeof controllerName}:createInterface`;
|
|
11
11
|
handler: SnapInterfaceController['createInterface'];
|
|
12
12
|
};
|
|
13
|
-
export
|
|
13
|
+
export type GetInterface = {
|
|
14
14
|
type: `${typeof controllerName}:getInterface`;
|
|
15
15
|
handler: SnapInterfaceController['getInterface'];
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type UpdateInterface = {
|
|
18
18
|
type: `${typeof controllerName}:updateInterface`;
|
|
19
19
|
handler: SnapInterfaceController['updateInterface'];
|
|
20
20
|
};
|
|
21
|
-
export
|
|
21
|
+
export type DeleteInterface = {
|
|
22
22
|
type: `${typeof controllerName}:deleteInterface`;
|
|
23
23
|
handler: SnapInterfaceController['deleteInterface'];
|
|
24
24
|
};
|
|
25
|
-
export
|
|
25
|
+
export type UpdateInterfaceState = {
|
|
26
26
|
type: `${typeof controllerName}:updateInterfaceState`;
|
|
27
27
|
handler: SnapInterfaceController['updateInterfaceState'];
|
|
28
28
|
};
|
|
29
|
-
export
|
|
29
|
+
export type ResolveInterface = {
|
|
30
30
|
type: `${typeof controllerName}:resolveInterface`;
|
|
31
31
|
handler: SnapInterfaceController['resolveInterface'];
|
|
32
32
|
};
|
|
33
|
-
export
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
33
|
+
export type SnapInterfaceControllerAllowedActions = TestOrigin | MaybeUpdateState | HasApprovalRequest | AcceptRequest;
|
|
34
|
+
export type SnapInterfaceControllerActions = CreateInterface | GetInterface | UpdateInterface | DeleteInterface | UpdateInterfaceState | ResolveInterface;
|
|
35
|
+
export type SnapInterfaceControllerMessenger = RestrictedControllerMessenger<typeof controllerName, SnapInterfaceControllerActions | SnapInterfaceControllerAllowedActions, never, SnapInterfaceControllerAllowedActions['type'], never>;
|
|
36
|
+
export type StoredInterface = {
|
|
37
37
|
snapId: SnapId;
|
|
38
38
|
content: JSXElement;
|
|
39
39
|
state: InterfaceState;
|
|
40
40
|
context: InterfaceContext | null;
|
|
41
41
|
};
|
|
42
|
-
export
|
|
42
|
+
export type SnapInterfaceControllerState = {
|
|
43
43
|
interfaces: Record<string, StoredInterface>;
|
|
44
44
|
};
|
|
45
|
-
export
|
|
45
|
+
export type SnapInterfaceControllerArgs = {
|
|
46
46
|
messenger: SnapInterfaceControllerMessenger;
|
|
47
47
|
state?: SnapInterfaceControllerState;
|
|
48
48
|
};
|
|
@@ -6,8 +6,8 @@ import type { SnapRpcHookArgs } from '@metamask/snaps-utils';
|
|
|
6
6
|
import type { Duplex } from 'readable-stream';
|
|
7
7
|
import { Timer } from '../snaps/Timer';
|
|
8
8
|
import type { ExecutionService, ExecutionServiceMessenger, SnapExecutionData } from './ExecutionService';
|
|
9
|
-
export
|
|
10
|
-
export
|
|
9
|
+
export type SetupSnapProvider = (snapId: string, stream: Duplex) => void;
|
|
10
|
+
export type ExecutionServiceArgs = {
|
|
11
11
|
setupSnapProvider: SetupSnapProvider;
|
|
12
12
|
messenger: ExecutionServiceMessenger;
|
|
13
13
|
initTimeout?: number;
|
|
@@ -15,18 +15,18 @@ export declare type ExecutionServiceArgs = {
|
|
|
15
15
|
terminationTimeout?: number;
|
|
16
16
|
usePing?: boolean;
|
|
17
17
|
};
|
|
18
|
-
export
|
|
18
|
+
export type JobStreams = {
|
|
19
19
|
command: Duplex;
|
|
20
20
|
rpc: Duplex;
|
|
21
21
|
_connection: BasePostMessageStream;
|
|
22
22
|
};
|
|
23
|
-
export
|
|
23
|
+
export type Job<WorkerType> = {
|
|
24
24
|
id: string;
|
|
25
25
|
streams: JobStreams;
|
|
26
26
|
rpcEngine: JsonRpcEngine;
|
|
27
27
|
worker: WorkerType;
|
|
28
28
|
};
|
|
29
|
-
export
|
|
29
|
+
export type TerminateJobArgs<WorkerType> = Partial<Job<WorkerType>> & Pick<Job<WorkerType>, 'id'>;
|
|
30
30
|
export declare abstract class AbstractExecutionService<WorkerType> implements ExecutionService {
|
|
31
31
|
#private;
|
|
32
32
|
protected jobs: Map<string, Job<WorkerType>>;
|
|
@@ -1,68 +1,68 @@
|
|
|
1
1
|
import type { RestrictedControllerMessenger } from '@metamask/base-controller';
|
|
2
2
|
import type { SnapRpcHookArgs } from '@metamask/snaps-utils';
|
|
3
3
|
import type { Json } from '@metamask/utils';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
type TerminateSnap = (snapId: string) => Promise<void>;
|
|
5
|
+
type TerminateAll = () => Promise<void>;
|
|
6
|
+
type ExecuteSnap = (snapData: SnapExecutionData) => Promise<unknown>;
|
|
7
|
+
type HandleRpcRequest = (snapId: string, options: SnapRpcHookArgs) => Promise<unknown>;
|
|
8
8
|
export interface ExecutionService {
|
|
9
9
|
terminateSnap: TerminateSnap;
|
|
10
10
|
terminateAllSnaps: TerminateAll;
|
|
11
11
|
executeSnap: ExecuteSnap;
|
|
12
12
|
handleRpcRequest: HandleRpcRequest;
|
|
13
13
|
}
|
|
14
|
-
export
|
|
14
|
+
export type SnapExecutionData = {
|
|
15
15
|
snapId: string;
|
|
16
16
|
sourceCode: string;
|
|
17
17
|
endowments: Json;
|
|
18
18
|
};
|
|
19
|
-
export
|
|
19
|
+
export type SnapErrorJson = {
|
|
20
20
|
message: string;
|
|
21
21
|
code: number;
|
|
22
22
|
data?: Json;
|
|
23
23
|
};
|
|
24
24
|
declare const controllerName = "ExecutionService";
|
|
25
|
-
export
|
|
25
|
+
export type ErrorMessageEvent = {
|
|
26
26
|
type: 'ExecutionService:unhandledError';
|
|
27
27
|
payload: [string, SnapErrorJson];
|
|
28
28
|
};
|
|
29
|
-
export
|
|
29
|
+
export type OutboundRequest = {
|
|
30
30
|
type: 'ExecutionService:outboundRequest';
|
|
31
31
|
payload: [string];
|
|
32
32
|
};
|
|
33
|
-
export
|
|
33
|
+
export type OutboundResponse = {
|
|
34
34
|
type: 'ExecutionService:outboundResponse';
|
|
35
35
|
payload: [string];
|
|
36
36
|
};
|
|
37
|
-
export
|
|
37
|
+
export type ExecutionServiceEvents = ErrorMessageEvent | OutboundRequest | OutboundResponse;
|
|
38
38
|
/**
|
|
39
39
|
* Handles RPC request.
|
|
40
40
|
*/
|
|
41
|
-
export
|
|
41
|
+
export type HandleRpcRequestAction = {
|
|
42
42
|
type: `${typeof controllerName}:handleRpcRequest`;
|
|
43
43
|
handler: ExecutionService['handleRpcRequest'];
|
|
44
44
|
};
|
|
45
45
|
/**
|
|
46
46
|
* Executes a given snap.
|
|
47
47
|
*/
|
|
48
|
-
export
|
|
48
|
+
export type ExecuteSnapAction = {
|
|
49
49
|
type: `${typeof controllerName}:executeSnap`;
|
|
50
50
|
handler: ExecutionService['executeSnap'];
|
|
51
51
|
};
|
|
52
52
|
/**
|
|
53
53
|
* Terminates a given snap.
|
|
54
54
|
*/
|
|
55
|
-
export
|
|
55
|
+
export type TerminateSnapAction = {
|
|
56
56
|
type: `${typeof controllerName}:terminateSnap`;
|
|
57
57
|
handler: ExecutionService['terminateSnap'];
|
|
58
58
|
};
|
|
59
59
|
/**
|
|
60
60
|
* Terminates all snaps.
|
|
61
61
|
*/
|
|
62
|
-
export
|
|
62
|
+
export type TerminateAllSnapsAction = {
|
|
63
63
|
type: `${typeof controllerName}:terminateAllSnaps`;
|
|
64
64
|
handler: ExecutionService['terminateAllSnaps'];
|
|
65
65
|
};
|
|
66
|
-
export
|
|
67
|
-
export
|
|
66
|
+
export type ExecutionServiceActions = HandleRpcRequestAction | ExecuteSnapAction | TerminateSnapAction | TerminateAllSnapsAction;
|
|
67
|
+
export type ExecutionServiceMessenger = RestrictedControllerMessenger<'ExecutionService', ExecutionServiceActions, ExecutionServiceEvents, ExecutionServiceActions['type'], ExecutionServiceEvents['type']>;
|
|
68
68
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { BasePostMessageStream } from '@metamask/post-message-stream';
|
|
2
2
|
import type { JsonRpcRequest } from '@metamask/utils';
|
|
3
|
-
export
|
|
3
|
+
export type ProxyPostMessageStreamArgs = {
|
|
4
4
|
stream: BasePostMessageStream;
|
|
5
5
|
jobId: string;
|
|
6
6
|
extra?: Record<string, unknown>;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type ProxyPostMessage = {
|
|
9
9
|
jobId: string;
|
|
10
10
|
data: JsonRpcRequest;
|
|
11
11
|
extra?: Record<string, unknown>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BasePostMessageStream } from '@metamask/post-message-stream';
|
|
2
2
|
import type { ExecutionServiceArgs, TerminateJobArgs } from '../AbstractExecutionService';
|
|
3
3
|
import { AbstractExecutionService } from '../AbstractExecutionService';
|
|
4
|
-
|
|
4
|
+
type IframeExecutionEnvironmentServiceArgs = {
|
|
5
5
|
iframeUrl: URL;
|
|
6
6
|
} & ExecutionServiceArgs;
|
|
7
7
|
export declare class IframeExecutionService extends AbstractExecutionService<Window> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ExecutionServiceArgs } from '../AbstractExecutionService';
|
|
2
2
|
import { ProxyExecutionService } from '../proxy/ProxyExecutionService';
|
|
3
|
-
|
|
3
|
+
type OffscreenExecutionEnvironmentServiceArgs = {
|
|
4
4
|
offscreenPromise: Promise<unknown>;
|
|
5
5
|
} & ExecutionServiceArgs;
|
|
6
6
|
export declare class OffscreenExecutionService extends ProxyExecutionService {
|
|
@@ -2,7 +2,7 @@ import type { BasePostMessageStream } from '@metamask/post-message-stream';
|
|
|
2
2
|
import type { ExecutionServiceArgs, TerminateJobArgs } from '../AbstractExecutionService';
|
|
3
3
|
import { AbstractExecutionService } from '../AbstractExecutionService';
|
|
4
4
|
import { ProxyPostMessageStream } from '../ProxyPostMessageStream';
|
|
5
|
-
|
|
5
|
+
type ProxyExecutionEnvironmentServiceArgs = {
|
|
6
6
|
stream: BasePostMessageStream;
|
|
7
7
|
} & ExecutionServiceArgs;
|
|
8
8
|
export declare class ProxyExecutionService extends AbstractExecutionService<string> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ExecutionServiceArgs } from '../AbstractExecutionService';
|
|
2
2
|
import { ProxyExecutionService } from '../proxy/ProxyExecutionService';
|
|
3
3
|
import type { WebViewInterface } from './WebViewMessageStream';
|
|
4
|
-
export
|
|
4
|
+
export type WebViewExecutionServiceArgs = ExecutionServiceArgs & {
|
|
5
5
|
getWebView: () => Promise<WebViewInterface>;
|
|
6
6
|
};
|
|
7
7
|
export declare class WebViewExecutionService extends ProxyExecutionService {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { PostMessageEvent } from '@metamask/post-message-stream';
|
|
2
2
|
import { BasePostMessageStream } from '@metamask/post-message-stream';
|
|
3
|
-
export
|
|
3
|
+
export type WebViewInterface = {
|
|
4
4
|
injectJavaScript(js: string): void;
|
|
5
5
|
registerMessageListener(listener: (event: PostMessageEvent) => void): void;
|
|
6
6
|
unregisterMessageListener(listener: (event: PostMessageEvent) => void): void;
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
type WebViewStreamArgs = {
|
|
9
9
|
name: string;
|
|
10
10
|
target: string;
|
|
11
11
|
getWebView: () => Promise<WebViewInterface>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ExecutionServiceArgs, TerminateJobArgs } from '../AbstractExecutionService';
|
|
2
2
|
import { AbstractExecutionService } from '../AbstractExecutionService';
|
|
3
3
|
import { ProxyPostMessageStream } from '../ProxyPostMessageStream';
|
|
4
|
-
|
|
4
|
+
type WebWorkerExecutionEnvironmentServiceArgs = {
|
|
5
5
|
documentUrl: URL;
|
|
6
6
|
} & ExecutionServiceArgs;
|
|
7
7
|
export declare const WORKER_POOL_ID = "snaps-worker-pool";
|
|
@@ -21,7 +21,7 @@ export declare const controllerName = "SnapController";
|
|
|
21
21
|
export declare const SNAP_APPROVAL_INSTALL = "wallet_installSnap";
|
|
22
22
|
export declare const SNAP_APPROVAL_UPDATE = "wallet_updateSnap";
|
|
23
23
|
export declare const SNAP_APPROVAL_RESULT = "wallet_installSnapResult";
|
|
24
|
-
export
|
|
24
|
+
export type PendingRequest = {
|
|
25
25
|
requestId: unknown;
|
|
26
26
|
timer: Timer;
|
|
27
27
|
};
|
|
@@ -36,7 +36,7 @@ export interface PreinstalledSnap {
|
|
|
36
36
|
removable?: boolean;
|
|
37
37
|
hidden?: boolean;
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
type SnapRpcHandler = (options: SnapRpcHookArgs & {
|
|
40
40
|
timeout: number;
|
|
41
41
|
}) => Promise<unknown>;
|
|
42
42
|
/**
|
|
@@ -90,142 +90,142 @@ export interface SnapRuntimeData {
|
|
|
90
90
|
*/
|
|
91
91
|
stopping: boolean;
|
|
92
92
|
}
|
|
93
|
-
export
|
|
93
|
+
export type SnapError = {
|
|
94
94
|
message: string;
|
|
95
95
|
code: number;
|
|
96
96
|
data?: Json;
|
|
97
97
|
};
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
export
|
|
98
|
+
type CloseAllConnectionsFunction = (origin: string) => void;
|
|
99
|
+
type StoredSnaps = Record<SnapId, Snap>;
|
|
100
|
+
export type SnapControllerState = {
|
|
101
101
|
snaps: StoredSnaps;
|
|
102
102
|
snapStates: Record<SnapId, string | null>;
|
|
103
103
|
unencryptedSnapStates: Record<SnapId, string | null>;
|
|
104
104
|
};
|
|
105
|
-
export
|
|
105
|
+
export type PersistedSnapControllerState = SnapControllerState & {
|
|
106
106
|
snaps: Record<SnapId, PersistedSnap>;
|
|
107
107
|
snapStates: Record<SnapId, string>;
|
|
108
108
|
};
|
|
109
109
|
/**
|
|
110
110
|
* Gets the specified Snap from state.
|
|
111
111
|
*/
|
|
112
|
-
export
|
|
112
|
+
export type GetSnap = {
|
|
113
113
|
type: `${typeof controllerName}:get`;
|
|
114
114
|
handler: SnapController['get'];
|
|
115
115
|
};
|
|
116
116
|
/**
|
|
117
117
|
* Handles sending an inbound request to a snap and returns its result.
|
|
118
118
|
*/
|
|
119
|
-
export
|
|
119
|
+
export type HandleSnapRequest = {
|
|
120
120
|
type: `${typeof controllerName}:handleRequest`;
|
|
121
121
|
handler: SnapController['handleRequest'];
|
|
122
122
|
};
|
|
123
123
|
/**
|
|
124
124
|
* Gets the specified Snap's persisted state.
|
|
125
125
|
*/
|
|
126
|
-
export
|
|
126
|
+
export type GetSnapState = {
|
|
127
127
|
type: `${typeof controllerName}:getSnapState`;
|
|
128
128
|
handler: SnapController['getSnapState'];
|
|
129
129
|
};
|
|
130
130
|
/**
|
|
131
131
|
* Checks if the specified snap exists in state.
|
|
132
132
|
*/
|
|
133
|
-
export
|
|
133
|
+
export type HasSnap = {
|
|
134
134
|
type: `${typeof controllerName}:has`;
|
|
135
135
|
handler: SnapController['has'];
|
|
136
136
|
};
|
|
137
137
|
/**
|
|
138
138
|
* Updates the specified Snap's persisted state.
|
|
139
139
|
*/
|
|
140
|
-
export
|
|
140
|
+
export type UpdateSnapState = {
|
|
141
141
|
type: `${typeof controllerName}:updateSnapState`;
|
|
142
142
|
handler: SnapController['updateSnapState'];
|
|
143
143
|
};
|
|
144
144
|
/**
|
|
145
145
|
* Clears the specified Snap's persisted state.
|
|
146
146
|
*/
|
|
147
|
-
export
|
|
147
|
+
export type ClearSnapState = {
|
|
148
148
|
type: `${typeof controllerName}:clearSnapState`;
|
|
149
149
|
handler: SnapController['clearSnapState'];
|
|
150
150
|
};
|
|
151
151
|
/**
|
|
152
152
|
* Checks all installed snaps against the blocklist.
|
|
153
153
|
*/
|
|
154
|
-
export
|
|
154
|
+
export type UpdateBlockedSnaps = {
|
|
155
155
|
type: `${typeof controllerName}:updateBlockedSnaps`;
|
|
156
156
|
handler: SnapController['updateBlockedSnaps'];
|
|
157
157
|
};
|
|
158
|
-
export
|
|
158
|
+
export type EnableSnap = {
|
|
159
159
|
type: `${typeof controllerName}:enable`;
|
|
160
160
|
handler: SnapController['enableSnap'];
|
|
161
161
|
};
|
|
162
|
-
export
|
|
162
|
+
export type DisableSnap = {
|
|
163
163
|
type: `${typeof controllerName}:disable`;
|
|
164
164
|
handler: SnapController['disableSnap'];
|
|
165
165
|
};
|
|
166
|
-
export
|
|
166
|
+
export type RemoveSnap = {
|
|
167
167
|
type: `${typeof controllerName}:remove`;
|
|
168
168
|
handler: SnapController['removeSnap'];
|
|
169
169
|
};
|
|
170
|
-
export
|
|
170
|
+
export type GetPermittedSnaps = {
|
|
171
171
|
type: `${typeof controllerName}:getPermitted`;
|
|
172
172
|
handler: SnapController['getPermittedSnaps'];
|
|
173
173
|
};
|
|
174
|
-
export
|
|
174
|
+
export type GetAllSnaps = {
|
|
175
175
|
type: `${typeof controllerName}:getAll`;
|
|
176
176
|
handler: SnapController['getAllSnaps'];
|
|
177
177
|
};
|
|
178
|
-
export
|
|
178
|
+
export type IncrementActiveReferences = {
|
|
179
179
|
type: `${typeof controllerName}:incrementActiveReferences`;
|
|
180
180
|
handler: SnapController['incrementActiveReferences'];
|
|
181
181
|
};
|
|
182
|
-
export
|
|
182
|
+
export type DecrementActiveReferences = {
|
|
183
183
|
type: `${typeof controllerName}:decrementActiveReferences`;
|
|
184
184
|
handler: SnapController['decrementActiveReferences'];
|
|
185
185
|
};
|
|
186
|
-
export
|
|
186
|
+
export type InstallSnaps = {
|
|
187
187
|
type: `${typeof controllerName}:install`;
|
|
188
188
|
handler: SnapController['installSnaps'];
|
|
189
189
|
};
|
|
190
|
-
export
|
|
190
|
+
export type GetRegistryMetadata = {
|
|
191
191
|
type: `${typeof controllerName}:getRegistryMetadata`;
|
|
192
192
|
handler: SnapController['getRegistryMetadata'];
|
|
193
193
|
};
|
|
194
|
-
export
|
|
194
|
+
export type DisconnectOrigin = {
|
|
195
195
|
type: `${typeof controllerName}:disconnectOrigin`;
|
|
196
196
|
handler: SnapController['removeSnapFromSubject'];
|
|
197
197
|
};
|
|
198
|
-
export
|
|
198
|
+
export type RevokeDynamicPermissions = {
|
|
199
199
|
type: `${typeof controllerName}:revokeDynamicPermissions`;
|
|
200
200
|
handler: SnapController['revokeDynamicSnapPermissions'];
|
|
201
201
|
};
|
|
202
|
-
export
|
|
202
|
+
export type GetSnapFile = {
|
|
203
203
|
type: `${typeof controllerName}:getFile`;
|
|
204
204
|
handler: SnapController['getSnapFile'];
|
|
205
205
|
};
|
|
206
|
-
export
|
|
207
|
-
export
|
|
206
|
+
export type SnapControllerActions = ClearSnapState | GetSnap | GetSnapState | HandleSnapRequest | HasSnap | UpdateBlockedSnaps | UpdateSnapState | EnableSnap | DisableSnap | RemoveSnap | GetPermittedSnaps | InstallSnaps | GetAllSnaps | IncrementActiveReferences | DecrementActiveReferences | GetRegistryMetadata | DisconnectOrigin | RevokeDynamicPermissions | GetSnapFile;
|
|
207
|
+
export type SnapStateChange = {
|
|
208
208
|
type: `${typeof controllerName}:stateChange`;
|
|
209
209
|
payload: [SnapControllerState, Patch[]];
|
|
210
210
|
};
|
|
211
211
|
/**
|
|
212
212
|
* Emitted when an installed snap has been blocked.
|
|
213
213
|
*/
|
|
214
|
-
export
|
|
214
|
+
export type SnapBlocked = {
|
|
215
215
|
type: `${typeof controllerName}:snapBlocked`;
|
|
216
216
|
payload: [snapId: string, blockedSnapInfo?: BlockReason];
|
|
217
217
|
};
|
|
218
218
|
/**
|
|
219
219
|
* Emitted when a snap installation or update is started.
|
|
220
220
|
*/
|
|
221
|
-
export
|
|
221
|
+
export type SnapInstallStarted = {
|
|
222
222
|
type: `${typeof controllerName}:snapInstallStarted`;
|
|
223
223
|
payload: [snapId: SnapId, origin: string, isUpdate: boolean];
|
|
224
224
|
};
|
|
225
225
|
/**
|
|
226
226
|
* Emitted when a snap installation or update failed.
|
|
227
227
|
*/
|
|
228
|
-
export
|
|
228
|
+
export type SnapInstallFailed = {
|
|
229
229
|
type: `${typeof controllerName}:snapInstallFailed`;
|
|
230
230
|
payload: [snapId: SnapId, origin: string, isUpdate: boolean, error: string];
|
|
231
231
|
};
|
|
@@ -233,35 +233,35 @@ export declare type SnapInstallFailed = {
|
|
|
233
233
|
* Emitted when a snap has been started after being added and authorized during
|
|
234
234
|
* installation.
|
|
235
235
|
*/
|
|
236
|
-
export
|
|
236
|
+
export type SnapInstalled = {
|
|
237
237
|
type: `${typeof controllerName}:snapInstalled`;
|
|
238
238
|
payload: [snap: TruncatedSnap, origin: string];
|
|
239
239
|
};
|
|
240
240
|
/**
|
|
241
241
|
* Emitted when a snap that has previously been fully installed, is uninstalled.
|
|
242
242
|
*/
|
|
243
|
-
export
|
|
243
|
+
export type SnapUninstalled = {
|
|
244
244
|
type: `${typeof controllerName}:snapUninstalled`;
|
|
245
245
|
payload: [snap: TruncatedSnap];
|
|
246
246
|
};
|
|
247
247
|
/**
|
|
248
248
|
* Emitted when an installed snap has been unblocked.
|
|
249
249
|
*/
|
|
250
|
-
export
|
|
250
|
+
export type SnapUnblocked = {
|
|
251
251
|
type: `${typeof controllerName}:snapUnblocked`;
|
|
252
252
|
payload: [snapId: string];
|
|
253
253
|
};
|
|
254
254
|
/**
|
|
255
255
|
* Emitted when a snap is updated.
|
|
256
256
|
*/
|
|
257
|
-
export
|
|
257
|
+
export type SnapUpdated = {
|
|
258
258
|
type: `${typeof controllerName}:snapUpdated`;
|
|
259
259
|
payload: [snap: TruncatedSnap, oldVersion: string, origin: string];
|
|
260
260
|
};
|
|
261
261
|
/**
|
|
262
262
|
* Emitted when a snap is rolled back.
|
|
263
263
|
*/
|
|
264
|
-
export
|
|
264
|
+
export type SnapRolledback = {
|
|
265
265
|
type: `${typeof controllerName}:snapRolledback`;
|
|
266
266
|
payload: [snap: TruncatedSnap, failedVersion: string];
|
|
267
267
|
};
|
|
@@ -269,7 +269,7 @@ export declare type SnapRolledback = {
|
|
|
269
269
|
* Emitted when a Snap is terminated. This is different from the snap being
|
|
270
270
|
* stopped as it can also be triggered when a snap fails initialization.
|
|
271
271
|
*/
|
|
272
|
-
export
|
|
272
|
+
export type SnapTerminated = {
|
|
273
273
|
type: `${typeof controllerName}:snapTerminated`;
|
|
274
274
|
payload: [snap: TruncatedSnap];
|
|
275
275
|
};
|
|
@@ -277,30 +277,30 @@ export declare type SnapTerminated = {
|
|
|
277
277
|
* Emitted when a Snap is enabled by a user.
|
|
278
278
|
* This is not emitted by default when installing a snap.
|
|
279
279
|
*/
|
|
280
|
-
export
|
|
280
|
+
export type SnapEnabled = {
|
|
281
281
|
type: `${typeof controllerName}:snapEnabled`;
|
|
282
282
|
payload: [snap: TruncatedSnap];
|
|
283
283
|
};
|
|
284
284
|
/**
|
|
285
285
|
* Emitted when a Snap is disabled by a user.
|
|
286
286
|
*/
|
|
287
|
-
export
|
|
287
|
+
export type SnapDisabled = {
|
|
288
288
|
type: `${typeof controllerName}:snapDisabled`;
|
|
289
289
|
payload: [snap: TruncatedSnap];
|
|
290
290
|
};
|
|
291
|
-
export
|
|
292
|
-
export
|
|
293
|
-
export
|
|
294
|
-
|
|
295
|
-
|
|
291
|
+
export type SnapControllerEvents = SnapBlocked | SnapInstalled | SnapUninstalled | SnapInstallStarted | SnapInstallFailed | SnapStateChange | SnapUnblocked | SnapUpdated | SnapRolledback | SnapTerminated | SnapEnabled | SnapDisabled;
|
|
292
|
+
export type AllowedActions = GetEndowments | GetPermissions | GetSubjects | GetSubjectMetadata | AddSubjectMetadata | HasPermission | HasPermissions | RevokePermissions | RevokeAllPermissions | RevokePermissionForAllSubjects | GrantPermissions | AddApprovalRequest | HandleRpcRequestAction | ExecuteSnapAction | TerminateAllSnapsAction | TerminateSnapAction | UpdateCaveat | UpdateRequestState | GetResult | GetMetadata | Update | ResolveVersion | CreateInterface | GetInterface;
|
|
293
|
+
export type AllowedEvents = ExecutionServiceEvents | SnapInstalled | SnapUpdated;
|
|
294
|
+
type SnapControllerMessenger = RestrictedControllerMessenger<typeof controllerName, SnapControllerActions | AllowedActions, SnapControllerEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
|
|
295
|
+
type FeatureFlags = {
|
|
296
296
|
requireAllowlist?: boolean;
|
|
297
297
|
allowLocalSnaps?: boolean;
|
|
298
298
|
disableSnapInstallation?: boolean;
|
|
299
299
|
};
|
|
300
|
-
|
|
300
|
+
type DynamicFeatureFlags = {
|
|
301
301
|
disableSnaps?: boolean;
|
|
302
302
|
};
|
|
303
|
-
|
|
303
|
+
type SnapControllerArgs = {
|
|
304
304
|
/**
|
|
305
305
|
* A teardown function that allows the host to clean up its instrumentation
|
|
306
306
|
* for a running snap.
|
|
@@ -17,7 +17,7 @@ export interface SnapLocation {
|
|
|
17
17
|
fetch(path: string): Promise<VirtualFile>;
|
|
18
18
|
readonly shouldAlwaysReload?: boolean;
|
|
19
19
|
}
|
|
20
|
-
export
|
|
20
|
+
export type DetectSnapLocationOptions = NpmOptions & {
|
|
21
21
|
/**
|
|
22
22
|
* The function used to fetch data.
|
|
23
23
|
*
|
|
@@ -53,7 +53,7 @@ export declare class NpmLocation extends BaseNpmLocation {
|
|
|
53
53
|
*/
|
|
54
54
|
fetchNpmTarball(tarballUrl: URL): Promise<Map<string, VirtualFile<unknown>>>;
|
|
55
55
|
}
|
|
56
|
-
export
|
|
56
|
+
export type PartialNpmMetadata = {
|
|
57
57
|
versions: Record<string, {
|
|
58
58
|
dist: {
|
|
59
59
|
tarball: string;
|