@metamask/snaps-utils 7.4.0 → 7.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 (58) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/dist/{chunk-CQRPSEH3.js → chunk-37VHIRUJ.js} +27 -4
  3. package/dist/chunk-37VHIRUJ.js.map +1 -0
  4. package/dist/{chunk-QNPXK3B3.mjs → chunk-4I22UHIU.mjs} +3 -3
  5. package/dist/{chunk-MJGSG5N2.mjs → chunk-BZ7BMGXN.mjs} +20 -5
  6. package/dist/chunk-BZ7BMGXN.mjs.map +1 -0
  7. package/dist/{chunk-4YAWNZXM.js → chunk-IHHQU6IS.js} +20 -5
  8. package/dist/chunk-IHHQU6IS.js.map +1 -0
  9. package/dist/{chunk-DKDGMZFU.mjs → chunk-K2OTEZZZ.mjs} +27 -4
  10. package/dist/chunk-K2OTEZZZ.mjs.map +1 -0
  11. package/dist/{chunk-HVTYDKBO.js → chunk-K4B37F3L.js} +1 -1
  12. package/dist/chunk-K4B37F3L.js.map +1 -0
  13. package/dist/{chunk-IAHW6IFC.js → chunk-LNZLPDBB.js} +6 -6
  14. package/dist/{chunk-UCRFECSX.mjs → chunk-R6VG7F6Y.mjs} +3 -3
  15. package/dist/{chunk-N4KSSDO5.js → chunk-SWU464Y6.js} +11 -11
  16. package/dist/{chunk-RLA43SHY.mjs → chunk-VXLHHSAP.mjs} +3 -3
  17. package/dist/{chunk-3ZSYZX3I.js → chunk-YC2LIIR4.js} +5 -5
  18. package/dist/{chunk-2M6G46W6.mjs → chunk-YCIPY3UP.mjs} +1 -1
  19. package/dist/chunk-YCIPY3UP.mjs.map +1 -0
  20. package/dist/index.js +6 -6
  21. package/dist/index.mjs +5 -5
  22. package/dist/json-rpc.js +2 -2
  23. package/dist/json-rpc.mjs +1 -1
  24. package/dist/manifest/index.js +4 -4
  25. package/dist/manifest/index.mjs +3 -3
  26. package/dist/manifest/manifest.js +5 -5
  27. package/dist/manifest/manifest.mjs +4 -4
  28. package/dist/manifest/node.js +5 -5
  29. package/dist/manifest/node.mjs +4 -4
  30. package/dist/manifest/validation.js +4 -4
  31. package/dist/manifest/validation.mjs +3 -3
  32. package/dist/node.js +7 -7
  33. package/dist/node.mjs +6 -6
  34. package/dist/npm.js +5 -5
  35. package/dist/npm.mjs +4 -4
  36. package/dist/snaps.js +2 -2
  37. package/dist/snaps.mjs +1 -1
  38. package/dist/tsconfig.build.tsbuildinfo +1 -1
  39. package/dist/types/handlers.d.ts +168 -28
  40. package/dist/types/snaps.d.ts +4 -0
  41. package/dist/types/ui.d.ts +2 -1
  42. package/dist/ui.js +2 -2
  43. package/dist/ui.mjs +1 -1
  44. package/dist/validation.js +5 -5
  45. package/dist/validation.mjs +4 -4
  46. package/package.json +5 -5
  47. package/dist/chunk-2M6G46W6.mjs.map +0 -1
  48. package/dist/chunk-4YAWNZXM.js.map +0 -1
  49. package/dist/chunk-CQRPSEH3.js.map +0 -1
  50. package/dist/chunk-DKDGMZFU.mjs.map +0 -1
  51. package/dist/chunk-HVTYDKBO.js.map +0 -1
  52. package/dist/chunk-MJGSG5N2.mjs.map +0 -1
  53. /package/dist/{chunk-QNPXK3B3.mjs.map → chunk-4I22UHIU.mjs.map} +0 -0
  54. /package/dist/{chunk-IAHW6IFC.js.map → chunk-LNZLPDBB.js.map} +0 -0
  55. /package/dist/{chunk-UCRFECSX.mjs.map → chunk-R6VG7F6Y.mjs.map} +0 -0
  56. /package/dist/{chunk-N4KSSDO5.js.map → chunk-SWU464Y6.js.map} +0 -0
  57. /package/dist/{chunk-RLA43SHY.mjs.map → chunk-VXLHHSAP.mjs.map} +0 -0
  58. /package/dist/{chunk-3ZSYZX3I.js.map → chunk-YC2LIIR4.js.map} +0 -0
@@ -72,7 +72,7 @@ export declare const OnTransactionResponseWithIdStruct: import("superstruct").St
72
72
  severity: import("superstruct").Struct<SeverityLevel | undefined, SeverityLevel>;
73
73
  }>;
