@metamask/snaps-sdk 2.0.0 → 2.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.
@@ -42,7 +42,7 @@ export declare class SnapError extends Error {
42
42
  *
43
43
  * @returns Additional data for the error.
44
44
  */
45
- get data(): Record<string, Json>;
45
+ get data(): Record<string, Json> | undefined;
46
46
  /**
47
47
  * The error stack.
48
48
  *
@@ -81,8 +81,6 @@ export declare type SerializedSnapError = {
81
81
  code: typeof SNAP_ERROR_CODE;
82
82
  message: typeof SNAP_ERROR_MESSAGE;
83
83
  data: {
84
- cause: JsonRpcError & {
85
- data: Record<string, Json>;
86
- };
84
+ cause: JsonRpcError;
87
85
  };
88
86
  };
@@ -1,5 +1,5 @@
1
1
  export type { EnumToUnion } from './internals';
2
- export { getErrorData, getErrorMessage, getErrorStack, SNAP_ERROR_CODE, SNAP_ERROR_MESSAGE, literal, union, enumValue, } from './internals';
2
+ export { getErrorData, getErrorMessage, getErrorStack, SNAP_ERROR_CODE, SNAP_ERROR_MESSAGE, literal, union, enumValue, parseSvg, isSvg, } from './internals';
3
3
  export type { Json, JsonRpcError, JsonRpcRequest, JsonRpcParams, } from '@metamask/utils';
4
4
  export { assert } from '@metamask/utils';
5
5
  export * from './errors';
@@ -14,15 +14,41 @@ export declare type JsonRpcErrorFunction = typeof rpcErrors.parse;
14
14
  * @returns The created `SnapError` class.
15
15
  */
16
16
  export declare function createSnapError(fn: JsonRpcErrorFunction): {
17
- new (message?: string, data?: Record<string, Json>): {
17
+ new (message?: string): {
18
18
  readonly "__#3@#code": number;
19
19
  readonly "__#3@#message": string;
20
- readonly "__#3@#data": Record<string, Json>;
20
+ readonly "__#3@#data"?: Record<string, Json> | undefined;
21
21
  readonly "__#3@#stack"?: string | undefined;
22
22
  readonly name: string;
23
23
  readonly code: number;
24
24
  readonly message: string;
25
- readonly data: Record<string, Json>;
25
+ readonly data: Record<string, Json> | undefined;
26
+ readonly stack: string | undefined;
27
+ toJSON(): import("../errors").SerializedSnapError;
28
+ serialize(): import("../errors").SerializedSnapError;
29
+ };
30
+ new (data?: Record<string, Json>): {
31
+ readonly "__#3@#code": number;
32
+ readonly "__#3@#message": string;
33
+ readonly "__#3@#data"?: Record<string, Json> | undefined;
34
+ readonly "__#3@#stack"?: string | undefined;
35
+ readonly name: string;
36
+ readonly code: number;
37
+ readonly message: string;
38
+ readonly data: Record<string, Json> | undefined;
39
+ readonly stack: string | undefined;
40
+ toJSON(): import("../errors").SerializedSnapError;
41
+ serialize(): import("../errors").SerializedSnapError;
42
+ };
43
+ new (message?: string | Record<string, Json>, data?: Record<string, Json>): {
44
+ readonly "__#3@#code": number;
45
+ readonly "__#3@#message": string;
46
+ readonly "__#3@#data"?: Record<string, Json> | undefined;
47
+ readonly "__#3@#stack"?: string | undefined;
48
+ readonly name: string;
49
+ readonly code: number;
50
+ readonly message: string;
51
+ readonly data: Record<string, Json> | undefined;
26
52
  readonly stack: string | undefined;
27
53
  toJSON(): import("../errors").SerializedSnapError;
28
54
  serialize(): import("../errors").SerializedSnapError;
@@ -2,3 +2,4 @@ export * from './error-wrappers';
2
2
  export * from './errors';
3
3
  export * from './helpers';
4
4
  export * from './structs';
5
+ export * from './svg';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Parse and validate a string as an SVG.
3
+ *
4
+ * @param svg - An SVG string.
5
+ * @returns The SVG, its attributes and children in an object format.
6
+ */
7
+ export declare function parseSvg(svg: string): any;
8
+ /**
9
+ * Validate that a string is a valid SVG.
10
+ *
11
+ * @param svg - An SVG string.
12
+ * @returns True if the SVG is valid otherwise false.
13
+ */
14
+ export declare function isSvg(svg: string): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/snaps-sdk",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/MetaMask/snaps.git"
@@ -39,11 +39,11 @@
39
39
  "@metamask/providers": "^14.0.2",
40
40
  "@metamask/rpc-errors": "^6.1.0",
41
41
  "@metamask/utils": "^8.3.0",
42
- "is-svg": "^4.4.0",
42
+ "fast-xml-parser": "^4.3.4",
43
43
  "superstruct": "^1.0.3"
44
44
  },
45
45
  "devDependencies": {
46
- "@lavamoat/allow-scripts": "^3.0.0",
46
+ "@lavamoat/allow-scripts": "^3.0.2",
47
47
  "@metamask/auto-changelog": "^3.4.4",
48
48
  "@metamask/eslint-config": "^12.1.0",
49
49
  "@metamask/eslint-config-jest": "^12.1.0",