@metamask/snaps-utils 3.0.0 → 3.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.
- package/CHANGELOG.md +10 -1
- package/dist/cjs/auxiliary-files.js +40 -0
- package/dist/cjs/auxiliary-files.js.map +1 -0
- package/dist/cjs/errors.js +353 -3
- package/dist/cjs/errors.js.map +1 -1
- package/dist/cjs/index.browser.js +1 -0
- package/dist/cjs/index.browser.js.map +1 -1
- package/dist/cjs/index.executionenv.js +1 -0
- package/dist/cjs/index.executionenv.js.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/manifest/manifest.js +25 -5
- package/dist/cjs/manifest/manifest.js.map +1 -1
- package/dist/cjs/manifest/validation.js +6 -1
- package/dist/cjs/manifest/validation.js.map +1 -1
- package/dist/cjs/npm.js +5 -3
- package/dist/cjs/npm.js.map +1 -1
- package/dist/cjs/snaps.js +3 -2
- package/dist/cjs/snaps.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/validation.js.map +1 -1
- package/dist/cjs/virtual-file/VirtualFile.js +6 -0
- package/dist/cjs/virtual-file/VirtualFile.js.map +1 -1
- package/dist/esm/auxiliary-files.js +28 -0
- package/dist/esm/auxiliary-files.js.map +1 -0
- package/dist/esm/errors.js +350 -1
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/index.browser.js +1 -0
- package/dist/esm/index.browser.js.map +1 -1
- package/dist/esm/index.executionenv.js +1 -0
- package/dist/esm/index.executionenv.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/manifest/manifest.js +30 -5
- package/dist/esm/manifest/manifest.js.map +1 -1
- package/dist/esm/manifest/validation.js +3 -1
- package/dist/esm/manifest/validation.js.map +1 -1
- package/dist/esm/npm.js +5 -3
- package/dist/esm/npm.js.map +1 -1
- package/dist/esm/snaps.js +3 -2
- package/dist/esm/snaps.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/validation.js.map +1 -1
- package/dist/esm/virtual-file/VirtualFile.js +7 -1
- package/dist/esm/virtual-file/VirtualFile.js.map +1 -1
- package/dist/types/auxiliary-files.d.ts +13 -0
- package/dist/types/errors.d.ts +182 -0
- package/dist/types/index.browser.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.executionenv.d.ts +1 -0
- package/dist/types/manifest/manifest.d.ts +11 -1
- package/dist/types/manifest/validation.d.ts +4 -0
- package/dist/types/snaps.d.ts +13 -6
- package/dist/types/types.d.ts +6 -0
- package/dist/types/validation.d.ts +2 -2
- package/package.json +17 -18
package/dist/types/snaps.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { SubjectPermissions, PermissionConstraint } from '@metamask/permission-controller';
|
|
2
2
|
import type { BlockReason } from '@metamask/snaps-registry';
|
|
3
|
-
import type { Json,
|
|
4
|
-
import type { SerializedEthereumRpcError } from 'eth-rpc-errors/dist/classes';
|
|
3
|
+
import type { Json, JsonRpcError, Opaque, SemVerVersion } from '@metamask/utils';
|
|
5
4
|
import type { Struct } from 'superstruct';
|
|
6
5
|
import type { SnapManifest, SnapPermissions } from './manifest/validation';
|
|
7
|
-
import type {
|
|
6
|
+
import type { FetchedSnapFiles, SnapId, SnapsPermissionRequest } from './types';
|
|
8
7
|
import { SnapIdPrefixes, SnapValidationFailureReason } from './types';
|
|
9
8
|
export declare const PROPOSED_NAME_REGEX: RegExp;
|
|
10
9
|
/**
|
|
@@ -44,6 +43,10 @@ export declare type VersionHistory = {
|
|
|
44
43
|
version: string;
|
|
45
44
|
date: number;
|
|
46
45
|
};
|
|
46
|
+
export declare type SnapAuxilaryFile = {
|
|
47
|
+
path: string;
|
|
48
|
+
value: string;
|
|
49
|
+
};
|
|
47
50
|
export declare type PersistedSnap = Snap;
|
|
48
51
|
/**
|
|
49
52
|
* A Snap as it exists in {@link SnapController} state.
|
|
@@ -91,6 +94,10 @@ export declare type Snap = {
|
|
|
91
94
|
* Can be used to derive when the Snap was installed, when it was updated to a certain version and who requested the change.
|
|
92
95
|
*/
|
|
93
96
|
versionHistory: VersionHistory[];
|
|
97
|
+
/**
|
|
98
|
+
* Static auxiliary files that can be loaded at runtime.
|
|
99
|
+
*/
|
|
100
|
+
auxiliaryFiles?: SnapAuxilaryFile[];
|
|
94
101
|
};
|
|
95
102
|
export declare type TruncatedSnapFields = 'id' | 'initialPermissions' | 'version' | 'enabled' | 'blocked';
|
|
96
103
|
/**
|
|
@@ -99,7 +106,7 @@ export declare type TruncatedSnapFields = 'id' | 'initialPermissions' | 'version
|
|
|
99
106
|
*/
|
|
100
107
|
export declare type TruncatedSnap = Pick<Snap, TruncatedSnapFields>;
|
|
101
108
|
export declare type ProcessSnapResult = TruncatedSnap | {
|
|
102
|
-
error:
|
|
109
|
+
error: JsonRpcError;
|
|
103
110
|
};
|
|
104
111
|
export declare type InstallSnapsResult = Record<SnapId, ProcessSnapResult>;
|
|
105
112
|
/**
|
|
@@ -116,7 +123,7 @@ export declare class ProgrammaticallyFixableSnapError extends Error {
|
|
|
116
123
|
* @param files - All required Snap files to be included in the checksum.
|
|
117
124
|
* @returns The Base64-encoded SHA-256 digest of the source code.
|
|
118
125
|
*/
|
|
119
|
-
export declare function getSnapChecksum(files:
|
|
126
|
+
export declare function getSnapChecksum(files: FetchedSnapFiles): string;
|
|
120
127
|
/**
|
|
121
128
|
* Checks whether the `source.shasum` property of a Snap manifest matches the
|
|
122
129
|
* shasum of the snap.
|
|
@@ -124,7 +131,7 @@ export declare function getSnapChecksum(files: Pick<SnapFiles, 'manifest' | 'sou
|
|
|
124
131
|
* @param files - All required Snap files to be included in the checksum.
|
|
125
132
|
* @param errorMessage - The error message to throw if validation fails.
|
|
126
133
|
*/
|
|
127
|
-
export declare function validateSnapShasum(files:
|
|
134
|
+
export declare function validateSnapShasum(files: FetchedSnapFiles, errorMessage?: string): void;
|
|
128
135
|
export declare const LOCALHOST_HOSTNAMES: readonly ["localhost", "127.0.0.1", "[::1]"];
|
|
129
136
|
export declare const BaseSnapIdStruct: Struct<string, null>;
|
|
130
137
|
export declare const LocalSnapIdStruct: Struct<string, null>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export declare type UnvalidatedSnapFiles = {
|
|
|
53
53
|
packageJson?: VirtualFile<Json>;
|
|
54
54
|
sourceCode?: VirtualFile;
|
|
55
55
|
svgIcon?: VirtualFile;
|
|
56
|
+
auxiliaryFiles: VirtualFile[];
|
|
56
57
|
};
|
|
57
58
|
/**
|
|
58
59
|
* An object for storing the contents of Snap files that have passed JSON
|
|
@@ -63,7 +64,12 @@ export declare type SnapFiles = {
|
|
|
63
64
|
packageJson: VirtualFile<NpmSnapPackageJson>;
|
|
64
65
|
sourceCode: VirtualFile;
|
|
65
66
|
svgIcon?: VirtualFile;
|
|
67
|
+
auxiliaryFiles: VirtualFile[];
|
|
66
68
|
};
|
|
69
|
+
/**
|
|
70
|
+
* A subset of snap files extracted from a fetched snap.
|
|
71
|
+
*/
|
|
72
|
+
export declare type FetchedSnapFiles = Pick<SnapFiles, 'manifest' | 'sourceCode' | 'svgIcon' | 'auxiliaryFiles'>;
|
|
67
73
|
/**
|
|
68
74
|
* The possible prefixes for snap ids.
|
|
69
75
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FetchedSnapFiles } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Validates the files contained in a fetched snap.
|
|
4
4
|
*
|
|
5
5
|
* @param files - All potentially included files in a fetched snap.
|
|
6
6
|
* @throws If any of the files are considered invalid.
|
|
7
7
|
*/
|
|
8
|
-
export declare function validateFetchedSnap(files:
|
|
8
|
+
export declare function validateFetchedSnap(files: FetchedSnapFiles): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/MetaMask/snaps.git"
|
|
@@ -60,25 +60,24 @@
|
|
|
60
60
|
"build:cjs": "swc src --out-dir dist/cjs --config-file ../../.swcrc.build.json --config module.type=commonjs",
|
|
61
61
|
"build:clean": "yarn clean && yarn build",
|
|
62
62
|
"clean": "rimraf '*.tsbuildinfo' 'dist'",
|
|
63
|
-
"prepare-manifest:preview": "../../scripts/prepare-preview-manifest.sh",
|
|
64
63
|
"publish:preview": "yarn npm publish --tag preview",
|
|
65
64
|
"lint:ci": "yarn lint",
|
|
66
65
|
"lint:dependencies": "depcheck"
|
|
67
66
|
},
|
|
68
67
|
"dependencies": {
|
|
69
|
-
"@babel/core": "^7.
|
|
70
|
-
"@babel/types": "^7.
|
|
68
|
+
"@babel/core": "^7.23.2",
|
|
69
|
+
"@babel/types": "^7.23.0",
|
|
71
70
|
"@metamask/base-controller": "^3.2.0",
|
|
72
71
|
"@metamask/key-tree": "^9.0.0",
|
|
73
|
-
"@metamask/permission-controller": "^
|
|
74
|
-
"@metamask/
|
|
75
|
-
"@metamask/snaps-
|
|
72
|
+
"@metamask/permission-controller": "^5.0.0",
|
|
73
|
+
"@metamask/rpc-errors": "^6.1.0",
|
|
74
|
+
"@metamask/snaps-registry": "^2.1.0",
|
|
75
|
+
"@metamask/snaps-ui": "^3.0.1",
|
|
76
76
|
"@metamask/utils": "^8.1.0",
|
|
77
77
|
"@noble/hashes": "^1.3.1",
|
|
78
78
|
"@scure/base": "^1.1.1",
|
|
79
79
|
"chalk": "^4.1.2",
|
|
80
80
|
"cron-parser": "^4.5.0",
|
|
81
|
-
"eth-rpc-errors": "^4.0.3",
|
|
82
81
|
"fast-deep-equal": "^3.1.3",
|
|
83
82
|
"fast-json-stable-stringify": "^2.1.0",
|
|
84
83
|
"is-svg": "^4.4.0",
|
|
@@ -108,15 +107,15 @@
|
|
|
108
107
|
"@types/validate-npm-package-name": "^4.0.0",
|
|
109
108
|
"@typescript-eslint/eslint-plugin": "^5.42.1",
|
|
110
109
|
"@typescript-eslint/parser": "^5.42.1",
|
|
111
|
-
"@wdio/browser-runner": "^8.
|
|
112
|
-
"@wdio/cli": "^8.
|
|
113
|
-
"@wdio/globals": "^8.
|
|
114
|
-
"@wdio/mocha-framework": "^8.
|
|
115
|
-
"@wdio/spec-reporter": "^8.
|
|
116
|
-
"@wdio/static-server-service": "^8.
|
|
117
|
-
"@wdio/types": "^8.
|
|
110
|
+
"@wdio/browser-runner": "^8.19.0",
|
|
111
|
+
"@wdio/cli": "^8.19.0",
|
|
112
|
+
"@wdio/globals": "^8.19.0",
|
|
113
|
+
"@wdio/mocha-framework": "^8.19.0",
|
|
114
|
+
"@wdio/spec-reporter": "^8.19.0",
|
|
115
|
+
"@wdio/static-server-service": "^8.19.0",
|
|
116
|
+
"@wdio/types": "^8.19.0",
|
|
118
117
|
"deepmerge": "^4.2.2",
|
|
119
|
-
"depcheck": "^1.4.
|
|
118
|
+
"depcheck": "^1.4.7",
|
|
120
119
|
"esbuild": "^0.18.10",
|
|
121
120
|
"eslint": "^8.27.0",
|
|
122
121
|
"eslint-config-prettier": "^8.5.0",
|
|
@@ -126,7 +125,7 @@
|
|
|
126
125
|
"eslint-plugin-n": "^15.7.0",
|
|
127
126
|
"eslint-plugin-prettier": "^4.2.1",
|
|
128
127
|
"eslint-plugin-promise": "^6.1.1",
|
|
129
|
-
"expect-webdriverio": "^4.1
|
|
128
|
+
"expect-webdriverio": "^4.4.1",
|
|
130
129
|
"istanbul-lib-coverage": "^3.2.0",
|
|
131
130
|
"istanbul-lib-report": "^3.0.0",
|
|
132
131
|
"istanbul-reports": "^3.1.5",
|
|
@@ -141,7 +140,7 @@
|
|
|
141
140
|
"vite-tsconfig-paths": "^4.0.5",
|
|
142
141
|
"wdio-chromedriver-service": "^8.1.1",
|
|
143
142
|
"wdio-geckodriver-service": "^5.0.2",
|
|
144
|
-
"webdriverio": "^8.
|
|
143
|
+
"webdriverio": "^8.19.0"
|
|
145
144
|
},
|
|
146
145
|
"engines": {
|
|
147
146
|
"node": "^18.16 || >=20"
|