@metamask/snaps-utils 9.1.0 → 9.2.1
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 +18 -1
- package/dist/cronjob.d.cts +9 -9
- package/dist/cronjob.d.mts +9 -9
- package/dist/eval-worker.cjs +4 -5
- package/dist/eval-worker.cjs.map +1 -1
- package/dist/eval-worker.mjs +3 -4
- package/dist/eval-worker.mjs.map +1 -1
- package/dist/handlers/asset-historical-price.cjs +25 -0
- package/dist/handlers/asset-historical-price.cjs.map +1 -0
- package/dist/handlers/asset-historical-price.d.cts +37 -0
- package/dist/handlers/asset-historical-price.d.cts.map +1 -0
- package/dist/handlers/asset-historical-price.d.mts +37 -0
- package/dist/handlers/asset-historical-price.d.mts.map +1 -0
- package/dist/handlers/asset-historical-price.mjs +22 -0
- package/dist/handlers/asset-historical-price.mjs.map +1 -0
- package/dist/handlers/assets-conversion.cjs +38 -0
- package/dist/handlers/assets-conversion.cjs.map +1 -0
- package/dist/handlers/assets-conversion.d.cts +90 -0
- package/dist/handlers/assets-conversion.d.cts.map +1 -0
- package/dist/handlers/assets-conversion.d.mts +90 -0
- package/dist/handlers/assets-conversion.d.mts.map +1 -0
- package/dist/handlers/assets-conversion.mjs +35 -0
- package/dist/handlers/assets-conversion.mjs.map +1 -0
- package/dist/handlers/exports.cjs +113 -0
- package/dist/handlers/exports.cjs.map +1 -0
- package/dist/handlers/exports.d.cts +81 -0
- package/dist/handlers/exports.d.cts.map +1 -0
- package/dist/handlers/exports.d.mts +81 -0
- package/dist/handlers/exports.d.mts.map +1 -0
- package/dist/{handlers.mjs → handlers/exports.mjs} +10 -45
- package/dist/handlers/exports.mjs.map +1 -0
- package/dist/handlers/home-page.cjs +16 -0
- package/dist/handlers/home-page.cjs.map +1 -0
- package/dist/handlers/home-page.d.cts +268 -0
- package/dist/handlers/home-page.d.cts.map +1 -0
- package/dist/handlers/home-page.d.mts +268 -0
- package/dist/handlers/home-page.d.mts.map +1 -0
- package/dist/handlers/home-page.mjs +13 -0
- package/dist/handlers/home-page.mjs.map +1 -0
- package/dist/handlers/index.cjs +26 -0
- package/dist/handlers/index.cjs.map +1 -0
- package/dist/handlers/index.d.cts +10 -0
- package/dist/handlers/index.d.cts.map +1 -0
- package/dist/handlers/index.d.mts +10 -0
- package/dist/handlers/index.d.mts.map +1 -0
- package/dist/handlers/index.mjs +10 -0
- package/dist/handlers/index.mjs.map +1 -0
- package/dist/handlers/name-lookup.cjs +21 -0
- package/dist/handlers/name-lookup.cjs.map +1 -0
- package/dist/handlers/name-lookup.d.cts +67 -0
- package/dist/handlers/name-lookup.d.cts.map +1 -0
- package/dist/handlers/name-lookup.d.mts +67 -0
- package/dist/handlers/name-lookup.d.mts.map +1 -0
- package/dist/handlers/name-lookup.mjs +18 -0
- package/dist/handlers/name-lookup.mjs.map +1 -0
- package/dist/handlers/settings-page.cjs +6 -0
- package/dist/handlers/settings-page.cjs.map +1 -0
- package/dist/handlers/settings-page.d.cts +90 -0
- package/dist/handlers/settings-page.d.cts.map +1 -0
- package/dist/handlers/settings-page.d.mts +90 -0
- package/dist/handlers/settings-page.d.mts.map +1 -0
- package/dist/handlers/settings-page.mjs +3 -0
- package/dist/handlers/settings-page.mjs.map +1 -0
- package/dist/handlers/signature.cjs +6 -0
- package/dist/handlers/signature.cjs.map +1 -0
- package/dist/handlers/signature.d.cts +92 -0
- package/dist/handlers/signature.d.cts.map +1 -0
- package/dist/handlers/signature.d.mts +92 -0
- package/dist/handlers/signature.d.mts.map +1 -0
- package/dist/handlers/signature.mjs +3 -0
- package/dist/handlers/signature.mjs.map +1 -0
- package/dist/handlers/transaction.cjs +19 -0
- package/dist/handlers/transaction.cjs.map +1 -0
- package/dist/handlers/transaction.d.cts +280 -0
- package/dist/handlers/transaction.d.cts.map +1 -0
- package/dist/handlers/transaction.d.mts +280 -0
- package/dist/handlers/transaction.d.mts.map +1 -0
- package/dist/handlers/transaction.mjs +16 -0
- package/dist/handlers/transaction.mjs.map +1 -0
- package/dist/{handler-types.cjs → handlers/types.cjs} +3 -3
- package/dist/handlers/types.cjs.map +1 -0
- package/dist/{handler-types.d.mts → handlers/types.d.cts} +22 -2
- package/dist/handlers/types.d.cts.map +1 -0
- package/dist/{handler-types.d.cts → handlers/types.d.mts} +22 -2
- package/dist/handlers/types.d.mts.map +1 -0
- package/dist/{handler-types.mjs → handlers/types.mjs} +2 -2
- package/dist/handlers/types.mjs.map +1 -0
- package/dist/iframe.test.browser.cjs +20 -19
- package/dist/iframe.test.browser.cjs.map +1 -1
- package/dist/iframe.test.browser.mjs +2 -1
- package/dist/iframe.test.browser.mjs.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.executionenv.cjs +3 -2
- package/dist/index.executionenv.cjs.map +1 -1
- package/dist/index.executionenv.d.cts +3 -2
- package/dist/index.executionenv.d.cts.map +1 -1
- package/dist/index.executionenv.d.mts +3 -2
- package/dist/index.executionenv.d.mts.map +1 -1
- package/dist/index.executionenv.mjs +3 -2
- package/dist/index.executionenv.mjs.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/json-rpc.cjs.map +1 -1
- package/dist/json-rpc.d.cts +2 -2
- package/dist/json-rpc.d.cts.map +1 -1
- package/dist/json-rpc.d.mts +2 -2
- package/dist/json-rpc.d.mts.map +1 -1
- package/dist/json-rpc.mjs.map +1 -1
- package/dist/json.cjs +5 -1
- package/dist/json.cjs.map +1 -1
- package/dist/json.d.cts +3 -0
- package/dist/json.d.cts.map +1 -1
- package/dist/json.d.mts +3 -0
- package/dist/json.d.mts.map +1 -1
- package/dist/json.mjs +5 -1
- package/dist/json.mjs.map +1 -1
- package/dist/localization.d.cts +5 -5
- package/dist/localization.d.mts +5 -5
- package/dist/manifest/validation.d.cts +12 -12
- package/dist/manifest/validation.d.mts +12 -12
- package/dist/time.cjs +34 -0
- package/dist/time.cjs.map +1 -0
- package/dist/time.d.cts +9 -0
- package/dist/time.d.cts.map +1 -0
- package/dist/time.d.mts +9 -0
- package/dist/time.d.mts.map +1 -0
- package/dist/time.mjs +31 -0
- package/dist/time.mjs.map +1 -0
- package/dist/types.d.cts +2 -2
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +2 -2
- package/dist/types.d.mts.map +1 -1
- package/package.json +17 -24
- package/dist/handler-types.cjs.map +0 -1
- package/dist/handler-types.d.cts.map +0 -1
- package/dist/handler-types.d.mts.map +0 -1
- package/dist/handler-types.mjs.map +0 -1
- package/dist/handlers.cjs +0 -148
- package/dist/handlers.cjs.map +0 -1
- package/dist/handlers.d.cts +0 -887
- package/dist/handlers.d.cts.map +0 -1
- package/dist/handlers.d.mts +0 -887
- package/dist/handlers.d.mts.map +0 -1
- package/dist/handlers.mjs.map +0 -1
|
@@ -10,22 +10,22 @@ export declare const bip32entropy: <Type extends {
|
|
|
10
10
|
}, Schema>(struct: Struct<Type, Schema>) => Struct<Type, Schema>;
|
|
11
11
|
export declare const CurveStruct: Describe<SupportedCurve>;
|
|
12
12
|
export declare const Bip32EntropyStruct: Struct<{
|
|
13
|
-
curve: "ed25519" | "ed25519Bip32" | "secp256k1";
|
|
14
13
|
path: string[];
|
|
14
|
+
curve: "secp256k1" | "ed25519" | "ed25519Bip32";
|
|
15
15
|
}, {
|
|
16
16
|
path: Struct<string[], Struct<string, null>>;
|
|
17
|
-
curve: Describe<"
|
|
17
|
+
curve: Describe<"secp256k1" | "ed25519" | "ed25519Bip32">;
|
|
18
18
|
}>;
|
|
19
19
|
export type Bip32Entropy = Infer<typeof Bip32EntropyStruct>;
|
|
20
20
|
export declare const SnapGetBip32EntropyPermissionsStruct: Struct<{
|
|
21
|
-
curve: "ed25519" | "ed25519Bip32" | "secp256k1";
|
|
22
21
|
path: string[];
|
|
22
|
+
curve: "secp256k1" | "ed25519" | "ed25519Bip32";
|
|
23
23
|
}[], Struct<{
|
|
24
|
-
curve: "ed25519" | "ed25519Bip32" | "secp256k1";
|
|
25
24
|
path: string[];
|
|
25
|
+
curve: "secp256k1" | "ed25519" | "ed25519Bip32";
|
|
26
26
|
}, {
|
|
27
27
|
path: Struct<string[], Struct<string, null>>;
|
|
28
|
-
curve: Describe<"
|
|
28
|
+
curve: Describe<"secp256k1" | "ed25519" | "ed25519Bip32">;
|
|
29
29
|
}>>;
|
|
30
30
|
export declare const SemVerRangeStruct: Struct<string, null>;
|
|
31
31
|
export declare const SnapIdsStruct: Struct<Record<string, {
|
|
@@ -60,20 +60,20 @@ export declare const SnapAuxilaryFilesStruct: Struct<string[], Struct<string, nu
|
|
|
60
60
|
export declare const InitialConnectionsStruct: Struct<Record<string & URL, {}>, null>;
|
|
61
61
|
export type InitialConnections = Infer<typeof InitialConnectionsStruct>;
|
|
62
62
|
export declare const SnapManifestStruct: Struct<{
|
|
63
|
+
description: string;
|
|
63
64
|
source: {
|
|
65
|
+
shasum: string;
|
|
64
66
|
location: {
|
|
65
67
|
npm: {
|
|
66
|
-
registry: "https://registry.npmjs.org" | "https://registry.npmjs.org/";
|
|
67
68
|
filePath: string;
|
|
68
69
|
packageName: string;
|
|
70
|
+
registry: "https://registry.npmjs.org" | "https://registry.npmjs.org/";
|
|
69
71
|
iconPath?: string | undefined;
|
|
70
72
|
};
|
|
71
73
|
};
|
|
72
|
-
shasum: string;
|
|
73
74
|
files?: string[] | undefined;
|
|
74
75
|
locales?: string[] | undefined;
|
|
75
76
|
};
|
|
76
|
-
description: string;
|
|
77
77
|
version: import("@metamask/utils").SemVerVersion;
|
|
78
78
|
proposedName: string;
|
|
79
79
|
initialPermissions: Partial<{
|
|
@@ -147,31 +147,31 @@ export declare const SnapManifestStruct: Struct<{
|
|
|
147
147
|
url: Struct<string, null>;
|
|
148
148
|
}>;
|
|
149
149
|
source: Struct<{
|
|
150
|
+
shasum: string;
|
|
150
151
|
location: {
|
|
151
152
|
npm: {
|
|
152
|
-
registry: "https://registry.npmjs.org" | "https://registry.npmjs.org/";
|
|
153
153
|
filePath: string;
|
|
154
154
|
packageName: string;
|
|
155
|
+
registry: "https://registry.npmjs.org" | "https://registry.npmjs.org/";
|
|
155
156
|
iconPath?: string | undefined;
|
|
156
157
|
};
|
|
157
158
|
};
|
|
158
|
-
shasum: string;
|
|
159
159
|
files?: string[] | undefined;
|
|
160
160
|
locales?: string[] | undefined;
|
|
161
161
|
}, {
|
|
162
162
|
shasum: Struct<string, null>;
|
|
163
163
|
location: Struct<{
|
|
164
164
|
npm: {
|
|
165
|
-
registry: "https://registry.npmjs.org" | "https://registry.npmjs.org/";
|
|
166
165
|
filePath: string;
|
|
167
166
|
packageName: string;
|
|
167
|
+
registry: "https://registry.npmjs.org" | "https://registry.npmjs.org/";
|
|
168
168
|
iconPath?: string | undefined;
|
|
169
169
|
};
|
|
170
170
|
}, {
|
|
171
171
|
npm: Struct<{
|
|
172
|
-
registry: "https://registry.npmjs.org" | "https://registry.npmjs.org/";
|
|
173
172
|
filePath: string;
|
|
174
173
|
packageName: string;
|
|
174
|
+
registry: "https://registry.npmjs.org" | "https://registry.npmjs.org/";
|
|
175
175
|
iconPath?: string | undefined;
|
|
176
176
|
}, {
|
|
177
177
|
filePath: Struct<string, null>;
|
package/dist/time.cjs
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ISO8601DateStruct = exports.ISO8601DurationStruct = void 0;
|
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
5
|
+
const luxon_1 = require("luxon");
|
|
6
|
+
/**
|
|
7
|
+
* Refines a string as an ISO 8601 duration.
|
|
8
|
+
*/
|
|
9
|
+
exports.ISO8601DurationStruct = (0, superstruct_1.refine)((0, superstruct_1.string)(), 'ISO 8601 duration', (value) => {
|
|
10
|
+
const parsedDuration = luxon_1.Duration.fromISO(value);
|
|
11
|
+
if (!parsedDuration.isValid) {
|
|
12
|
+
return 'Not a valid ISO 8601 duration';
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Regex to match the offset part of an ISO 8601 date.
|
|
18
|
+
*/
|
|
19
|
+
const offsetRegex = /Z|([+-]\d{2}:?\d{2})$/u;
|
|
20
|
+
/**
|
|
21
|
+
* Refines a string as an ISO 8601 date.
|
|
22
|
+
*/
|
|
23
|
+
exports.ISO8601DateStruct = (0, superstruct_1.refine)((0, superstruct_1.string)(), 'ISO 8601 date', (value) => {
|
|
24
|
+
const parsedDate = luxon_1.DateTime.fromISO(value);
|
|
25
|
+
if (!parsedDate.isValid) {
|
|
26
|
+
return 'Not a valid ISO 8601 date';
|
|
27
|
+
}
|
|
28
|
+
if (!offsetRegex.test(value)) {
|
|
29
|
+
// Luxon doesn't have a reliable way to check if timezone info was not provided
|
|
30
|
+
return 'ISO 8601 date must have timezone information';
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=time.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time.cjs","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AACvD,iCAA2C;AAE3C;;GAEG;AACU,QAAA,qBAAqB,GAAG,IAAA,oBAAM,EACzC,IAAA,oBAAM,GAAE,EACR,mBAAmB,EACnB,CAAC,KAAK,EAAE,EAAE;IACR,MAAM,cAAc,GAAG,gBAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/C,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;QAC5B,OAAO,+BAA+B,CAAC;IACzC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,GAAG,wBAAwB,CAAC;AAE7C;;GAEG;AACU,QAAA,iBAAiB,GAAG,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,eAAe,EAAE,CAAC,KAAK,EAAE,EAAE;IAC3E,MAAM,UAAU,GAAG,gBAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAE3C,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QACxB,OAAO,2BAA2B,CAAC;IACrC,CAAC;IAED,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,+EAA+E;QAC/E,OAAO,8CAA8C,CAAC;IACxD,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC,CAAC","sourcesContent":["import { refine, string } from '@metamask/superstruct';\nimport { DateTime, Duration } from 'luxon';\n\n/**\n * Refines a string as an ISO 8601 duration.\n */\nexport const ISO8601DurationStruct = refine(\n string(),\n 'ISO 8601 duration',\n (value) => {\n const parsedDuration = Duration.fromISO(value);\n if (!parsedDuration.isValid) {\n return 'Not a valid ISO 8601 duration';\n }\n return true;\n },\n);\n\n/**\n * Regex to match the offset part of an ISO 8601 date.\n */\nconst offsetRegex = /Z|([+-]\\d{2}:?\\d{2})$/u;\n\n/**\n * Refines a string as an ISO 8601 date.\n */\nexport const ISO8601DateStruct = refine(string(), 'ISO 8601 date', (value) => {\n const parsedDate = DateTime.fromISO(value);\n\n if (!parsedDate.isValid) {\n return 'Not a valid ISO 8601 date';\n }\n\n if (!offsetRegex.test(value)) {\n // Luxon doesn't have a reliable way to check if timezone info was not provided\n return 'ISO 8601 date must have timezone information';\n }\n\n return true;\n});\n"]}
|
package/dist/time.d.cts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refines a string as an ISO 8601 duration.
|
|
3
|
+
*/
|
|
4
|
+
export declare const ISO8601DurationStruct: import("@metamask/superstruct").Struct<string, null>;
|
|
5
|
+
/**
|
|
6
|
+
* Refines a string as an ISO 8601 date.
|
|
7
|
+
*/
|
|
8
|
+
export declare const ISO8601DateStruct: import("@metamask/superstruct").Struct<string, null>;
|
|
9
|
+
//# sourceMappingURL=time.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time.d.cts","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,qBAAqB,sDAUjC,CAAC;AAOF;;GAEG;AACH,eAAO,MAAM,iBAAiB,sDAa5B,CAAC"}
|
package/dist/time.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refines a string as an ISO 8601 duration.
|
|
3
|
+
*/
|
|
4
|
+
export declare const ISO8601DurationStruct: import("@metamask/superstruct").Struct<string, null>;
|
|
5
|
+
/**
|
|
6
|
+
* Refines a string as an ISO 8601 date.
|
|
7
|
+
*/
|
|
8
|
+
export declare const ISO8601DateStruct: import("@metamask/superstruct").Struct<string, null>;
|
|
9
|
+
//# sourceMappingURL=time.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time.d.mts","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,qBAAqB,sDAUjC,CAAC;AAOF;;GAEG;AACH,eAAO,MAAM,iBAAiB,sDAa5B,CAAC"}
|
package/dist/time.mjs
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { refine, string } from "@metamask/superstruct";
|
|
2
|
+
import { DateTime, Duration } from "luxon";
|
|
3
|
+
/**
|
|
4
|
+
* Refines a string as an ISO 8601 duration.
|
|
5
|
+
*/
|
|
6
|
+
export const ISO8601DurationStruct = refine(string(), 'ISO 8601 duration', (value) => {
|
|
7
|
+
const parsedDuration = Duration.fromISO(value);
|
|
8
|
+
if (!parsedDuration.isValid) {
|
|
9
|
+
return 'Not a valid ISO 8601 duration';
|
|
10
|
+
}
|
|
11
|
+
return true;
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Regex to match the offset part of an ISO 8601 date.
|
|
15
|
+
*/
|
|
16
|
+
const offsetRegex = /Z|([+-]\d{2}:?\d{2})$/u;
|
|
17
|
+
/**
|
|
18
|
+
* Refines a string as an ISO 8601 date.
|
|
19
|
+
*/
|
|
20
|
+
export const ISO8601DateStruct = refine(string(), 'ISO 8601 date', (value) => {
|
|
21
|
+
const parsedDate = DateTime.fromISO(value);
|
|
22
|
+
if (!parsedDate.isValid) {
|
|
23
|
+
return 'Not a valid ISO 8601 date';
|
|
24
|
+
}
|
|
25
|
+
if (!offsetRegex.test(value)) {
|
|
26
|
+
// Luxon doesn't have a reliable way to check if timezone info was not provided
|
|
27
|
+
return 'ISO 8601 date must have timezone information';
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=time.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time.mjs","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,8BAA8B;AACvD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc;AAE3C;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CACzC,MAAM,EAAE,EACR,mBAAmB,EACnB,CAAC,KAAK,EAAE,EAAE;IACR,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/C,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;QAC5B,OAAO,+BAA+B,CAAC;IACzC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,GAAG,wBAAwB,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,eAAe,EAAE,CAAC,KAAK,EAAE,EAAE;IAC3E,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAE3C,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QACxB,OAAO,2BAA2B,CAAC;IACrC,CAAC;IAED,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,+EAA+E;QAC/E,OAAO,8CAA8C,CAAC;IACxD,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC,CAAC","sourcesContent":["import { refine, string } from '@metamask/superstruct';\nimport { DateTime, Duration } from 'luxon';\n\n/**\n * Refines a string as an ISO 8601 duration.\n */\nexport const ISO8601DurationStruct = refine(\n string(),\n 'ISO 8601 duration',\n (value) => {\n const parsedDuration = Duration.fromISO(value);\n if (!parsedDuration.isValid) {\n return 'Not a valid ISO 8601 duration';\n }\n return true;\n },\n);\n\n/**\n * Regex to match the offset part of an ISO 8601 date.\n */\nconst offsetRegex = /Z|([+-]\\d{2}:?\\d{2})$/u;\n\n/**\n * Refines a string as an ISO 8601 date.\n */\nexport const ISO8601DateStruct = refine(string(), 'ISO 8601 date', (value) => {\n const parsedDate = DateTime.fromISO(value);\n\n if (!parsedDate.isValid) {\n return 'Not a valid ISO 8601 date';\n }\n\n if (!offsetRegex.test(value)) {\n // Luxon doesn't have a reliable way to check if timezone info was not provided\n return 'ISO 8601 date must have timezone information';\n }\n\n return true;\n});\n"]}
|
package/dist/types.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Infer, Struct } from "@metamask/superstruct";
|
|
2
2
|
import type { Json } from "@metamask/utils";
|
|
3
3
|
import type { SnapCaveatType } from "./caveats.cjs";
|
|
4
|
-
import type { SnapFunctionExports, SnapRpcHookArgs } from "./handlers.cjs";
|
|
4
|
+
import type { SnapFunctionExports, SnapRpcHookArgs } from "./handlers/index.cjs";
|
|
5
5
|
import type { LocalizationFile } from "./localization.cjs";
|
|
6
6
|
import type { SnapManifest } from "./manifest/index.cjs";
|
|
7
7
|
import type { VirtualFile } from "./virtual-file/index.cjs";
|
|
@@ -11,8 +11,8 @@ export declare enum NpmSnapFileNames {
|
|
|
11
11
|
}
|
|
12
12
|
export declare const NameStruct: Struct<string, null>;
|
|
13
13
|
export declare const NpmSnapPackageJsonStruct: Struct<{
|
|
14
|
-
name: string;
|
|
15
14
|
version: import("@metamask/utils").SemVerVersion;
|
|
15
|
+
name: string;
|
|
16
16
|
main?: string | undefined;
|
|
17
17
|
repository?: {
|
|
18
18
|
type: string;
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,8BAA8B;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAG5C,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAkB;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,8BAA8B;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAG5C,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAkB;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,6BAAmB;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,2BAAuB;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,6BAAmB;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,iCAAuB;AAElD,oBAAY,gBAAgB;IAC1B,WAAW,iBAAiB;IAC5B,QAAQ,uBAAuB;CAChC;AAED,eAAO,MAAM,UAAU,sBAOtB,CAAC;AAIF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;EAUnC,CAAC;AAEH,MAAM,M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,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;AAEjC,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;AAE1E,KAAK,UAAU,CAAC,IAAI,SAAS,MAAM,IAAI;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,GAAG,UAAU,WAAW,GAAG,CAAC,+BAWrC,CAAC;AAEL;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,OAAO,EACZ,IAAI,GAAE,UAAU,CAAC,GAAG,CAAM,GACzB,GAAG,IAAI,MAAM,GAAG,GAAG,CAErB;AAGD,eAAO,MAAM,0BAA0B,gBAAgB,CAAC;AAExD,MAAM,MAAM,sBAAsB,GAAG;IACnC,CAAC,0BAA0B,CAAC,EAAE;QAC5B,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,cAAc,CAAC,OAAO,CAAC;gBAC7B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;aAC7B;SACF,CAAC;KACH,CAAC;CACH,CAAC"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Infer, Struct } from "@metamask/superstruct";
|
|
2
2
|
import type { Json } from "@metamask/utils";
|
|
3
3
|
import type { SnapCaveatType } from "./caveats.mjs";
|
|
4
|
-
import type { SnapFunctionExports, SnapRpcHookArgs } from "./handlers.mjs";
|
|
4
|
+
import type { SnapFunctionExports, SnapRpcHookArgs } from "./handlers/index.mjs";
|
|
5
5
|
import type { LocalizationFile } from "./localization.mjs";
|
|
6
6
|
import type { SnapManifest } from "./manifest/index.mjs";
|
|
7
7
|
import type { VirtualFile } from "./virtual-file/index.mjs";
|
|
@@ -11,8 +11,8 @@ export declare enum NpmSnapFileNames {
|
|
|
11
11
|
}
|
|
12
12
|
export declare const NameStruct: Struct<string, null>;
|
|
13
13
|
export declare const NpmSnapPackageJsonStruct: Struct<{
|
|
14
|
-
name: string;
|
|
15
14
|
version: import("@metamask/utils").SemVerVersion;
|
|
15
|
+
name: string;
|
|
16
16
|
main?: string | undefined;
|
|
17
17
|
repository?: {
|
|
18
18
|
type: string;
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,8BAA8B;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAG5C,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAkB;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,8BAA8B;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAG5C,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAkB;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,6BAAmB;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,2BAAuB;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,6BAAmB;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,iCAAuB;AAElD,oBAAY,gBAAgB;IAC1B,WAAW,iBAAiB;IAC5B,QAAQ,uBA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|
+
"version": "9.2.1",
|
|
4
4
|
"description": "A collection of utilities for MetaMask Snaps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -70,9 +70,10 @@
|
|
|
70
70
|
"publish:preview": "yarn npm publish --tag preview",
|
|
71
71
|
"since-latest-release": "../../scripts/since-latest-release.sh",
|
|
72
72
|
"test": "jest --reporters=jest-silent-reporter && yarn test:browser",
|
|
73
|
-
"test:browser": "
|
|
73
|
+
"test:browser": "vitest",
|
|
74
|
+
"test:browser:firefox": "vitest --config ./vitest.config.firefox.mts",
|
|
74
75
|
"test:clean": "jest --clearCache",
|
|
75
|
-
"test:post": "ts-node scripts/coverage.ts && rimraf coverage/jest coverage/
|
|
76
|
+
"test:post": "ts-node scripts/coverage.ts && rimraf coverage/jest coverage/vite",
|
|
76
77
|
"test:verbose": "jest --verbose",
|
|
77
78
|
"test:watch": "jest --watch"
|
|
78
79
|
},
|
|
@@ -85,9 +86,9 @@
|
|
|
85
86
|
"@metamask/rpc-errors": "^7.0.2",
|
|
86
87
|
"@metamask/slip44": "^4.1.0",
|
|
87
88
|
"@metamask/snaps-registry": "^3.2.3",
|
|
88
|
-
"@metamask/snaps-sdk": "^6.
|
|
89
|
-
"@metamask/superstruct": "^3.1
|
|
90
|
-
"@metamask/utils": "^11.
|
|
89
|
+
"@metamask/snaps-sdk": "^6.22.1",
|
|
90
|
+
"@metamask/superstruct": "^3.2.1",
|
|
91
|
+
"@metamask/utils": "^11.4.0",
|
|
91
92
|
"@noble/hashes": "^1.7.1",
|
|
92
93
|
"@scure/base": "^1.1.1",
|
|
93
94
|
"chalk": "^4.1.2",
|
|
@@ -95,38 +96,31 @@
|
|
|
95
96
|
"fast-deep-equal": "^3.1.3",
|
|
96
97
|
"fast-json-stable-stringify": "^2.1.0",
|
|
97
98
|
"fast-xml-parser": "^4.4.1",
|
|
99
|
+
"luxon": "^3.5.0",
|
|
98
100
|
"marked": "^12.0.1",
|
|
99
101
|
"rfdc": "^1.3.0",
|
|
100
102
|
"semver": "^7.5.4",
|
|
101
|
-
"ses": "^1.
|
|
103
|
+
"ses": "^1.12.0",
|
|
102
104
|
"validate-npm-package-name": "^5.0.0"
|
|
103
105
|
},
|
|
104
106
|
"devDependencies": {
|
|
105
|
-
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
|
|
106
|
-
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
|
|
107
107
|
"@lavamoat/allow-scripts": "^3.0.4",
|
|
108
|
-
"@metamask/auto-changelog": "^
|
|
108
|
+
"@metamask/auto-changelog": "^5.0.1",
|
|
109
109
|
"@metamask/post-message-stream": "^9.0.0",
|
|
110
110
|
"@swc/core": "1.3.78",
|
|
111
111
|
"@swc/jest": "^0.2.26",
|
|
112
|
+
"@testing-library/dom": "^10.4.0",
|
|
112
113
|
"@ts-bridge/cli": "^0.6.1",
|
|
113
114
|
"@types/jest": "^27.5.1",
|
|
114
|
-
"@types/
|
|
115
|
+
"@types/luxon": "^3",
|
|
115
116
|
"@types/node": "18.14.2",
|
|
116
117
|
"@types/semver": "^7.5.0",
|
|
117
118
|
"@types/validate-npm-package-name": "^4.0.0",
|
|
118
|
-
"@
|
|
119
|
-
"@
|
|
120
|
-
"@wdio/globals": "^8.19.0",
|
|
121
|
-
"@wdio/mocha-framework": "^8.19.0",
|
|
122
|
-
"@wdio/spec-reporter": "^8.19.0",
|
|
123
|
-
"@wdio/static-server-service": "^8.19.0",
|
|
124
|
-
"@wdio/types": "^8.19.0",
|
|
119
|
+
"@vitest/browser": "^3.1.1",
|
|
120
|
+
"@vitest/coverage-istanbul": "3.1.1",
|
|
125
121
|
"deepmerge": "^4.2.2",
|
|
126
122
|
"depcheck": "^1.4.7",
|
|
127
|
-
"esbuild": "^0.25.1",
|
|
128
123
|
"eslint": "^9.11.0",
|
|
129
|
-
"expect-webdriverio": "^4.4.1",
|
|
130
124
|
"istanbul-lib-coverage": "^3.2.0",
|
|
131
125
|
"istanbul-lib-report": "^3.0.0",
|
|
132
126
|
"istanbul-reports": "^3.1.5",
|
|
@@ -137,11 +131,10 @@
|
|
|
137
131
|
"rimraf": "^4.1.2",
|
|
138
132
|
"ts-node": "^10.9.1",
|
|
139
133
|
"typescript": "~5.3.3",
|
|
140
|
-
"vite": "^6.2.
|
|
134
|
+
"vite": "^6.2.6",
|
|
135
|
+
"vite-plugin-node-polyfills": "^0.23.0",
|
|
141
136
|
"vite-tsconfig-paths": "^4.0.5",
|
|
142
|
-
"
|
|
143
|
-
"wdio-geckodriver-service": "^5.0.2",
|
|
144
|
-
"webdriverio": "^8.19.0"
|
|
137
|
+
"vitest": "^3.1.1"
|
|
145
138
|
},
|
|
146
139
|
"engines": {
|
|
147
140
|
"node": "^18.16 || >=20"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handler-types.cjs","sourceRoot":"","sources":["../src/handler-types.ts"],"names":[],"mappings":";;;AAAA,IAAY,WAeX;AAfD,WAAY,WAAW;IACrB,4CAA6B,CAAA;IAC7B,0CAA2B,CAAA;IAC3B,8CAA+B,CAAA;IAC/B,sCAAuB,CAAA;IACvB,sCAAuB,CAAA;IACvB,oCAAqB,CAAA;IACrB,4CAA6B,CAAA;IAC7B,oDAAqC,CAAA;IACrC,wCAAyB,CAAA;IACzB,gDAAiC,CAAA;IACjC,0CAA2B,CAAA;IAC3B,gDAAiC,CAAA;IACjC,wDAAyC,CAAA;IACzC,sDAAuC,CAAA;AACzC,CAAC,EAfW,WAAW,2BAAX,WAAW,QAetB;AA0BY,QAAA,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC","sourcesContent":["export enum HandlerType {\n OnRpcRequest = 'onRpcRequest',\n OnSignature = 'onSignature',\n OnTransaction = 'onTransaction',\n OnCronjob = 'onCronjob',\n OnInstall = 'onInstall',\n OnUpdate = 'onUpdate',\n OnNameLookup = 'onNameLookup',\n OnKeyringRequest = 'onKeyringRequest',\n OnHomePage = 'onHomePage',\n OnSettingsPage = 'onSettingsPage',\n OnUserInput = 'onUserInput',\n OnAssetsLookup = 'onAssetsLookup',\n OnAssetsConversion = 'onAssetsConversion',\n OnProtocolRequest = 'onProtocolRequest',\n}\n\nexport type SnapHandler = {\n /**\n * The type of handler.\n */\n type: HandlerType;\n\n /**\n * Whether the handler is required, i.e., whether the request will fail if the\n * handler is called, but the snap does not export it.\n *\n * This is primarily used for the lifecycle handlers, which are optional.\n */\n required: boolean;\n\n /**\n * Validate the given snap export. This should return a type guard for the\n * handler type.\n *\n * @param snapExport - The export to validate.\n * @returns Whether the export is valid.\n */\n validator: (snapExport: unknown) => boolean;\n};\n\nexport const SNAP_EXPORT_NAMES = Object.values(HandlerType);\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handler-types.d.cts","sourceRoot":"","sources":["../src/handler-types.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,aAAa,kBAAkB;IAC/B,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,YAAY,iBAAiB;IAC7B,gBAAgB,qBAAqB;IACrC,UAAU,eAAe;IACzB,cAAc,mBAAmB;IACjC,WAAW,gBAAgB;IAC3B,cAAc,mBAAmB;IACjC,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;CACxC;AAED,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC;IAElB;;;;;OAKG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;;;;;OAMG;IACH,SAAS,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,OAAO,CAAC;CAC7C,CAAC;AAEF,eAAO,MAAM,iBAAiB,eAA6B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handler-types.d.mts","sourceRoot":"","sources":["../src/handler-types.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,aAAa,kBAAkB;IAC/B,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,YAAY,iBAAiB;IAC7B,gBAAgB,qBAAqB;IACrC,UAAU,eAAe;IACzB,cAAc,mBAAmB;IACjC,WAAW,gBAAgB;IAC3B,cAAc,mBAAmB;IACjC,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;CACxC;AAED,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC;IAElB;;;;;OAKG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;;;;;OAMG;IACH,SAAS,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,OAAO,CAAC;CAC7C,CAAC;AAEF,eAAO,MAAM,iBAAiB,eAA6B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handler-types.mjs","sourceRoot":"","sources":["../src/handler-types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,WAeX;AAfD,WAAY,WAAW;IACrB,4CAA6B,CAAA;IAC7B,0CAA2B,CAAA;IAC3B,8CAA+B,CAAA;IAC/B,sCAAuB,CAAA;IACvB,sCAAuB,CAAA;IACvB,oCAAqB,CAAA;IACrB,4CAA6B,CAAA;IAC7B,oDAAqC,CAAA;IACrC,wCAAyB,CAAA;IACzB,gDAAiC,CAAA;IACjC,0CAA2B,CAAA;IAC3B,gDAAiC,CAAA;IACjC,wDAAyC,CAAA;IACzC,sDAAuC,CAAA;AACzC,CAAC,EAfW,WAAW,KAAX,WAAW,QAetB;AA0BD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC","sourcesContent":["export enum HandlerType {\n OnRpcRequest = 'onRpcRequest',\n OnSignature = 'onSignature',\n OnTransaction = 'onTransaction',\n OnCronjob = 'onCronjob',\n OnInstall = 'onInstall',\n OnUpdate = 'onUpdate',\n OnNameLookup = 'onNameLookup',\n OnKeyringRequest = 'onKeyringRequest',\n OnHomePage = 'onHomePage',\n OnSettingsPage = 'onSettingsPage',\n OnUserInput = 'onUserInput',\n OnAssetsLookup = 'onAssetsLookup',\n OnAssetsConversion = 'onAssetsConversion',\n OnProtocolRequest = 'onProtocolRequest',\n}\n\nexport type SnapHandler = {\n /**\n * The type of handler.\n */\n type: HandlerType;\n\n /**\n * Whether the handler is required, i.e., whether the request will fail if the\n * handler is called, but the snap does not export it.\n *\n * This is primarily used for the lifecycle handlers, which are optional.\n */\n required: boolean;\n\n /**\n * Validate the given snap export. This should return a type guard for the\n * handler type.\n *\n * @param snapExport - The export to validate.\n * @returns Whether the export is valid.\n */\n validator: (snapExport: unknown) => boolean;\n};\n\nexport const SNAP_EXPORT_NAMES = Object.values(HandlerType);\n"]}
|
package/dist/handlers.cjs
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OnNameLookupResponseStruct = exports.DomainResolutionResponseStruct = exports.AddressResolutionResponseStruct = exports.DomainResolutionStruct = exports.AddressResolutionStruct = exports.OnSettingsPageResponseStruct = exports.OnHomePageResponseStruct = exports.OnHomePageResponseWithIdStruct = exports.OnHomePageResponseWithContentStruct = exports.OnSignatureResponseStruct = exports.OnTransactionResponseStruct = exports.OnTransactionResponseWithContentStruct = exports.OnTransactionResponseWithIdStruct = exports.OnTransactionSeverityResponseStruct = exports.SNAP_EXPORTS = void 0;
|
|
4
|
-
const snaps_sdk_1 = require("@metamask/snaps-sdk");
|
|
5
|
-
const superstruct_1 = require("@metamask/superstruct");
|
|
6
|
-
const handler_types_1 = require("./handler-types.cjs");
|
|
7
|
-
exports.SNAP_EXPORTS = {
|
|
8
|
-
[handler_types_1.HandlerType.OnRpcRequest]: {
|
|
9
|
-
type: handler_types_1.HandlerType.OnRpcRequest,
|
|
10
|
-
required: true,
|
|
11
|
-
validator: (snapExport) => {
|
|
12
|
-
return typeof snapExport === 'function';
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
[handler_types_1.HandlerType.OnTransaction]: {
|
|
16
|
-
type: handler_types_1.HandlerType.OnTransaction,
|
|
17
|
-
required: true,
|
|
18
|
-
validator: (snapExport) => {
|
|
19
|
-
return typeof snapExport === 'function';
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
[handler_types_1.HandlerType.OnCronjob]: {
|
|
23
|
-
type: handler_types_1.HandlerType.OnCronjob,
|
|
24
|
-
required: true,
|
|
25
|
-
validator: (snapExport) => {
|
|
26
|
-
return typeof snapExport === 'function';
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
[handler_types_1.HandlerType.OnNameLookup]: {
|
|
30
|
-
type: handler_types_1.HandlerType.OnNameLookup,
|
|
31
|
-
required: true,
|
|
32
|
-
validator: (snapExport) => {
|
|
33
|
-
return typeof snapExport === 'function';
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
[handler_types_1.HandlerType.OnInstall]: {
|
|
37
|
-
type: handler_types_1.HandlerType.OnInstall,
|
|
38
|
-
required: false,
|
|
39
|
-
validator: (snapExport) => {
|
|
40
|
-
return typeof snapExport === 'function';
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
[handler_types_1.HandlerType.OnUpdate]: {
|
|
44
|
-
type: handler_types_1.HandlerType.OnUpdate,
|
|
45
|
-
required: false,
|
|
46
|
-
validator: (snapExport) => {
|
|
47
|
-
return typeof snapExport === 'function';
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
[handler_types_1.HandlerType.OnKeyringRequest]: {
|
|
51
|
-
type: handler_types_1.HandlerType.OnKeyringRequest,
|
|
52
|
-
required: true,
|
|
53
|
-
validator: (snapExport) => {
|
|
54
|
-
return typeof snapExport === 'function';
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
[handler_types_1.HandlerType.OnHomePage]: {
|
|
58
|
-
type: handler_types_1.HandlerType.OnHomePage,
|
|
59
|
-
required: true,
|
|
60
|
-
validator: (snapExport) => {
|
|
61
|
-
return typeof snapExport === 'function';
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
[handler_types_1.HandlerType.OnSettingsPage]: {
|
|
65
|
-
type: handler_types_1.HandlerType.OnSettingsPage,
|
|
66
|
-
required: true,
|
|
67
|
-
validator: (snapExport) => {
|
|
68
|
-
return typeof snapExport === 'function';
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
[handler_types_1.HandlerType.OnSignature]: {
|
|
72
|
-
type: handler_types_1.HandlerType.OnSignature,
|
|
73
|
-
required: true,
|
|
74
|
-
validator: (snapExport) => {
|
|
75
|
-
return typeof snapExport === 'function';
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
[handler_types_1.HandlerType.OnUserInput]: {
|
|
79
|
-
type: handler_types_1.HandlerType.OnUserInput,
|
|
80
|
-
required: false,
|
|
81
|
-
validator: (snapExport) => {
|
|
82
|
-
return typeof snapExport === 'function';
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
[handler_types_1.HandlerType.OnAssetsLookup]: {
|
|
86
|
-
type: handler_types_1.HandlerType.OnAssetsLookup,
|
|
87
|
-
required: true,
|
|
88
|
-
validator: (snapExport) => {
|
|
89
|
-
return typeof snapExport === 'function';
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
[handler_types_1.HandlerType.OnAssetsConversion]: {
|
|
93
|
-
type: handler_types_1.HandlerType.OnAssetsConversion,
|
|
94
|
-
required: true,
|
|
95
|
-
validator: (snapExport) => {
|
|
96
|
-
return typeof snapExport === 'function';
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
[handler_types_1.HandlerType.OnProtocolRequest]: {
|
|
100
|
-
type: handler_types_1.HandlerType.OnProtocolRequest,
|
|
101
|
-
required: true,
|
|
102
|
-
validator: (snapExport) => {
|
|
103
|
-
return typeof snapExport === 'function';
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
exports.OnTransactionSeverityResponseStruct = (0, superstruct_1.object)({
|
|
108
|
-
severity: (0, superstruct_1.optional)((0, superstruct_1.literal)(snaps_sdk_1.SeverityLevel.Critical)),
|
|
109
|
-
});
|
|
110
|
-
exports.OnTransactionResponseWithIdStruct = (0, superstruct_1.assign)(exports.OnTransactionSeverityResponseStruct, (0, superstruct_1.object)({
|
|
111
|
-
id: (0, superstruct_1.string)(),
|
|
112
|
-
}));
|
|
113
|
-
exports.OnTransactionResponseWithContentStruct = (0, superstruct_1.assign)(exports.OnTransactionSeverityResponseStruct, (0, superstruct_1.object)({
|
|
114
|
-
content: snaps_sdk_1.ComponentOrElementStruct,
|
|
115
|
-
}));
|
|
116
|
-
exports.OnTransactionResponseStruct = (0, superstruct_1.nullable)((0, superstruct_1.union)([
|
|
117
|
-
exports.OnTransactionResponseWithContentStruct,
|
|
118
|
-
exports.OnTransactionResponseWithIdStruct,
|
|
119
|
-
]));
|
|
120
|
-
exports.OnSignatureResponseStruct = exports.OnTransactionResponseStruct;
|
|
121
|
-
exports.OnHomePageResponseWithContentStruct = (0, superstruct_1.object)({
|
|
122
|
-
content: snaps_sdk_1.ComponentOrElementStruct,
|
|
123
|
-
});
|
|
124
|
-
exports.OnHomePageResponseWithIdStruct = (0, superstruct_1.object)({
|
|
125
|
-
id: (0, superstruct_1.string)(),
|
|
126
|
-
});
|
|
127
|
-
exports.OnHomePageResponseStruct = (0, superstruct_1.union)([
|
|
128
|
-
exports.OnHomePageResponseWithContentStruct,
|
|
129
|
-
exports.OnHomePageResponseWithIdStruct,
|
|
130
|
-
]);
|
|
131
|
-
exports.OnSettingsPageResponseStruct = exports.OnHomePageResponseStruct;
|
|
132
|
-
exports.AddressResolutionStruct = (0, superstruct_1.object)({
|
|
133
|
-
protocol: (0, superstruct_1.string)(),
|
|
134
|
-
resolvedDomain: (0, superstruct_1.string)(),
|
|
135
|
-
});
|
|
136
|
-
exports.DomainResolutionStruct = (0, superstruct_1.object)({
|
|
137
|
-
protocol: (0, superstruct_1.string)(),
|
|
138
|
-
resolvedAddress: (0, superstruct_1.string)(),
|
|
139
|
-
domainName: (0, superstruct_1.string)(),
|
|
140
|
-
});
|
|
141
|
-
exports.AddressResolutionResponseStruct = (0, superstruct_1.object)({
|
|
142
|
-
resolvedDomains: (0, superstruct_1.size)((0, superstruct_1.array)(exports.AddressResolutionStruct), 1, Infinity),
|
|
143
|
-
});
|
|
144
|
-
exports.DomainResolutionResponseStruct = (0, superstruct_1.object)({
|
|
145
|
-
resolvedAddresses: (0, superstruct_1.size)((0, superstruct_1.array)(exports.DomainResolutionStruct), 1, Infinity),
|
|
146
|
-
});
|
|
147
|
-
exports.OnNameLookupResponseStruct = (0, superstruct_1.nullable)((0, superstruct_1.union)([exports.AddressResolutionResponseStruct, exports.DomainResolutionResponseStruct]));
|
|
148
|
-
//# sourceMappingURL=handlers.cjs.map
|
package/dist/handlers.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.cjs","sourceRoot":"","sources":["../src/handlers.ts"],"names":[],"mappings":";;;AAgBA,mDAA8E;AAC9E,uDAU+B;AAG/B,uDAA8C;AAQjC,QAAA,YAAY,GAAG;IAC1B,CAAC,2BAAW,CAAC,YAAY,CAAC,EAAE;QAC1B,IAAI,EAAE,2BAAW,CAAC,YAAY;QAC9B,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,CAAC,UAAmB,EAAqC,EAAE;YACpE,OAAO,OAAO,UAAU,KAAK,UAAU,CAAC;QAC1C,CAAC;KACF;IACD,CAAC,2BAAW,CAAC,aAAa,CAAC,EAAE;QAC3B,IAAI,EAAE,2BAAW,CAAC,aAAa;QAC/B,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,CAAC,UAAmB,EAAsC,EAAE;YACrE,OAAO,OAAO,UAAU,KAAK,UAAU,CAAC;QAC1C,CAAC;KACF;IACD,CAAC,2BAA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,UAAU,EAAE,IAAA,oBAAM,GAAE;CACrB,CAAC,CAAC;AAEU,QAAA,+BAA+B,GAAG,IAAA,oBAAM,EAAC;IACpD,eAAe,EAAE,IAAA,kBAAI,EAAC,IAAA,mBAAK,EAAC,+BAAuB,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC;CACnE,CAAC,CAAC;AAEU,QAAA,8BAA8B,GAAG,IAAA,oBAAM,EAAC;IACnD,iBAAiB,EAAE,IAAA,kBAAI,EAAC,IAAA,mBAAK,EAAC,8BAAsB,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC;CACpE,CAAC,CAAC;AAEU,QAAA,0BAA0B,GAAG,IAAA,sBAAQ,EAChD,IAAA,mBAAK,EAAC,CAAC,uCAA+B,EAAE,sCAA8B,CAAC,CAAC,CACzE,CAAC","sourcesContent":["import type {\n OnAssetsConversionHandler,\n OnAssetsLookupHandler,\n OnCronjobHandler,\n OnHomePageHandler,\n OnInstallHandler,\n OnKeyringRequestHandler,\n OnNameLookupHandler,\n OnProtocolRequestHandler,\n OnRpcRequestHandler,\n OnSettingsPageHandler,\n OnSignatureHandler,\n OnTransactionHandler,\n OnUpdateHandler,\n OnUserInputHandler,\n} from '@metamask/snaps-sdk';\nimport { ComponentOrElementStruct, SeverityLevel } from '@metamask/snaps-sdk';\nimport {\n assign,\n literal,\n nullable,\n object,\n optional,\n string,\n array,\n size,\n union,\n} from '@metamask/superstruct';\n\nimport type { SnapHandler } from './handler-types';\nimport { HandlerType } from './handler-types';\n\nexport type SnapRpcHookArgs = {\n origin: string;\n handler: HandlerType;\n request: Record<string, unknown>;\n};\n\nexport const SNAP_EXPORTS = {\n [HandlerType.OnRpcRequest]: {\n type: HandlerType.OnRpcRequest,\n required: true,\n validator: (snapExport: unknown): snapExport is OnRpcRequestHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnTransaction]: {\n type: HandlerType.OnTransaction,\n required: true,\n validator: (snapExport: unknown): snapExport is OnTransactionHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnCronjob]: {\n type: HandlerType.OnCronjob,\n required: true,\n validator: (snapExport: unknown): snapExport is OnCronjobHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnNameLookup]: {\n type: HandlerType.OnNameLookup,\n required: true,\n validator: (snapExport: unknown): snapExport is OnNameLookupHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnInstall]: {\n type: HandlerType.OnInstall,\n required: false,\n validator: (snapExport: unknown): snapExport is OnInstallHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnUpdate]: {\n type: HandlerType.OnUpdate,\n required: false,\n validator: (snapExport: unknown): snapExport is OnUpdateHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnKeyringRequest]: {\n type: HandlerType.OnKeyringRequest,\n required: true,\n validator: (snapExport: unknown): snapExport is OnKeyringRequestHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnHomePage]: {\n type: HandlerType.OnHomePage,\n required: true,\n validator: (snapExport: unknown): snapExport is OnHomePageHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnSettingsPage]: {\n type: HandlerType.OnSettingsPage,\n required: true,\n validator: (snapExport: unknown): snapExport is OnSettingsPageHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnSignature]: {\n type: HandlerType.OnSignature,\n required: true,\n validator: (snapExport: unknown): snapExport is OnSignatureHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnUserInput]: {\n type: HandlerType.OnUserInput,\n required: false,\n validator: (snapExport: unknown): snapExport is OnUserInputHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnAssetsLookup]: {\n type: HandlerType.OnAssetsLookup,\n required: true,\n validator: (snapExport: unknown): snapExport is OnAssetsLookupHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnAssetsConversion]: {\n type: HandlerType.OnAssetsConversion,\n required: true,\n validator: (\n snapExport: unknown,\n ): snapExport is OnAssetsConversionHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnProtocolRequest]: {\n type: HandlerType.OnProtocolRequest,\n required: true,\n validator: (\n snapExport: unknown,\n ): snapExport is OnProtocolRequestHandler => {\n return typeof snapExport === 'function';\n },\n },\n} as const;\n\nexport const OnTransactionSeverityResponseStruct = object({\n severity: optional(literal(SeverityLevel.Critical)),\n});\n\nexport const OnTransactionResponseWithIdStruct = assign(\n OnTransactionSeverityResponseStruct,\n object({\n id: string(),\n }),\n);\n\nexport const OnTransactionResponseWithContentStruct = assign(\n OnTransactionSeverityResponseStruct,\n object({\n content: ComponentOrElementStruct,\n }),\n);\n\nexport const OnTransactionResponseStruct = nullable(\n union([\n OnTransactionResponseWithContentStruct,\n OnTransactionResponseWithIdStruct,\n ]),\n);\n\nexport const OnSignatureResponseStruct = OnTransactionResponseStruct;\n\nexport const OnHomePageResponseWithContentStruct = object({\n content: ComponentOrElementStruct,\n});\n\nexport const OnHomePageResponseWithIdStruct = object({\n id: string(),\n});\n\nexport const OnHomePageResponseStruct = union([\n OnHomePageResponseWithContentStruct,\n OnHomePageResponseWithIdStruct,\n]);\n\nexport const OnSettingsPageResponseStruct = OnHomePageResponseStruct;\n\nexport const AddressResolutionStruct = object({\n protocol: string(),\n resolvedDomain: string(),\n});\n\nexport const DomainResolutionStruct = object({\n protocol: string(),\n resolvedAddress: string(),\n domainName: string(),\n});\n\nexport const AddressResolutionResponseStruct = object({\n resolvedDomains: size(array(AddressResolutionStruct), 1, Infinity),\n});\n\nexport const DomainResolutionResponseStruct = object({\n resolvedAddresses: size(array(DomainResolutionStruct), 1, Infinity),\n});\n\nexport const OnNameLookupResponseStruct = nullable(\n union([AddressResolutionResponseStruct, DomainResolutionResponseStruct]),\n);\n\n/**\n * Utility type for getting the handler function type from a handler type.\n */\nexport type HandlerFunction<Type extends SnapHandler> =\n Type['validator'] extends (snapExport: unknown) => snapExport is infer Handler\n ? Handler\n : never;\n\n/**\n * All the function-based handlers that a snap can implement.\n */\nexport type SnapFunctionExports = {\n [Key in keyof typeof SNAP_EXPORTS]?: HandlerFunction<\n (typeof SNAP_EXPORTS)[Key]\n >;\n};\n\n/**\n * All handlers that a snap can implement.\n */\nexport type SnapExports = SnapFunctionExports;\n"]}
|