@metamask/snaps-utils 7.0.1 → 7.0.2

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.
@@ -112,6 +112,7 @@ export declare const OnTransactionResponseWithContentStruct: import("superstruct
112
112
  type: import("@metamask/snaps-sdk").NodeType.Input;
113
113
  name: string;
114
114
  value?: string | undefined;
115
+ error?: string | undefined;
115
116
  label?: string | undefined;
116
117
  inputType?: "number" | "text" | "password" | undefined;
117
118
  placeholder?: string | undefined;
@@ -128,6 +129,7 @@ export declare const OnTransactionResponseWithContentStruct: import("superstruct
128
129
  type: import("@metamask/snaps-sdk").NodeType.Input;
129
130
  name: string;
130
131
  value?: string | undefined;
132
+ error?: string | undefined;
131
133
  label?: string | undefined;
132
134
  inputType?: "number" | "text" | "password" | undefined;
133
135
  placeholder?: string | undefined;
@@ -181,6 +183,7 @@ export declare const OnTransactionResponseWithContentStruct: import("superstruct
181
183
  type: import("@metamask/snaps-sdk").NodeType.Input;
182
184
  name: string;
183
185
  value?: string | undefined;
186
+ error?: string | undefined;
184
187
  label?: string | undefined;
185
188
  inputType?: "number" | "text" | "password" | undefined;
186
189
  placeholder?: string | undefined;
@@ -197,6 +200,7 @@ export declare const OnTransactionResponseWithContentStruct: import("superstruct
197
200
  type: import("@metamask/snaps-sdk").NodeType.Input;
198
201
  name: string;
199
202
  value?: string | undefined;
203
+ error?: string | undefined;
200
204
  label?: string | undefined;
201
205
  inputType?: "number" | "text" | "password" | undefined;
202
206
  placeholder?: string | undefined;
@@ -254,6 +258,7 @@ export declare const OnTransactionResponseStruct: import("superstruct").Struct<{
254
258
  type: import("@metamask/snaps-sdk").NodeType.Input;
255
259
  name: string;
256
260
  value?: string | undefined;
261
+ error?: string | undefined;
257
262
  label?: string | undefined;
258
263
  inputType?: "number" | "text" | "password" | undefined;
259
264
  placeholder?: string | undefined;
@@ -270,6 +275,7 @@ export declare const OnTransactionResponseStruct: import("superstruct").Struct<{
270
275
  type: import("@metamask/snaps-sdk").NodeType.Input;
271
276
  name: string;
272
277
  value?: string | undefined;
278
+ error?: string | undefined;
273
279
  label?: string | undefined;
274
280
  inputType?: "number" | "text" | "password" | undefined;
275
281
  placeholder?: string | undefined;
@@ -327,6 +333,7 @@ export declare const OnSignatureResponseStruct: import("superstruct").Struct<{
327
333
  type: import("@metamask/snaps-sdk").NodeType.Input;
328
334
  name: string;
329
335
  value?: string | undefined;
336
+ error?: string | undefined;
330
337
  label?: string | undefined;
331
338
  inputType?: "number" | "text" | "password" | undefined;
332
339
  placeholder?: string | undefined;
@@ -343,6 +350,7 @@ export declare const OnSignatureResponseStruct: import("superstruct").Struct<{
343
350
  type: import("@metamask/snaps-sdk").NodeType.Input;
344
351
  name: string;
345
352
  value?: string | undefined;
353
+ error?: string | undefined;
346
354
  label?: string | undefined;
347
355
  inputType?: "number" | "text" | "password" | undefined;
348
356
  placeholder?: string | undefined;
@@ -397,6 +405,7 @@ export declare const OnHomePageResponseWithContentStruct: import("superstruct").
397
405
  type: import("@metamask/snaps-sdk").NodeType.Input;
398
406
  name: string;
399
407
  value?: string | undefined;
408
+ error?: string | undefined;
400
409
  label?: string | undefined;
401
410
  inputType?: "number" | "text" | "password" | undefined;
402
411
  placeholder?: string | undefined;
@@ -413,6 +422,7 @@ export declare const OnHomePageResponseWithContentStruct: import("superstruct").
413
422
  type: import("@metamask/snaps-sdk").NodeType.Input;
414
423
  name: string;
415
424
  value?: string | undefined;
425
+ error?: string | undefined;
416
426
  label?: string | undefined;
417
427
  inputType?: "number" | "text" | "password" | undefined;
418
428
  placeholder?: string | undefined;
@@ -465,6 +475,7 @@ export declare const OnHomePageResponseWithContentStruct: import("superstruct").
465
475
  type: import("@metamask/snaps-sdk").NodeType.Input;
466
476
  name: string;
467
477
  value?: string | undefined;
478
+ error?: string | undefined;
468
479
  label?: string | undefined;
469
480
  inputType?: "number" | "text" | "password" | undefined;
470
481
  placeholder?: string | undefined;
@@ -481,6 +492,7 @@ export declare const OnHomePageResponseWithContentStruct: import("superstruct").
481
492
  type: import("@metamask/snaps-sdk").NodeType.Input;
482
493
  name: string;
483
494
  value?: string | undefined;
495
+ error?: string | undefined;
484
496
  label?: string | undefined;
485
497
  inputType?: "number" | "text" | "password" | undefined;
486
498
  placeholder?: string | undefined;
@@ -539,6 +551,7 @@ export declare const OnHomePageResponseStruct: import("superstruct").Struct<{
539
551
  type: import("@metamask/snaps-sdk").NodeType.Input;
540
552
  name: string;
541
553
  value?: string | undefined;
554
+ error?: string | undefined;
542
555
  label?: string | undefined;
543
556
  inputType?: "number" | "text" | "password" | undefined;
544
557
  placeholder?: string | undefined;
@@ -555,6 +568,7 @@ export declare const OnHomePageResponseStruct: import("superstruct").Struct<{
555
568
  type: import("@metamask/snaps-sdk").NodeType.Input;
556
569
  name: string;
557
570
  value?: string | undefined;
571
+ error?: string | undefined;
558
572
  label?: string | undefined;
559
573
  inputType?: "number" | "text" | "password" | undefined;
560
574
  placeholder?: string | undefined;
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkQ7RCL5IEjs = require('./chunk-Q7RCL5IE.js');
3
+ var _chunkYMUOYQFUjs = require('./chunk-YMUOYQFU.js');
4
4
  require('./chunk-ENKAY3PI.js');
5
5
  require('./chunk-TG4BDSYJ.js');
6
- require('./chunk-4BDR6KRH.js');
6
+ require('./chunk-M3KAAQFK.js');
7
7
  require('./chunk-6LOYTBS3.js');
8
8
  require('./chunk-CMOSYNZR.js');
9
9
  require('./chunk-CQRPSEH3.js');
@@ -20,5 +20,5 @@ require('./chunk-NUCLSR2G.js');
20
20
  require('./chunk-PHUTP7NB.js');
21
21
 
22
22
 
23
- exports.validateFetchedSnap = _chunkQ7RCL5IEjs.validateFetchedSnap;
23
+ exports.validateFetchedSnap = _chunkYMUOYQFUjs.validateFetchedSnap;
24
24
  //# sourceMappingURL=validation.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  validateFetchedSnap
3
- } from "./chunk-WF56W2AR.mjs";
3
+ } from "./chunk-LGT3PBPZ.mjs";
4
4
  import "./chunk-LCWDLIK5.mjs";
5
5
  import "./chunk-2IWSQJKQ.mjs";
6
- import "./chunk-MCEKOGEG.mjs";
6
+ import "./chunk-MNCFAD4E.mjs";
7
7
  import "./chunk-EXUEHPZ4.mjs";
8
8
  import "./chunk-T6FWIDA6.mjs";
9
9
  import "./chunk-DKDGMZFU.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/snaps-utils",
3
- "version": "7.0.1",
3
+ "version": "7.0.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/MetaMask/snaps.git"
@@ -58,7 +58,7 @@
58
58
  "@metamask/rpc-errors": "^6.2.1",
59
59
  "@metamask/slip44": "^3.1.0",
60
60
  "@metamask/snaps-registry": "^3.0.0",
61
- "@metamask/snaps-sdk": "^3.0.1",
61
+ "@metamask/snaps-sdk": "^3.1.0",
62
62
  "@metamask/utils": "^8.3.0",
63
63
  "@noble/hashes": "^1.3.1",
64
64
  "@scure/base": "^1.1.1",
@@ -75,7 +75,7 @@
75
75
  "devDependencies": {
76
76
  "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
77
77
  "@esbuild-plugins/node-modules-polyfill": "^0.2.2",
78
- "@lavamoat/allow-scripts": "^3.0.2",
78
+ "@lavamoat/allow-scripts": "^3.0.3",
79
79
  "@metamask/auto-changelog": "^3.4.4",
80
80
  "@metamask/eslint-config": "^12.1.0",
81
81
  "@metamask/eslint-config-jest": "^12.1.0",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/icon.ts"],"names":[],"mappings":";AAAA,SAAS,OAAO,gBAAgB;AAChC,SAAS,cAAc;AAIhB,IAAM,oBAAoB;AAC1B,IAAM,yBAAyB,GAAG,KAAK;AAAA,EAC5C,oBAAoB;AACtB,CAAC;AAOM,SAAS,iBAAiB,MAAmB;AAClD,SAAO,KAAK,KAAK,SAAS,MAAM,GAAG,sCAAsC;AAEzE;AAAA,IACE,OAAO,WAAW,KAAK,OAAO,MAAM,KAAK;AAAA,IACzC,sDAAsD,sBAAsB;AAAA,EAC9E;AAEA,SAAO,MAAM,KAAK,SAAS,CAAC,GAAG,gCAAgC;AACjE;AAQO,SAAS,iBAAiB,KAGxB;AACP,MAAI;AACF,UAAM,SAAS,SAAS,GAAG;AAE3B,UAAM,SAAS,OAAO,UAAU;AAChC,UAAM,QAAQ,OAAO,SAAS;AAE9B,QAAI,UAAU,OAAO;AACnB,aAAO,EAAE,QAAQ,MAAM;AAAA,IACzB;AAEA,UAAM,UAAU,OAAO,WAAW;AAClC,QAAI,SAAS;AAEX,YAAM,CAAC,OAAO,OAAO,cAAc,aAAa,IAAI,QAAQ,MAAM,GAAG;AAErE,UAAI,gBAAgB,eAAe;AACjC,cAAM,cAAc,SAAS,cAAc,EAAE;AAC7C,cAAM,eAAe,SAAS,eAAe,EAAE;AAE/C,eAAO,OAAO,UAAU,WAAW,KAAK,cAAc,CAAC;AACvD,eAAO,OAAO,UAAU,YAAY,KAAK,eAAe,CAAC;AAEzD,eAAO;AAAA,UACL,OAAO;AAAA,UACP,QAAQ;AAAA,QACV;AAAA,MACF;AAAA,IACF;AAAA,EACF,QAAQ;AACN,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AAEA,SAAO;AACT","sourcesContent":["import { isSvg, parseSvg } from '@metamask/snaps-sdk';\nimport { assert } from '@metamask/utils';\n\nimport type { VirtualFile } from './virtual-file';\n\nexport const SVG_MAX_BYTE_SIZE = 100_000;\nexport const SVG_MAX_BYTE_SIZE_TEXT = `${Math.floor(\n SVG_MAX_BYTE_SIZE / 1000,\n)}kb`;\n\n/**\n * Assert that a virtual file containing a Snap icon is valid.\n *\n * @param icon - A virtual file containing a Snap icon.\n */\nexport function assertIsSnapIcon(icon: VirtualFile) {\n assert(icon.path.endsWith('.svg'), 'Expected snap icon to end in \".svg\".');\n\n assert(\n Buffer.byteLength(icon.value, 'utf8') <= SVG_MAX_BYTE_SIZE,\n `The specified SVG icon exceeds the maximum size of ${SVG_MAX_BYTE_SIZE_TEXT}.`,\n );\n\n assert(isSvg(icon.toString()), 'Snap icon must be a valid SVG.');\n}\n\n/**\n * Extract the dimensions of an image from an SVG string if possible.\n *\n * @param svg - An SVG string.\n * @returns The height and width of the SVG or null.\n */\nexport function getSvgDimensions(svg: string): {\n height: number;\n width: number;\n} | null {\n try {\n const parsed = parseSvg(svg);\n\n const height = parsed['@_height'];\n const width = parsed['@_width'];\n\n if (height && width) {\n return { height, width };\n }\n\n const viewBox = parsed['@_viewBox'];\n if (viewBox) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_minX, _minY, viewBoxWidth, viewBoxHeight] = viewBox.split(' ');\n\n if (viewBoxWidth && viewBoxHeight) {\n const parsedWidth = parseInt(viewBoxWidth, 10);\n const parsedHeight = parseInt(viewBoxHeight, 10);\n\n assert(Number.isInteger(parsedWidth) && parsedWidth > 0);\n assert(Number.isInteger(parsedHeight) && parsedHeight > 0);\n\n return {\n width: parsedWidth,\n height: parsedHeight,\n };\n }\n }\n } catch {\n throw new Error('Snap icon must be a valid SVG.');\n }\n\n return null;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/icon.ts"],"sourcesContent":["import { isSvg, parseSvg } from '@metamask/snaps-sdk';\nimport { assert } from '@metamask/utils';\n\nimport type { VirtualFile } from './virtual-file';\n\nexport const SVG_MAX_BYTE_SIZE = 100_000;\nexport const SVG_MAX_BYTE_SIZE_TEXT = `${Math.floor(\n SVG_MAX_BYTE_SIZE / 1000,\n)}kb`;\n\n/**\n * Assert that a virtual file containing a Snap icon is valid.\n *\n * @param icon - A virtual file containing a Snap icon.\n */\nexport function assertIsSnapIcon(icon: VirtualFile) {\n assert(icon.path.endsWith('.svg'), 'Expected snap icon to end in \".svg\".');\n\n assert(\n Buffer.byteLength(icon.value, 'utf8') <= SVG_MAX_BYTE_SIZE,\n `The specified SVG icon exceeds the maximum size of ${SVG_MAX_BYTE_SIZE_TEXT}.`,\n );\n\n assert(isSvg(icon.toString()), 'Snap icon must be a valid SVG.');\n}\n\n/**\n * Extract the dimensions of an image from an SVG string if possible.\n *\n * @param svg - An SVG string.\n * @returns The height and width of the SVG or null.\n */\nexport function getSvgDimensions(svg: string): {\n height: number;\n width: number;\n} | null {\n try {\n const parsed = parseSvg(svg);\n\n const height = parsed['@_height'];\n const width = parsed['@_width'];\n\n if (height && width) {\n return { height, width };\n }\n\n const viewBox = parsed['@_viewBox'];\n if (viewBox) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_minX, _minY, viewBoxWidth, viewBoxHeight] = viewBox.split(' ');\n\n if (viewBoxWidth && viewBoxHeight) {\n const parsedWidth = parseInt(viewBoxWidth, 10);\n const parsedHeight = parseInt(viewBoxHeight, 10);\n\n assert(Number.isInteger(parsedWidth) && parsedWidth > 0);\n assert(Number.isInteger(parsedHeight) && parsedHeight > 0);\n\n return {\n width: parsedWidth,\n height: parsedHeight,\n };\n }\n }\n } catch {\n throw new Error('Snap icon must be a valid SVG.');\n }\n\n return null;\n}\n"],"mappings":";AAAA,SAAS,OAAO,gBAAgB;AAChC,SAAS,cAAc;AAIhB,IAAM,oBAAoB;AAC1B,IAAM,yBAAyB,GAAG,KAAK;AAAA,EAC5C,oBAAoB;AACtB,CAAC;AAOM,SAAS,iBAAiB,MAAmB;AAClD,SAAO,KAAK,KAAK,SAAS,MAAM,GAAG,sCAAsC;AAEzE;AAAA,IACE,OAAO,WAAW,KAAK,OAAO,MAAM,KAAK;AAAA,IACzC,sDAAsD,sBAAsB;AAAA,EAC9E;AAEA,SAAO,MAAM,KAAK,SAAS,CAAC,GAAG,gCAAgC;AACjE;AAQO,SAAS,iBAAiB,KAGxB;AACP,MAAI;AACF,UAAM,SAAS,SAAS,GAAG;AAE3B,UAAM,SAAS,OAAO,UAAU;AAChC,UAAM,QAAQ,OAAO,SAAS;AAE9B,QAAI,UAAU,OAAO;AACnB,aAAO,EAAE,QAAQ,MAAM;AAAA,IACzB;AAEA,UAAM,UAAU,OAAO,WAAW;AAClC,QAAI,SAAS;AAEX,YAAM,CAAC,OAAO,OAAO,cAAc,aAAa,IAAI,QAAQ,MAAM,GAAG;AAErE,UAAI,gBAAgB,eAAe;AACjC,cAAM,cAAc,SAAS,cAAc,EAAE;AAC7C,cAAM,eAAe,SAAS,eAAe,EAAE;AAE/C,eAAO,OAAO,UAAU,WAAW,KAAK,cAAc,CAAC;AACvD,eAAO,OAAO,UAAU,YAAY,KAAK,eAAe,CAAC;AAEzD,eAAO;AAAA,UACL,OAAO;AAAA,UACP,QAAQ;AAAA,QACV;AAAA,MACF;AAAA,IACF;AAAA,EACF,QAAQ;AACN,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AAEA,SAAO;AACT;","names":[]}