@metamask/snaps-controllers 3.6.0 → 4.1.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 (55) hide show
  1. package/CHANGELOG.md +19 -1
  2. package/dist/cjs/cronjob/CronjobController.js +2 -2
  3. package/dist/cjs/cronjob/CronjobController.js.map +1 -1
  4. package/dist/cjs/services/ProxyPostMessageStream.js +3 -10
  5. package/dist/cjs/services/ProxyPostMessageStream.js.map +1 -1
  6. package/dist/cjs/services/node/NodeProcessExecutionService.js +13 -1
  7. package/dist/cjs/services/node/NodeProcessExecutionService.js.map +1 -1
  8. package/dist/cjs/services/node/NodeThreadExecutionService.js +14 -1
  9. package/dist/cjs/services/node/NodeThreadExecutionService.js.map +1 -1
  10. package/dist/cjs/services/offscreen/OffscreenExecutionService.js +36 -99
  11. package/dist/cjs/services/offscreen/OffscreenExecutionService.js.map +1 -1
  12. package/dist/cjs/services/proxy/ProxyExecutionService.js +110 -0
  13. package/dist/cjs/services/proxy/ProxyExecutionService.js.map +1 -0
  14. package/dist/cjs/snaps/SnapController.js +206 -96
  15. package/dist/cjs/snaps/SnapController.js.map +1 -1
  16. package/dist/cjs/snaps/endowments/enum.js +1 -0
  17. package/dist/cjs/snaps/endowments/enum.js.map +1 -1
  18. package/dist/cjs/snaps/endowments/index.js +12 -4
  19. package/dist/cjs/snaps/endowments/index.js.map +1 -1
  20. package/dist/cjs/snaps/endowments/signature-insight.js +106 -0
  21. package/dist/cjs/snaps/endowments/signature-insight.js.map +1 -0
  22. package/dist/cjs/utils.js +32 -0
  23. package/dist/cjs/utils.js.map +1 -1
  24. package/dist/esm/cronjob/CronjobController.js +2 -2
  25. package/dist/esm/cronjob/CronjobController.js.map +1 -1
  26. package/dist/esm/services/ProxyPostMessageStream.js +3 -10
  27. package/dist/esm/services/ProxyPostMessageStream.js.map +1 -1
  28. package/dist/esm/services/node/NodeProcessExecutionService.js +13 -1
  29. package/dist/esm/services/node/NodeProcessExecutionService.js.map +1 -1
  30. package/dist/esm/services/node/NodeThreadExecutionService.js +14 -1
  31. package/dist/esm/services/node/NodeThreadExecutionService.js.map +1 -1
  32. package/dist/esm/services/offscreen/OffscreenExecutionService.js +36 -99
  33. package/dist/esm/services/offscreen/OffscreenExecutionService.js.map +1 -1
  34. package/dist/esm/services/proxy/ProxyExecutionService.js +100 -0
  35. package/dist/esm/services/proxy/ProxyExecutionService.js.map +1 -0
  36. package/dist/esm/snaps/SnapController.js +208 -98
  37. package/dist/esm/snaps/SnapController.js.map +1 -1
  38. package/dist/esm/snaps/endowments/enum.js +1 -0
  39. package/dist/esm/snaps/endowments/enum.js.map +1 -1
  40. package/dist/esm/snaps/endowments/index.js +10 -4
  41. package/dist/esm/snaps/endowments/index.js.map +1 -1
  42. package/dist/esm/snaps/endowments/signature-insight.js +99 -0
  43. package/dist/esm/snaps/endowments/signature-insight.js.map +1 -0
  44. package/dist/esm/utils.js +37 -0
  45. package/dist/esm/utils.js.map +1 -1
  46. package/dist/types/cronjob/CronjobController.d.ts +2 -2
  47. package/dist/types/services/ProxyPostMessageStream.d.ts +1 -2
  48. package/dist/types/services/offscreen/OffscreenExecutionService.d.ts +5 -22
  49. package/dist/types/services/proxy/ProxyExecutionService.d.ts +39 -0
  50. package/dist/types/snaps/SnapController.d.ts +33 -20
  51. package/dist/types/snaps/endowments/enum.d.ts +1 -0
  52. package/dist/types/snaps/endowments/index.d.ts +12 -0
  53. package/dist/types/snaps/endowments/signature-insight.d.ts +39 -0
  54. package/dist/types/utils.d.ts +99 -0
  55. package/package.json +10 -10
