@metamask/snaps-utils 3.1.0 → 3.3.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 +12 -1
- package/dist/cjs/eval-worker.js +2 -2
- package/dist/cjs/eval-worker.js.map +1 -1
- package/dist/cjs/handler-types.js +32 -0
- package/dist/cjs/handler-types.js.map +1 -0
- package/dist/cjs/handlers.js +37 -27
- package/dist/cjs/handlers.js.map +1 -1
- package/dist/cjs/index.browser.js +2 -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 +2 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/localization.js +113 -0
- package/dist/cjs/localization.js.map +1 -0
- package/dist/cjs/manifest/manifest.js +23 -9
- package/dist/cjs/manifest/manifest.js.map +1 -1
- package/dist/cjs/manifest/validation.js +3 -2
- package/dist/cjs/manifest/validation.js.map +1 -1
- package/dist/cjs/npm.js +16 -3
- package/dist/cjs/npm.js.map +1 -1
- package/dist/cjs/snaps.js.map +1 -1
- package/dist/cjs/types.js +0 -5
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/validation.js +2 -0
- package/dist/cjs/validation.js.map +1 -1
- package/dist/esm/eval-worker.js +1 -1
- package/dist/esm/eval-worker.js.map +1 -1
- package/dist/esm/handler-types.js +14 -0
- package/dist/esm/handler-types.js.map +1 -0
- package/dist/esm/handlers.js +17 -10
- package/dist/esm/handlers.js.map +1 -1
- package/dist/esm/index.browser.js +2 -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 +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/localization.js +115 -0
- package/dist/esm/localization.js.map +1 -0
- package/dist/esm/manifest/manifest.js +30 -12
- package/dist/esm/manifest/manifest.js.map +1 -1
- package/dist/esm/manifest/validation.js +4 -3
- package/dist/esm/manifest/validation.js.map +1 -1
- package/dist/esm/npm.js +16 -3
- package/dist/esm/npm.js.map +1 -1
- package/dist/esm/snaps.js.map +1 -1
- package/dist/esm/types.js +0 -2
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/validation.js +2 -0
- package/dist/esm/validation.js.map +1 -1
- package/dist/types/handler-types.d.ts +32 -0
- package/dist/types/handlers.d.ts +95 -36
- package/dist/types/index.browser.d.ts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.executionenv.d.ts +1 -0
- package/dist/types/localization.d.ts +143 -0
- package/dist/types/manifest/manifest.d.ts +15 -6
- package/dist/types/manifest/validation.d.ts +5 -2
- package/dist/types/snaps.d.ts +5 -0
- package/dist/types/types.d.ts +6 -10
- package/package.json +2 -2
|
@@ -193,8 +193,6 @@ export declare type SnapPermissions = Infer<typeof PermissionsStruct>;
|
|
|
193
193
|
export declare const SnapAuxilaryFilesStruct: Struct<string[], Struct<string, null>>;
|
|
194
194
|
export declare const SnapManifestStruct: Struct<{
|
|
195
195
|
description: string;
|
|
196
|
-
version: import("@metamask/utils").SemVerVersion;
|
|
197
|
-
proposedName: string;
|
|
198
196
|
source: {
|
|
199
197
|
location: {
|
|
200
198
|
npm: {
|
|
@@ -206,7 +204,10 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
206
204
|
};
|
|
207
205
|
shasum: string;
|
|
208
206
|
files?: string[] | undefined;
|
|
207
|
+
locales?: string[] | undefined;
|
|
209
208
|
};
|
|
209
|
+
version: import("@metamask/utils").SemVerVersion;
|
|
210
|
+
proposedName: string;
|
|
210
211
|
initialPermissions: {
|
|
211
212
|
'endowment:network-access'?: {} | undefined;
|
|
212
213
|
'endowment:webassembly'?: {} | undefined;
|
|
@@ -282,6 +283,7 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
282
283
|
};
|
|
283
284
|
shasum: string;
|
|
284
285
|
files?: string[] | undefined;
|
|
286
|
+
locales?: string[] | undefined;
|
|
285
287
|
}, {
|
|
286
288
|
shasum: Struct<string, null>;
|
|
287
289
|
location: Struct<{
|
|
@@ -305,6 +307,7 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
305
307
|
}>;
|
|
306
308
|
}>;
|
|
307
309
|
files: Struct<string[] | undefined, Struct<string, null>>;
|
|
310
|
+
locales: Struct<string[] | undefined, Struct<string, null>>;
|
|
308
311
|
}>;
|
|
309
312
|
initialPermissions: Struct<{
|
|
310
313
|
'endowment:network-access'?: {} | undefined;
|
package/dist/types/snaps.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { SubjectPermissions, PermissionConstraint } from '@metamask/permiss
|
|
|
2
2
|
import type { BlockReason } from '@metamask/snaps-registry';
|
|
3
3
|
import type { Json, JsonRpcError, Opaque, SemVerVersion } from '@metamask/utils';
|
|
4
4
|
import type { Struct } from 'superstruct';
|
|
5
|
+
import type { LocalizationFile } from './localization';
|
|
5
6
|
import type { SnapManifest, SnapPermissions } from './manifest/validation';
|
|
6
7
|
import type { FetchedSnapFiles, SnapId, SnapsPermissionRequest } from './types';
|
|
7
8
|
import { SnapIdPrefixes, SnapValidationFailureReason } from './types';
|
|
@@ -98,6 +99,10 @@ export declare type Snap = {
|
|
|
98
99
|
* Static auxiliary files that can be loaded at runtime.
|
|
99
100
|
*/
|
|
100
101
|
auxiliaryFiles?: SnapAuxilaryFile[];
|
|
102
|
+
/**
|
|
103
|
+
* Localization files which are used to translate the manifest.
|
|
104
|
+
*/
|
|
105
|
+
localizationFiles?: LocalizationFile[];
|
|
101
106
|
};
|
|
102
107
|
export declare type TruncatedSnapFields = 'id' | 'initialPermissions' | 'version' | 'enabled' | 'blocked';
|
|
103
108
|
/**
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Json } from '@metamask/utils';
|
|
2
2
|
import type { Infer, Struct } from 'superstruct';
|
|
3
3
|
import type { SnapCaveatType } from './caveats';
|
|
4
|
-
import type { SnapFunctionExports } from './handlers';
|
|
5
|
-
import {
|
|
4
|
+
import type { SnapFunctionExports, SnapRpcHookArgs } from './handlers';
|
|
5
|
+
import type { LocalizationFile } from './localization';
|
|
6
6
|
import type { SnapManifest } from './manifest';
|
|
7
7
|
import type { VirtualFile } from './virtual-file';
|
|
8
8
|
export declare enum NpmSnapFileNames {
|
|
@@ -13,11 +13,11 @@ export declare const NameStruct: Struct<string, null>;
|
|
|
13
13
|
export declare const NpmSnapPackageJsonStruct: Struct<{
|
|
14
14
|
name: string;
|
|
15
15
|
version: import("@metamask/utils").SemVerVersion;
|
|
16
|
+
main?: string | undefined;
|
|
16
17
|
repository?: {
|
|
17
18
|
type: string;
|
|
18
19
|
url: string;
|
|
19
20
|
} | undefined;
|
|
20
|
-
main?: string | undefined;
|
|
21
21
|
}, {
|
|
22
22
|
version: Struct<import("@metamask/utils").SemVerVersion, null>;
|
|
23
23
|
name: Struct<string, null>;
|
|
@@ -54,6 +54,7 @@ export declare type UnvalidatedSnapFiles = {
|
|
|
54
54
|
sourceCode?: VirtualFile;
|
|
55
55
|
svgIcon?: VirtualFile;
|
|
56
56
|
auxiliaryFiles: VirtualFile[];
|
|
57
|
+
localizationFiles: VirtualFile[];
|
|
57
58
|
};
|
|
58
59
|
/**
|
|
59
60
|
* An object for storing the contents of Snap files that have passed JSON
|
|
@@ -65,11 +66,12 @@ export declare type SnapFiles = {
|
|
|
65
66
|
sourceCode: VirtualFile;
|
|
66
67
|
svgIcon?: VirtualFile;
|
|
67
68
|
auxiliaryFiles: VirtualFile[];
|
|
69
|
+
localizationFiles: VirtualFile<LocalizationFile>[];
|
|
68
70
|
};
|
|
69
71
|
/**
|
|
70
72
|
* A subset of snap files extracted from a fetched snap.
|
|
71
73
|
*/
|
|
72
|
-
export declare type FetchedSnapFiles = Pick<SnapFiles, 'manifest' | 'sourceCode' | 'svgIcon' | 'auxiliaryFiles'>;
|
|
74
|
+
export declare type FetchedSnapFiles = Pick<SnapFiles, 'manifest' | 'sourceCode' | 'svgIcon' | 'auxiliaryFiles' | 'localizationFiles'>;
|
|
73
75
|
/**
|
|
74
76
|
* The possible prefixes for snap ids.
|
|
75
77
|
*/
|
|
@@ -92,12 +94,6 @@ export declare enum SNAP_STREAM_NAMES {
|
|
|
92
94
|
JSON_RPC = "jsonRpc",
|
|
93
95
|
COMMAND = "command"
|
|
94
96
|
}
|
|
95
|
-
export declare const SNAP_EXPORT_NAMES: HandlerType[];
|
|
96
|
-
export declare type SnapRpcHookArgs = {
|
|
97
|
-
origin: string;
|
|
98
|
-
handler: HandlerType;
|
|
99
|
-
request: Record<string, unknown>;
|
|
100
|
-
};
|
|
101
97
|
export declare type SnapRpcHook = (options: SnapRpcHookArgs) => Promise<unknown>;
|
|
102
98
|
declare type ObjectParameters<Type extends Record<string, (...args: any[]) => unknown>> = Parameters<Type[keyof Type]>;
|
|
103
99
|
export declare type SnapExportsParameters = ObjectParameters<SnapFunctionExports>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/MetaMask/snaps.git"
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@metamask/permission-controller": "^5.0.0",
|
|
73
73
|
"@metamask/rpc-errors": "^6.1.0",
|
|
74
74
|
"@metamask/snaps-registry": "^2.1.0",
|
|
75
|
-
"@metamask/snaps-ui": "^3.0
|
|
75
|
+
"@metamask/snaps-ui": "^3.1.0",
|
|
76
76
|
"@metamask/utils": "^8.1.0",
|
|
77
77
|
"@noble/hashes": "^1.3.1",
|
|
78
78
|
"@scure/base": "^1.1.1",
|