@metamask/snaps-controllers 9.3.1 → 9.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/dist/{chunk-JLIW4CNS.js → chunk-2D5PGL7S.js} +7 -7
  3. package/dist/chunk-2D5PGL7S.js.map +1 -0
  4. package/dist/{chunk-6GMWL4JR.mjs → chunk-2SRKMEUV.mjs} +2 -2
  5. package/dist/chunk-2SRKMEUV.mjs.map +1 -0
  6. package/dist/{chunk-QYQLJCPR.js → chunk-36QDTCDZ.js} +2 -1
  7. package/dist/chunk-36QDTCDZ.js.map +1 -0
  8. package/dist/{chunk-POQSARDG.js → chunk-3WWZDKQL.js} +7 -7
  9. package/dist/{chunk-FKQTV3LO.js → chunk-6K4MATNG.js} +4 -4
  10. package/dist/chunk-6K4MATNG.js.map +1 -0
  11. package/dist/{chunk-LWBPKSU2.js → chunk-6Z4WDAVC.js} +3 -3
  12. package/dist/{chunk-WKQRCGUW.mjs → chunk-BAUQWPSP.mjs} +2 -2
  13. package/dist/chunk-BAUQWPSP.mjs.map +1 -0
  14. package/dist/{chunk-XFUP7RFI.js → chunk-DSOZPX7I.js} +1 -1
  15. package/dist/chunk-DSOZPX7I.js.map +1 -0
  16. package/dist/{chunk-G245VWEY.mjs → chunk-F3ZMDQ52.mjs} +2 -1
  17. package/dist/chunk-F3ZMDQ52.mjs.map +1 -0
  18. package/dist/{chunk-3T6W5VI2.mjs → chunk-HULNFJMA.mjs} +11 -3
  19. package/dist/chunk-HULNFJMA.mjs.map +1 -0
  20. package/dist/{chunk-CPUUURMT.js → chunk-I25KLPIS.js} +2 -2
  21. package/dist/chunk-I25KLPIS.js.map +1 -0
  22. package/dist/{chunk-6M4XK4PN.mjs → chunk-I5V56NYO.mjs} +2 -2
  23. package/dist/chunk-I5V56NYO.mjs.map +1 -0
  24. package/dist/{chunk-XWDEGRM5.js → chunk-K3TNQEM5.js} +2 -2
  25. package/dist/chunk-K3TNQEM5.js.map +1 -0
  26. package/dist/{chunk-2MH7QYBP.mjs → chunk-QWN3UOMA.mjs} +3 -3
  27. package/dist/chunk-QWN3UOMA.mjs.map +1 -0
  28. package/dist/{chunk-H7TB7I6Z.js → chunk-RZ2NHZXH.js} +11 -3
  29. package/dist/chunk-RZ2NHZXH.js.map +1 -0
  30. package/dist/{chunk-RDBT3ZJQ.js → chunk-TIURYSSR.js} +2 -2
  31. package/dist/{chunk-RDBT3ZJQ.js.map → chunk-TIURYSSR.js.map} +1 -1
  32. package/dist/{chunk-B3UTLNYS.mjs → chunk-UM4NFNEI.mjs} +2 -2
  33. package/dist/{chunk-33RRV7F4.mjs → chunk-Z4BUMSH3.mjs} +1 -1
  34. package/dist/chunk-Z4BUMSH3.mjs.map +1 -0
  35. package/dist/{chunk-23PVLQFV.mjs → chunk-Z5QWRDUN.mjs} +2 -2
  36. package/dist/chunk-Z5QWRDUN.mjs.map +1 -0
  37. package/dist/{chunk-2AEM5R2M.mjs → chunk-ZKG6FRKN.mjs} +4 -4
  38. package/dist/cronjob/CronjobController.js +11 -11
  39. package/dist/cronjob/CronjobController.mjs +10 -10
  40. package/dist/cronjob/index.js +11 -11
  41. package/dist/cronjob/index.mjs +10 -10
  42. package/dist/index.js +11 -11
  43. package/dist/index.mjs +10 -10
  44. package/dist/insights/SnapInsightsController.js +8 -8
  45. package/dist/insights/SnapInsightsController.mjs +7 -7
  46. package/dist/insights/index.js +8 -8
  47. package/dist/insights/index.mjs +7 -7
  48. package/dist/interface/SnapInterfaceController.js +3 -3
  49. package/dist/interface/SnapInterfaceController.mjs +2 -2
  50. package/dist/interface/index.js +3 -3
  51. package/dist/interface/index.mjs +2 -2
  52. package/dist/interface/utils.js +2 -2
  53. package/dist/interface/utils.mjs +1 -1
  54. package/dist/node.js +11 -11
  55. package/dist/node.mjs +10 -10
  56. package/dist/react-native.js +11 -11
  57. package/dist/react-native.mjs +10 -10
  58. package/dist/snaps/SnapController.js +7 -7
  59. package/dist/snaps/SnapController.mjs +6 -6
  60. package/dist/snaps/index.js +7 -7
  61. package/dist/snaps/index.mjs +6 -6
  62. package/dist/snaps/location/http.js +2 -2
  63. package/dist/snaps/location/http.mjs +1 -1
  64. package/dist/snaps/location/index.js +5 -5
  65. package/dist/snaps/location/index.mjs +4 -4
  66. package/dist/snaps/location/local.js +3 -3
  67. package/dist/snaps/location/local.mjs +2 -2
  68. package/dist/snaps/location/location.js +5 -5
  69. package/dist/snaps/location/location.mjs +4 -4
  70. package/dist/snaps/location/npm.js +2 -2
  71. package/dist/snaps/location/npm.mjs +1 -1
  72. package/dist/snaps/registry/index.js +2 -2
  73. package/dist/snaps/registry/index.mjs +1 -1
  74. package/dist/snaps/registry/json.js +2 -2
  75. package/dist/snaps/registry/json.mjs +1 -1
  76. package/dist/tsconfig.build.tsbuildinfo +1 -1
  77. package/dist/types/cronjob/CronjobController.d.ts +10 -8
  78. package/dist/types/insights/SnapInsightsController.d.ts +12 -8
  79. package/dist/types/interface/SnapInterfaceController.d.ts +16 -13
  80. package/dist/types/services/AbstractExecutionService.d.ts +5 -5
  81. package/dist/types/services/ExecutionService.d.ts +16 -16
  82. package/dist/types/services/ProxyPostMessageStream.d.ts +2 -2
  83. package/dist/types/services/iframe/IframeExecutionService.d.ts +1 -1
  84. package/dist/types/services/offscreen/OffscreenExecutionService.d.ts +1 -1
  85. package/dist/types/services/proxy/ProxyExecutionService.d.ts +1 -1
  86. package/dist/types/services/webview/WebViewExecutionService.d.ts +1 -1
  87. package/dist/types/services/webview/WebViewMessageStream.d.ts +2 -2
  88. package/dist/types/services/webworker/WebWorkerExecutionService.d.ts +1 -1
  89. package/dist/types/snaps/SnapController.d.ts +52 -47
  90. package/dist/types/snaps/Timer.d.ts +1 -1
  91. package/dist/types/snaps/location/location.d.ts +1 -1
  92. package/dist/types/snaps/location/npm.d.ts +1 -1
  93. package/dist/types/snaps/registry/json.d.ts +13 -11
  94. package/dist/types/snaps/registry/registry.d.ts +5 -5
  95. package/dist/types/types/controllers.d.ts +8 -8
  96. package/dist/types/types/encryptor.d.ts +5 -5
  97. package/dist/types/utils.d.ts +14 -7
  98. package/package.json +5 -5
  99. package/dist/chunk-23PVLQFV.mjs.map +0 -1
  100. package/dist/chunk-2MH7QYBP.mjs.map +0 -1
  101. package/dist/chunk-33RRV7F4.mjs.map +0 -1
  102. package/dist/chunk-3T6W5VI2.mjs.map +0 -1
  103. package/dist/chunk-6GMWL4JR.mjs.map +0 -1
  104. package/dist/chunk-6M4XK4PN.mjs.map +0 -1
  105. package/dist/chunk-CPUUURMT.js.map +0 -1
  106. package/dist/chunk-FKQTV3LO.js.map +0 -1
  107. package/dist/chunk-G245VWEY.mjs.map +0 -1
  108. package/dist/chunk-H7TB7I6Z.js.map +0 -1
  109. package/dist/chunk-JLIW4CNS.js.map +0 -1
  110. package/dist/chunk-QYQLJCPR.js.map +0 -1
  111. package/dist/chunk-WKQRCGUW.mjs.map +0 -1
  112. package/dist/chunk-XFUP7RFI.js.map +0 -1
  113. package/dist/chunk-XWDEGRM5.js.map +0 -1
  114. /package/dist/{chunk-POQSARDG.js.map → chunk-3WWZDKQL.js.map} +0 -0
  115. /package/dist/{chunk-LWBPKSU2.js.map → chunk-6Z4WDAVC.js.map} +0 -0
  116. /package/dist/{chunk-B3UTLNYS.mjs.map → chunk-UM4NFNEI.mjs.map} +0 -0
  117. /package/dist/{chunk-2AEM5R2M.mjs.map → chunk-ZKG6FRKN.mjs.map} +0 -0
