@metamask/snaps-utils 3.2.0 → 4.0.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 (89) hide show
  1. package/CHANGELOG.md +35 -1
  2. package/dist/cjs/auxiliary-files.js +6 -19
  3. package/dist/cjs/auxiliary-files.js.map +1 -1
  4. package/dist/cjs/checksum.js +22 -5
  5. package/dist/cjs/checksum.js.map +1 -1
  6. package/dist/cjs/cronjob.js.map +1 -1
  7. package/dist/cjs/enum.js.map +1 -1
  8. package/dist/cjs/errors.js +6 -154
  9. package/dist/cjs/errors.js.map +1 -1
  10. package/dist/cjs/handler-types.js +1 -0
  11. package/dist/cjs/handler-types.js.map +1 -1
  12. package/dist/cjs/handlers.js +17 -11
  13. package/dist/cjs/handlers.js.map +1 -1
  14. package/dist/cjs/index.browser.js +2 -0
  15. package/dist/cjs/index.browser.js.map +1 -1
  16. package/dist/cjs/index.js +2 -7
  17. package/dist/cjs/index.js.map +1 -1
  18. package/dist/cjs/localization.js +113 -0
  19. package/dist/cjs/localization.js.map +1 -0
  20. package/dist/cjs/manifest/manifest.js +33 -19
  21. package/dist/cjs/manifest/manifest.js.map +1 -1
  22. package/dist/cjs/manifest/validation.js +3 -2
  23. package/dist/cjs/manifest/validation.js.map +1 -1
  24. package/dist/cjs/namespace.js +5 -1
  25. package/dist/cjs/namespace.js.map +1 -1
  26. package/dist/cjs/npm.js +18 -5
  27. package/dist/cjs/npm.js.map +1 -1
  28. package/dist/cjs/snaps.js +7 -6
  29. package/dist/cjs/snaps.js.map +1 -1
  30. package/dist/cjs/structs.js.map +1 -1
  31. package/dist/cjs/types.js.map +1 -1
  32. package/dist/cjs/ui.js +51 -0
  33. package/dist/cjs/ui.js.map +1 -0
  34. package/dist/cjs/validation.js +4 -2
  35. package/dist/cjs/validation.js.map +1 -1
  36. package/dist/esm/auxiliary-files.js +1 -6
  37. package/dist/esm/auxiliary-files.js.map +1 -1
  38. package/dist/esm/checksum.js +25 -6
  39. package/dist/esm/checksum.js.map +1 -1
  40. package/dist/esm/cronjob.js +1 -1
  41. package/dist/esm/cronjob.js.map +1 -1
  42. package/dist/esm/enum.js.map +1 -1
  43. package/dist/esm/errors.js +2 -157
  44. package/dist/esm/errors.js.map +1 -1
  45. package/dist/esm/handler-types.js +1 -0
  46. package/dist/esm/handler-types.js.map +1 -1
  47. package/dist/esm/handlers.js +13 -7
  48. package/dist/esm/handlers.js.map +1 -1
  49. package/dist/esm/index.browser.js +2 -0
  50. package/dist/esm/index.browser.js.map +1 -1
  51. package/dist/esm/index.js +2 -1
  52. package/dist/esm/index.js.map +1 -1
  53. package/dist/esm/localization.js +115 -0
  54. package/dist/esm/localization.js.map +1 -0
  55. package/dist/esm/manifest/manifest.js +37 -19
  56. package/dist/esm/manifest/manifest.js.map +1 -1
  57. package/dist/esm/manifest/validation.js +4 -3
  58. package/dist/esm/manifest/validation.js.map +1 -1
  59. package/dist/esm/namespace.js +3 -2
  60. package/dist/esm/namespace.js.map +1 -1
  61. package/dist/esm/npm.js +18 -5
  62. package/dist/esm/npm.js.map +1 -1
  63. package/dist/esm/snaps.js +7 -6
  64. package/dist/esm/snaps.js.map +1 -1
  65. package/dist/esm/structs.js.map +1 -1
  66. package/dist/esm/types.js.map +1 -1
  67. package/dist/esm/ui.js +48 -0
  68. package/dist/esm/ui.js.map +1 -0
  69. package/dist/esm/validation.js +4 -2
  70. package/dist/esm/validation.js.map +1 -1
  71. package/dist/types/auxiliary-files.d.ts +1 -5
  72. package/dist/types/checksum.d.ts +9 -2
  73. package/dist/types/enum.d.ts +1 -21
  74. package/dist/types/errors.d.ts +1 -109
  75. package/dist/types/handler-types.d.ts +2 -1
  76. package/dist/types/handlers.d.ts +73 -152
  77. package/dist/types/index.browser.d.ts +2 -0
  78. package/dist/types/index.d.ts +2 -1
  79. package/dist/types/localization.d.ts +143 -0
  80. package/dist/types/manifest/manifest.d.ts +16 -7
  81. package/dist/types/manifest/validation.d.ts +83 -78
  82. package/dist/types/namespace.d.ts +11 -10
  83. package/dist/types/npm.d.ts +1 -1
  84. package/dist/types/snaps.d.ts +13 -43
  85. package/dist/types/structs.d.ts +23 -0
  86. package/dist/types/types.d.ts +4 -2
  87. package/dist/types/ui.d.ts +20 -0
  88. package/dist/types/validation.d.ts +1 -1
  89. package/package.json +3 -3