@@ -0,0 +1,39 @@
1
+ import type { PermissionSpecificationBuilder, EndowmentGetterParams, PermissionValidatorConstraint, PermissionConstraint, CaveatSpecificationConstraint } 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.SignatureInsight;
7
+ export declare const signatureInsightEndowmentBuilder: Readonly<{
8
+ readonly targetName: SnapEndowments.SignatureInsight;
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
+ * PermissionController 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 getSignatureInsightCaveatMapper(value: Json): Pick<PermissionConstraint, 'caveats'>;
26
+ /**
27
+ * Getter function to get the signature origin 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 signature origin caveat from.
34
+ * @returns The signature origin, or `null` if the permission does not have a
35
+ * signature origin caveat.
36
+ */
37
+ export declare function getSignatureOriginCaveat(permission?: PermissionConstraint): boolean | null;
38
+ export declare const signatureInsightCaveatSpecifications: Record<SnapCaveatType.SignatureOrigin, CaveatSpecificationConstraint>;
39
+ export {};
@@ -1,3 +1,4 @@
1
+ import type { SnapId } from '@metamask/snaps-sdk';
1
2
  import type { SnapLocation } from './snaps';
2
3
  import { Timer } from './snaps/Timer';
3
4
  /**
@@ -134,4 +135,102 @@ export declare type Mutable<Type extends Record<string, unknown>, TargetKey exte
134
135
  * @returns The array of files as {@link VirtualFile}s.
135
136
  */
136
137
  export declare function getSnapFiles(location: SnapLocation, files?: string[] | undefined): Promise<import("@metamask/snaps-utils").VirtualFile<unknown>[]>;
138
+ /**
139
+ * Fetch the Snap manifest, source code, and any other files from the given
140
+ * location.
141
+ *
142
+ * @param snapId - The ID of the Snap to fetch.
143
+ * @param location - The location of the Snap.
144
+ * @returns The Snap files and location.
145
+ * @throws If the Snap files are invalid, or if the Snap could not be fetched.
146
+ */
147
+ export declare function fetchSnap(snapId: SnapId, location: SnapLocation): Promise<{
148
+ manifest: import("@metamask/snaps-utils").VirtualFile<{
149
+ description: string;
150
+ version: import("@metamask/utils").SemVerVersion;
151
+ source: {
152
+ location: {
153
+ npm: {
154
+ registry: "https://registry.npmjs.org" | "https://registry.npmjs.org/";
155
+ filePath: string;
156
+ packageName: string;
157
+ iconPath?: string | undefined;
158
+ };
159
+ };
160
+ shasum: string;
161
+ files?: string[] | undefined;
162
+ locales?: string[] | undefined;
163
+ };
164
+ proposedName: string;
165
+ initialPermissions: {
166
+ snap_dialog?: {} | undefined;
167
+ snap_getBip32Entropy?: {
168
+ path: string[];
169
+ curve: "ed25519" | "secp256k1";
170
+ }[] | undefined;
171
+ snap_getBip32PublicKey?: {
172
+ path: string[];
173
+ curve: "ed25519" | "secp256k1";
174
+ }[] | undefined;
175
+ snap_getBip44Entropy?: {
176
+ coinType: number;
177
+ }[] | undefined;
178
+ snap_getEntropy?: {} | undefined;
179
+ snap_getLocale?: {} | undefined;
180
+ snap_manageAccounts?: {} | undefined;
181
+ snap_manageState?: {} | undefined;
182
+ snap_notify?: {} | undefined;
183
+ wallet_snap?: Record<string, {
184
+ version?: string | undefined;
185
+ }> | undefined;
186
+ 'endowment:ethereum-provider'?: {} | undefined;
187
+ 'endowment:network-access'?: {} | undefined;
188
+ 'endowment:webassembly'?: {} | undefined;
189
+ 'endowment:signature-insight'?: {
190
+ allowSignatureOrigin?: boolean | undefined;
191
+ } | undefined;
192
+ 'endowment:transaction-insight'?: {
193
+ allowTransactionOrigin?: boolean | undefined;
194
+ } | undefined;
195
+ 'endowment:cronjob'?: {
196
+ jobs: {
197
+ request: {
198
+ method: string;
199
+ id?: string | number | null | undefined;
200
+ jsonrpc?: "2.0" | undefined;
201
+ params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
202
+ };
203
+ expression: string;
204
+ }[];
205
+ } | undefined;
206
+ 'endowment:rpc'?: {
207
+ dapps?: boolean | undefined;
208
+ snaps?: boolean | undefined;
209
+ allowedOrigins?: string[] | undefined;
210
+ } | undefined;
211
+ 'endowment:name-lookup'?: `${string}:${string}`[] | undefined;
212
+ 'endowment:keyring'?: {
213
+ allowedOrigins?: string[] | undefined;
214
+ } | undefined;
215
+ snap_confirm?: {} | undefined;
216
+ };
217
+ manifestVersion: "0.1";
218
+ repository?: {
219
+ type: string;
220
+ url: string;
221
+ } | undefined;
222
+ initialConnections?: Record<string & URL, {}> | undefined;
223
+ $schema?: string | undefined;
224
+ }>;
225
+ sourceCode: import("@metamask/snaps-utils").VirtualFile<unknown>;
226
+ svgIcon: import("@metamask/snaps-utils").VirtualFile<unknown> | undefined;
227
+ auxiliaryFiles: import("@metamask/snaps-utils").VirtualFile<unknown>[];
228
+ localizationFiles: import("@metamask/snaps-utils").VirtualFile<{
229
+ locale: string;
230
+ messages: Record<string, {
231
+ message: string;
232
+ description?: string | undefined;
233
+ }>;
234
+ }>[];
235
+ }>;
137
236
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/snaps-controllers",
3
- "version": "3.6.0",
3
+ "version": "4.1.0",
4
4
  "description": "Controllers for MetaMask Snaps.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,18 +43,18 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@metamask/approval-controller": "^5.1.1",
46
- "@metamask/base-controller": "^4.0.0",
46
+ "@metamask/base-controller": "^4.1.0",
47
47
  "@metamask/json-rpc-engine": "^7.3.1",
48
48
  "@metamask/object-multiplex": "^2.0.0",
49
- "@metamask/permission-controller": "^7.0.0",
49
+ "@metamask/permission-controller": "^7.1.0",
50
50
  "@metamask/phishing-controller": "^8.0.1",
51
51
  "@metamask/post-message-stream": "^7.0.0",
52
52
  "@metamask/rpc-errors": "^6.1.0",
53
53
  "@metamask/snaps-registry": "^3.0.0",
54
- "@metamask/snaps-rpc-methods": "^4.1.0",
55
- "@metamask/snaps-sdk": "^1.3.1",
56
- "@metamask/snaps-utils": "^5.1.1",
57
- "@metamask/utils": "^8.2.1",
54
+ "@metamask/snaps-rpc-methods": "^5.0.0",
55
+ "@metamask/snaps-sdk": "^1.4.0",
56
+ "@metamask/snaps-utils": "^5.2.0",
57
+ "@metamask/utils": "^8.3.0",
58
58
  "@xstate/fsm": "^2.0.0",
59
59
  "browserify-zlib": "^0.2.0",
60
60
  "concat-stream": "^2.0.0",
@@ -69,8 +69,8 @@
69
69
  "devDependencies": {
70
70
  "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
71
71
  "@esbuild-plugins/node-modules-polyfill": "^0.2.2",
72
- "@lavamoat/allow-scripts": "^2.5.1",
73
- "@metamask/auto-changelog": "^3.4.3",
72
+ "@lavamoat/allow-scripts": "^3.0.0",
73
+ "@metamask/auto-changelog": "^3.4.4",
74
74
  "@metamask/eslint-config": "^12.1.0",
75
75
  "@metamask/eslint-config-jest": "^12.1.0",
76
76
  "@metamask/eslint-config-nodejs": "^12.1.0",
@@ -125,7 +125,7 @@
125
125
  "webdriverio": "^8.19.0"
126
126
  },
127
127
  "peerDependencies": {
128
- "@metamask/snaps-execution-environments": "^3.4.3"
128
+ "@metamask/snaps-execution-environments": "^3.5.0"
129
129
  },
130
130
  "peerDependenciesMeta": {
131
131
  "@metamask/snaps-execution-environments": {