74
74
  export declare const OnTransactionResponseWithContentStruct: import("superstruct").Struct<{
75
- content: import("@metamask/snaps-sdk/jsx-runtime").JSXElement | import("@metamask/snaps-sdk").Panel | {
75
+ content: import("@metamask/snaps-sdk").Panel | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").BoldProps, "Bold"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ItalicProps, "Italic"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").AddressProps, "Address"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").BoxProps, "Box"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CopyableProps, "Copyable"> | import("@metamask/snaps-sdk/jsx").SnapElement<Record<string, never>, "Divider"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").LinkProps, "Link"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").RowProps, "Row"> | import("@metamask/snaps-sdk/jsx").SnapElement<Record<string, never>, "Spinner"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").TextProps, "Text"> | {
76
76
  value: string;
77
77
  type: import("@metamask/snaps-sdk").NodeType.Copyable;
78
78
  sensitive?: boolean | undefined;
@@ -113,9 +113,9 @@ export declare const OnTransactionResponseWithContentStruct: import("superstruct
113
113
  name: string;
114
114
  value?: string | undefined;
115
115
  error?: string | undefined;
116
- placeholder?: string | undefined;
117
116
  label?: string | undefined;
118
117
  inputType?: "number" | "text" | "password" | undefined;
118
+ placeholder?: string | undefined;
119
119
  } | {
120
120
  value: string;
121
121
  type: import("@metamask/snaps-sdk").NodeType.Button;
@@ -130,9 +130,9 @@ export declare const OnTransactionResponseWithContentStruct: import("superstruct
130
130
  name: string;
131
131
  value?: string | undefined;
132
132
  error?: string | undefined;
133
- placeholder?: string | undefined;
134
133
  label?: string | undefined;
135
134
  inputType?: "number" | "text" | "password" | undefined;
135
+ placeholder?: string | undefined;
136
136
  } | {
137
137
  value: string;
138
138
  type: import("@metamask/snaps-sdk").NodeType.Button;
@@ -140,10 +140,30 @@ export declare const OnTransactionResponseWithContentStruct: import("superstruct
140
140
  variant?: "primary" | "secondary" | undefined;
141
141
  buttonType?: "button" | "submit" | undefined;
142
142
  })[];
143
- };
143
+ } | import("@metamask/snaps-sdk/jsx").SnapElement<{
144
+ name: string;
145
+ type?: "number" | "text" | "password" | undefined;
146
+ value?: string | undefined;
147
+ placeholder?: string | undefined;
148
+ }, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
149
+ name: string;
150
+ value?: string | undefined;
151
+ children: import("@metamask/snaps-sdk/jsx").MaybeArray<import("@metamask/snaps-sdk/jsx").SnapElement<{
152
+ value: string;
153
+ children: string;
154
+ }, "Option">>;
155
+ }, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
156
+ children: import("@metamask/snaps-sdk/jsx").MaybeArray<import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FieldProps, "Field">>;
157
+ name: string;
158
+ }, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
159
+ children: import("@metamask/snaps-sdk/jsx").StringElement;
160
+ }, "Heading"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
161
+ src: string;
162
+ alt?: string | undefined;
163
+ }, "Image">;
144
164
  severity?: SeverityLevel | undefined;
145
165
  }, {
146
- content: import("superstruct").Struct<import("@metamask/snaps-sdk/jsx-runtime").JSXElement | import("@metamask/snaps-sdk").Panel | {
166
+ content: import("superstruct").Struct<import("@metamask/snaps-sdk").Panel | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").BoldProps, "Bold"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ItalicProps, "Italic"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").AddressProps, "Address"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").BoxProps, "Box"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CopyableProps, "Copyable"> | import("@metamask/snaps-sdk/jsx").SnapElement<Record<string, never>, "Divider"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").LinkProps, "Link"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").RowProps, "Row"> | import("@metamask/snaps-sdk/jsx").SnapElement<Record<string, never>, "Spinner"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").TextProps, "Text"> | {
147
167
  value: string;
148
168
  type: import("@metamask/snaps-sdk").NodeType.Copyable;
149
169
  sensitive?: boolean | undefined;
@@ -184,9 +204,9 @@ export declare const OnTransactionResponseWithContentStruct: import("superstruct
184
204
  name: string;
185
205
  value?: string | undefined;
186
206
  error?: string | undefined;
187
- placeholder?: string | undefined;
188
207
  label?: string | undefined;
189
208
  inputType?: "number" | "text" | "password" | undefined;
209
+ placeholder?: string | undefined;
190
210
  } | {
191
211
  value: string;
192
212
  type: import("@metamask/snaps-sdk").NodeType.Button;
@@ -201,9 +221,9 @@ export declare const OnTransactionResponseWithContentStruct: import("superstruct
201
221
  name: string;
202
222
  value?: string | undefined;
203
223
  error?: string | undefined;
204
- placeholder?: string | undefined;
205
224
  label?: string | undefined;
206
225
  inputType?: "number" | "text" | "password" | undefined;
226
+ placeholder?: string | undefined;
207
227
  } | {
208
228
  value: string;
209
229
  type: import("@metamask/snaps-sdk").NodeType.Button;
@@ -211,14 +231,34 @@ export declare const OnTransactionResponseWithContentStruct: import("superstruct
211
231
  variant?: "primary" | "secondary" | undefined;
212
232
  buttonType?: "button" | "submit" | undefined;
213
233
  })[];
214
- }, null>;
234
+ } | import("@metamask/snaps-sdk/jsx").SnapElement<{
235
+ name: string;
236
+ type?: "number" | "text" | "password" | undefined;
237
+ value?: string | undefined;
238
+ placeholder?: string | undefined;
239
+ }, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
240
+ name: string;
241
+ value?: string | undefined;
242
+ children: import("@metamask/snaps-sdk/jsx").MaybeArray<import("@metamask/snaps-sdk/jsx").SnapElement<{
243
+ value: string;
244
+ children: string;
245
+ }, "Option">>;
246
+ }, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
247
+ children: import("@metamask/snaps-sdk/jsx").MaybeArray<import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FieldProps, "Field">>;
248
+ name: string;
249
+ }, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
250
+ children: import("@metamask/snaps-sdk/jsx").StringElement;
251
+ }, "Heading"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
252
+ src: string;
253
+ alt?: string | undefined;
254
+ }, "Image">, null>;
215
255
  severity: import("superstruct").Struct<SeverityLevel | undefined, SeverityLevel>;
216
256
  }>;