@@ -1,8 +1,7 @@
1
- import type { Json, JsonRpcParams, JsonRpcRequest } from '@metamask/utils';
2
- import type { Infer } from 'superstruct';
1
+ import type { OnCronjobHandler, OnHomePageHandler, OnKeyringRequestHandler, OnNameLookupHandler, OnRpcRequestHandler, OnTransactionHandler } from '@metamask/snaps-sdk';
2
+ import { SeverityLevel } from '@metamask/snaps-sdk';
3
3
  import type { SnapHandler } from './handler-types';
4
4
  import { HandlerType } from './handler-types';
5
- import type { AccountAddress, Caip2ChainId } from './namespace';
6
5
  export declare type SnapRpcHookArgs = {
7
6
  origin: string;
8
7
  handler: HandlerType;
@@ -12,7 +11,7 @@ export declare const SNAP_EXPORTS: {
12
11
  readonly onRpcRequest: {
13
12
  readonly type: HandlerType.OnRpcRequest;
14
13
  readonly required: true;
15
- readonly validator: (snapExport: unknown) => snapExport is OnRpcRequestHandler<JsonRpcParams>;
14
+ readonly validator: (snapExport: unknown) => snapExport is OnRpcRequestHandler<import("@metamask/snaps-sdk").JsonRpcParams>;
16
15
  };
17
16
  readonly onTransaction: {
18
17
  readonly type: HandlerType.OnTransaction;
@@ -22,7 +21,7 @@ export declare const SNAP_EXPORTS: {
22
21
  readonly onCronjob: {
23
22
  readonly type: HandlerType.OnCronjob;
24
23
  readonly required: true;
25
- readonly validator: (snapExport: unknown) => snapExport is OnCronjobHandler<JsonRpcParams>;
24
+ readonly validator: (snapExport: unknown) => snapExport is OnCronjobHandler<import("@metamask/snaps-sdk").JsonRpcParams>;
26
25
  };
27
26
  readonly onNameLookup: {
28
27
  readonly type: HandlerType.OnNameLookup;
@@ -32,190 +31,112 @@ export declare const SNAP_EXPORTS: {
32
31
  readonly onInstall: {
33
32
  readonly type: HandlerType.OnInstall;
34
33
  readonly required: false;
35
- readonly validator: (snapExport: unknown) => snapExport is LifecycleEventHandler;
34
+ readonly validator: (snapExport: unknown) => snapExport is import("@metamask/snaps-sdk").LifecycleEventHandler;
36
35
  };
37
36
  readonly onUpdate: {
38
37
  readonly type: HandlerType.OnUpdate;
39
38
  readonly required: false;
40
- readonly validator: (snapExport: unknown) => snapExport is LifecycleEventHandler;
39
+ readonly validator: (snapExport: unknown) => snapExport is import("@metamask/snaps-sdk").LifecycleEventHandler;
41
40
  };
42
41
  readonly onKeyringRequest: {
43
42
  readonly type: HandlerType.OnKeyringRequest;
44
43
  readonly required: true;
45
- readonly validator: (snapExport: unknown) => snapExport is OnKeyringRequestHandler<JsonRpcParams>;
44
+ readonly validator: (snapExport: unknown) => snapExport is OnKeyringRequestHandler<import("@metamask/snaps-sdk").JsonRpcParams>;
45
+ };
46
+ readonly onHomePage: {
47
+ readonly type: HandlerType.OnHomePage;
48
+ readonly required: true;
49
+ readonly validator: (snapExport: unknown) => snapExport is OnHomePageHandler;
46
50
  };
47
51
  };
48
- /**
49
- * The `onRpcRequest` handler. This is called whenever a JSON-RPC request is
50
- * made to the snap.
51
- *
52
- * @param args - The request arguments.
53
- * @param args.origin - The origin of the request. This can be the ID of another
54
- * snap, or the URL of a dapp.
55
- * @param args.request - The JSON-RPC request sent to the snap.
56
- * @returns The JSON-RPC response. This must be a JSON-serializable value.
57
- */
58
- export declare type OnRpcRequestHandler<Params extends JsonRpcParams = JsonRpcParams> = (args: {
59
- origin: string;
60
- request: JsonRpcRequest<Params>;
61
- }) => Promise<unknown>;
62
- /**
63
- * Enum used to specify the severity level of content being returned from a transaction insight.
64
- */
65
- export declare enum SeverityLevel {
66
- Critical = "critical"
67
- }
68
52
  export declare const OnTransactionResponseStruct: import("superstruct").Struct<{
69
- content: import("@metamask/snaps-ui").Panel | {
53
+ content: import("@metamask/snaps-sdk").Panel | {
70
54
  value: string;
71
- type: import("@metamask/snaps-ui").NodeType.Copyable;
55
+ type: import("@metamask/snaps-sdk").NodeType.Copyable;
56
+ sensitive?: boolean | undefined;
72
57
  } | {
73
- type: import("@metamask/snaps-ui").NodeType.Divider;
58
+ type: import("@metamask/snaps-sdk").NodeType.Divider;
74
59
  } | {
75
60
  value: string;
76
- type: import("@metamask/snaps-ui").NodeType.Heading;
77
- } | {
78
- type: import("@metamask/snaps-ui").NodeType.Spinner;
61
+ type: import("@metamask/snaps-sdk").NodeType.Heading;
79
62
  } | {
80
63
  value: string;
81
- type: import("@metamask/snaps-ui").NodeType.Text;
82
- markdown?: boolean | undefined;
64
+ type: import("@metamask/snaps-sdk").NodeType.Image;
65
+ } | {
66
+ type: import("@metamask/snaps-sdk").NodeType.Spinner;
83
67
  } | {
84
68
  value: string;
85
- type: import("@metamask/snaps-ui").NodeType.Image;
69
+ type: import("@metamask/snaps-sdk").NodeType.Text;
70
+ markdown?: boolean | undefined;
86
71
  };
87
72
  severity?: SeverityLevel | undefined;
88
- }, {
89
- content: import("superstruct").Struct<import("@metamask/snaps-ui").Panel | {
73
+ } | null, {
74
+ content: import("superstruct").Struct<import("@metamask/snaps-sdk").Panel | {
90
75
  value: string;
91
- type: import("@metamask/snaps-ui").NodeType.Copyable;
76
+ type: import("@metamask/snaps-sdk").NodeType.Copyable;
77
+ sensitive?: boolean | undefined;
92
78
  } | {
93
- type: import("@metamask/snaps-ui").NodeType.Divider;
79
+ type: import("@metamask/snaps-sdk").NodeType.Divider;
94
80
  } | {
95
81
  value: string;
96
- type: import("@metamask/snaps-ui").NodeType.Heading;
97
- } | {
98
- type: import("@metamask/snaps-ui").NodeType.Spinner;
82
+ type: import("@metamask/snaps-sdk").NodeType.Heading;
99
83
  } | {
100
84
  value: string;
101
- type: import("@metamask/snaps-ui").NodeType.Text;
102
- markdown?: boolean | undefined;
85
+ type: import("@metamask/snaps-sdk").NodeType.Image;
86
+ } | {
87
+ type: import("@metamask/snaps-sdk").NodeType.Spinner;
103
88
  } | {
104
89
  value: string;
105
- type: import("@metamask/snaps-ui").NodeType.Image;
90
+ type: import("@metamask/snaps-sdk").NodeType.Text;
91
+ markdown?: boolean | undefined;
106
92
  }, null>;
107
93
  severity: import("superstruct").Struct<SeverityLevel | undefined, SeverityLevel>;
108
94
  }>;
109
- /**
110
- * The response from a snap's `onTransaction` handler.
111
- *
112
- * @property content - A custom UI component, that will be shown in MetaMask. Can be created using `@metamask/snaps-ui`.
113
- *
114
- * If the snap has no insights about the transaction, this should be `null`.
115
- */
116
- export declare type OnTransactionResponse = Infer<typeof OnTransactionResponseStruct>;
117
- /**
118
- * The `onTransaction` handler. This is called whenever a transaction is
119
- * submitted to the snap. It can return insights about the transaction, which
120
- * will be displayed to the user.
121
- *
122
- * @param args - The request arguments.
123
- * @param args.transaction - The transaction object.
124
- * @param args.chainId - The CAIP-2 chain ID of the network the transaction is
125
- * being submitted to.
126
- * @param args.transactionOrigin - The origin of the transaction. This is the
127
- * URL of the dapp that submitted the transaction.
128
- * @returns Insights about the transaction. See {@link OnTransactionResponse}.
129
- */
130
- export declare type OnTransactionHandler = (args: {
131
- transaction: {
132
- [key: string]: Json;
95
+ export declare const OnHomePageResponseStruct: import("superstruct").Struct<{
96
+ content: import("@metamask/snaps-sdk").Panel | {
97
+ value: string;
98
+ type: import("@metamask/snaps-sdk").NodeType.Copyable;
99
+ sensitive?: boolean | undefined;
100
+ } | {
101
+ type: import("@metamask/snaps-sdk").NodeType.Divider;
102
+ } | {
103
+ value: string;
104
+ type: import("@metamask/snaps-sdk").NodeType.Heading;
105
+ } | {
106
+ value: string;
107
+ type: import("@metamask/snaps-sdk").NodeType.Image;
108
+ } | {
109
+ type: import("@metamask/snaps-sdk").NodeType.Spinner;
110
+ } | {
111
+ value: string;
112
+ type: import("@metamask/snaps-sdk").NodeType.Text;
113
+ markdown?: boolean | undefined;
133
114
  };
134
- chainId: string;
135
- transactionOrigin?: string;
136
- }) => Promise<OnTransactionResponse>;
137
- /**
138
- * The `onCronjob` handler. This is called on a regular interval, as defined by
139
- * the snap's manifest.
140
- *
141
- * @param args - The request arguments.
142
- * @param args.request - The JSON-RPC request sent to the snap.
143
- */
144
- export declare type OnCronjobHandler<Params extends JsonRpcParams = JsonRpcParams> = (args: {
145
- request: JsonRpcRequest<Params>;
146
- }) => Promise<unknown>;
147
- /**
148
- * A handler that can be used for the lifecycle hooks.
149
- */
150
- export declare type LifecycleEventHandler = (args: {
151
- request: JsonRpcRequest;
152
- }) => Promise<unknown>;
153
- /**
154
- * The `onInstall` handler. This is called after the snap is installed.
155
- *
156
- * This type is an alias for {@link LifecycleEventHandler}.
157
- */
158
- export declare type OnInstallHandler = LifecycleEventHandler;
159
- /**
160
- * The `onUpdate` handler. This is called after the snap is updated.
161
- *
162
- * This type is an alias for {@link LifecycleEventHandler}.
163
- */
164
- export declare type OnUpdateHandler = LifecycleEventHandler;
165
- /**
166
- * The `onKeyringRequest` handler. This is called by the MetaMask client for
167
- * privileged keyring actions.
168
- *
169
- * @param args - The request arguments.
170
- * @param args.origin - The origin of the request. This can be the ID of
171
- * another snap, or the URL of a dapp.
172
- * @param args.request - The JSON-RPC request sent to the snap.
173
- */
174
- export declare type OnKeyringRequestHandler<Params extends JsonRpcParams = JsonRpcParams> = (args: {
175
- origin: string;
176
- request: JsonRpcRequest<Params>;
177
- }) => Promise<unknown>;
115
+ }, {
116
+ content: import("superstruct").Struct<import("@metamask/snaps-sdk").Panel | {
117
+ value: string;
118
+ type: import("@metamask/snaps-sdk").NodeType.Copyable;
119
+ sensitive?: boolean | undefined;
120
+ } | {
121
+ type: import("@metamask/snaps-sdk").NodeType.Divider;
122
+ } | {
123
+ value: string;
124
+ type: import("@metamask/snaps-sdk").NodeType.Heading;
125
+ } | {
126
+ value: string;
127
+ type: import("@metamask/snaps-sdk").NodeType.Image;
128
+ } | {
129
+ type: import("@metamask/snaps-sdk").NodeType.Spinner;
130
+ } | {
131
+ value: string;
132
+ type: import("@metamask/snaps-sdk").NodeType.Text;
133
+ markdown?: boolean | undefined;
134
+ }, null>;
135
+ }>;
178
136
  /**
179
137
  * Utility type for getting the handler function type from a handler type.
180
138
  */
181
139
  export declare type HandlerFunction<Type extends SnapHandler> = Type['validator'] extends (snapExport: unknown) => snapExport is infer Handler ? Handler : never;
182
- /**
183
- * The response from a snap's `onNameLookup` handler.
184
- *
185
- * @property resolvedAddress - The resolved address for a given domain.
186
- * @property resolvedDomain - The resolved domain for a given address.
187
- *
188
- *
189
- * If the snap has no resolved address/domain from its lookup, this should be `null`.
190
- */
191
- export declare type OnNameLookupResponse = {
192
- resolvedAddress: AccountAddress;
193
- resolvedDomain?: never;
194
- } | {
195
- resolvedDomain: string;
196
- resolvedAddress?: never;
197
- } | null;
198
- export declare type OnNameLookupArgs = {
199
- chainId: Caip2ChainId;
200
- } & ({
201
- domain: string;
202
- address?: never;
203
- } | {
204
- address: string;
205
- domain?: never;
206
- });
207
- /**
208
- * The `onNameLookup` handler. This is called whenever content is entered
209
- * into the send to field for sending assets to an EOA address.
210
- *
211
- * @param args - The request arguments.
212
- * @param args.domain - The human-readable address that is to be resolved.
213
- * @param args.chainId - The CAIP-2 chain ID of the network the transaction is
214
- * being submitted to.
215
- * @param args.address - The address that is to be resolved.
216
- * @returns Resolved address/domain from the lookup. See {@link OnNameLookupResponse}.
217
- */
218
- export declare type OnNameLookupHandler = (args: OnNameLookupArgs) => Promise<OnNameLookupResponse>;
219
140
  /**
220
141
  * All the function-based handlers that a snap can implement.
221
142
  */
@@ -13,6 +13,7 @@ export * from './handler-types';
13
13
  export * from './iframe';
14
14
  export * from './json';
15
15
  export * from './json-rpc';
16
+ export * from './localization';
16
17
  export * from './logging';
17
18
  export * from './manifest/index.browser';
18
19
  export * from './namespace';
@@ -21,6 +22,7 @@ export * from './snaps';
21
22
  export * from './strings';
22
23
  export * from './structs';
23
24
  export * from './types';
25
+ export * from './ui';
24
26
  export * from './validation';
25
27
  export * from './versions';
26
28
  export * from './virtual-file/index.browser';
@@ -15,6 +15,7 @@ export * from './handler-types';
15
15
  export * from './iframe';
16
16
  export * from './json';
17
17
  export * from './json-rpc';
18
+ export * from './localization';
18
19
  export * from './logging';
19
20
  export * from './manifest';
20
21
  export * from './mock';
@@ -26,7 +27,7 @@ export * from './snaps';
26
27
  export * from './strings';
27
28
  export * from './structs';
28
29
  export * from './types';
30
+ export * from './ui';
29
31
  export * from './validation';
30
32
  export * from './versions';
31
33
  export * from './virtual-file';
32
- export { assertLinksAreSafe } from '@metamask/snaps-ui';
@@ -0,0 +1,143 @@
1
+ import type { Infer } from 'superstruct';
2
+ import type { SnapManifest } from './manifest';
3
+ import type { VirtualFile } from './virtual-file';
4
+ export declare const LOCALIZABLE_FIELDS: readonly ["description", "proposedName"];
5
+ export declare const LocalizationFileStruct: import("superstruct").Struct<{
6
+ locale: string;
7
+ messages: Record<string, {
8
+ message: string;
9
+ description?: string | undefined;
10
+ }>;
11
+ }, {
12
+ locale: import("superstruct").Struct<string, null>;
13
+ messages: import("superstruct").Struct<Record<string, {
14
+ message: string;
15
+ description?: string | undefined;
16
+ }>, null>;
17
+ }>;
18
+ export declare type LocalizationFile = Infer<typeof LocalizationFileStruct>;
19
+ /**
20
+ * Validate a list of localization files.
21
+ *
22
+ * @param localizationFiles - The localization files to validate.
23
+ * @returns The validated localization files.
24
+ * @throws If any of the files are considered invalid.
25
+ */
26
+ export declare function getValidatedLocalizationFiles(localizationFiles: VirtualFile[]): VirtualFile<LocalizationFile>[];
27
+ /**
28
+ * Get the localization file for a given locale. If the locale is not found,
29
+ * the English localization file will be returned.
30
+ *
31
+ * @param locale - The locale to use.
32
+ * @param localizationFiles - The localization files to use.
33
+ * @returns The localization file, or `undefined` if no localization file was
34
+ * found.
35
+ */
36
+ export declare function getLocalizationFile(locale: string, localizationFiles: LocalizationFile[]): {
37
+ locale: string;
38
+ messages: Record<string, {
39
+ message: string;
40
+ description?: string | undefined;
41
+ }>;
42
+ } | undefined;
43
+ export declare const TRANSLATION_REGEX: RegExp;
44
+ /**
45
+ * Translate a string using a localization file. This will replace all instances
46
+ * of `{{key}}` with the localized version of `key`.
47
+ *
48
+ * @param value - The string to translate.
49
+ * @param file - The localization file to use, or `undefined` if no localization
50
+ * file was found.
51
+ * @returns The translated string.
52
+ * @throws If the string contains a key that is not present in the localization
53
+ * file, or if no localization file was found.
54
+ */
55
+ export declare function translate(value: string, file: LocalizationFile | undefined): string;
56
+ /**
57
+ * Get the localized Snap manifest for a given locale. This will replace all
58
+ * localized strings in the manifest with the localized version.
59
+ *
60
+ * @param snapManifest - The Snap manifest to localize.
61
+ * @param locale - The locale to use.
62
+ * @param localizationFiles - The localization files to use.
63
+ * @returns The localized Snap manifest.
64
+ */
65
+ export declare function getLocalizedSnapManifest(snapManifest: SnapManifest, locale: string, localizationFiles: LocalizationFile[]): {
66
+ description: string;
67
+ version: import("@metamask/utils").SemVerVersion;
68
+ source: {
69
+ location: {
70
+ npm: {
71
+ registry: "https://registry.npmjs.org" | "https://registry.npmjs.org/";
72
+ filePath: string;
73
+ packageName: string;
74
+ iconPath?: string | undefined;
75
+ };
76
+ };
77
+ shasum: string;
78
+ files?: string[] | undefined;
79
+ locales?: string[] | undefined;
80
+ };
81
+ proposedName: string;
82
+ initialPermissions: {
83
+ snap_dialog?: {} | undefined;
84
+ snap_getBip32Entropy?: {
85
+ path: string[];
86
+ curve: "ed25519" | "secp256k1";
87
+ }[] | undefined;
88
+ snap_getBip32PublicKey?: {
89
+ path: string[];
90
+ curve: "ed25519" | "secp256k1";
91
+ }[] | undefined;
92
+ snap_getBip44Entropy?: {
93
+ coinType: number;
94
+ }[] | undefined;
95
+ snap_getEntropy?: {} | undefined;
96
+ snap_manageAccounts?: {} | undefined;
97
+ snap_manageState?: {} | undefined;
98
+ snap_notify?: {} | undefined;
99
+ wallet_snap?: Record<string, {
100
+ version?: string | undefined;
101
+ }> | undefined;
102
+ 'endowment:network-access'?: {} | undefined;
103
+ 'endowment:webassembly'?: {} | undefined;
104
+ 'endowment:transaction-insight'?: {
105
+ allowTransactionOrigin?: boolean | undefined;
106
+ } | undefined;
107
+ 'endowment:cronjob'?: {
108
+ jobs: {
109
+ request: {
110
+ method: string;
111
+ params?: Record<string, import("@metamask/snaps-sdk").Json> | import("@metamask/snaps-sdk").Json[] | undefined;
112
+ id?: string | number | null | undefined;
113
+ jsonrpc?: "2.0" | undefined;
114
+ };
115
+ expression: string;
116
+ }[];
117
+ } | undefined;
118
+ 'endowment:rpc'?: {
119
+ dapps?: boolean | undefined;
120
+ snaps?: boolean | undefined;
121
+ allowedOrigins?: string[] | undefined;
122
+ } | undefined;
123
+ 'endowment:name-lookup'?: `${string}:${string}`[] | undefined;
124
+ 'endowment:keyring'?: {
125
+ allowedOrigins?: string[] | undefined;
126
+ } | undefined;
127
+ snap_confirm?: {} | undefined;
128
+ };
129
+ manifestVersion: "0.1";
130
+ repository?: {
131
+ type: string;
132
+ url: string;
133
+ } | undefined;
134
+ $schema?: string | undefined;
135
+ };
136
+ /**
137
+ * Validate the localization files for a Snap manifest.
138
+ *
139
+ * @param snapManifest - The Snap manifest to validate.
140
+ * @param localizationFiles - The localization files to validate.
141
+ * @throws If the manifest cannot be localized.
142
+ */
143
+ export declare function validateSnapManifestLocalizations(snapManifest: SnapManifest, localizationFiles: LocalizationFile[]): void;
@@ -46,7 +46,7 @@ export declare function checkManifest(basePath: string, writeManifest?: boolean,
46
46
  * @param error - The {@link ProgrammaticallyFixableSnapError} that was thrown.
47
47
  * @returns A copy of the manifest file where the cause of the error is fixed.
48
48
  */
49
- export declare function fixManifest(snapFiles: SnapFiles, error: ProgrammaticallyFixableSnapError): VirtualFile<SnapManifest>;
49
+ export declare function fixManifest(snapFiles: SnapFiles, error: ProgrammaticallyFixableSnapError): Promise<VirtualFile<SnapManifest>>;
50
50
  /**
51
51
  * Given an unvalidated Snap manifest, attempts to extract the location of the
52
52
  * bundle source file location and read the file.
@@ -67,14 +67,22 @@ export declare function getSnapSourceCode(basePath: string, manifest: Json, sour
67
67
  */
68
68
  export declare function getSnapIcon(basePath: string, manifest: Json): Promise<VirtualFile | undefined>;
69
69
  /**
70
- * Given an unvalidated Snap manifest, attempts to extract the auxiliary files
71
- * and read them.
70
+ * Get an array of paths from an unvalidated Snap manifest.
72
71
  *
73
- * @param basePath - The path to the folder with the manifest files.
74
72
  * @param manifest - The unvalidated Snap manifest file contents.
73
+ * @param selector - A function that returns the paths to the files.
74
+ * @returns The paths to the files, if any.
75
+ */
76
+ export declare function getSnapFilePaths(manifest: Json, selector: (manifest: Partial<SnapManifest>) => string[] | undefined): string[] | undefined;
77
+ /**
78
+ * Given an unvalidated Snap manifest, attempts to extract the files with the
79
+ * given paths and read them.
80
+ *
81
+ * @param basePath - The path to the folder with the manifest files.
82
+ * @param paths - The paths to the files.
75
83
  * @returns A list of auxiliary files and their contents, if any.
76
84
  */
77
- export declare function getSnapAuxiliaryFiles(basePath: string, manifest: Json): Promise<VirtualFile[] | undefined>;
85
+ export declare function getSnapFiles(basePath: string, paths: string[] | undefined): Promise<VirtualFile[] | undefined>;
78
86
  /**
79
87
  * Sorts the given manifest in our preferred sort order and removes the
80
88
  * `repository` field if it is falsy (it may be `null`).
@@ -84,7 +92,7 @@ export declare function getSnapAuxiliaryFiles(basePath: string, manifest: Json):
84
92
  */
85
93
  export declare function getWritableManifest(manifest: SnapManifest): SnapManifest;
86
94
  /**
87
- * Validates the fields of an npm Snap manifest that has already passed JSON
95
+ * Validates the fields of an NPM Snap manifest that has already passed JSON
88
96
  * Schema validation.
89
97
  *
90
98
  * @param snapFiles - The relevant snap files to validate.
@@ -93,5 +101,6 @@ export declare function getWritableManifest(manifest: SnapManifest): SnapManifes
93
101
  * @param snapFiles.sourceCode - The Snap's source code.
94
102
  * @param snapFiles.svgIcon - The Snap's optional icon.
95
103
  * @param snapFiles.auxiliaryFiles - Any auxiliary files required by the snap at runtime.
104
+ * @param snapFiles.localizationFiles - The Snap's localization files.
96
105
  */
97
- export declare function validateNpmSnapManifest({ manifest, packageJson, sourceCode, svgIcon, auxiliaryFiles, }: SnapFiles): void;
106
+ export declare function validateNpmSnapManifest({ manifest, packageJson, sourceCode, svgIcon, auxiliaryFiles, localizationFiles, }: SnapFiles): Promise<void>;