@@ -1,30 +1,32 @@
1
- import type { RestrictedControllerMessenger } from '@metamask/base-controller';
1
+ import type { RestrictedControllerMessenger, ControllerGetStateAction, ControllerStateChangeEvent } from '@metamask/base-controller';
2
2
  import { BaseController } from '@metamask/base-controller';
3
3
  import type { GetPermissions } from '@metamask/permission-controller';
4
4
  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 declare type CronjobControllerActions = GetAllSnaps | HandleSnapRequest | GetPermissions;
9
- export declare type CronjobControllerEvents = SnapInstalled | SnapUninstalled | SnapUpdated | SnapEnabled | SnapDisabled;
10
- export declare type CronjobControllerMessenger = RestrictedControllerMessenger<'CronjobController', CronjobControllerActions, CronjobControllerEvents, CronjobControllerActions['type'], CronjobControllerEvents['type']>;
8
+ export type CronjobControllerGetStateAction = ControllerGetStateAction<typeof controllerName, CronjobControllerState>;
9
+ export type CronjobControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, CronjobControllerState>;
10
+ export type CronjobControllerActions = GetAllSnaps | HandleSnapRequest | GetPermissions | CronjobControllerGetStateAction;
11
+ export type CronjobControllerEvents = SnapInstalled | SnapUninstalled | SnapUpdated | SnapEnabled | SnapDisabled | CronjobControllerStateChangeEvent;
12
+ export type CronjobControllerMessenger = RestrictedControllerMessenger<typeof controllerName, CronjobControllerActions, CronjobControllerEvents, CronjobControllerActions['type'], CronjobControllerEvents['type']>;
11
13
  export declare const DAILY_TIMEOUT: number;