217
257
  export declare const OnTransactionResponseStruct: import("superstruct").Struct<{
218
258
  id: string;
219
259
  severity?: SeverityLevel | undefined;
220
260
  } | {
221
- content: import("@metamask/snaps-sdk/jsx-runtime").JSXElement | import("@metamask/snaps-sdk").Panel | {
261
+ content: import("@metamask/snaps-sdk").Panel | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").BoldProps, "Bold"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ItalicProps, "Italic"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").AddressProps, "Address"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").BoxProps, "Box"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CopyableProps, "Copyable"> | import("@metamask/snaps-sdk/jsx").SnapElement<Record<string, never>, "Divider"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").LinkProps, "Link"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").RowProps, "Row"> | import("@metamask/snaps-sdk/jsx").SnapElement<Record<string, never>, "Spinner"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").TextProps, "Text"> | {
222
262
  value: string;
223
263
  type: import("@metamask/snaps-sdk").NodeType.Copyable;
224
264
  sensitive?: boolean | undefined;
@@ -259,9 +299,9 @@ export declare const OnTransactionResponseStruct: import("superstruct").Struct<{
259
299
  name: string;
260
300
  value?: string | undefined;
261
301
  error?: string | undefined;
262
- placeholder?: string | undefined;
263
302
  label?: string | undefined;
264
303
  inputType?: "number" | "text" | "password" | undefined;
304
+ placeholder?: string | undefined;
265
305
  } | {
266
306
  value: string;
267
307
  type: import("@metamask/snaps-sdk").NodeType.Button;
@@ -276,9 +316,9 @@ export declare const OnTransactionResponseStruct: import("superstruct").Struct<{
276
316
  name: string;
277
317
  value?: string | undefined;
278
318
  error?: string | undefined;
279
- placeholder?: string | undefined;
280
319
  label?: string | undefined;
281
320
  inputType?: "number" | "text" | "password" | undefined;
321
+ placeholder?: string | undefined;
282
322
  } | {
283
323
  value: string;
284
324
  type: import("@metamask/snaps-sdk").NodeType.Button;
@@ -286,14 +326,34 @@ export declare const OnTransactionResponseStruct: import("superstruct").Struct<{
286
326
  variant?: "primary" | "secondary" | undefined;
287
327
  buttonType?: "button" | "submit" | undefined;
288
328
  })[];
289
- };
329
+ } | import("@metamask/snaps-sdk/jsx").SnapElement<{
330
+ name: string;
331
+ type?: "number" | "text" | "password" | undefined;
332
+ value?: string | undefined;
333
+ placeholder?: string | undefined;
334
+ }, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
335
+ name: string;
336
+ value?: string | undefined;
337
+ children: import("@metamask/snaps-sdk/jsx").MaybeArray<import("@metamask/snaps-sdk/jsx").SnapElement<{
338
+ value: string;
339
+ children: string;
340
+ }, "Option">>;
341
+ }, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
342
+ children: import("@metamask/snaps-sdk/jsx").MaybeArray<import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FieldProps, "Field">>;
343
+ name: string;
344
+ }, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
345
+ children: import("@metamask/snaps-sdk/jsx").StringElement;
346
+ }, "Heading"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
347
+ src: string;
348
+ alt?: string | undefined;
349
+ }, "Image">;
290
350
  severity?: SeverityLevel | undefined;
291
351
  } | null, null>;
292
352
  export declare const OnSignatureResponseStruct: import("superstruct").Struct<{
293
353
  id: string;
294
354
  severity?: SeverityLevel | undefined;
295
355
  } | {
296
- content: import("@metamask/snaps-sdk/jsx-runtime").JSXElement | import("@metamask/snaps-sdk").Panel | {
356
+ content: import("@metamask/snaps-sdk").Panel | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").BoldProps, "Bold"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ItalicProps, "Italic"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").AddressProps, "Address"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").BoxProps, "Box"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CopyableProps, "Copyable"> | import("@metamask/snaps-sdk/jsx").SnapElement<Record<string, never>, "Divider"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").LinkProps, "Link"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").RowProps, "Row"> | import("@metamask/snaps-sdk/jsx").SnapElement<Record<string, never>, "Spinner"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").TextProps, "Text"> | {
297
357
  value: string;
298
358
  type: import("@metamask/snaps-sdk").NodeType.Copyable;
299
359
  sensitive?: boolean | undefined;
@@ -334,9 +394,9 @@ export declare const OnSignatureResponseStruct: import("superstruct").Struct<{
334
394
  name: string;
335
395
  value?: string | undefined;
336
396
  error?: string | undefined;
337
- placeholder?: string | undefined;
338
397
  label?: string | undefined;
339
398
  inputType?: "number" | "text" | "password" | undefined;
399
+ placeholder?: string | undefined;
340
400
  } | {
341
401
  value: string;
342
402
  type: import("@metamask/snaps-sdk").NodeType.Button;
@@ -351,9 +411,9 @@ export declare const OnSignatureResponseStruct: import("superstruct").Struct<{
351
411
  name: string;
352
412
  value?: string | undefined;
353
413
  error?: string | undefined;
354
- placeholder?: string | undefined;
355
414
  label?: string | undefined;
356
415
  inputType?: "number" | "text" | "password" | undefined;
416
+ placeholder?: string | undefined;
357
417
  } | {
358
418
  value: string;
359
419
  type: import("@metamask/snaps-sdk").NodeType.Button;
@@ -361,11 +421,31 @@ export declare const OnSignatureResponseStruct: import("superstruct").Struct<{
361
421
  variant?: "primary" | "secondary" | undefined;
362
422
  buttonType?: "button" | "submit" | undefined;
363
423
  })[];
364
- };
424
+ } | import("@metamask/snaps-sdk/jsx").SnapElement<{
425
+ name: string;
426
+ type?: "number" | "text" | "password" | undefined;
427
+ value?: string | undefined;
428
+ placeholder?: string | undefined;
429
+ }, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
430
+ name: string;
431
+ value?: string | undefined;
432
+ children: import("@metamask/snaps-sdk/jsx").MaybeArray<import("@metamask/snaps-sdk/jsx").SnapElement<{
433
+ value: string;
434
+ children: string;
435
+ }, "Option">>;
436
+ }, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
437
+ children: import("@metamask/snaps-sdk/jsx").MaybeArray<import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FieldProps, "Field">>;
438
+ name: string;
439
+ }, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
440
+ children: import("@metamask/snaps-sdk/jsx").StringElement;
441
+ }, "Heading"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
442
+ src: string;
443
+ alt?: string | undefined;
444
+ }, "Image">;
365
445
  severity?: SeverityLevel | undefined;
366
446
  } | null, null>;
