@metamask/snaps-utils 2.0.1 → 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 +20 -1
- package/dist/cjs/auxiliary-files.js +40 -0
- package/dist/cjs/auxiliary-files.js.map +1 -0
- package/dist/cjs/caveats.js +3 -0
- package/dist/cjs/caveats.js.map +1 -1
- package/dist/cjs/errors.js +353 -3
- package/dist/cjs/errors.js.map +1 -1
- package/dist/cjs/handlers.js +8 -0
- package/dist/cjs/handlers.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/json-rpc.js +39 -4
- package/dist/cjs/json-rpc.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 +7 -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/cjs/virtual-file/toVirtualFile.js.map +1 -1
- package/dist/esm/auxiliary-files.js +28 -0
- package/dist/esm/auxiliary-files.js.map +1 -0
- package/dist/esm/caveats.js +3 -0
- package/dist/esm/caveats.js.map +1 -1
- package/dist/esm/errors.js +350 -1
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/handlers.js +8 -0
- package/dist/esm/handlers.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/json-rpc.js +46 -6
- package/dist/esm/json-rpc.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 +5 -2
- 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/esm/virtual-file/toVirtualFile.js.map +1 -1
- package/dist/types/auxiliary-files.d.ts +13 -0
- package/dist/types/caveats.d.ts +4 -0
- package/dist/types/errors.d.ts +182 -0
- package/dist/types/handlers.d.ts +21 -2
- 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/json-rpc.d.ts +28 -1
- package/dist/types/manifest/manifest.d.ts +11 -1
- package/dist/types/manifest/validation.d.ts +30 -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/dist/types/virtual-file/toVirtualFile.d.ts +1 -1
- package/package.json +20 -21
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "VirtualFile", {
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
const _utils = require("@metamask/utils");
|
|
20
|
+
const _base = require("@scure/base");
|
|
20
21
|
const _deepclone = require("../deep-clone");
|
|
21
22
|
function _define_property(obj, key, value) {
|
|
22
23
|
if (key in obj) {
|
|
@@ -36,6 +37,11 @@ class VirtualFile {
|
|
|
36
37
|
if (typeof this.value === 'string') {
|
|
37
38
|
(0, _utils.assert)(encoding === undefined, 'Tried to encode string.');
|
|
38
39
|
return this.value;
|
|
40
|
+
} else if (this.value instanceof Uint8Array && encoding === 'hex') {
|
|
41
|
+
return (0, _utils.bytesToHex)(this.value);
|
|
42
|
+
} else if (this.value instanceof Uint8Array && encoding === 'base64') {
|
|
43
|
+
// TODO: Use @metamask/utils for this
|
|
44
|
+
return _base.base64.encode(this.value);
|
|
39
45
|
}
|
|
40
46
|
const decoder = new TextDecoder(encoding);
|
|
41
47
|
return decoder.decode(this.value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/virtual-file/VirtualFile.ts"],"sourcesContent":["// TODO(ritave): Move into separate package @metamask/vfile / @metamask/utils + @metamask/to-vfile when passes code review\n// TODO(ritave): Streaming vfile contents similar to vinyl maybe?\n// TODO(ritave): Move fixing manifest in cli and bundler plugins to write messages to vfile\n// similar to unified instead of throwing \"ProgrammaticallyFixableErrors\".\n//\n// Using https://github.com/vfile/vfile would be helpful, but they only support ESM and we need to support CommonJS.\n// https://github.com/gulpjs/vinyl is also good, but they normalize paths, which we can't do, because\n// we're calculating checksums based on original path.\nimport { assert } from '@metamask/utils';\n\nimport { deepClone } from '../deep-clone';\n\n/**\n * This map registers the type of the {@link VirtualFile.data} key of a {@link VirtualFile}.\n *\n * This type can be augmented to register custom `data` types.\n *\n * @example\n * declare module '@metamask/snaps-utils' {\n * interface DataMap {\n * // `file.data.name` is typed as `string`\n * name: string\n * }\n * }\n */\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions, @typescript-eslint/no-empty-interface\nexport interface DataMap {}\n\nexport type Value = string | Uint8Array;\nexport type Compatible<Result = unknown> =\n | string\n | Uint8Array\n | Options<Result>;\nexport type Data = Record<string, unknown> & Partial<DataMap>;\nexport type Options<Result = unknown> = {\n value: Value;\n path?: string;\n data?: Data;\n result?: Result;\n};\n\nexport class VirtualFile<Result = unknown> {\n constructor(value?: Compatible<Result>) {\n let options: Options | undefined;\n if (typeof value === 'string' || value instanceof Uint8Array) {\n options = { value };\n } else {\n options = value;\n }\n\n this.value = options?.value ?? '';\n // This situations happens when there's no .result used,\n // we expect the file to have default generic in that situation:\n // VirtualFile<unknown> which will handle undefined properly\n //\n // While not 100% type safe, it'll be way less frustrating to work with.\n // The alternative would be to have VirtualFile.result be Result | undefined\n // and that would result in needing to branch out and check in all situations.\n //\n // In short, optimizing for most common use case.\n this.result = options?.result ?? (undefined as any);\n this.data = options?.data ?? {};\n this.path = options?.path ?? '/';\n }\n\n value: Value;\n\n result: Result;\n\n data: Data;\n\n path: string;\n\n toString(encoding?: string) {\n if (typeof this.value === 'string') {\n assert(encoding === undefined, 'Tried to encode string.');\n return this.value;\n }\n const decoder = new TextDecoder(encoding);\n return decoder.decode(this.value);\n }\n\n clone() {\n const vfile = new VirtualFile<Result>();\n if (typeof this.value === 'string') {\n vfile.value = this.value;\n } else {\n // deep-clone doesn't clone Buffer properly, even if it's a sub-class of Uint8Array\n vfile.value = this.value.slice(0);\n }\n vfile.result = deepClone(this.result);\n vfile.data = deepClone(this.data);\n vfile.path = this.path;\n return vfile;\n }\n}\n"],"names":["VirtualFile","toString","encoding","value","assert","undefined","decoder","TextDecoder","decode","clone","vfile","slice","result","deepClone","data","path","constructor","options"
|
|
1
|
+
{"version":3,"sources":["../../../src/virtual-file/VirtualFile.ts"],"sourcesContent":["// TODO(ritave): Move into separate package @metamask/vfile / @metamask/utils + @metamask/to-vfile when passes code review\n// TODO(ritave): Streaming vfile contents similar to vinyl maybe?\n// TODO(ritave): Move fixing manifest in cli and bundler plugins to write messages to vfile\n// similar to unified instead of throwing \"ProgrammaticallyFixableErrors\".\n//\n// Using https://github.com/vfile/vfile would be helpful, but they only support ESM and we need to support CommonJS.\n// https://github.com/gulpjs/vinyl is also good, but they normalize paths, which we can't do, because\n// we're calculating checksums based on original path.\nimport { assert, bytesToHex } from '@metamask/utils';\nimport { base64 } from '@scure/base';\n\nimport { deepClone } from '../deep-clone';\n\n/**\n * This map registers the type of the {@link VirtualFile.data} key of a {@link VirtualFile}.\n *\n * This type can be augmented to register custom `data` types.\n *\n * @example\n * declare module '@metamask/snaps-utils' {\n * interface DataMap {\n * // `file.data.name` is typed as `string`\n * name: string\n * }\n * }\n */\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions, @typescript-eslint/no-empty-interface\nexport interface DataMap {}\n\nexport type Value = string | Uint8Array;\nexport type Compatible<Result = unknown> =\n | string\n | Uint8Array\n | Options<Result>;\nexport type Data = Record<string, unknown> & Partial<DataMap>;\nexport type Options<Result = unknown> = {\n value: Value;\n path?: string;\n data?: Data;\n result?: Result;\n};\n\nexport class VirtualFile<Result = unknown> {\n constructor(value?: Compatible<Result>) {\n let options: Options | undefined;\n if (typeof value === 'string' || value instanceof Uint8Array) {\n options = { value };\n } else {\n options = value;\n }\n\n this.value = options?.value ?? '';\n // This situations happens when there's no .result used,\n // we expect the file to have default generic in that situation:\n // VirtualFile<unknown> which will handle undefined properly\n //\n // While not 100% type safe, it'll be way less frustrating to work with.\n // The alternative would be to have VirtualFile.result be Result | undefined\n // and that would result in needing to branch out and check in all situations.\n //\n // In short, optimizing for most common use case.\n this.result = options?.result ?? (undefined as any);\n this.data = options?.data ?? {};\n this.path = options?.path ?? '/';\n }\n\n value: Value;\n\n result: Result;\n\n data: Data;\n\n path: string;\n\n toString(encoding?: string) {\n if (typeof this.value === 'string') {\n assert(encoding === undefined, 'Tried to encode string.');\n return this.value;\n } else if (this.value instanceof Uint8Array && encoding === 'hex') {\n return bytesToHex(this.value);\n } else if (this.value instanceof Uint8Array && encoding === 'base64') {\n // TODO: Use @metamask/utils for this\n return base64.encode(this.value);\n }\n const decoder = new TextDecoder(encoding);\n return decoder.decode(this.value);\n }\n\n clone() {\n const vfile = new VirtualFile<Result>();\n if (typeof this.value === 'string') {\n vfile.value = this.value;\n } else {\n // deep-clone doesn't clone Buffer properly, even if it's a sub-class of Uint8Array\n vfile.value = this.value.slice(0);\n }\n vfile.result = deepClone(this.result);\n vfile.data = deepClone(this.data);\n vfile.path = this.path;\n return vfile;\n }\n}\n"],"names":["VirtualFile","toString","encoding","value","assert","undefined","Uint8Array","bytesToHex","base64","encode","decoder","TextDecoder","decode","clone","vfile","slice","result","deepClone","data","path","constructor","options"],"mappings":"AAAA,0HAA0H;AAC1H,iEAAiE;AACjE,2FAA2F;AAC3F,wFAAwF;AACxF,EAAE;AACF,oHAAoH;AACpH,qGAAqG;AACrG,sDAAsD;;;;;+BAmCzCA;;;eAAAA;;;uBAlCsB;sBACZ;2BAEG;;;;;;;;;;;;;;AA+BnB,MAAMA;IAgCXC,SAASC,QAAiB,EAAE;QAC1B,IAAI,OAAO,IAAI,CAACC,KAAK,KAAK,UAAU;YAClCC,IAAAA,aAAM,EAACF,aAAaG,WAAW;YAC/B,OAAO,IAAI,CAACF,KAAK;QACnB,OAAO,IAAI,IAAI,CAACA,KAAK,YAAYG,cAAcJ,aAAa,OAAO;YACjE,OAAOK,IAAAA,iBAAU,EAAC,IAAI,CAACJ,KAAK;QAC9B,OAAO,IAAI,IAAI,CAACA,KAAK,YAAYG,cAAcJ,aAAa,UAAU;YACpE,qCAAqC;YACrC,OAAOM,YAAM,CAACC,MAAM,CAAC,IAAI,CAACN,KAAK;QACjC;QACA,MAAMO,UAAU,IAAIC,YAAYT;QAChC,OAAOQ,QAAQE,MAAM,CAAC,IAAI,CAACT,KAAK;IAClC;IAEAU,QAAQ;QACN,MAAMC,QAAQ,IAAId;QAClB,IAAI,OAAO,IAAI,CAACG,KAAK,KAAK,UAAU;YAClCW,MAAMX,KAAK,GAAG,IAAI,CAACA,KAAK;QAC1B,OAAO;YACL,mFAAmF;YACnFW,MAAMX,KAAK,GAAG,IAAI,CAACA,KAAK,CAACY,KAAK,CAAC;QACjC;QACAD,MAAME,MAAM,GAAGC,IAAAA,oBAAS,EAAC,IAAI,CAACD,MAAM;QACpCF,MAAMI,IAAI,GAAGD,IAAAA,oBAAS,EAAC,IAAI,CAACC,IAAI;QAChCJ,MAAMK,IAAI,GAAG,IAAI,CAACA,IAAI;QACtB,OAAOL;IACT;IAzDAM,YAAYjB,KAA0B,CAAE;QAuBxCA,uBAAAA,SAAAA,KAAAA;QAEAa,uBAAAA,UAAAA,KAAAA;QAEAE,uBAAAA,QAAAA,KAAAA;QAEAC,uBAAAA,QAAAA,KAAAA;QA5BE,IAAIE;QACJ,IAAI,OAAOlB,UAAU,YAAYA,iBAAiBG,YAAY;YAC5De,UAAU;gBAAElB;YAAM;QACpB,OAAO;YACLkB,UAAUlB;QACZ;QAEA,IAAI,CAACA,KAAK,GAAGkB,SAASlB,SAAS;QAC/B,wDAAwD;QACxD,gEAAgE;QAChE,4DAA4D;QAC5D,EAAE;QACF,wEAAwE;QACxE,4EAA4E;QAC5E,8EAA8E;QAC9E,EAAE;QACF,iDAAiD;QACjD,IAAI,CAACa,MAAM,GAAGK,SAASL,UAAWX;QAClC,IAAI,CAACa,IAAI,GAAGG,SAASH,QAAQ,CAAC;QAC9B,IAAI,CAACC,IAAI,GAAGE,SAASF,QAAQ;IAC/B;AAqCF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/virtual-file/toVirtualFile.ts"],"sourcesContent":["import { promises as fsPromises } from 'fs';\n\nimport { VirtualFile } from './VirtualFile';\n\n/**\n * Reads a file from filesystem and creates a vfile.\n *\n * @param path - Filesystem path to load the contents from.\n * @param encoding - Optional encoding to pass down to fs.readFile.\n * @returns Promise returning VFile with loaded file contents.\n */\nexport async function readVirtualFile(\n path: string,\n encoding: BufferEncoding | null = null,\n) {\n return new VirtualFile({\n path,\n value: await fsPromises.readFile(path, { encoding }),\n });\n}\n\ntype WriteVFileOptions = Exclude<\n Parameters<typeof fsPromises['writeFile']>[2],\n undefined\n>;\n\n/**\n * Writes vfile to filesystem.\n *\n * @param vfile - The vfile to write.\n * @param options - Options to pass down to fs.writeFile.\n */\nexport async function writeVirtualFile(\n vfile: VirtualFile,\n options?: WriteVFileOptions,\n) {\n return fsPromises.writeFile(vfile.path, vfile.value, options);\n}\n"],"names":["readVirtualFile","writeVirtualFile","path","encoding","VirtualFile","value","fsPromises","readFile","vfile","options","writeFile"],"mappings":";;;;;;;;;;;IAWsBA,eAAe;eAAfA;;IAqBAC,gBAAgB;eAAhBA;;;oBAhCiB;6BAEX;AASrB,eAAeD,gBACpBE,IAAY,EACZC,WAAkC,IAAI;IAEtC,OAAO,IAAIC,wBAAW,CAAC;QACrBF;QACAG,OAAO,MAAMC,YAAU,CAACC,QAAQ,CAACL,MAAM;YAAEC;QAAS;IACpD;AACF;AAaO,eAAeF,iBACpBO,KAAkB,EAClBC,OAA2B;IAE3B,OAAOH,YAAU,CAACI,SAAS,CAACF,MAAMN,IAAI,EAAEM,MAAMH,KAAK,EAAEI;AACvD"}
|
|
1
|
+
{"version":3,"sources":["../../../src/virtual-file/toVirtualFile.ts"],"sourcesContent":["import { promises as fsPromises } from 'fs';\n\nimport { VirtualFile } from './VirtualFile';\n\n/**\n * Reads a file from filesystem and creates a vfile.\n *\n * @param path - Filesystem path to load the contents from.\n * @param encoding - Optional encoding to pass down to fs.readFile.\n * @returns Promise returning VFile with loaded file contents.\n */\nexport async function readVirtualFile(\n path: string,\n encoding: BufferEncoding | null = null,\n) {\n return new VirtualFile({\n path,\n value: await fsPromises.readFile(path, { encoding }),\n });\n}\n\ntype WriteVFileOptions = Exclude<\n Parameters<(typeof fsPromises)['writeFile']>[2],\n undefined\n>;\n\n/**\n * Writes vfile to filesystem.\n *\n * @param vfile - The vfile to write.\n * @param options - Options to pass down to fs.writeFile.\n */\nexport async function writeVirtualFile(\n vfile: VirtualFile,\n options?: WriteVFileOptions,\n) {\n return fsPromises.writeFile(vfile.path, vfile.value, options);\n}\n"],"names":["readVirtualFile","writeVirtualFile","path","encoding","VirtualFile","value","fsPromises","readFile","vfile","options","writeFile"],"mappings":";;;;;;;;;;;IAWsBA,eAAe;eAAfA;;IAqBAC,gBAAgB;eAAhBA;;;oBAhCiB;6BAEX;AASrB,eAAeD,gBACpBE,IAAY,EACZC,WAAkC,IAAI;IAEtC,OAAO,IAAIC,wBAAW,CAAC;QACrBF;QACAG,OAAO,MAAMC,YAAU,CAACC,QAAQ,CAACL,MAAM;YAAEC;QAAS;IACpD;AACF;AAaO,eAAeF,iBACpBO,KAAkB,EAClBC,OAA2B;IAE3B,OAAOH,YAAU,CAACI,SAAS,CAACF,MAAMN,IAAI,EAAEM,MAAMH,KAAK,EAAEI;AACvD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { bytesToHex, bytesToString } from '@metamask/utils';
|
|
2
|
+
import { base64 } from '@scure/base';
|
|
3
|
+
export var AuxiliaryFileEncoding;
|
|
4
|
+
(function(AuxiliaryFileEncoding) {
|
|
5
|
+
AuxiliaryFileEncoding["Base64"] = 'base64';
|
|
6
|
+
AuxiliaryFileEncoding["Hex"] = 'hex';
|
|
7
|
+
AuxiliaryFileEncoding["Utf8"] = 'utf8';
|
|
8
|
+
})(AuxiliaryFileEncoding || (AuxiliaryFileEncoding = {}));
|
|
9
|
+
/**
|
|
10
|
+
* Re-encodes an auxiliary file if needed depending on the requested file encoding.
|
|
11
|
+
*
|
|
12
|
+
* @param value - The base64 value stored for the auxiliary file.
|
|
13
|
+
* @param encoding - The chosen encoding.
|
|
14
|
+
* @returns The file encoded in the requested encoding.
|
|
15
|
+
*/ export function encodeAuxiliaryFile(value, encoding) {
|
|
16
|
+
// Input is assumed to be the stored file in base64.
|
|
17
|
+
if (encoding === AuxiliaryFileEncoding.Base64) {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
// TODO: Use @metamask/utils for this
|
|
21
|
+
const decoded = base64.decode(value);
|
|
22
|
+
if (encoding === AuxiliaryFileEncoding.Utf8) {
|
|
23
|
+
return bytesToString(decoded);
|
|
24
|
+
}
|
|
25
|
+
return bytesToHex(decoded);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=auxiliary-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/auxiliary-files.ts"],"sourcesContent":["import { bytesToHex, bytesToString } from '@metamask/utils';\nimport { base64 } from '@scure/base';\n\nexport enum AuxiliaryFileEncoding {\n Base64 = 'base64',\n Hex = 'hex',\n Utf8 = 'utf8',\n}\n\n/**\n * Re-encodes an auxiliary file if needed depending on the requested file encoding.\n *\n * @param value - The base64 value stored for the auxiliary file.\n * @param encoding - The chosen encoding.\n * @returns The file encoded in the requested encoding.\n */\nexport function encodeAuxiliaryFile(\n value: string,\n encoding: AuxiliaryFileEncoding,\n) {\n // Input is assumed to be the stored file in base64.\n if (encoding === AuxiliaryFileEncoding.Base64) {\n return value;\n }\n\n // TODO: Use @metamask/utils for this\n const decoded = base64.decode(value);\n if (encoding === AuxiliaryFileEncoding.Utf8) {\n return bytesToString(decoded);\n }\n\n return bytesToHex(decoded);\n}\n"],"names":["bytesToHex","bytesToString","base64","AuxiliaryFileEncoding","Base64","Hex","Utf8","encodeAuxiliaryFile","value","encoding","decoded","decode"],"mappings":"AAAA,SAASA,UAAU,EAAEC,aAAa,QAAQ,kBAAkB;AAC5D,SAASC,MAAM,QAAQ,cAAc;WAE9B;UAAKC,qBAAqB;IAArBA,sBACVC,YAAS;IADCD,sBAEVE,SAAM;IAFIF,sBAGVG,UAAO;GAHGH,0BAAAA;AAMZ;;;;;;CAMC,GACD,OAAO,SAASI,oBACdC,KAAa,EACbC,QAA+B;IAE/B,oDAAoD;IACpD,IAAIA,aAAaN,sBAAsBC,MAAM,EAAE;QAC7C,OAAOI;IACT;IAEA,qCAAqC;IACrC,MAAME,UAAUR,OAAOS,MAAM,CAACH;IAC9B,IAAIC,aAAaN,sBAAsBG,IAAI,EAAE;QAC3C,OAAOL,cAAcS;IACvB;IAEA,OAAOV,WAAWU;AACpB"}
|
package/dist/esm/caveats.js
CHANGED
|
@@ -16,6 +16,9 @@ export var SnapCaveatType;
|
|
|
16
16
|
* The origins that a Snap can receive JSON-RPC messages from.
|
|
17
17
|
*/ "RpcOrigin"] = 'rpcOrigin';
|
|
18
18
|
SnapCaveatType[/**
|
|
19
|
+
* The origins that a Snap can receive keyring messages from.
|
|
20
|
+
*/ "KeyringOrigin"] = 'keyringOrigin';
|
|
21
|
+
SnapCaveatType[/**
|
|
19
22
|
* Caveat specifying the snap IDs that can be interacted with.
|
|
20
23
|
*/ "SnapIds"] = 'snapIds';
|
|
21
24
|
SnapCaveatType[/**
|
package/dist/esm/caveats.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/caveats.ts"],"sourcesContent":["export enum SnapCaveatType {\n /**\n * Permitted derivation paths, used by `snap_getBip32Entropy`.\n */\n PermittedDerivationPaths = 'permittedDerivationPaths',\n\n /**\n * Permitted coin types, used by `snap_getBip44Entropy`.\n */\n PermittedCoinTypes = 'permittedCoinTypes',\n\n /**\n * Caveat specifying a snap cronjob.\n */\n SnapCronjob = 'snapCronjob',\n\n /**\n * Caveat specifying access to the transaction origin, used by `endowment:transaction-insight`.\n */\n TransactionOrigin = 'transactionOrigin',\n\n /**\n * The origins that a Snap can receive JSON-RPC messages from.\n */\n RpcOrigin = 'rpcOrigin',\n\n /**\n * Caveat specifying the snap IDs that can be interacted with.\n */\n SnapIds = 'snapIds',\n\n /**\n * Caveat specifying the CAIP-2 chain IDs that a snap can service, currently limited to `endowment:name-lookup`.\n */\n ChainIds = 'chainIds',\n}\n"],"names":["SnapCaveatType","PermittedDerivationPaths","PermittedCoinTypes","SnapCronjob","TransactionOrigin","RpcOrigin","SnapIds","ChainIds"],"mappings":"WAAO;UAAKA,cAAc;IAAdA,eACV;;GAEC,GACDC,8BAA2B;IAJjBD,eAMV;;GAEC,GACDE,wBAAqB;IATXF,eAWV;;GAEC,GACDG,iBAAc;IAdJH,eAgBV;;GAEC,GACDI,uBAAoB;IAnBVJ,eAqBV;;GAEC,GACDK,eAAY;IAxBFL,eA0BV;;GAEC,GACDM,
|
|
1
|
+
{"version":3,"sources":["../../src/caveats.ts"],"sourcesContent":["export enum SnapCaveatType {\n /**\n * Permitted derivation paths, used by `snap_getBip32Entropy`.\n */\n PermittedDerivationPaths = 'permittedDerivationPaths',\n\n /**\n * Permitted coin types, used by `snap_getBip44Entropy`.\n */\n PermittedCoinTypes = 'permittedCoinTypes',\n\n /**\n * Caveat specifying a snap cronjob.\n */\n SnapCronjob = 'snapCronjob',\n\n /**\n * Caveat specifying access to the transaction origin, used by `endowment:transaction-insight`.\n */\n TransactionOrigin = 'transactionOrigin',\n\n /**\n * The origins that a Snap can receive JSON-RPC messages from.\n */\n RpcOrigin = 'rpcOrigin',\n\n /**\n * The origins that a Snap can receive keyring messages from.\n */\n KeyringOrigin = 'keyringOrigin',\n\n /**\n * Caveat specifying the snap IDs that can be interacted with.\n */\n SnapIds = 'snapIds',\n\n /**\n * Caveat specifying the CAIP-2 chain IDs that a snap can service, currently limited to `endowment:name-lookup`.\n */\n ChainIds = 'chainIds',\n}\n"],"names":["SnapCaveatType","PermittedDerivationPaths","PermittedCoinTypes","SnapCronjob","TransactionOrigin","RpcOrigin","KeyringOrigin","SnapIds","ChainIds"],"mappings":"WAAO;UAAKA,cAAc;IAAdA,eACV;;GAEC,GACDC,8BAA2B;IAJjBD,eAMV;;GAEC,GACDE,wBAAqB;IATXF,eAWV;;GAEC,GACDG,iBAAc;IAdJH,eAgBV;;GAEC,GACDI,uBAAoB;IAnBVJ,eAqBV;;GAEC,GACDK,eAAY;IAxBFL,eA0BV;;GAEC,GACDM,mBAAgB;IA7BNN,eA+BV;;GAEC,GACDO,aAAU;IAlCAP,eAoCV;;GAEC,GACDQ,cAAW;GAvCDR,mBAAAA"}
|
package/dist/esm/errors.js
CHANGED
|
@@ -1,4 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
function _check_private_redeclaration(obj, privateCollection) {
|
|
2
|
+
if (privateCollection.has(obj)) {
|
|
3
|
+
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
7
|
+
if (descriptor.get) {
|
|
8
|
+
return descriptor.get.call(receiver);
|
|
9
|
+
}
|
|
10
|
+
return descriptor.value;
|
|
11
|
+
}
|
|
12
|
+
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
13
|
+
if (descriptor.set) {
|
|
14
|
+
descriptor.set.call(receiver, value);
|
|
15
|
+
} else {
|
|
16
|
+
if (!descriptor.writable) {
|
|
17
|
+
throw new TypeError("attempted to set read only private field");
|
|
18
|
+
}
|
|
19
|
+
descriptor.value = value;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
23
|
+
if (!privateMap.has(receiver)) {
|
|
24
|
+
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
25
|
+
}
|
|
26
|
+
return privateMap.get(receiver);
|
|
27
|
+
}
|
|
28
|
+
function _class_private_field_get(receiver, privateMap) {
|
|
29
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
30
|
+
return _class_apply_descriptor_get(receiver, descriptor);
|
|
31
|
+
}
|
|
32
|
+
function _class_private_field_init(obj, privateMap, value) {
|
|
33
|
+
_check_private_redeclaration(obj, privateMap);
|
|
34
|
+
privateMap.set(obj, value);
|
|
35
|
+
}
|
|
36
|
+
function _class_private_field_set(receiver, privateMap, value) {
|
|
37
|
+
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
38
|
+
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
import { errorCodes, JsonRpcError as RpcError, serializeCause } from '@metamask/rpc-errors';
|
|
42
|
+
import { hasProperty, isJsonRpcError, isObject, isValidJson } from '@metamask/utils';
|
|
2
43
|
/**
|
|
3
44
|
* Get the error message from an unknown error type.
|
|
4
45
|
*
|
|
@@ -13,5 +54,313 @@ import { hasProperty, isObject } from '@metamask/utils';
|
|
|
13
54
|
}
|
|
14
55
|
return String(error);
|
|
15
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Get the error stack from an unknown error type.
|
|
59
|
+
*
|
|
60
|
+
* @param error - The error to get the stack from.
|
|
61
|
+
* @returns The error stack, or undefined if the error does not have a valid
|
|
62
|
+
* stack.
|
|
63
|
+
*/ export function getErrorStack(error) {
|
|
64
|
+
if (isObject(error) && hasProperty(error, 'stack') && typeof error.stack === 'string') {
|
|
65
|
+
return error.stack;
|
|
66
|
+
}
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get the error code from an unknown error type.
|
|
71
|
+
*
|
|
72
|
+
* @param error - The error to get the code from.
|
|
73
|
+
* @returns The error code, or `-32603` if the error does not have a valid code.
|
|
74
|
+
*/ export function getErrorCode(error) {
|
|
75
|
+
if (isObject(error) && hasProperty(error, 'code') && typeof error.code === 'number' && Number.isInteger(error.code)) {
|
|
76
|
+
return error.code;
|
|
77
|
+
}
|
|
78
|
+
return errorCodes.rpc.internal;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get the error data from an unknown error type.
|
|
82
|
+
*
|
|
83
|
+
* @param error - The error to get the data from.
|
|
84
|
+
* @returns The error data, or an empty object if the error does not have valid
|
|
85
|
+
* data.
|
|
86
|
+
*/ export function getErrorData(error) {
|
|
87
|
+
if (isObject(error) && hasProperty(error, 'data') && typeof error.data === 'object' && error.data !== null && isValidJson(error.data) && !Array.isArray(error.data)) {
|
|
88
|
+
return error.data;
|
|
89
|
+
}
|
|
90
|
+
return {};
|
|
91
|
+
}
|
|
92
|
+
export const SNAP_ERROR_WRAPPER_CODE = -31001;
|
|
93
|
+
export const SNAP_ERROR_WRAPPER_MESSAGE = 'Wrapped Snap Error';
|
|
94
|
+
export const SNAP_ERROR_CODE = -31002;
|
|
95
|
+
export const SNAP_ERROR_MESSAGE = 'Snap Error';
|
|
96
|
+
var _error = /*#__PURE__*/ new WeakMap(), _message = /*#__PURE__*/ new WeakMap(), _stack = /*#__PURE__*/ new WeakMap();
|
|
97
|
+
export class WrappedSnapError extends Error {
|
|
98
|
+
/**
|
|
99
|
+
* The error name.
|
|
100
|
+
*
|
|
101
|
+
* @returns The error name.
|
|
102
|
+
*/ get name() {
|
|
103
|
+
return 'WrappedSnapError';
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The error message.
|
|
107
|
+
*
|
|
108
|
+
* @returns The error message.
|
|
109
|
+
*/ get message() {
|
|
110
|
+
return _class_private_field_get(this, _message);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The error stack.
|
|
114
|
+
*
|
|
115
|
+
* @returns The error stack.
|
|
116
|
+
*/ get stack() {
|
|
117
|
+
return _class_private_field_get(this, _stack);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Convert the error to a JSON object.
|
|
121
|
+
*
|
|
122
|
+
* @returns The JSON object.
|
|
123
|
+
*/ toJSON() {
|
|
124
|
+
const cause = isSnapError(_class_private_field_get(this, _error)) ? _class_private_field_get(this, _error).serialize() : serializeCause(_class_private_field_get(this, _error));
|
|
125
|
+
return {
|
|
126
|
+
code: SNAP_ERROR_WRAPPER_CODE,
|
|
127
|
+
message: SNAP_ERROR_WRAPPER_MESSAGE,
|
|
128
|
+
data: {
|
|
129
|
+
cause
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Serialize the error to a JSON object. This is called by
|
|
135
|
+
* `@metamask/rpc-errors` when serializing the error.
|
|
136
|
+
*
|
|
137
|
+
* @returns The JSON object.
|
|
138
|
+
*/ serialize() {
|
|
139
|
+
return this.toJSON();
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Create a new `WrappedSnapError`.
|
|
143
|
+
*
|
|
144
|
+
* @param error - The error to create the `WrappedSnapError` from.
|
|
145
|
+
*/ constructor(error){
|
|
146
|
+
const message = getErrorMessage(error);
|
|
147
|
+
super(message);
|
|
148
|
+
_class_private_field_init(this, _error, {
|
|
149
|
+
writable: true,
|
|
150
|
+
value: void 0
|
|
151
|
+
});
|
|
152
|
+
_class_private_field_init(this, _message, {
|
|
153
|
+
writable: true,
|
|
154
|
+
value: void 0
|
|
155
|
+
});
|
|
156
|
+
_class_private_field_init(this, _stack, {
|
|
157
|
+
writable: true,
|
|
158
|
+
value: void 0
|
|
159
|
+
});
|
|
160
|
+
_class_private_field_set(this, _error, error);
|
|
161
|
+
_class_private_field_set(this, _message, message);
|
|
162
|
+
_class_private_field_set(this, _stack, getErrorStack(error));
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
var _code = /*#__PURE__*/ new WeakMap(), _message1 = /*#__PURE__*/ new WeakMap(), _data = /*#__PURE__*/ new WeakMap(), _stack1 = /*#__PURE__*/ new WeakMap();
|
|
166
|
+
/**
|
|
167
|
+
* A generic error which can be thrown by a Snap, without it causing the Snap to
|
|
168
|
+
* crash.
|
|
169
|
+
*/ export class SnapError extends Error {
|
|
170
|
+
/**
|
|
171
|
+
* The error name.
|
|
172
|
+
*
|
|
173
|
+
* @returns The error name.
|
|
174
|
+
*/ get name() {
|
|
175
|
+
return 'SnapError';
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The error code.
|
|
179
|
+
*
|
|
180
|
+
* @returns The error code.
|
|
181
|
+
*/ get code() {
|
|
182
|
+
return _class_private_field_get(this, _code);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The error message.
|
|
186
|
+
*
|
|
187
|
+
* @returns The error message.
|
|
188
|
+
*/ get message() {
|
|
189
|
+
return _class_private_field_get(this, _message1);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Additional data for the error.
|
|
193
|
+
*
|
|
194
|
+
* @returns Additional data for the error.
|
|
195
|
+
*/ get data() {
|
|
196
|
+
return _class_private_field_get(this, _data);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* The error stack.
|
|
200
|
+
*
|
|
201
|
+
* @returns The error stack.
|
|
202
|
+
*/ get stack() {
|
|
203
|
+
return _class_private_field_get(this, _stack1);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Convert the error to a JSON object.
|
|
207
|
+
*
|
|
208
|
+
* @returns The JSON object.
|
|
209
|
+
*/ toJSON() {
|
|
210
|
+
return {
|
|
211
|
+
code: SNAP_ERROR_CODE,
|
|
212
|
+
message: SNAP_ERROR_MESSAGE,
|
|
213
|
+
data: {
|
|
214
|
+
cause: {
|
|
215
|
+
code: this.code,
|
|
216
|
+
message: this.message,
|
|
217
|
+
stack: this.stack,
|
|
218
|
+
data: this.data
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Serialize the error to a JSON object. This is called by
|
|
225
|
+
* `@metamask/rpc-errors` when serializing the error.
|
|
226
|
+
*
|
|
227
|
+
* @returns The JSON object.
|
|
228
|
+
*/ serialize() {
|
|
229
|
+
return this.toJSON();
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Create a new `SnapError`.
|
|
233
|
+
*
|
|
234
|
+
* @param error - The error to create the `SnapError` from. If this is a
|
|
235
|
+
* `string`, it will be used as the error message. If this is an `Error`, its
|
|
236
|
+
* `message` property will be used as the error message. If this is a
|
|
237
|
+
* `JsonRpcError`, its `message` property will be used as the error message
|
|
238
|
+
* and its `code` property will be used as the error code. Otherwise, the
|
|
239
|
+
* error will be converted to a string and used as the error message.
|
|
240
|
+
* @param data - Additional data to include in the error. This will be merged
|
|
241
|
+
* with the error data, if any.
|
|
242
|
+
*/ constructor(error, data = {}){
|
|
243
|
+
const message = getErrorMessage(error);
|
|
244
|
+
super(message);
|
|
245
|
+
_class_private_field_init(this, _code, {
|
|
246
|
+
writable: true,
|
|
247
|
+
value: void 0
|
|
248
|
+
});
|
|
249
|
+
_class_private_field_init(this, _message1, {
|
|
250
|
+
writable: true,
|
|
251
|
+
value: void 0
|
|
252
|
+
});
|
|
253
|
+
_class_private_field_init(this, _data, {
|
|
254
|
+
writable: true,
|
|
255
|
+
value: void 0
|
|
256
|
+
});
|
|
257
|
+
_class_private_field_init(this, _stack1, {
|
|
258
|
+
writable: true,
|
|
259
|
+
value: void 0
|
|
260
|
+
});
|
|
261
|
+
_class_private_field_set(this, _message1, message);
|
|
262
|
+
_class_private_field_set(this, _code, getErrorCode(error));
|
|
263
|
+
_class_private_field_set(this, _data, {
|
|
264
|
+
...getErrorData(error),
|
|
265
|
+
...data
|
|
266
|
+
});
|
|
267
|
+
_class_private_field_set(this, _stack1, super.stack);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Check if an object is a `SnapError`.
|
|
272
|
+
*
|
|
273
|
+
* @param error - The object to check.
|
|
274
|
+
* @returns Whether the object is a `SnapError`.
|
|
275
|
+
*/ export function isSnapError(error) {
|
|
276
|
+
if (isObject(error) && 'serialize' in error && typeof error.serialize === 'function') {
|
|
277
|
+
const serialized = error.serialize();
|
|
278
|
+
return isJsonRpcError(serialized) && isSerializedSnapError(serialized);
|
|
279
|
+
}
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Check if a JSON-RPC error is a `SnapError`.
|
|
284
|
+
*
|
|
285
|
+
* @param error - The object to check.
|
|
286
|
+
* @returns Whether the object is a `SnapError`.
|
|
287
|
+
*/ export function isSerializedSnapError(error) {
|
|
288
|
+
return error.code === SNAP_ERROR_CODE && error.message === SNAP_ERROR_MESSAGE;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Check if a JSON-RPC error is a `WrappedSnapError`.
|
|
292
|
+
*
|
|
293
|
+
* @param error - The object to check.
|
|
294
|
+
* @returns Whether the object is a `WrappedSnapError`.
|
|
295
|
+
*/ export function isWrappedSnapError(error) {
|
|
296
|
+
return isJsonRpcError(error) && error.code === SNAP_ERROR_WRAPPER_CODE && error.message === SNAP_ERROR_WRAPPER_MESSAGE;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Get a JSON-RPC error with the given code, message, stack, and data.
|
|
300
|
+
*
|
|
301
|
+
* @param code - The error code.
|
|
302
|
+
* @param message - The error message.
|
|
303
|
+
* @param stack - The error stack.
|
|
304
|
+
* @param data - Additional data for the error.
|
|
305
|
+
* @returns The JSON-RPC error.
|
|
306
|
+
*/ function getJsonRpcError(code, message, stack, data) {
|
|
307
|
+
const error = new RpcError(code, message, data);
|
|
308
|
+
error.stack = stack;
|
|
309
|
+
return error;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Attempt to unwrap an unknown error to a `JsonRpcError`. This function will
|
|
313
|
+
* try to get the error code, message, and data from the error, and return a
|
|
314
|
+
* `JsonRpcError` with those properties.
|
|
315
|
+
*
|
|
316
|
+
* @param error - The error to unwrap.
|
|
317
|
+
* @returns A tuple containing the unwrapped error and a boolean indicating
|
|
318
|
+
* whether the error was handled.
|
|
319
|
+
*/ export function unwrapError(error) {
|
|
320
|
+
// This logic is a bit complicated, but it's necessary to handle all the
|
|
321
|
+
// different types of errors that can be thrown by a Snap.
|
|
322
|
+
// If the error is a wrapped Snap error, unwrap it.
|
|
323
|
+
if (isWrappedSnapError(error)) {
|
|
324
|
+
// The wrapped error can be a JSON-RPC error, or an unknown error. If it's
|
|
325
|
+
// a JSON-RPC error, we can unwrap it further.
|
|
326
|
+
if (isJsonRpcError(error.data.cause)) {
|
|
327
|
+
// If the JSON-RPC error is a wrapped Snap error, unwrap it further.
|
|
328
|
+
if (isSerializedSnapError(error.data.cause)) {
|
|
329
|
+
const { code, message, stack, data } = error.data.cause.data.cause;
|
|
330
|
+
return [
|
|
331
|
+
getJsonRpcError(code, message, stack, data),
|
|
332
|
+
true
|
|
333
|
+
];
|
|
334
|
+
}
|
|
335
|
+
// Otherwise, we use the original JSON-RPC error.
|
|
336
|
+
const { code, message, stack, data } = error.data.cause;
|
|
337
|
+
return [
|
|
338
|
+
getJsonRpcError(code, message, stack, data),
|
|
339
|
+
false
|
|
340
|
+
];
|
|
341
|
+
}
|
|
342
|
+
// Otherwise, we throw an internal error with the wrapped error as the
|
|
343
|
+
// message.
|
|
344
|
+
return [
|
|
345
|
+
getJsonRpcError(errorCodes.rpc.internal, getErrorMessage(error.data.cause), getErrorStack(error.data.cause)),
|
|
346
|
+
false
|
|
347
|
+
];
|
|
348
|
+
}
|
|
349
|
+
// The error can be a non-wrapped JSON-RPC error, in which case we can just
|
|
350
|
+
// re-throw it with the same code, message, and data.
|
|
351
|
+
if (isJsonRpcError(error)) {
|
|
352
|
+
const { code, message, stack, data } = error;
|
|
353
|
+
return [
|
|
354
|
+
getJsonRpcError(code, message, stack, data),
|
|
355
|
+
false
|
|
356
|
+
];
|
|
357
|
+
}
|
|
358
|
+
// If the error is not a wrapped error, we don't know how to handle it, so we
|
|
359
|
+
// throw an internal error with the error as the message.
|
|
360
|
+
return [
|
|
361
|
+
getJsonRpcError(errorCodes.rpc.internal, getErrorMessage(error), getErrorStack(error)),
|
|
362
|
+
false
|
|
363
|
+
];
|
|
364
|
+
}
|
|
16
365
|
|
|
17
366
|
//# sourceMappingURL=errors.js.map
|
package/dist/esm/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/errors.ts"],"sourcesContent":["import { hasProperty, isObject } from '@metamask/utils';\n\n/**\n * Get the error message from an unknown error type.\n *\n * - If the error is an object with a `message` property, return the message.\n * - Otherwise, return the error converted to a string.\n *\n * @param error - The error to get the message from.\n * @returns The error message.\n */\nexport function getErrorMessage(error: unknown) {\n if (\n isObject(error) &&\n hasProperty(error, 'message') &&\n typeof error.message === 'string'\n ) {\n return error.message;\n }\n\n return String(error);\n}\n"],"names":["hasProperty","isObject","getErrorMessage","error","message","String"],"mappings":"AAAA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,kBAAkB;AAExD;;;;;;;;CAQC,GACD,OAAO,SAASC,gBAAgBC,KAAc;IAC5C,IACEF,SAASE,UACTH,YAAYG,OAAO,cACnB,OAAOA,MAAMC,OAAO,KAAK,UACzB;QACA,OAAOD,MAAMC,OAAO;IACtB;IAEA,OAAOC,OAAOF;AAChB"}
|
|
1
|
+
{"version":3,"sources":["../../src/errors.ts"],"sourcesContent":["import {\n errorCodes,\n JsonRpcError as RpcError,\n serializeCause,\n} from '@metamask/rpc-errors';\nimport type { DataWithOptionalCause } from '@metamask/rpc-errors';\nimport type { Json, JsonRpcError } from '@metamask/utils';\nimport {\n hasProperty,\n isJsonRpcError,\n isObject,\n isValidJson,\n} from '@metamask/utils';\n\n/**\n * Get the error message from an unknown error type.\n *\n * - If the error is an object with a `message` property, return the message.\n * - Otherwise, return the error converted to a string.\n *\n * @param error - The error to get the message from.\n * @returns The error message.\n */\nexport function getErrorMessage(error: unknown) {\n if (\n isObject(error) &&\n hasProperty(error, 'message') &&\n typeof error.message === 'string'\n ) {\n return error.message;\n }\n\n return String(error);\n}\n\n/**\n * Get the error stack from an unknown error type.\n *\n * @param error - The error to get the stack from.\n * @returns The error stack, or undefined if the error does not have a valid\n * stack.\n */\nexport function getErrorStack(error: unknown) {\n if (\n isObject(error) &&\n hasProperty(error, 'stack') &&\n typeof error.stack === 'string'\n ) {\n return error.stack;\n }\n\n return undefined;\n}\n\n/**\n * Get the error code from an unknown error type.\n *\n * @param error - The error to get the code from.\n * @returns The error code, or `-32603` if the error does not have a valid code.\n */\nexport function getErrorCode(error: unknown) {\n if (\n isObject(error) &&\n hasProperty(error, 'code') &&\n typeof error.code === 'number' &&\n Number.isInteger(error.code)\n ) {\n return error.code;\n }\n\n return errorCodes.rpc.internal;\n}\n\n/**\n * Get the error data from an unknown error type.\n *\n * @param error - The error to get the data from.\n * @returns The error data, or an empty object if the error does not have valid\n * data.\n */\nexport function getErrorData(error: unknown) {\n if (\n isObject(error) &&\n hasProperty(error, 'data') &&\n typeof error.data === 'object' &&\n error.data !== null &&\n isValidJson(error.data) &&\n !Array.isArray(error.data)\n ) {\n return error.data;\n }\n\n return {};\n}\n\nexport const SNAP_ERROR_WRAPPER_CODE = -31001;\nexport const SNAP_ERROR_WRAPPER_MESSAGE = 'Wrapped Snap Error';\n\nexport const SNAP_ERROR_CODE = -31002;\nexport const SNAP_ERROR_MESSAGE = 'Snap Error';\n\nexport type SerializedSnapErrorWrapper = {\n code: typeof SNAP_ERROR_WRAPPER_CODE;\n message: typeof SNAP_ERROR_WRAPPER_MESSAGE;\n data: {\n cause: Json;\n };\n};\n\nexport type SerializedSnapError = {\n code: typeof SNAP_ERROR_CODE;\n message: typeof SNAP_ERROR_MESSAGE;\n data: {\n cause: JsonRpcError & {\n data: Record<string, Json>;\n };\n };\n};\n\nexport class WrappedSnapError extends Error {\n readonly #error: unknown;\n\n readonly #message: string;\n\n readonly #stack?: string;\n\n /**\n * Create a new `WrappedSnapError`.\n *\n * @param error - The error to create the `WrappedSnapError` from.\n */\n constructor(error: unknown) {\n const message = getErrorMessage(error);\n super(message);\n\n this.#error = error;\n this.#message = message;\n this.#stack = getErrorStack(error);\n }\n\n /**\n * The error name.\n *\n * @returns The error name.\n */\n get name() {\n return 'WrappedSnapError';\n }\n\n /**\n * The error message.\n *\n * @returns The error message.\n */\n get message() {\n return this.#message;\n }\n\n /**\n * The error stack.\n *\n * @returns The error stack.\n */\n get stack() {\n return this.#stack;\n }\n\n /**\n * Convert the error to a JSON object.\n *\n * @returns The JSON object.\n */\n toJSON(): SerializedSnapErrorWrapper {\n const cause = isSnapError(this.#error)\n ? this.#error.serialize()\n : serializeCause(this.#error);\n\n return {\n code: SNAP_ERROR_WRAPPER_CODE,\n message: SNAP_ERROR_WRAPPER_MESSAGE,\n data: {\n cause,\n },\n };\n }\n\n /**\n * Serialize the error to a JSON object. This is called by\n * `@metamask/rpc-errors` when serializing the error.\n *\n * @returns The JSON object.\n */\n serialize() {\n return this.toJSON();\n }\n}\n\n/**\n * A generic error which can be thrown by a Snap, without it causing the Snap to\n * crash.\n */\nexport class SnapError extends Error {\n readonly #code: number;\n\n readonly #message: string;\n\n readonly #data: Record<string, Json>;\n\n readonly #stack?: string;\n\n /**\n * Create a new `SnapError`.\n *\n * @param error - The error to create the `SnapError` from. If this is a\n * `string`, it will be used as the error message. If this is an `Error`, its\n * `message` property will be used as the error message. If this is a\n * `JsonRpcError`, its `message` property will be used as the error message\n * and its `code` property will be used as the error code. Otherwise, the\n * error will be converted to a string and used as the error message.\n * @param data - Additional data to include in the error. This will be merged\n * with the error data, if any.\n */\n constructor(\n error: string | Error | JsonRpcError,\n data: Record<string, Json> = {},\n ) {\n const message = getErrorMessage(error);\n super(message);\n\n this.#message = message;\n this.#code = getErrorCode(error);\n this.#data = { ...getErrorData(error), ...data };\n this.#stack = super.stack;\n }\n\n /**\n * The error name.\n *\n * @returns The error name.\n */\n get name() {\n return 'SnapError';\n }\n\n /**\n * The error code.\n *\n * @returns The error code.\n */\n get code() {\n return this.#code;\n }\n\n /**\n * The error message.\n *\n * @returns The error message.\n */\n get message() {\n return this.#message;\n }\n\n /**\n * Additional data for the error.\n *\n * @returns Additional data for the error.\n */\n get data() {\n return this.#data;\n }\n\n /**\n * The error stack.\n *\n * @returns The error stack.\n */\n get stack() {\n return this.#stack;\n }\n\n /**\n * Convert the error to a JSON object.\n *\n * @returns The JSON object.\n */\n toJSON(): SerializedSnapError {\n return {\n code: SNAP_ERROR_CODE,\n message: SNAP_ERROR_MESSAGE,\n data: {\n cause: {\n code: this.code,\n message: this.message,\n stack: this.stack,\n data: this.data,\n },\n },\n };\n }\n\n /**\n * Serialize the error to a JSON object. This is called by\n * `@metamask/rpc-errors` when serializing the error.\n *\n * @returns The JSON object.\n */\n serialize() {\n return this.toJSON();\n }\n}\n\n/**\n * Check if an object is a `SnapError`.\n *\n * @param error - The object to check.\n * @returns Whether the object is a `SnapError`.\n */\nexport function isSnapError(error: unknown): error is SnapError {\n if (\n isObject(error) &&\n 'serialize' in error &&\n typeof error.serialize === 'function'\n ) {\n const serialized = error.serialize();\n return isJsonRpcError(serialized) && isSerializedSnapError(serialized);\n }\n\n return false;\n}\n\n/**\n * Check if a JSON-RPC error is a `SnapError`.\n *\n * @param error - The object to check.\n * @returns Whether the object is a `SnapError`.\n */\nexport function isSerializedSnapError(\n error: JsonRpcError,\n): error is SerializedSnapError {\n return error.code === SNAP_ERROR_CODE && error.message === SNAP_ERROR_MESSAGE;\n}\n\n/**\n * Check if a JSON-RPC error is a `WrappedSnapError`.\n *\n * @param error - The object to check.\n * @returns Whether the object is a `WrappedSnapError`.\n */\nexport function isWrappedSnapError(\n error: unknown,\n): error is SerializedSnapErrorWrapper {\n return (\n isJsonRpcError(error) &&\n error.code === SNAP_ERROR_WRAPPER_CODE &&\n error.message === SNAP_ERROR_WRAPPER_MESSAGE\n );\n}\n\n/**\n * Get a JSON-RPC error with the given code, message, stack, and data.\n *\n * @param code - The error code.\n * @param message - The error message.\n * @param stack - The error stack.\n * @param data - Additional data for the error.\n * @returns The JSON-RPC error.\n */\nfunction getJsonRpcError(\n code: number,\n message: string,\n stack?: string,\n data?: Json,\n) {\n const error = new RpcError(code, message, data);\n error.stack = stack;\n\n return error;\n}\n\n/**\n * Attempt to unwrap an unknown error to a `JsonRpcError`. This function will\n * try to get the error code, message, and data from the error, and return a\n * `JsonRpcError` with those properties.\n *\n * @param error - The error to unwrap.\n * @returns A tuple containing the unwrapped error and a boolean indicating\n * whether the error was handled.\n */\nexport function unwrapError(\n error: unknown,\n): [error: RpcError<DataWithOptionalCause>, isHandled: boolean] {\n // This logic is a bit complicated, but it's necessary to handle all the\n // different types of errors that can be thrown by a Snap.\n\n // If the error is a wrapped Snap error, unwrap it.\n if (isWrappedSnapError(error)) {\n // The wrapped error can be a JSON-RPC error, or an unknown error. If it's\n // a JSON-RPC error, we can unwrap it further.\n if (isJsonRpcError(error.data.cause)) {\n // If the JSON-RPC error is a wrapped Snap error, unwrap it further.\n if (isSerializedSnapError(error.data.cause)) {\n const { code, message, stack, data } = error.data.cause.data.cause;\n return [getJsonRpcError(code, message, stack, data), true];\n }\n\n // Otherwise, we use the original JSON-RPC error.\n const { code, message, stack, data } = error.data.cause;\n return [getJsonRpcError(code, message, stack, data), false];\n }\n\n // Otherwise, we throw an internal error with the wrapped error as the\n // message.\n return [\n getJsonRpcError(\n errorCodes.rpc.internal,\n getErrorMessage(error.data.cause),\n getErrorStack(error.data.cause),\n ),\n false,\n ];\n }\n\n // The error can be a non-wrapped JSON-RPC error, in which case we can just\n // re-throw it with the same code, message, and data.\n if (isJsonRpcError(error)) {\n const { code, message, stack, data } = error;\n return [getJsonRpcError(code, message, stack, data), false];\n }\n\n // If the error is not a wrapped error, we don't know how to handle it, so we\n // throw an internal error with the error as the message.\n return [\n getJsonRpcError(\n errorCodes.rpc.internal,\n getErrorMessage(error),\n getErrorStack(error),\n ),\n false,\n ];\n}\n"],"names":["errorCodes","JsonRpcError","RpcError","serializeCause","hasProperty","isJsonRpcError","isObject","isValidJson","getErrorMessage","error","message","String","getErrorStack","stack","undefined","getErrorCode","code","Number","isInteger","rpc","internal","getErrorData","data","Array","isArray","SNAP_ERROR_WRAPPER_CODE","SNAP_ERROR_WRAPPER_MESSAGE","SNAP_ERROR_CODE","SNAP_ERROR_MESSAGE","WrappedSnapError","Error","name","toJSON","cause","isSnapError","serialize","constructor","SnapError","serialized","isSerializedSnapError","isWrappedSnapError","getJsonRpcError","unwrapError"],"mappings":"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"}
|
package/dist/esm/handlers.js
CHANGED
|
@@ -6,6 +6,7 @@ export var HandlerType;
|
|
|
6
6
|
HandlerType["OnInstall"] = 'onInstall';
|
|
7
7
|
HandlerType["OnUpdate"] = 'onUpdate';
|
|
8
8
|
HandlerType["OnNameLookup"] = 'onNameLookup';
|
|
9
|
+
HandlerType["OnKeyringRequest"] = 'onKeyringRequest';
|
|
9
10
|
})(HandlerType || (HandlerType = {}));
|
|
10
11
|
export const SNAP_EXPORTS = {
|
|
11
12
|
[HandlerType.OnRpcRequest]: {
|
|
@@ -49,6 +50,13 @@ export const SNAP_EXPORTS = {
|
|
|
49
50
|
validator: (snapExport)=>{
|
|
50
51
|
return typeof snapExport === 'function';
|
|
51
52
|
}
|
|
53
|
+
},
|
|
54
|
+
[HandlerType.OnKeyringRequest]: {
|
|
55
|
+
type: HandlerType.OnKeyringRequest,
|
|
56
|
+
required: true,
|
|
57
|
+
validator: (snapExport)=>{
|
|
58
|
+
return typeof snapExport === 'function';
|
|
59
|
+
}
|
|
52
60
|
}
|
|
53
61
|
};
|
|
54
62
|
export var SeverityLevel;
|
package/dist/esm/handlers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/handlers.ts"],"sourcesContent":["import type { Component } from '@metamask/snaps-ui';\nimport type { Json, JsonRpcParams, JsonRpcRequest } from '@metamask/utils';\n\nimport type { EnumToUnion } from './enum';\nimport type { AccountAddress, Caip2ChainId } from './namespace';\n\nexport enum HandlerType {\n OnRpcRequest = 'onRpcRequest',\n OnTransaction = 'onTransaction',\n OnCronjob = 'onCronjob',\n OnInstall = 'onInstall',\n OnUpdate = 'onUpdate',\n OnNameLookup = 'onNameLookup',\n}\n\ntype 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_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} as const;\n\n/**\n * The `onRpcRequest` handler. This is called whenever a JSON-RPC request is\n * made to the snap.\n *\n * @param args - The request arguments.\n * @param args.origin - The origin of the request. This can be the ID of another\n * snap, or the URL of a dapp.\n * @param args.request - The JSON-RPC request sent to the snap.\n * @returns The JSON-RPC response. This must be a JSON-serializable value.\n */\nexport type OnRpcRequestHandler<Params extends JsonRpcParams = JsonRpcParams> =\n (args: {\n origin: string;\n request: JsonRpcRequest<Params>;\n }) => Promise<unknown>;\n\n/**\n * Enum used to specify the severity level of content being returned from a transaction insight.\n */\nexport enum SeverityLevel {\n Critical = 'critical',\n}\n\n/**\n * The response from a snap's `onTransaction` handler.\n *\n * @property content - A custom UI component, that will be shown in MetaMask. Can be created using `@metamask/snaps-ui`.\n *\n * If the snap has no insights about the transaction, this should be `null`.\n */\nexport type OnTransactionResponse = {\n content: Component | null;\n severity?: EnumToUnion<SeverityLevel>;\n};\n\n/**\n * The `onTransaction` handler. This is called whenever a transaction is\n * submitted to the snap. It can return insights about the transaction, which\n * will be displayed to the user.\n *\n * @param args - The request arguments.\n * @param args.transaction - The transaction object.\n * @param args.chainId - The CAIP-2 chain ID of the network the transaction is\n * being submitted to.\n * @param args.transactionOrigin - The origin of the transaction. This is the\n * URL of the dapp that submitted the transaction.\n * @returns Insights about the transaction. See {@link OnTransactionResponse}.\n */\n// TODO: Improve type.\nexport type OnTransactionHandler = (args: {\n transaction: { [key: string]: Json };\n chainId: string;\n transactionOrigin?: string;\n}) => Promise<OnTransactionResponse>;\n\n/**\n * The `onCronjob` handler. This is called on a regular interval, as defined by\n * the snap's manifest.\n *\n * @param args - The request arguments.\n * @param args.request - The JSON-RPC request sent to the snap.\n */\nexport type OnCronjobHandler<Params extends JsonRpcParams = JsonRpcParams> =\n (args: { request: JsonRpcRequest<Params> }) => Promise<unknown>;\n\n/**\n * A handler that can be used for the lifecycle hooks.\n */\nexport type LifecycleEventHandler = (args: {\n request: JsonRpcRequest;\n}) => Promise<unknown>;\n\n/**\n * The `onInstall` handler. This is called after the snap is installed.\n *\n * This type is an alias for {@link LifecycleEventHandler}.\n */\nexport type OnInstallHandler = LifecycleEventHandler;\n\n/**\n * The `onUpdate` handler. This is called after the snap is updated.\n *\n * This type is an alias for {@link LifecycleEventHandler}.\n */\nexport type OnUpdateHandler = LifecycleEventHandler;\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 * The response from a snap's `onNameLookup` handler.\n *\n * @property resolvedAddress - The resolved address for a given domain.\n * @property resolvedDomain - The resolved domain for a given address.\n *\n *\n * If the snap has no resolved address/domain from its lookup, this should be `null`.\n */\nexport type OnNameLookupResponse =\n | {\n resolvedAddress: AccountAddress;\n resolvedDomain?: never;\n }\n | { resolvedDomain: string; resolvedAddress?: never }\n | null;\n\nexport type OnNameLookupArgs = {\n chainId: Caip2ChainId;\n} & ({ domain: string; address?: never } | { address: string; domain?: never });\n\n/**\n * The `onNameLookup` handler. This is called whenever content is entered\n * into the send to field for sending assets to an EOA address.\n *\n * @param args - The request arguments.\n * @param args.domain - The human-readable address that is to be resolved.\n * @param args.chainId - The CAIP-2 chain ID of the network the transaction is\n * being submitted to.\n * @param args.address - The address that is to be resolved.\n * @returns Resolved address/domain from the lookup. See {@link OnNameLookupResponse}.\n */\nexport type OnNameLookupHandler = (\n args: OnNameLookupArgs,\n) => Promise<OnNameLookupResponse>;\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"],"names":["HandlerType","OnRpcRequest","OnTransaction","OnCronjob","OnInstall","OnUpdate","OnNameLookup","SNAP_EXPORTS","type","required","validator","snapExport","SeverityLevel","Critical"],"mappings":"WAMO;UAAKA,WAAW;IAAXA,YACVC,kBAAe;IADLD,YAEVE,mBAAgB;IAFNF,YAGVG,eAAY;IAHFH,YAIVI,eAAY;IAJFJ,YAKVK,cAAW;IALDL,YAMVM,kBAAe;
|
|
1
|
+
{"version":3,"sources":["../../src/handlers.ts"],"sourcesContent":["import type { Component } from '@metamask/snaps-ui';\nimport type { Json, JsonRpcParams, JsonRpcRequest } from '@metamask/utils';\n\nimport type { EnumToUnion } from './enum';\nimport type { AccountAddress, Caip2ChainId } from './namespace';\n\nexport enum HandlerType {\n OnRpcRequest = 'onRpcRequest',\n OnTransaction = 'onTransaction',\n OnCronjob = 'onCronjob',\n OnInstall = 'onInstall',\n OnUpdate = 'onUpdate',\n OnNameLookup = 'onNameLookup',\n OnKeyringRequest = 'onKeyringRequest',\n}\n\ntype 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_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} as const;\n\n/**\n * The `onRpcRequest` handler. This is called whenever a JSON-RPC request is\n * made to the snap.\n *\n * @param args - The request arguments.\n * @param args.origin - The origin of the request. This can be the ID of another\n * snap, or the URL of a dapp.\n * @param args.request - The JSON-RPC request sent to the snap.\n * @returns The JSON-RPC response. This must be a JSON-serializable value.\n */\nexport type OnRpcRequestHandler<Params extends JsonRpcParams = JsonRpcParams> =\n (args: {\n origin: string;\n request: JsonRpcRequest<Params>;\n }) => Promise<unknown>;\n\n/**\n * Enum used to specify the severity level of content being returned from a transaction insight.\n */\nexport enum SeverityLevel {\n Critical = 'critical',\n}\n\n/**\n * The response from a snap's `onTransaction` handler.\n *\n * @property content - A custom UI component, that will be shown in MetaMask. Can be created using `@metamask/snaps-ui`.\n *\n * If the snap has no insights about the transaction, this should be `null`.\n */\nexport type OnTransactionResponse = {\n content: Component | null;\n severity?: EnumToUnion<SeverityLevel>;\n};\n\n/**\n * The `onTransaction` handler. This is called whenever a transaction is\n * submitted to the snap. It can return insights about the transaction, which\n * will be displayed to the user.\n *\n * @param args - The request arguments.\n * @param args.transaction - The transaction object.\n * @param args.chainId - The CAIP-2 chain ID of the network the transaction is\n * being submitted to.\n * @param args.transactionOrigin - The origin of the transaction. This is the\n * URL of the dapp that submitted the transaction.\n * @returns Insights about the transaction. See {@link OnTransactionResponse}.\n */\n// TODO: Improve type.\nexport type OnTransactionHandler = (args: {\n transaction: { [key: string]: Json };\n chainId: string;\n transactionOrigin?: string;\n}) => Promise<OnTransactionResponse>;\n\n/**\n * The `onCronjob` handler. This is called on a regular interval, as defined by\n * the snap's manifest.\n *\n * @param args - The request arguments.\n * @param args.request - The JSON-RPC request sent to the snap.\n */\nexport type OnCronjobHandler<Params extends JsonRpcParams = JsonRpcParams> =\n (args: { request: JsonRpcRequest<Params> }) => Promise<unknown>;\n\n/**\n * A handler that can be used for the lifecycle hooks.\n */\nexport type LifecycleEventHandler = (args: {\n request: JsonRpcRequest;\n}) => Promise<unknown>;\n\n/**\n * The `onInstall` handler. This is called after the snap is installed.\n *\n * This type is an alias for {@link LifecycleEventHandler}.\n */\nexport type OnInstallHandler = LifecycleEventHandler;\n\n/**\n * The `onUpdate` handler. This is called after the snap is updated.\n *\n * This type is an alias for {@link LifecycleEventHandler}.\n */\nexport type OnUpdateHandler = LifecycleEventHandler;\n\n/**\n * The `onKeyringRequest` handler. This is called by the MetaMask client for\n * privileged keyring actions.\n *\n * @param args - The request arguments.\n * @param args.origin - The origin of the request. This can be the ID of\n * another snap, or the URL of a dapp.\n * @param args.request - The JSON-RPC request sent to the snap.\n */\nexport type OnKeyringRequestHandler<\n Params extends JsonRpcParams = JsonRpcParams,\n> = (args: {\n origin: string;\n request: JsonRpcRequest<Params>;\n}) => Promise<unknown>;\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 * The response from a snap's `onNameLookup` handler.\n *\n * @property resolvedAddress - The resolved address for a given domain.\n * @property resolvedDomain - The resolved domain for a given address.\n *\n *\n * If the snap has no resolved address/domain from its lookup, this should be `null`.\n */\nexport type OnNameLookupResponse =\n | {\n resolvedAddress: AccountAddress;\n resolvedDomain?: never;\n }\n | { resolvedDomain: string; resolvedAddress?: never }\n | null;\n\nexport type OnNameLookupArgs = {\n chainId: Caip2ChainId;\n} & ({ domain: string; address?: never } | { address: string; domain?: never });\n\n/**\n * The `onNameLookup` handler. This is called whenever content is entered\n * into the send to field for sending assets to an EOA address.\n *\n * @param args - The request arguments.\n * @param args.domain - The human-readable address that is to be resolved.\n * @param args.chainId - The CAIP-2 chain ID of the network the transaction is\n * being submitted to.\n * @param args.address - The address that is to be resolved.\n * @returns Resolved address/domain from the lookup. See {@link OnNameLookupResponse}.\n */\nexport type OnNameLookupHandler = (\n args: OnNameLookupArgs,\n) => Promise<OnNameLookupResponse>;\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"],"names":["HandlerType","OnRpcRequest","OnTransaction","OnCronjob","OnInstall","OnUpdate","OnNameLookup","OnKeyringRequest","SNAP_EXPORTS","type","required","validator","snapExport","SeverityLevel","Critical"],"mappings":"WAMO;UAAKA,WAAW;IAAXA,YACVC,kBAAe;IADLD,YAEVE,mBAAgB;IAFNF,YAGVG,eAAY;IAHFH,YAIVI,eAAY;IAJFJ,YAKVK,cAAW;IALDL,YAMVM,kBAAe;IANLN,YAOVO,sBAAmB;GAPTP,gBAAAA;AAkCZ,OAAO,MAAMQ,eAAe;IAC1B,CAACR,YAAYC,YAAY,CAAC,EAAE;QAC1BQ,MAAMT,YAAYC,YAAY;QAC9BS,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACZ,YAAYE,aAAa,CAAC,EAAE;QAC3BO,MAAMT,YAAYE,aAAa;QAC/BQ,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACZ,YAAYG,SAAS,CAAC,EAAE;QACvBM,MAAMT,YAAYG,SAAS;QAC3BO,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACZ,YAAYM,YAAY,CAAC,EAAE;QAC1BG,MAAMT,YAAYM,YAAY;QAC9BI,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACZ,YAAYI,SAAS,CAAC,EAAE;QACvBK,MAAMT,YAAYI,SAAS;QAC3BM,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACZ,YAAYK,QAAQ,CAAC,EAAE;QACtBI,MAAMT,YAAYK,QAAQ;QAC1BK,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACZ,YAAYO,gBAAgB,CAAC,EAAE;QAC9BE,MAAMT,YAAYO,gBAAgB;QAClCG,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;AACF,EAAW;WAqBJ;UAAKC,aAAa;IAAbA,cACVC,cAAW;GADDD,kBAAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.browser.ts"],"sourcesContent":["export * from './array';\nexport * from './caveats';\nexport * from './checksum';\nexport * from './cronjob';\nexport * from './deep-clone';\nexport * from './default-endowments';\nexport * from './entropy';\nexport * from './enum';\nexport * from './errors';\nexport * from './handlers';\nexport * from './iframe';\nexport * from './json';\nexport * from './json-rpc';\nexport * from './logging';\nexport * from './manifest/index.browser';\nexport * from './namespace';\nexport * from './path';\nexport * from './snaps';\nexport * from './strings';\nexport * from './structs';\nexport * from './types';\nexport * from './validation';\nexport * from './versions';\nexport * from './virtual-file/index.browser';\n"],"names":[],"mappings":"AAAA,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,uBAAuB;AACrC,cAAc,YAAY;AAC1B,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,2BAA2B;AACzC,cAAc,cAAc;AAC5B,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,aAAa;AAC3B,cAAc,+BAA+B"}
|
|
1
|
+
{"version":3,"sources":["../../src/index.browser.ts"],"sourcesContent":["export * from './array';\nexport * from './auxiliary-files';\nexport * from './caveats';\nexport * from './checksum';\nexport * from './cronjob';\nexport * from './deep-clone';\nexport * from './default-endowments';\nexport * from './entropy';\nexport * from './enum';\nexport * from './errors';\nexport * from './handlers';\nexport * from './iframe';\nexport * from './json';\nexport * from './json-rpc';\nexport * from './logging';\nexport * from './manifest/index.browser';\nexport * from './namespace';\nexport * from './path';\nexport * from './snaps';\nexport * from './strings';\nexport * from './structs';\nexport * from './types';\nexport * from './validation';\nexport * from './versions';\nexport * from './virtual-file/index.browser';\n"],"names":[],"mappings":"AAAA,cAAc,UAAU;AACxB,cAAc,oBAAoB;AAClC,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,uBAAuB;AACrC,cAAc,YAAY;AAC1B,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,2BAA2B;AACzC,cAAc,cAAc;AAC5B,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,aAAa;AAC3B,cAAc,+BAA+B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.executionenv.ts"],"sourcesContent":["// Special entrypoint for execution environments for bundle sizing reasons\nexport * from './handlers';\nexport * from './logging';\nexport * from './namespace';\nexport * from './types';\n"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,cAAc;AAC5B,cAAc,UAAU"}
|
|
1
|
+
{"version":3,"sources":["../../src/index.executionenv.ts"],"sourcesContent":["// Special entrypoint for execution environments for bundle sizing reasons\nexport * from './errors';\nexport * from './handlers';\nexport * from './logging';\nexport * from './namespace';\nexport * from './types';\n"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,cAAc;AAC5B,cAAc,UAAU"}
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './array';\nexport * from './caveats';\nexport * from './cronjob';\nexport * from './checksum';\nexport * from './deep-clone';\nexport * from './default-endowments';\nexport * from './entropy';\nexport * from './enum';\nexport * from './eval';\nexport * from './errors';\nexport * from './fs';\nexport * from './handlers';\nexport * from './iframe';\nexport * from './json';\nexport * from './json-rpc';\nexport * from './logging';\nexport * from './manifest';\nexport * from './mock';\nexport * from './namespace';\nexport * from './npm';\nexport * from './path';\nexport * from './post-process';\nexport * from './snaps';\nexport * from './strings';\nexport * from './structs';\nexport * from './types';\nexport * from './validation';\nexport * from './versions';\nexport * from './virtual-file';\n"],"names":[],"mappings":"AAAA,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,eAAe;AAC7B,cAAc,uBAAuB;AACrC,cAAc,YAAY;AAC1B,cAAc,SAAS;AACvB,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,OAAO;AACrB,cAAc,aAAa;AAC3B,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,SAAS;AACvB,cAAc,cAAc;AAC5B,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB,cAAc,iBAAiB;AAC/B,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,aAAa;AAC3B,cAAc,iBAAiB"}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './array';\nexport * from './auxiliary-files';\nexport * from './caveats';\nexport * from './cronjob';\nexport * from './checksum';\nexport * from './deep-clone';\nexport * from './default-endowments';\nexport * from './entropy';\nexport * from './enum';\nexport * from './eval';\nexport * from './errors';\nexport * from './fs';\nexport * from './handlers';\nexport * from './iframe';\nexport * from './json';\nexport * from './json-rpc';\nexport * from './logging';\nexport * from './manifest';\nexport * from './mock';\nexport * from './namespace';\nexport * from './npm';\nexport * from './path';\nexport * from './post-process';\nexport * from './snaps';\nexport * from './strings';\nexport * from './structs';\nexport * from './types';\nexport * from './validation';\nexport * from './versions';\nexport * from './virtual-file';\n"],"names":[],"mappings":"AAAA,cAAc,UAAU;AACxB,cAAc,oBAAoB;AAClC,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,eAAe;AAC7B,cAAc,uBAAuB;AACrC,cAAc,YAAY;AAC1B,cAAc,SAAS;AACvB,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,OAAO;AACrB,cAAc,aAAa;AAC3B,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,SAAS;AACvB,cAAc,cAAc;AAC5B,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB,cAAc,iBAAiB;AAC/B,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,eAAe;AAC7B,cAAc,aAAa;AAC3B,cAAc,iBAAiB"}
|