12
- export declare type CronjobControllerArgs = {
14
+ export type CronjobControllerArgs = {
13
15
  messenger: CronjobControllerMessenger;
14
16
  /**
15
17
  * Persisted state that will be used for rehydration.
16
18
  */
17
19
  state?: CronjobControllerState;
18
20
  };
19
- export declare type Cronjob = {
21
+ export type Cronjob = {
20
22
  timer?: Timer;
21
23
  id: string;
22
24
  snapId: SnapId;
23
25
  } & CronjobSpecification;
24
- export declare type StoredJobInformation = {
26
+ export type StoredJobInformation = {
25
27
  lastRun: number;
26
28
  };
27
- export declare type CronjobControllerState = {
29
+ export type CronjobControllerState = {
28
30
  jobs: Record<string, StoredJobInformation>;
29
31
  };
30
32
  declare const controllerName = "CronjobController";
@@ -1,4 +1,4 @@
1
- import type { RestrictedControllerMessenger } from '@metamask/base-controller';
1
+ import type { RestrictedControllerMessenger, ControllerGetStateAction, ControllerStateChangeEvent } from '@metamask/base-controller';
2
2
  import { BaseController } from '@metamask/base-controller';
3
3
  import type { GetPermissions } from '@metamask/permission-controller';
4
4
  import type { SnapId } from '@metamask/snaps-sdk';
@@ -6,20 +6,24 @@ 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 declare type SnapInsightsControllerAllowedActions = HandleSnapRequest | GetAllSnaps | GetPermissions | DeleteInterface;
10
- export declare type SnapInsightsControllerActions = never;
11
- export declare type SnapInsightsControllerAllowedEvents = TransactionControllerUnapprovedTransactionAddedEvent | TransactionControllerTransactionStatusUpdatedEvent | SignatureStateChange;
12
- export declare type SnapInsightsControllerMessenger = RestrictedControllerMessenger<typeof controllerName, SnapInsightsControllerActions | SnapInsightsControllerAllowedActions, SnapInsightsControllerAllowedEvents, SnapInsightsControllerAllowedActions['type'], SnapInsightsControllerAllowedEvents['type']>;
13
- export declare type SnapInsight = {
9
+ export type SnapInsightsControllerAllowedActions = HandleSnapRequest | GetAllSnaps | GetPermissions | DeleteInterface;
10
+ export type SnapInsightsControllerGetStateAction = ControllerGetStateAction<typeof controllerName, SnapInsightsControllerState>;
11
+ export type SnapInsightsControllerActions = SnapInsightsControllerGetStateAction;
12
+ export type SnapInsightControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, SnapInsightsControllerState>;
13
+ export type SnapInsightControllerEvents = SnapInsightControllerStateChangeEvent;
14
+ export type SnapInsightsControllerAllowedEvents = TransactionControllerUnapprovedTransactionAddedEvent | TransactionControllerTransactionStatusUpdatedEvent | SignatureStateChange;
15
+ export type SnapInsightsControllerMessenger = RestrictedControllerMessenger<typeof controllerName, SnapInsightsControllerActions | SnapInsightsControllerAllowedActions, SnapInsightControllerEvents | SnapInsightsControllerAllowedEvents, SnapInsightsControllerAllowedActions['type'], SnapInsightsControllerAllowedEvents['type']>;
16
+ export type SnapInsight = {
14
17
  snapId: SnapId;
15
18
  interfaceId?: string | null;
16
19
  error?: string;
17
20
  loading: boolean;
21
+ severity?: string;
18
22
  };
19
- export declare type SnapInsightsControllerState = {
23
+ export type SnapInsightsControllerState = {
20
24
  insights: Record<string, Record<SnapId, SnapInsight>>;
21
25
  };
22
- export declare type SnapInsightsControllerArgs = {
26
+ export type SnapInsightsControllerArgs = {
23
27
  messenger: SnapInsightsControllerMessenger;
24
28
  state?: SnapInsightsControllerState;
25
29
  };
@@ -1,48 +1,51 @@
1
1
  import type { AcceptRequest, HasApprovalRequest } from '@metamask/approval-controller';
2
- import type { RestrictedControllerMessenger } from '@metamask/base-controller';
2
+ import type { RestrictedControllerMessenger, ControllerGetStateAction, ControllerStateChangeEvent } from '@metamask/base-controller';
3
3
  import { BaseController } from '@metamask/base-controller';
4
4
  import type { MaybeUpdateState, TestOrigin } from '@metamask/phishing-controller';
5
5
  import type { InterfaceState, SnapId, ComponentOrElement, InterfaceContext } from '@metamask/snaps-sdk';
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 declare type CreateInterface = {
9
+ export type CreateInterface = {
10
10
  type: `${typeof controllerName}:createInterface`;
11
11
  handler: SnapInterfaceController['createInterface'];
12
12
  };
13
- export declare type GetInterface = {
13
+ export type GetInterface = {
14
14
  type: `${typeof controllerName}:getInterface`;
15
15
  handler: SnapInterfaceController['getInterface'];
16
16
  };
17
- export declare type UpdateInterface = {
17
+ export type UpdateInterface = {
18
18
  type: `${typeof controllerName}:updateInterface`;
19
19
  handler: SnapInterfaceController['updateInterface'];
20
20
  };
21
- export declare type DeleteInterface = {
21
+ export type DeleteInterface = {
22
22
  type: `${typeof controllerName}:deleteInterface`;
23
23
  handler: SnapInterfaceController['deleteInterface'];
24
24
  };
25
- export declare type UpdateInterfaceState = {
25
+ export type UpdateInterfaceState = {
26
26
  type: `${typeof controllerName}:updateInterfaceState`;
27
27
  handler: SnapInterfaceController['updateInterfaceState'];
28
28
  };
29
- export declare type ResolveInterface = {
29
+ export type ResolveInterface = {
30
30
  type: `${typeof controllerName}:resolveInterface`;
31
31
  handler: SnapInterfaceController['resolveInterface'];
32
32
  };
33
- export declare type SnapInterfaceControllerAllowedActions = TestOrigin | MaybeUpdateState | HasApprovalRequest | AcceptRequest;
34
- export declare type SnapInterfaceControllerActions = CreateInterface | GetInterface | UpdateInterface | DeleteInterface | UpdateInterfaceState | ResolveInterface;
35
- export declare type SnapInterfaceControllerMessenger = RestrictedControllerMessenger<typeof controllerName, SnapInterfaceControllerActions | SnapInterfaceControllerAllowedActions, never, SnapInterfaceControllerAllowedActions['type'], never>;
36
- export declare type StoredInterface = {
33
+ export type SnapInterfaceControllerGetStateAction = ControllerGetStateAction<typeof controllerName, SnapInterfaceControllerState>;
34
+ export type SnapInterfaceControllerAllowedActions = TestOrigin | MaybeUpdateState | HasApprovalRequest | AcceptRequest;
35
+ export type SnapInterfaceControllerActions = CreateInterface | GetInterface | UpdateInterface | DeleteInterface | UpdateInterfaceState | ResolveInterface | SnapInterfaceControllerGetStateAction;
36
+ export type SnapInterfaceControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, SnapInterfaceControllerState>;
37
+ export type SnapInterfaceControllerEvents = SnapInterfaceControllerStateChangeEvent;
38
+ export type SnapInterfaceControllerMessenger = RestrictedControllerMessenger<typeof controllerName, SnapInterfaceControllerActions | SnapInterfaceControllerAllowedActions, SnapInterfaceControllerEvents, SnapInterfaceControllerAllowedActions['type'], SnapInterfaceControllerEvents['type']>;
39
+ export type StoredInterface = {
37
40
  snapId: SnapId;
38
41
  content: JSXElement;
39
42
  state: InterfaceState;
40
43
  context: InterfaceContext | null;
41
44
  };
42
- export declare type SnapInterfaceControllerState = {
45
+ export type SnapInterfaceControllerState = {
43
46
  interfaces: Record<string, StoredInterface>;
44
47
  };
45
- export declare type SnapInterfaceControllerArgs = {
48
+ export type SnapInterfaceControllerArgs = {
46
49
  messenger: SnapInterfaceControllerMessenger;
47
50
  state?: SnapInterfaceControllerState;
48
51
  };
@@ -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 declare type SetupSnapProvider = (snapId: string, stream: Duplex) => void;
10
- export declare type ExecutionServiceArgs = {
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 declare type JobStreams = {
18
+ export type JobStreams = {
19
19
  command: Duplex;
20
20
  rpc: Duplex;
21
21
  _connection: BasePostMessageStream;
22
22
  };
23
- export declare type Job<WorkerType> = {
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 declare type TerminateJobArgs<WorkerType> = Partial<Job<WorkerType>> & Pick<Job<WorkerType>, 'id'>;
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
- declare type TerminateSnap = (snapId: string) => Promise<void>;
5
- declare type TerminateAll = () => Promise<void>;
6
- declare type ExecuteSnap = (snapData: SnapExecutionData) => Promise<unknown>;
7
- declare type HandleRpcRequest = (snapId: string, options: SnapRpcHookArgs) => Promise<unknown>;
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 declare type SnapExecutionData = {
14
+ export type SnapExecutionData = {
15
15
  snapId: string;
16
16
  sourceCode: string;
17
17
  endowments: Json;
18
18
  };
19
- export declare type SnapErrorJson = {
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 declare type ErrorMessageEvent = {
25
+ export type ErrorMessageEvent = {
26
26
  type: 'ExecutionService:unhandledError';
27
27
  payload: [string, SnapErrorJson];
28
28
  };
29
- export declare type OutboundRequest = {
29
+ export type OutboundRequest = {
30
30
  type: 'ExecutionService:outboundRequest';
31
31
  payload: [string];
32
32
  };
33
- export declare type OutboundResponse = {
33
+ export type OutboundResponse = {
34
34
  type: 'ExecutionService:outboundResponse';
35
35
  payload: [string];
36
36
  };
37
- export declare type ExecutionServiceEvents = ErrorMessageEvent | OutboundRequest | OutboundResponse;
37
+ export type ExecutionServiceEvents = ErrorMessageEvent | OutboundRequest | OutboundResponse;
38
38
  /**
39
39
  * Handles RPC request.
40
40
  */
41
- export declare type HandleRpcRequestAction = {
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 declare type ExecuteSnapAction = {
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 declare type TerminateSnapAction = {
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 declare type TerminateAllSnapsAction = {
62
+ export type TerminateAllSnapsAction = {
63
63
  type: `${typeof controllerName}:terminateAllSnaps`;
64
64
  handler: ExecutionService['terminateAllSnaps'];
65
65
  };
66
- export declare type ExecutionServiceActions = HandleRpcRequestAction | ExecuteSnapAction | TerminateSnapAction | TerminateAllSnapsAction;
67
- export declare type ExecutionServiceMessenger = RestrictedControllerMessenger<'ExecutionService', ExecutionServiceActions, ExecutionServiceEvents, ExecutionServiceActions['type'], ExecutionServiceEvents['type']>;
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 declare type ProxyPostMessageStreamArgs = {
3
+ export type ProxyPostMessageStreamArgs = {
4
4
  stream: BasePostMessageStream;
5
5
  jobId: string;
6
6
  extra?: Record<string, unknown>;
7
7
  };
8
- export declare type ProxyPostMessage = {
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
- declare type IframeExecutionEnvironmentServiceArgs = {
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
- declare type OffscreenExecutionEnvironmentServiceArgs = {
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
- declare type ProxyExecutionEnvironmentServiceArgs = {
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 declare type WebViewExecutionServiceArgs = ExecutionServiceArgs & {
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 declare type WebViewInterface = {
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
- declare type WebViewStreamArgs = {
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
- declare type WebWorkerExecutionEnvironmentServiceArgs = {
4
+ type WebWorkerExecutionEnvironmentServiceArgs = {
5
5
  documentUrl: URL;
6
6
  } & ExecutionServiceArgs;
7
7
  export declare const WORKER_POOL_ID = "snaps-worker-pool";
@@ -1,5 +1,5 @@
1
1
  import type { AddApprovalRequest, UpdateRequestState } from '@metamask/approval-controller';
2
- import type { RestrictedControllerMessenger } from '@metamask/base-controller';
2
+ import type { RestrictedControllerMessenger, ControllerGetStateAction, ControllerStateChangeEvent } from '@metamask/base-controller';
3
3
  import { BaseController } from '@metamask/base-controller';
4
4
  import type { GetEndowments, GetPermissions, GetSubjectMetadata, AddSubjectMetadata, GetSubjects, GrantPermissions, HasPermission, HasPermissions, RevokeAllPermissions, RevokePermissionForAllSubjects, RevokePermissions, UpdateCaveat } from '@metamask/permission-controller';
5
5
  import type { BlockReason } from '@metamask/snaps-registry';
@@ -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 declare type PendingRequest = {
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
- declare type SnapRpcHandler = (options: SnapRpcHookArgs & {
39
+ type SnapRpcHandler = (options: SnapRpcHookArgs & {
40
40
  timeout: number;
41
41
  }) => Promise<unknown>;
42
42
  /**
@@ -90,142 +90,143 @@ export interface SnapRuntimeData {
90
90
  */
91
91
  stopping: boolean;
92
92
  }
93
- export declare type SnapError = {
93
+ export type SnapError = {
94
94
  message: string;
95
95
  code: number;
96
96
  data?: Json;
97
97
  };
98
- declare type CloseAllConnectionsFunction = (origin: string) => void;
99
- declare type StoredSnaps = Record<SnapId, Snap>;
100
- export declare type SnapControllerState = {
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 declare type PersistedSnapControllerState = SnapControllerState & {
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 declare type GetSnap = {
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 declare type HandleSnapRequest = {
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 declare type GetSnapState = {
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 declare type HasSnap = {
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 declare type UpdateSnapState = {
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 declare type ClearSnapState = {
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 declare type UpdateBlockedSnaps = {
154
+ export type UpdateBlockedSnaps = {
155
155
  type: `${typeof controllerName}:updateBlockedSnaps`;
156
156
  handler: SnapController['updateBlockedSnaps'];
157
157
  };
158
- export declare type EnableSnap = {
158
+ export type EnableSnap = {
159
159
  type: `${typeof controllerName}:enable`;
160
160
  handler: SnapController['enableSnap'];
161
161
  };
162
- export declare type DisableSnap = {
162
+ export type DisableSnap = {
163
163
  type: `${typeof controllerName}:disable`;
164
164
  handler: SnapController['disableSnap'];
165
165
  };
166
- export declare type RemoveSnap = {
166
+ export type RemoveSnap = {
167
167
  type: `${typeof controllerName}:remove`;
168
168
  handler: SnapController['removeSnap'];
169
169
  };
170
- export declare type GetPermittedSnaps = {
170
+ export type GetPermittedSnaps = {
171
171
  type: `${typeof controllerName}:getPermitted`;
172
172
  handler: SnapController['getPermittedSnaps'];
173
173
  };
174
- export declare type GetAllSnaps = {
174
+ export type GetAllSnaps = {
175
175
  type: `${typeof controllerName}:getAll`;
176
176
  handler: SnapController['getAllSnaps'];
177
177
  };
178
- export declare type IncrementActiveReferences = {
178
+ export type IncrementActiveReferences = {
179
179
  type: `${typeof controllerName}:incrementActiveReferences`;
180
180
  handler: SnapController['incrementActiveReferences'];
181
181
  };
182
- export declare type DecrementActiveReferences = {
182
+ export type DecrementActiveReferences = {
183
183
  type: `${typeof controllerName}:decrementActiveReferences`;
184
184
  handler: SnapController['decrementActiveReferences'];
185
185
  };
186
- export declare type InstallSnaps = {
186
+ export type InstallSnaps = {
187
187
  type: `${typeof controllerName}:install`;
188
188
  handler: SnapController['installSnaps'];
189
189
  };
190
- export declare type GetRegistryMetadata = {
190
+ export type GetRegistryMetadata = {
191
191
  type: `${typeof controllerName}:getRegistryMetadata`;
192
192
  handler: SnapController['getRegistryMetadata'];
193
193
  };
194
- export declare type DisconnectOrigin = {
194
+ export type DisconnectOrigin = {
195
195
  type: `${typeof controllerName}:disconnectOrigin`;
196
196
  handler: SnapController['removeSnapFromSubject'];
197
197
  };
198
- export declare type RevokeDynamicPermissions = {
198
+ export type RevokeDynamicPermissions = {
199
199
  type: `${typeof controllerName}:revokeDynamicPermissions`;
200
200
  handler: SnapController['revokeDynamicSnapPermissions'];
201
201
  };
202
- export declare type GetSnapFile = {
202
+ export type GetSnapFile = {
203
203
  type: `${typeof controllerName}:getFile`;
204
204
  handler: SnapController['getSnapFile'];
205
205
  };
206
- export declare type SnapControllerActions = ClearSnapState | GetSnap | GetSnapState | HandleSnapRequest | HasSnap | UpdateBlockedSnaps | UpdateSnapState | EnableSnap | DisableSnap | RemoveSnap | GetPermittedSnaps | InstallSnaps | GetAllSnaps | IncrementActiveReferences | DecrementActiveReferences | GetRegistryMetadata | DisconnectOrigin | RevokeDynamicPermissions | GetSnapFile;
207
- export declare type SnapStateChange = {
206
+ export type SnapControllerGetStateAction = ControllerGetStateAction<typeof controllerName, SnapControllerState>;
207
+ export type SnapControllerActions = ClearSnapState | GetSnap | GetSnapState | HandleSnapRequest | HasSnap | UpdateBlockedSnaps | UpdateSnapState | EnableSnap | DisableSnap | RemoveSnap | GetPermittedSnaps | InstallSnaps | GetAllSnaps | IncrementActiveReferences | DecrementActiveReferences | GetRegistryMetadata | DisconnectOrigin | RevokeDynamicPermissions | GetSnapFile | SnapControllerGetStateAction;
208
+ export type SnapStateChange = {
208
209
  type: `${typeof controllerName}:stateChange`;
209
210
  payload: [SnapControllerState, Patch[]];
210
211
  };
211
212
  /**
212
213
  * Emitted when an installed snap has been blocked.
213
214
  */
214
- export declare type SnapBlocked = {
215
+ export type SnapBlocked = {
215
216
  type: `${typeof controllerName}:snapBlocked`;
216
217
  payload: [snapId: string, blockedSnapInfo?: BlockReason];
217
218
  };
218
219
  /**
219
220
  * Emitted when a snap installation or update is started.
220
221
  */
221
- export declare type SnapInstallStarted = {
222
+ export type SnapInstallStarted = {
222
223
  type: `${typeof controllerName}:snapInstallStarted`;
223
224
  payload: [snapId: SnapId, origin: string, isUpdate: boolean];
224
225
  };
225
226
  /**
226
227
  * Emitted when a snap installation or update failed.
227
228
  */
228
- export declare type SnapInstallFailed = {
229
+ export type SnapInstallFailed = {
229
230
  type: `${typeof controllerName}:snapInstallFailed`;
230
231
  payload: [snapId: SnapId, origin: string, isUpdate: boolean, error: string];
231
232
  };
@@ -233,35 +234,35 @@ export declare type SnapInstallFailed = {
233
234
  * Emitted when a snap has been started after being added and authorized during
234
235
  * installation.
235
236
  */
236
- export declare type SnapInstalled = {
237
+ export type SnapInstalled = {
237
238
  type: `${typeof controllerName}:snapInstalled`;
238
239
  payload: [snap: TruncatedSnap, origin: string];
239
240
  };
240
241
  /**
241
242
  * Emitted when a snap that has previously been fully installed, is uninstalled.
242
243
  */
243
- export declare type SnapUninstalled = {
244
+ export type SnapUninstalled = {
244
245
  type: `${typeof controllerName}:snapUninstalled`;
245
246
  payload: [snap: TruncatedSnap];
246
247
  };
247
248
  /**
248
249
  * Emitted when an installed snap has been unblocked.
249
250
  */
250
- export declare type SnapUnblocked = {
251
+ export type SnapUnblocked = {
251
252
  type: `${typeof controllerName}:snapUnblocked`;
252
253
  payload: [snapId: string];
253
254
  };
254
255
  /**
255
256
  * Emitted when a snap is updated.
256
257
  */
257
- export declare type SnapUpdated = {
258
+ export type SnapUpdated = {
258
259
  type: `${typeof controllerName}:snapUpdated`;
259
260
  payload: [snap: TruncatedSnap, oldVersion: string, origin: string];
260
261
  };
261
262
  /**
262
263
  * Emitted when a snap is rolled back.
263
264
  */
264
- export declare type SnapRolledback = {
265
+ export type SnapRolledback = {
265
266
  type: `${typeof controllerName}:snapRolledback`;
266
267
  payload: [snap: TruncatedSnap, failedVersion: string];
267
268
  };
@@ -269,7 +270,7 @@ export declare type SnapRolledback = {
269
270
  * Emitted when a Snap is terminated. This is different from the snap being
270
271
  * stopped as it can also be triggered when a snap fails initialization.
271
272
  */
272
- export declare type SnapTerminated = {
273
+ export type SnapTerminated = {
273
274
  type: `${typeof controllerName}:snapTerminated`;
274
275
  payload: [snap: TruncatedSnap];
275
276
  };
@@ -277,30 +278,34 @@ export declare type SnapTerminated = {
277
278
  * Emitted when a Snap is enabled by a user.
278
279
  * This is not emitted by default when installing a snap.
279
280
  */
280
- export declare type SnapEnabled = {
281
+ export type SnapEnabled = {
281
282
  type: `${typeof controllerName}:snapEnabled`;
282
283
  payload: [snap: TruncatedSnap];
283
284
  };
284
285
  /**
285
286
  * Emitted when a Snap is disabled by a user.
286
287
  */
287
- export declare type SnapDisabled = {
288
+ export type SnapDisabled = {
288
289
  type: `${typeof controllerName}:snapDisabled`;
289
290
  payload: [snap: TruncatedSnap];
290
291
  };
291
- export declare type SnapControllerEvents = SnapBlocked | SnapInstalled | SnapUninstalled | SnapInstallStarted | SnapInstallFailed | SnapStateChange | SnapUnblocked | SnapUpdated | SnapRolledback | SnapTerminated | SnapEnabled | SnapDisabled;
292
- export declare 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 declare type AllowedEvents = ExecutionServiceEvents | SnapInstalled | SnapUpdated;
294
- declare type SnapControllerMessenger = RestrictedControllerMessenger<typeof controllerName, SnapControllerActions | AllowedActions, SnapControllerEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
295
- declare type FeatureFlags = {
292
+ /**
293
+ * Emitted when there is a state change.
294
+ */
295
+ export type SnapControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, SnapControllerState>;
296
+ export type SnapControllerEvents = SnapBlocked | SnapInstalled | SnapUninstalled | SnapInstallStarted | SnapInstallFailed | SnapStateChange | SnapUnblocked | SnapUpdated | SnapRolledback | SnapTerminated | SnapEnabled | SnapDisabled | SnapControllerStateChangeEvent;
297
+ 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;
298
+ export type AllowedEvents = ExecutionServiceEvents | SnapInstalled | SnapUpdated;
299
+ type SnapControllerMessenger = RestrictedControllerMessenger<typeof controllerName, SnapControllerActions | AllowedActions, SnapControllerEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
300
+ type FeatureFlags = {
296
301
  requireAllowlist?: boolean;
297
302
  allowLocalSnaps?: boolean;
298
303
  disableSnapInstallation?: boolean;
299
304
  };
300
- declare type DynamicFeatureFlags = {
305
+ type DynamicFeatureFlags = {
301
306
  disableSnaps?: boolean;
302
307
  };
303
- declare type SnapControllerArgs = {
308
+ type SnapControllerArgs = {
304
309
  /**
305
310
  * A teardown function that allows the host to clean up its instrumentation
306
311
  * for a running snap.
@@ -1,4 +1,4 @@
1
- export declare type TimerStatus = 'stopped' | 'paused' | 'running' | 'finished';
1
+ export type TimerStatus = 'stopped' | 'paused' | 'running' | 'finished';
2
2
  export declare class Timer {
3
3
  private state;
4
4
  /**