367
447
  export declare const OnHomePageResponseWithContentStruct: import("superstruct").Struct<{
368
- content: import("@metamask/snaps-sdk/jsx-runtime").JSXElement | import("@metamask/snaps-sdk").Panel | {
448
+ content: import("@metamask/snaps-sdk").Panel | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").BoldProps, "Bold"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ItalicProps, "Italic"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").AddressProps, "Address"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").BoxProps, "Box"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CopyableProps, "Copyable"> | import("@metamask/snaps-sdk/jsx").SnapElement<Record<string, never>, "Divider"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").LinkProps, "Link"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").RowProps, "Row"> | import("@metamask/snaps-sdk/jsx").SnapElement<Record<string, never>, "Spinner"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").TextProps, "Text"> | {
369
449
  value: string;
370
450
  type: import("@metamask/snaps-sdk").NodeType.Copyable;
371
451
  sensitive?: boolean | undefined;
@@ -406,9 +486,9 @@ export declare const OnHomePageResponseWithContentStruct: import("superstruct").
406
486
  name: string;
407
487
  value?: string | undefined;
408
488
  error?: string | undefined;
409
- placeholder?: string | undefined;
410
489
  label?: string | undefined;
411
490
  inputType?: "number" | "text" | "password" | undefined;
491
+ placeholder?: string | undefined;
412
492
  } | {
413
493
  value: string;
414
494
  type: import("@metamask/snaps-sdk").NodeType.Button;
@@ -423,9 +503,9 @@ export declare const OnHomePageResponseWithContentStruct: import("superstruct").
423
503
  name: string;
424
504
  value?: string | undefined;
425
505
  error?: string | undefined;
426
- placeholder?: string | undefined;
427
506
  label?: string | undefined;
428
507
  inputType?: "number" | "text" | "password" | undefined;
508
+ placeholder?: string | undefined;
429
509
  } | {
430
510
  value: string;
431
511
  type: import("@metamask/snaps-sdk").NodeType.Button;
@@ -433,9 +513,29 @@ export declare const OnHomePageResponseWithContentStruct: import("superstruct").
433
513
  variant?: "primary" | "secondary" | undefined;
434
514
  buttonType?: "button" | "submit" | undefined;
435
515
  })[];
436
- };
516
+ } | import("@metamask/snaps-sdk/jsx").SnapElement<{
517
+ name: string;
518
+ type?: "number" | "text" | "password" | undefined;
519
+ value?: string | undefined;
520
+ placeholder?: string | undefined;
521
+ }, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
522
+ name: string;
523
+ value?: string | undefined;
524
+ children: import("@metamask/snaps-sdk/jsx").MaybeArray<import("@metamask/snaps-sdk/jsx").SnapElement<{
525
+ value: string;
526
+ children: string;
527
+ }, "Option">>;
528
+ }, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
529
+ children: import("@metamask/snaps-sdk/jsx").MaybeArray<import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FieldProps, "Field">>;
530
+ name: string;
531
+ }, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
532
+ children: import("@metamask/snaps-sdk/jsx").StringElement;
533
+ }, "Heading"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
534
+ src: string;
535
+ alt?: string | undefined;
536
+ }, "Image">;
437
537
  }, {
438
- content: import("superstruct").Struct<import("@metamask/snaps-sdk/jsx-runtime").JSXElement | import("@metamask/snaps-sdk").Panel | {
538
+ content: import("superstruct").Struct<import("@metamask/snaps-sdk").Panel | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").BoldProps, "Bold"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ItalicProps, "Italic"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").AddressProps, "Address"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").BoxProps, "Box"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CopyableProps, "Copyable"> | import("@metamask/snaps-sdk/jsx").SnapElement<Record<string, never>, "Divider"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").LinkProps, "Link"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").RowProps, "Row"> | import("@metamask/snaps-sdk/jsx").SnapElement<Record<string, never>, "Spinner"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").TextProps, "Text"> | {
439
539
  value: string;
440
540
  type: import("@metamask/snaps-sdk").NodeType.Copyable;
441
541
  sensitive?: boolean | undefined;
@@ -476,9 +576,9 @@ export declare const OnHomePageResponseWithContentStruct: import("superstruct").
476
576
  name: string;
477
577
  value?: string | undefined;
478
578
  error?: string | undefined;
479
- placeholder?: string | undefined;
480
579
  label?: string | undefined;
481
580
  inputType?: "number" | "text" | "password" | undefined;
581
+ placeholder?: string | undefined;
482
582
  } | {
483
583
  value: string;
484
584
  type: import("@metamask/snaps-sdk").NodeType.Button;
@@ -493,9 +593,9 @@ export declare const OnHomePageResponseWithContentStruct: import("superstruct").
493
593
  name: string;
494
594
  value?: string | undefined;
495
595
  error?: string | undefined;
496
- placeholder?: string | undefined;
497
596
  label?: string | undefined;
498
597
  inputType?: "number" | "text" | "password" | undefined;
598
+ placeholder?: string | undefined;
499
599
  } | {
500
600
  value: string;
501
601
  type: import("@metamask/snaps-sdk").NodeType.Button;
@@ -503,7 +603,27 @@ export declare const OnHomePageResponseWithContentStruct: import("superstruct").
503
603
  variant?: "primary" | "secondary" | undefined;
504
604
  buttonType?: "button" | "submit" | undefined;
505
605
  })[];
506
- }, null>;
606
+ } | import("@metamask/snaps-sdk/jsx").SnapElement<{
607
+ name: string;
608
+ type?: "number" | "text" | "password" | undefined;
609
+ value?: string | undefined;
610
+ placeholder?: string | undefined;
611
+ }, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
612
+ name: string;
613
+ value?: string | undefined;
614
+ children: import("@metamask/snaps-sdk/jsx").MaybeArray<import("@metamask/snaps-sdk/jsx").SnapElement<{
615
+ value: string;
616
+ children: string;
617
+ }, "Option">>;
618
+ }, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
619
+ children: import("@metamask/snaps-sdk/jsx").MaybeArray<import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FieldProps, "Field">>;
620
+ name: string;
621
+ }, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
622
+ children: import("@metamask/snaps-sdk/jsx").StringElement;
623
+ }, "Heading"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
624
+ src: string;
625
+ alt?: string | undefined;
626
+ }, "Image">, null>;
507
627
  }>;
508
628
  export declare const OnHomePageResponseWithIdStruct: import("superstruct").Struct<{
509
629
  id: string;
@@ -511,7 +631,7 @@ export declare const OnHomePageResponseWithIdStruct: import("superstruct").Struc
511
631
  id: import("superstruct").Struct<string, null>;
512
632
  }>;
513
633
  export declare const OnHomePageResponseStruct: import("superstruct").Struct<{
514
- content: import("@metamask/snaps-sdk/jsx-runtime").JSXElement | import("@metamask/snaps-sdk").Panel | {
634
+ content: import("@metamask/snaps-sdk").Panel | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").BoldProps, "Bold"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ItalicProps, "Italic"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").AddressProps, "Address"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").BoxProps, "Box"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").CopyableProps, "Copyable"> | import("@metamask/snaps-sdk/jsx").SnapElement<Record<string, never>, "Divider"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").LinkProps, "Link"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").RowProps, "Row"> | import("@metamask/snaps-sdk/jsx").SnapElement<Record<string, never>, "Spinner"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").TextProps, "Text"> | {
515
635
  value: string;
516
636
  type: import("@metamask/snaps-sdk").NodeType.Copyable;
517
637
  sensitive?: boolean | undefined;
@@ -552,9 +672,9 @@ export declare const OnHomePageResponseStruct: import("superstruct").Struct<{
552
672
  name: string;
553
673
  value?: string | undefined;
554
674
  error?: string | undefined;
555
- placeholder?: string | undefined;
556
675
  label?: string | undefined;
557
676
  inputType?: "number" | "text" | "password" | undefined;
677
+ placeholder?: string | undefined;
558
678
  } | {
559
679
  value: string;
560
680
  type: import("@metamask/snaps-sdk").NodeType.Button;
@@ -569,9 +689,9 @@ export declare const OnHomePageResponseStruct: import("superstruct").Struct<{
569
689
  name: string;
570
690
  value?: string | undefined;
571
691
  error?: string | undefined;
572
- placeholder?: string | undefined;
573
692
  label?: string | undefined;
574
693
  inputType?: "number" | "text" | "password" | undefined;
694
+ placeholder?: string | undefined;
575
695
  } | {
576
696
  value: string;
577
697
  type: import("@metamask/snaps-sdk").NodeType.Button;
@@ -579,7 +699,27 @@ export declare const OnHomePageResponseStruct: import("superstruct").Struct<{
579
699
  variant?: "primary" | "secondary" | undefined;
580
700
  buttonType?: "button" | "submit" | undefined;
581
701
  })[];
582
- };
702
+ } | import("@metamask/snaps-sdk/jsx").SnapElement<{
703
+ name: string;
704
+ type?: "number" | "text" | "password" | undefined;
705
+ value?: string | undefined;
706
+ placeholder?: string | undefined;
707
+ }, "Input"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
708
+ name: string;
709
+ value?: string | undefined;
710
+ children: import("@metamask/snaps-sdk/jsx").MaybeArray<import("@metamask/snaps-sdk/jsx").SnapElement<{
711
+ value: string;
712
+ children: string;
713
+ }, "Option">>;
714
+ }, "Dropdown"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
715
+ children: import("@metamask/snaps-sdk/jsx").MaybeArray<import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").ButtonProps, "Button"> | import("@metamask/snaps-sdk/jsx").SnapElement<import("@metamask/snaps-sdk/jsx").FieldProps, "Field">>;
716
+ name: string;
717
+ }, "Form"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
718
+ children: import("@metamask/snaps-sdk/jsx").StringElement;
719
+ }, "Heading"> | import("@metamask/snaps-sdk/jsx").SnapElement<{
720
+ src: string;
721
+ alt?: string | undefined;
722
+ }, "Image">;
583
723
  } | {
584
724
  id: string;
585
725
  }, null>;
@@ -95,6 +95,10 @@ export declare type Snap = TruncatedSnap & {
95
95
  * A lack of specifying this option will be deemed as removable.
96
96
  */
97
97
  removable?: boolean;
98
+ /**
99
+ * Flag to signal whether this snap should be hidden from the user or not.
100
+ */
101
+ hidden?: boolean;
98
102
  };
99
103
  export declare type TruncatedSnapFields = 'id' | 'initialPermissions' | 'version' | 'enabled' | 'blocked';
100
104
  /**
@@ -1,12 +1,13 @@
1
1
  import type { Component } from '@metamask/snaps-sdk';
2
2
  import type { JSXElement, LinkElement, MaybeArray, StandardFormattingElement } from '@metamask/snaps-sdk/jsx';
3
+ import type { NonEmptyArray } from '@metamask/utils';
3
4
  /**
4
5
  * Get all text children from a markdown string.
5
6
  *
6
7
  * @param value - The markdown string.
7
8
  * @returns The text children.
8
9
  */
9
- export declare function getTextChildren(value: string): (string | StandardFormattingElement | LinkElement)[];
10
+ export declare function getTextChildren(value: string): NonEmptyArray<string | StandardFormattingElement | LinkElement>;
10
11
  /**
11
12
  * Get a JSX element from a legacy UI component. This supports all legacy UI
12
13
  * components, and maps them to their JSX equivalents where possible.
package/dist/ui.js CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunk4YAWNZXMjs = require('./chunk-4YAWNZXM.js');
10
+ var _chunkIHHQU6ISjs = require('./chunk-IHHQU6IS.js');
11
11
  require('./chunk-PHUTP7NB.js');
12
12
 
13
13
 
@@ -18,5 +18,5 @@ require('./chunk-PHUTP7NB.js');
18
18
 
19
19
 
20
20
 
21
- exports.getJsxChildren = _chunk4YAWNZXMjs.getJsxChildren; exports.getJsxElementFromComponent = _chunk4YAWNZXMjs.getJsxElementFromComponent; exports.getTextChildren = _chunk4YAWNZXMjs.getTextChildren; exports.getTotalTextLength = _chunk4YAWNZXMjs.getTotalTextLength; exports.hasChildren = _chunk4YAWNZXMjs.hasChildren; exports.validateJsxLinks = _chunk4YAWNZXMjs.validateJsxLinks; exports.validateTextLinks = _chunk4YAWNZXMjs.validateTextLinks; exports.walkJsx = _chunk4YAWNZXMjs.walkJsx;
21
+ exports.getJsxChildren = _chunkIHHQU6ISjs.getJsxChildren; exports.getJsxElementFromComponent = _chunkIHHQU6ISjs.getJsxElementFromComponent; exports.getTextChildren = _chunkIHHQU6ISjs.getTextChildren; exports.getTotalTextLength = _chunkIHHQU6ISjs.getTotalTextLength; exports.hasChildren = _chunkIHHQU6ISjs.hasChildren; exports.validateJsxLinks = _chunkIHHQU6ISjs.validateJsxLinks; exports.validateTextLinks = _chunkIHHQU6ISjs.validateTextLinks; exports.walkJsx = _chunkIHHQU6ISjs.walkJsx;
22
22
  //# sourceMappingURL=ui.js.map
package/dist/ui.mjs CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  validateJsxLinks,
8
8
  validateTextLinks,
9
9
  walkJsx
10
- } from "./chunk-MJGSG5N2.mjs";
10
+ } from "./chunk-BZ7BMGXN.mjs";
11
11
  import "./chunk-JMDSN227.mjs";
12
12
  export {
13
13
  getJsxChildren,
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk3ZSYZX3Ijs = require('./chunk-3ZSYZX3I.js');
4
- require('./chunk-IAHW6IFC.js');
5
- require('./chunk-HVTYDKBO.js');
3
+ var _chunkYC2LIIR4js = require('./chunk-YC2LIIR4.js');
4
+ require('./chunk-LNZLPDBB.js');
5
+ require('./chunk-K4B37F3L.js');
6
6
  require('./chunk-M3KAAQFK.js');
7
7
  require('./chunk-6LOYTBS3.js');
8
8
  require('./chunk-CMOSYNZR.js');
9
- require('./chunk-CQRPSEH3.js');
9
+ require('./chunk-37VHIRUJ.js');
10
10
  require('./chunk-R5DO7T2D.js');
11
11
  require('./chunk-ZT3KKTS2.js');
12
12
  require('./chunk-7VJ2BOVU.js');
@@ -20,5 +20,5 @@ require('./chunk-NUCLSR2G.js');
20
20
  require('./chunk-PHUTP7NB.js');
21
21
 
22
22
 
23
- exports.validateFetchedSnap = _chunk3ZSYZX3Ijs.validateFetchedSnap;
23
+ exports.validateFetchedSnap = _chunkYC2LIIR4js.validateFetchedSnap;
24
24
  //# sourceMappingURL=validation.js.map
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  validateFetchedSnap
3
- } from "./chunk-RLA43SHY.mjs";
4
- import "./chunk-QNPXK3B3.mjs";
5
- import "./chunk-2M6G46W6.mjs";
3
+ } from "./chunk-VXLHHSAP.mjs";
4
+ import "./chunk-4I22UHIU.mjs";
5
+ import "./chunk-YCIPY3UP.mjs";
6
6
  import "./chunk-MNCFAD4E.mjs";
7
7
  import "./chunk-EXUEHPZ4.mjs";
8
8
  import "./chunk-T6FWIDA6.mjs";
9
- import "./chunk-DKDGMZFU.mjs";
9
+ import "./chunk-K2OTEZZZ.mjs";
10
10
  import "./chunk-WZ457PEQ.mjs";
11
11
  import "./chunk-AS5P6JRP.mjs";
12
12
  import "./chunk-UNNEBOL4.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/snaps-utils",
3
- "version": "7.4.0",
3
+ "version": "7.5.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/MetaMask/snaps.git"
@@ -53,12 +53,12 @@
53
53
  "@babel/core": "^7.23.2",
54
54
  "@babel/types": "^7.23.0",
55
55
  "@metamask/base-controller": "^5.0.2",
56
- "@metamask/key-tree": "^9.1.0",
56
+ "@metamask/key-tree": "^9.1.1",
57
57
  "@metamask/permission-controller": "^9.0.2",
58
58
  "@metamask/rpc-errors": "^6.2.1",
59
59
  "@metamask/slip44": "^3.1.0",
60
60
  "@metamask/snaps-registry": "^3.1.0",
61
- "@metamask/snaps-sdk": "^4.2.0",
61
+ "@metamask/snaps-sdk": "^4.4.2",
62
62
  "@metamask/utils": "^8.3.0",
63
63
  "@noble/hashes": "^1.3.1",
64
64
  "@scure/base": "^1.1.1",
@@ -76,13 +76,13 @@
76
76
  "devDependencies": {
77
77
  "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
78
78
  "@esbuild-plugins/node-modules-polyfill": "^0.2.2",
79
- "@lavamoat/allow-scripts": "^3.0.3",
79
+ "@lavamoat/allow-scripts": "^3.0.4",
80
80
  "@metamask/auto-changelog": "^3.4.4",
81
81
  "@metamask/eslint-config": "^12.1.0",
82
82
  "@metamask/eslint-config-jest": "^12.1.0",
83
83
  "@metamask/eslint-config-nodejs": "^12.1.0",
84
84
  "@metamask/eslint-config-typescript": "^12.1.0",
85
- "@metamask/post-message-stream": "^8.0.0",
85
+ "@metamask/post-message-stream": "^8.1.0",
86
86
  "@swc/core": "1.3.78",
87
87
  "@swc/jest": "^0.2.26",
88
88
  "@types/jest": "^27.5.1",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/snaps.ts"],"sourcesContent":["import type {\n Caveat,\n SubjectPermissions,\n PermissionConstraint,\n} from '@metamask/permission-controller';\nimport type { BlockReason } from '@metamask/snaps-registry';\nimport type { SnapId, Snap as TruncatedSnap } from '@metamask/snaps-sdk';\nimport type { Json } from '@metamask/utils';\nimport { assert, isObject, assertStruct } from '@metamask/utils';\nimport { base64 } from '@scure/base';\nimport stableStringify from 'fast-json-stable-stringify';\nimport type { Struct } from 'superstruct';\nimport {\n empty,\n enums,\n intersection,\n literal,\n pattern,\n refine,\n string,\n union,\n validate,\n} from 'superstruct';\nimport validateNPMPackage from 'validate-npm-package-name';\n\nimport { SnapCaveatType } from './caveats';\nimport { checksumFiles } from './checksum';\nimport type { LocalizationFile } from './localization';\nimport type {\n InitialConnections,\n SnapManifest,\n SnapPermissions,\n} from './manifest/validation';\nimport type { FetchedSnapFiles, SnapsPermissionRequest } from './types';\nimport { SnapIdPrefixes, SnapValidationFailureReason, uri } from './types';\nimport type { VirtualFile } from './virtual-file';\n\n// This RegEx matches valid npm package names (with some exceptions) and space-\n// separated alphanumerical words, optionally with dashes and underscores.\n// The RegEx consists of two parts. The first part matches space-separated\n// words. It is based on the following Stackoverflow answer:\n// https://stackoverflow.com/a/34974982\n// The second part, after the pipe operator, is the same RegEx used for the\n// `name` field of the official package.json JSON Schema, except that we allow\n// mixed-case letters. It was originally copied from:\n// https://github.com/SchemaStore/schemastore/blob/81a16897c1dabfd98c72242a5fd62eb080ff76d8/src/schemas/json/package.json#L132-L138\nexport const PROPOSED_NAME_REGEX =\n /^(?:[A-Za-z0-9-_]+( [A-Za-z0-9-_]+)*)|(?:(?:@[A-Za-z0-9-*~][A-Za-z0-9-*._~]*\\/)?[A-Za-z0-9-~][A-Za-z0-9-._~]*)$/u;\n\nexport enum SnapStatus {\n Installing = 'installing',\n Updating = 'updating',\n Running = 'running',\n Stopped = 'stopped',\n Crashed = 'crashed',\n}\n\nexport enum SnapStatusEvents {\n Start = 'START',\n Stop = 'STOP',\n Crash = 'CRASH',\n Update = 'UPDATE',\n}\n\nexport type StatusContext = { snapId: SnapId };\nexport type StatusEvents = { type: SnapStatusEvents };\nexport type StatusStates = {\n value: SnapStatus;\n context: StatusContext;\n};\nexport type Status = StatusStates['value'];\n\nexport type VersionHistory = {\n origin: string;\n version: string;\n // Unix timestamp\n date: number;\n};\n\nexport type SnapAuxilaryFile = {\n path: string;\n // Value here should be stored as base64\n value: string;\n};\n\nexport type PersistedSnap = Snap;\n\n/**\n * A Snap as it exists in {@link SnapController} state.\n */\nexport type Snap = TruncatedSnap & {\n /**\n * The initial connections of the Snap, optional, requested on installation.\n */\n initialConnections?: InitialConnections;\n /**\n * The initial permissions of the Snap, which will be requested when it is\n * installed.\n */\n initialPermissions: SnapPermissions;\n\n /**\n * The source code of the Snap.\n */\n sourceCode: string;\n\n /**\n * The Snap's manifest file.\n */\n manifest: SnapManifest;\n\n /**\n * Information detailing why the snap is blocked.\n */\n blockInformation?: BlockReason;\n\n /**\n * The current status of the Snap, e.g. whether it's running or stopped.\n */\n status: Status;\n\n /**\n * The version history of the Snap.\n * Can be used to derive when the Snap was installed, when it was updated to a certain version and who requested the change.\n */\n versionHistory: VersionHistory[];\n\n /**\n * Static auxiliary files that can be loaded at runtime.\n */\n auxiliaryFiles?: SnapAuxilaryFile[];\n\n /**\n * Localization files which are used to translate the manifest.\n */\n localizationFiles?: LocalizationFile[];\n\n /**\n * Flag to signal whether this snap was preinstalled or not.\n *\n * A lack of specifying this option will be deemed as not preinstalled.\n */\n preinstalled?: boolean;\n\n /**\n * Flag to signal whether this snap is removable or not.\n *\n * A lack of specifying this option will be deemed as removable.\n */\n removable?: boolean;\n};\n\nexport type TruncatedSnapFields =\n | 'id'\n | 'initialPermissions'\n | 'version'\n | 'enabled'\n | 'blocked';\n\n/**\n * An error indicating that a Snap validation failure is programmatically\n * fixable during development.\n */\nexport class ProgrammaticallyFixableSnapError extends Error {\n reason: SnapValidationFailureReason;\n\n constructor(message: string, reason: SnapValidationFailureReason) {\n super(message);\n this.reason = reason;\n }\n}\n\n/**\n * Gets a checksummable manifest by removing the shasum property and reserializing the JSON using a deterministic algorithm.\n *\n * @param manifest - The manifest itself.\n * @returns A virtual file containing the checksummable manifest.\n */\nfunction getChecksummableManifest(\n manifest: VirtualFile<SnapManifest>,\n): VirtualFile {\n const manifestCopy = manifest.clone() as VirtualFile<any>;\n delete manifestCopy.result.source.shasum;\n\n // We use fast-json-stable-stringify to deterministically serialize the JSON\n // This is required before checksumming so we get reproducible checksums across platforms etc\n manifestCopy.value = stableStringify(manifestCopy.result);\n return manifestCopy;\n}\n\n/**\n * Calculates the Base64-encoded SHA-256 digest of all required Snap files.\n *\n * @param files - All required Snap files to be included in the checksum.\n * @returns The Base64-encoded SHA-256 digest of the source code.\n */\nexport async function getSnapChecksum(\n files: FetchedSnapFiles,\n): Promise<string> {\n const { manifest, sourceCode, svgIcon, auxiliaryFiles, localizationFiles } =\n files;\n\n const all = [\n getChecksummableManifest(manifest),\n sourceCode,\n svgIcon,\n ...auxiliaryFiles,\n ...localizationFiles,\n ].filter((file) => file !== undefined);\n\n return base64.encode(await checksumFiles(all as VirtualFile[]));\n}\n\n/**\n * Checks whether the `source.shasum` property of a Snap manifest matches the\n * shasum of the snap.\n *\n * @param files - All required Snap files to be included in the checksum.\n * @param errorMessage - The error message to throw if validation fails.\n */\nexport async function validateSnapShasum(\n files: FetchedSnapFiles,\n errorMessage = 'Invalid Snap manifest: manifest shasum does not match computed shasum.',\n): Promise<void> {\n if (files.manifest.result.source.shasum !== (await getSnapChecksum(files))) {\n throw new ProgrammaticallyFixableSnapError(\n errorMessage,\n SnapValidationFailureReason.ShasumMismatch,\n );\n }\n}\n\nexport const LOCALHOST_HOSTNAMES = ['localhost', '127.0.0.1', '[::1]'] as const;\n\n// Require snap ids to only consist of printable ASCII characters\nexport const BaseSnapIdStruct = pattern(string(), /^[\\x21-\\x7E]*$/u);\n\nconst LocalSnapIdSubUrlStruct = uri({\n protocol: enums(['http:', 'https:']),\n hostname: enums(LOCALHOST_HOSTNAMES),\n hash: empty(string()),\n search: empty(string()),\n});\n\nexport const LocalSnapIdStruct = refine(\n BaseSnapIdStruct,\n 'local Snap Id',\n (value) => {\n if (!value.startsWith(SnapIdPrefixes.local)) {\n return `Expected local snap ID, got \"${value}\".`;\n }\n\n const [error] = validate(\n value.slice(SnapIdPrefixes.local.length),\n LocalSnapIdSubUrlStruct,\n );\n return error ?? true;\n },\n);\nexport const NpmSnapIdStruct = intersection([\n BaseSnapIdStruct,\n uri({\n protocol: literal(SnapIdPrefixes.npm),\n pathname: refine(string(), 'package name', function* (value) {\n const normalized = value.startsWith('/') ? value.slice(1) : value;\n const { errors, validForNewPackages, warnings } =\n validateNPMPackage(normalized);\n if (!validForNewPackages) {\n if (errors === undefined) {\n assert(warnings !== undefined);\n yield* warnings;\n } else {\n yield* errors;\n }\n }\n return true;\n }),\n search: empty(string()),\n hash: empty(string()),\n }),\n]) as unknown as Struct<string, null>;\n\nexport const HttpSnapIdStruct = intersection([\n BaseSnapIdStruct,\n uri({\n protocol: enums(['http:', 'https:']),\n search: empty(string()),\n hash: empty(string()),\n }),\n]) as unknown as Struct<string, null>;\n\nexport const SnapIdStruct = union([NpmSnapIdStruct, LocalSnapIdStruct]);\n\n/**\n * Extracts the snap prefix from a snap ID.\n *\n * @param snapId - The snap ID to extract the prefix from.\n * @returns The snap prefix from a snap id, e.g. `npm:`.\n */\nexport function getSnapPrefix(snapId: string): SnapIdPrefixes {\n const prefix = Object.values(SnapIdPrefixes).find((possiblePrefix) =>\n snapId.startsWith(possiblePrefix),\n );\n if (prefix !== undefined) {\n return prefix;\n }\n throw new Error(`Invalid or no prefix found for \"${snapId}\"`);\n}\n\n/**\n * Strips snap prefix from a full snap ID.\n *\n * @param snapId - The snap ID to strip.\n * @returns The stripped snap ID.\n */\nexport function stripSnapPrefix(snapId: string): string {\n return snapId.replace(getSnapPrefix(snapId), '');\n}\n\n/**\n * Assert that the given value is a valid snap ID.\n *\n * @param value - The value to check.\n * @throws If the value is not a valid snap ID.\n */\nexport function assertIsValidSnapId(value: unknown): asserts value is SnapId {\n assertStruct(value, SnapIdStruct, 'Invalid snap ID');\n}\n\n/**\n * Typeguard to ensure a chainId follows the CAIP-2 standard.\n *\n * @param chainId - The chainId being tested.\n * @returns `true` if the value is a valid CAIP chain id, and `false` otherwise.\n */\nexport function isCaipChainId(chainId: unknown): chainId is string {\n return (\n typeof chainId === 'string' &&\n /^(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-a-zA-Z0-9]{1,32})$/u.test(\n chainId,\n )\n );\n}\n\n/**\n * Utility function to check if an origin has permission (and caveat) for a particular snap.\n *\n * @param permissions - An origin's permissions object.\n * @param snapId - The id of the snap.\n * @returns A boolean based on if an origin has the specified snap.\n */\nexport function isSnapPermitted(\n permissions: SubjectPermissions<PermissionConstraint>,\n snapId: SnapId,\n) {\n return Boolean(\n (\n (\n (permissions?.wallet_snap?.caveats?.find(\n (caveat) => caveat.type === SnapCaveatType.SnapIds,\n ) ?? {}) as Caveat<string, Json>\n ).value as Record<string, unknown>\n )?.[snapId],\n );\n}\n\n/**\n * Checks whether the passed in requestedPermissions is a valid\n * permission request for a `wallet_snap` permission.\n *\n * @param requestedPermissions - The requested permissions.\n * @throws If the criteria is not met.\n */\nexport function verifyRequestedSnapPermissions(\n requestedPermissions: unknown,\n): asserts requestedPermissions is SnapsPermissionRequest {\n assert(\n isObject(requestedPermissions),\n 'Requested permissions must be an object.',\n );\n\n const { wallet_snap: walletSnapPermission } = requestedPermissions;\n\n assert(\n isObject(walletSnapPermission),\n 'wallet_snap is missing from the requested permissions.',\n );\n\n const { caveats } = walletSnapPermission;\n\n assert(\n Array.isArray(caveats) && caveats.length === 1,\n 'wallet_snap must have a caveat property with a single-item array value.',\n );\n\n const [caveat] = caveats;\n\n assert(\n isObject(caveat) &&\n caveat.type === SnapCaveatType.SnapIds &&\n isObject(caveat.value),\n `The requested permissions do not have a valid ${SnapCaveatType.SnapIds} caveat.`,\n );\n}\n\nexport type { Snap as TruncatedSnap } from '@metamask/snaps-sdk';\n"],"mappings":";;;;;;;;;AAQA,SAAS,QAAQ,UAAU,oBAAoB;AAC/C,SAAS,cAAc;AACvB,OAAO,qBAAqB;AAE5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAO,wBAAwB;AAuBxB,IAAM,sBACX;AAEK,IAAK,aAAL,kBAAKA,gBAAL;AACL,EAAAA,YAAA,gBAAa;AACb,EAAAA,YAAA,cAAW;AACX,EAAAA,YAA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