@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.
Files changed (74) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/dist/cjs/auxiliary-files.js +40 -0
  3. package/dist/cjs/auxiliary-files.js.map +1 -0
  4. package/dist/cjs/caveats.js +3 -0
  5. package/dist/cjs/caveats.js.map +1 -1
  6. package/dist/cjs/errors.js +353 -3
  7. package/dist/cjs/errors.js.map +1 -1
  8. package/dist/cjs/handlers.js +8 -0
  9. package/dist/cjs/handlers.js.map +1 -1
  10. package/dist/cjs/index.browser.js +1 -0
  11. package/dist/cjs/index.browser.js.map +1 -1
  12. package/dist/cjs/index.executionenv.js +1 -0
  13. package/dist/cjs/index.executionenv.js.map +1 -1
  14. package/dist/cjs/index.js +1 -0
  15. package/dist/cjs/index.js.map +1 -1
  16. package/dist/cjs/json-rpc.js +39 -4
  17. package/dist/cjs/json-rpc.js.map +1 -1
  18. package/dist/cjs/manifest/manifest.js +25 -5
  19. package/dist/cjs/manifest/manifest.js.map +1 -1
  20. package/dist/cjs/manifest/validation.js +7 -1
  21. package/dist/cjs/manifest/validation.js.map +1 -1
  22. package/dist/cjs/npm.js +5 -3
  23. package/dist/cjs/npm.js.map +1 -1
  24. package/dist/cjs/snaps.js +3 -2
  25. package/dist/cjs/snaps.js.map +1 -1
  26. package/dist/cjs/types.js.map +1 -1
  27. package/dist/cjs/validation.js.map +1 -1
  28. package/dist/cjs/virtual-file/VirtualFile.js +6 -0
  29. package/dist/cjs/virtual-file/VirtualFile.js.map +1 -1
  30. package/dist/cjs/virtual-file/toVirtualFile.js.map +1 -1
  31. package/dist/esm/auxiliary-files.js +28 -0
  32. package/dist/esm/auxiliary-files.js.map +1 -0
  33. package/dist/esm/caveats.js +3 -0
  34. package/dist/esm/caveats.js.map +1 -1
  35. package/dist/esm/errors.js +350 -1
  36. package/dist/esm/errors.js.map +1 -1
  37. package/dist/esm/handlers.js +8 -0
  38. package/dist/esm/handlers.js.map +1 -1
  39. package/dist/esm/index.browser.js +1 -0
  40. package/dist/esm/index.browser.js.map +1 -1
  41. package/dist/esm/index.executionenv.js +1 -0
  42. package/dist/esm/index.executionenv.js.map +1 -1
  43. package/dist/esm/index.js +1 -0
  44. package/dist/esm/index.js.map +1 -1
  45. package/dist/esm/json-rpc.js +46 -6
  46. package/dist/esm/json-rpc.js.map +1 -1
  47. package/dist/esm/manifest/manifest.js +30 -5
  48. package/dist/esm/manifest/manifest.js.map +1 -1
  49. package/dist/esm/manifest/validation.js +5 -2
  50. package/dist/esm/manifest/validation.js.map +1 -1
  51. package/dist/esm/npm.js +5 -3
  52. package/dist/esm/npm.js.map +1 -1
  53. package/dist/esm/snaps.js +3 -2
  54. package/dist/esm/snaps.js.map +1 -1
  55. package/dist/esm/types.js.map +1 -1
  56. package/dist/esm/validation.js.map +1 -1
  57. package/dist/esm/virtual-file/VirtualFile.js +7 -1
  58. package/dist/esm/virtual-file/VirtualFile.js.map +1 -1
  59. package/dist/esm/virtual-file/toVirtualFile.js.map +1 -1
  60. package/dist/types/auxiliary-files.d.ts +13 -0
  61. package/dist/types/caveats.d.ts +4 -0
  62. package/dist/types/errors.d.ts +182 -0
  63. package/dist/types/handlers.d.ts +21 -2
  64. package/dist/types/index.browser.d.ts +1 -0
  65. package/dist/types/index.d.ts +1 -0
  66. package/dist/types/index.executionenv.d.ts +1 -0
  67. package/dist/types/json-rpc.d.ts +28 -1
  68. package/dist/types/manifest/manifest.d.ts +11 -1
  69. package/dist/types/manifest/validation.d.ts +30 -0
  70. package/dist/types/snaps.d.ts +13 -6
  71. package/dist/types/types.d.ts +6 -0
  72. package/dist/types/validation.d.ts +2 -2
  73. package/dist/types/virtual-file/toVirtualFile.d.ts +1 -1
  74. package/package.json +20 -21
package/CHANGELOG.md CHANGED
@@ -6,6 +6,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [3.1.0]
10
+ ### Added
11
+ - Add static file API ([#1836](https://github.com/MetaMask/snaps/pull/1836), [#1858](https://github.com/MetaMask/snaps/pull/1858))
12
+
13
+ ### Changed
14
+ - Update multiple MetaMask dependencies ([#1841](https://github.com/MetaMask/snaps/pull/1841))
15
+ - Bump Babel packages from `^7.20.12` to `^7.23.2` ([#1862](https://github.com/MetaMask/snaps/pull/1862))
16
+
17
+ ## [3.0.0]
18
+ ### Added
19
+ - Add keyring export and endowment ([#1787](https://github.com/MetaMask/snaps/pull/1787))
20
+ - Add optional `allowedOrigins` field to `endowment:rpc` ([#1822](https://github.com/MetaMask/snaps/pull/1822))
21
+ - This can be used to only accept certain origins in your Snap.
22
+
23
+ ### Changed
24
+ - **BREAKING:** Bump minimum Node.js version to `^18.16.0` ([#1741](https://github.com/MetaMask/snaps/pull/1741))
25
+
9
26
  ## [2.0.1]
10
27
  ### Changed
11
28
  - Remove deprecated `endowment:long-running` ([#1751](https://github.com/MetaMask/snaps/pull/1751))
@@ -50,7 +67,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
50
67
  - The version of the package no longer needs to match the version of all other
51
68
  MetaMask Snaps packages.
52
69
 
53
- [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@2.0.1...HEAD
70
+ [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@3.1.0...HEAD
71
+ [3.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@3.0.0...@metamask/snaps-utils@3.1.0
72
+ [3.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@2.0.1...@metamask/snaps-utils@3.0.0
54
73
  [2.0.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@2.0.0...@metamask/snaps-utils@2.0.1
55
74
  [2.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@0.38.4-flask.1...@metamask/snaps-utils@2.0.0
56
75
  [0.38.4-flask.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@0.38.3-flask.1...@metamask/snaps-utils@0.38.4-flask.1
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ AuxiliaryFileEncoding: function() {
13
+ return AuxiliaryFileEncoding;
14
+ },
15
+ encodeAuxiliaryFile: function() {
16
+ return encodeAuxiliaryFile;
17
+ }
18
+ });
19
+ const _utils = require("@metamask/utils");
20
+ const _base = require("@scure/base");
21
+ var AuxiliaryFileEncoding;
22
+ (function(AuxiliaryFileEncoding) {
23
+ AuxiliaryFileEncoding["Base64"] = 'base64';
24
+ AuxiliaryFileEncoding["Hex"] = 'hex';
25
+ AuxiliaryFileEncoding["Utf8"] = 'utf8';
26
+ })(AuxiliaryFileEncoding || (AuxiliaryFileEncoding = {}));
27
+ function encodeAuxiliaryFile(value, encoding) {
28
+ // Input is assumed to be the stored file in base64.
29
+ if (encoding === AuxiliaryFileEncoding.Base64) {
30
+ return value;
31
+ }
32
+ // TODO: Use @metamask/utils for this
33
+ const decoded = _base.base64.decode(value);
34
+ if (encoding === AuxiliaryFileEncoding.Utf8) {
35
+ return (0, _utils.bytesToString)(decoded);
36
+ }
37
+ return (0, _utils.bytesToHex)(decoded);
38
+ }
39
+
40
+ //# 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":["encodeAuxiliaryFile","AuxiliaryFileEncoding","Base64","Hex","Utf8","value","encoding","decoded","base64","decode","bytesToString","bytesToHex"],"mappings":";;;;;;;;;;;;;;IAgBgBA,mBAAmB;eAAnBA;;;uBAhB0B;sBACnB;IAEhB;UAAKC,qBAAqB;IAArBA,sBACVC,YAAS;IADCD,sBAEVE,SAAM;IAFIF,sBAGVG,UAAO;GAHGH,0BAAAA;AAaL,SAASD,oBACdK,KAAa,EACbC,QAA+B;IAE/B,oDAAoD;IACpD,IAAIA,aAAaL,sBAAsBC,MAAM,EAAE;QAC7C,OAAOG;IACT;IAEA,qCAAqC;IACrC,MAAME,UAAUC,YAAM,CAACC,MAAM,CAACJ;IAC9B,IAAIC,aAAaL,sBAAsBG,IAAI,EAAE;QAC3C,OAAOM,IAAAA,oBAAa,EAACH;IACvB;IAEA,OAAOI,IAAAA,iBAAU,EAACJ;AACpB"}
@@ -26,6 +26,9 @@ var SnapCaveatType;
26
26
  * The origins that a Snap can receive JSON-RPC messages from.
27
27
  */ "RpcOrigin"] = 'rpcOrigin';
28
28
  SnapCaveatType[/**
29
+ * The origins that a Snap can receive keyring messages from.
30
+ */ "KeyringOrigin"] = 'keyringOrigin';
31
+ SnapCaveatType[/**
29
32
  * Caveat specifying the snap IDs that can be interacted with.
30
33
  */ "SnapIds"] = 'snapIds';
31
34
  SnapCaveatType[/**
@@ -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":";;;;;;;;;;IAAO;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,aAAU;IA7BAN,eA+BV;;GAEC,GACDO,cAAW;GAlCDP,mBAAAA"}
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":";;;;;;;;;;IAAO;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"}
@@ -2,18 +2,368 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- Object.defineProperty(exports, "getErrorMessage", {
6
- enumerable: true,
7
- get: function() {
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ getErrorMessage: function() {
8
13
  return getErrorMessage;
14
+ },
15
+ getErrorStack: function() {
16
+ return getErrorStack;
17
+ },
18
+ getErrorCode: function() {
19
+ return getErrorCode;
20
+ },
21
+ getErrorData: function() {
22
+ return getErrorData;
23
+ },
24
+ SNAP_ERROR_WRAPPER_CODE: function() {
25
+ return SNAP_ERROR_WRAPPER_CODE;
26
+ },
27
+ SNAP_ERROR_WRAPPER_MESSAGE: function() {
28
+ return SNAP_ERROR_WRAPPER_MESSAGE;
29
+ },
30
+ SNAP_ERROR_CODE: function() {
31
+ return SNAP_ERROR_CODE;
32
+ },
33
+ SNAP_ERROR_MESSAGE: function() {
34
+ return SNAP_ERROR_MESSAGE;
35
+ },
36
+ WrappedSnapError: function() {
37
+ return WrappedSnapError;
38
+ },
39
+ SnapError: function() {
40
+ return SnapError;
41
+ },
42
+ isSnapError: function() {
43
+ return isSnapError;
44
+ },
45
+ isSerializedSnapError: function() {
46
+ return isSerializedSnapError;
47
+ },
48
+ isWrappedSnapError: function() {
49
+ return isWrappedSnapError;
50
+ },
51
+ unwrapError: function() {
52
+ return unwrapError;
9
53
  }
10
54
  });
55
+ const _rpcerrors = require("@metamask/rpc-errors");
11
56
  const _utils = require("@metamask/utils");
57
+ function _check_private_redeclaration(obj, privateCollection) {
58
+ if (privateCollection.has(obj)) {
59
+ throw new TypeError("Cannot initialize the same private elements twice on an object");
60
+ }
61
+ }
62
+ function _class_apply_descriptor_get(receiver, descriptor) {
63
+ if (descriptor.get) {
64
+ return descriptor.get.call(receiver);
65
+ }
66
+ return descriptor.value;
67
+ }
68
+ function _class_apply_descriptor_set(receiver, descriptor, value) {
69
+ if (descriptor.set) {
70
+ descriptor.set.call(receiver, value);
71
+ } else {
72
+ if (!descriptor.writable) {
73
+ throw new TypeError("attempted to set read only private field");
74
+ }
75
+ descriptor.value = value;
76
+ }
77
+ }
78
+ function _class_extract_field_descriptor(receiver, privateMap, action) {
79
+ if (!privateMap.has(receiver)) {
80
+ throw new TypeError("attempted to " + action + " private field on non-instance");
81
+ }
82
+ return privateMap.get(receiver);
83
+ }
84
+ function _class_private_field_get(receiver, privateMap) {
85
+ var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
86
+ return _class_apply_descriptor_get(receiver, descriptor);
87
+ }
88
+ function _class_private_field_init(obj, privateMap, value) {
89
+ _check_private_redeclaration(obj, privateMap);
90
+ privateMap.set(obj, value);
91
+ }
92
+ function _class_private_field_set(receiver, privateMap, value) {
93
+ var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
94
+ _class_apply_descriptor_set(receiver, descriptor, value);
95
+ return value;
96
+ }
12
97
  function getErrorMessage(error) {
13
98
  if ((0, _utils.isObject)(error) && (0, _utils.hasProperty)(error, 'message') && typeof error.message === 'string') {
14
99
  return error.message;
15
100
  }
16
101
  return String(error);
17
102
  }
103
+ function getErrorStack(error) {
104
+ if ((0, _utils.isObject)(error) && (0, _utils.hasProperty)(error, 'stack') && typeof error.stack === 'string') {
105
+ return error.stack;
106
+ }
107
+ return undefined;
108
+ }
109
+ function getErrorCode(error) {
110
+ if ((0, _utils.isObject)(error) && (0, _utils.hasProperty)(error, 'code') && typeof error.code === 'number' && Number.isInteger(error.code)) {
111
+ return error.code;
112
+ }
113
+ return _rpcerrors.errorCodes.rpc.internal;
114
+ }
115
+ function getErrorData(error) {
116
+ if ((0, _utils.isObject)(error) && (0, _utils.hasProperty)(error, 'data') && typeof error.data === 'object' && error.data !== null && (0, _utils.isValidJson)(error.data) && !Array.isArray(error.data)) {
117
+ return error.data;
118
+ }
119
+ return {};
120
+ }
121
+ const SNAP_ERROR_WRAPPER_CODE = -31001;
122
+ const SNAP_ERROR_WRAPPER_MESSAGE = 'Wrapped Snap Error';
123
+ const SNAP_ERROR_CODE = -31002;
124
+ const SNAP_ERROR_MESSAGE = 'Snap Error';
125
+ var _error = /*#__PURE__*/ new WeakMap(), _message = /*#__PURE__*/ new WeakMap(), _stack = /*#__PURE__*/ new WeakMap();
126
+ class WrappedSnapError extends Error {
127
+ /**
128
+ * The error name.
129
+ *
130
+ * @returns The error name.
131
+ */ get name() {
132
+ return 'WrappedSnapError';
133
+ }
134
+ /**
135
+ * The error message.
136
+ *
137
+ * @returns The error message.
138
+ */ get message() {
139
+ return _class_private_field_get(this, _message);
140
+ }
141
+ /**
142
+ * The error stack.
143
+ *
144
+ * @returns The error stack.
145
+ */ get stack() {
146
+ return _class_private_field_get(this, _stack);
147
+ }
148
+ /**
149
+ * Convert the error to a JSON object.
150
+ *
151
+ * @returns The JSON object.
152
+ */ toJSON() {
153
+ const cause = isSnapError(_class_private_field_get(this, _error)) ? _class_private_field_get(this, _error).serialize() : (0, _rpcerrors.serializeCause)(_class_private_field_get(this, _error));
154
+ return {
155
+ code: SNAP_ERROR_WRAPPER_CODE,
156
+ message: SNAP_ERROR_WRAPPER_MESSAGE,
157
+ data: {
158
+ cause
159
+ }
160
+ };
161
+ }
162
+ /**
163
+ * Serialize the error to a JSON object. This is called by
164
+ * `@metamask/rpc-errors` when serializing the error.
165
+ *
166
+ * @returns The JSON object.
167
+ */ serialize() {
168
+ return this.toJSON();
169
+ }
170
+ /**
171
+ * Create a new `WrappedSnapError`.
172
+ *
173
+ * @param error - The error to create the `WrappedSnapError` from.
174
+ */ constructor(error){
175
+ const message = getErrorMessage(error);
176
+ super(message);
177
+ _class_private_field_init(this, _error, {
178
+ writable: true,
179
+ value: void 0
180
+ });
181
+ _class_private_field_init(this, _message, {
182
+ writable: true,
183
+ value: void 0
184
+ });
185
+ _class_private_field_init(this, _stack, {
186
+ writable: true,
187
+ value: void 0
188
+ });
189
+ _class_private_field_set(this, _error, error);
190
+ _class_private_field_set(this, _message, message);
191
+ _class_private_field_set(this, _stack, getErrorStack(error));
192
+ }
193
+ }
194
+ var _code = /*#__PURE__*/ new WeakMap(), _message1 = /*#__PURE__*/ new WeakMap(), _data = /*#__PURE__*/ new WeakMap(), _stack1 = /*#__PURE__*/ new WeakMap();
195
+ class SnapError extends Error {
196
+ /**
197
+ * The error name.
198
+ *
199
+ * @returns The error name.
200
+ */ get name() {
201
+ return 'SnapError';
202
+ }
203
+ /**
204
+ * The error code.
205
+ *
206
+ * @returns The error code.
207
+ */ get code() {
208
+ return _class_private_field_get(this, _code);
209
+ }
210
+ /**
211
+ * The error message.
212
+ *
213
+ * @returns The error message.
214
+ */ get message() {
215
+ return _class_private_field_get(this, _message1);
216
+ }
217
+ /**
218
+ * Additional data for the error.
219
+ *
220
+ * @returns Additional data for the error.
221
+ */ get data() {
222
+ return _class_private_field_get(this, _data);
223
+ }
224
+ /**
225
+ * The error stack.
226
+ *
227
+ * @returns The error stack.
228
+ */ get stack() {
229
+ return _class_private_field_get(this, _stack1);
230
+ }
231
+ /**
232
+ * Convert the error to a JSON object.
233
+ *
234
+ * @returns The JSON object.
235
+ */ toJSON() {
236
+ return {
237
+ code: SNAP_ERROR_CODE,
238
+ message: SNAP_ERROR_MESSAGE,
239
+ data: {
240
+ cause: {
241
+ code: this.code,
242
+ message: this.message,
243
+ stack: this.stack,
244
+ data: this.data
245
+ }
246
+ }
247
+ };
248
+ }
249
+ /**
250
+ * Serialize the error to a JSON object. This is called by
251
+ * `@metamask/rpc-errors` when serializing the error.
252
+ *
253
+ * @returns The JSON object.
254
+ */ serialize() {
255
+ return this.toJSON();
256
+ }
257
+ /**
258
+ * Create a new `SnapError`.
259
+ *
260
+ * @param error - The error to create the `SnapError` from. If this is a
261
+ * `string`, it will be used as the error message. If this is an `Error`, its
262
+ * `message` property will be used as the error message. If this is a
263
+ * `JsonRpcError`, its `message` property will be used as the error message
264
+ * and its `code` property will be used as the error code. Otherwise, the
265
+ * error will be converted to a string and used as the error message.
266
+ * @param data - Additional data to include in the error. This will be merged
267
+ * with the error data, if any.
268
+ */ constructor(error, data = {}){
269
+ const message = getErrorMessage(error);
270
+ super(message);
271
+ _class_private_field_init(this, _code, {
272
+ writable: true,
273
+ value: void 0
274
+ });
275
+ _class_private_field_init(this, _message1, {
276
+ writable: true,
277
+ value: void 0
278
+ });
279
+ _class_private_field_init(this, _data, {
280
+ writable: true,
281
+ value: void 0
282
+ });
283
+ _class_private_field_init(this, _stack1, {
284
+ writable: true,
285
+ value: void 0
286
+ });
287
+ _class_private_field_set(this, _message1, message);
288
+ _class_private_field_set(this, _code, getErrorCode(error));
289
+ _class_private_field_set(this, _data, {
290
+ ...getErrorData(error),
291
+ ...data
292
+ });
293
+ _class_private_field_set(this, _stack1, super.stack);
294
+ }
295
+ }
296
+ function isSnapError(error) {
297
+ if ((0, _utils.isObject)(error) && 'serialize' in error && typeof error.serialize === 'function') {
298
+ const serialized = error.serialize();
299
+ return (0, _utils.isJsonRpcError)(serialized) && isSerializedSnapError(serialized);
300
+ }
301
+ return false;
302
+ }
303
+ function isSerializedSnapError(error) {
304
+ return error.code === SNAP_ERROR_CODE && error.message === SNAP_ERROR_MESSAGE;
305
+ }
306
+ function isWrappedSnapError(error) {
307
+ return (0, _utils.isJsonRpcError)(error) && error.code === SNAP_ERROR_WRAPPER_CODE && error.message === SNAP_ERROR_WRAPPER_MESSAGE;
308
+ }
309
+ /**
310
+ * Get a JSON-RPC error with the given code, message, stack, and data.
311
+ *
312
+ * @param code - The error code.
313
+ * @param message - The error message.
314
+ * @param stack - The error stack.
315
+ * @param data - Additional data for the error.
316
+ * @returns The JSON-RPC error.
317
+ */ function getJsonRpcError(code, message, stack, data) {
318
+ const error = new _rpcerrors.JsonRpcError(code, message, data);
319
+ error.stack = stack;
320
+ return error;
321
+ }
322
+ function unwrapError(error) {
323
+ // This logic is a bit complicated, but it's necessary to handle all the
324
+ // different types of errors that can be thrown by a Snap.
325
+ // If the error is a wrapped Snap error, unwrap it.
326
+ if (isWrappedSnapError(error)) {
327
+ // The wrapped error can be a JSON-RPC error, or an unknown error. If it's
328
+ // a JSON-RPC error, we can unwrap it further.
329
+ if ((0, _utils.isJsonRpcError)(error.data.cause)) {
330
+ // If the JSON-RPC error is a wrapped Snap error, unwrap it further.
331
+ if (isSerializedSnapError(error.data.cause)) {
332
+ const { code, message, stack, data } = error.data.cause.data.cause;
333
+ return [
334
+ getJsonRpcError(code, message, stack, data),
335
+ true
336
+ ];
337
+ }
338
+ // Otherwise, we use the original JSON-RPC error.
339
+ const { code, message, stack, data } = error.data.cause;
340
+ return [
341
+ getJsonRpcError(code, message, stack, data),
342
+ false
343
+ ];
344
+ }
345
+ // Otherwise, we throw an internal error with the wrapped error as the
346
+ // message.
347
+ return [
348
+ getJsonRpcError(_rpcerrors.errorCodes.rpc.internal, getErrorMessage(error.data.cause), getErrorStack(error.data.cause)),
349
+ false
350
+ ];
351
+ }
352
+ // The error can be a non-wrapped JSON-RPC error, in which case we can just
353
+ // re-throw it with the same code, message, and data.
354
+ if ((0, _utils.isJsonRpcError)(error)) {
355
+ const { code, message, stack, data } = error;
356
+ return [
357
+ getJsonRpcError(code, message, stack, data),
358
+ false
359
+ ];
360
+ }
361
+ // If the error is not a wrapped error, we don't know how to handle it, so we
362
+ // throw an internal error with the error as the message.
363
+ return [
364
+ getJsonRpcError(_rpcerrors.errorCodes.rpc.internal, getErrorMessage(error), getErrorStack(error)),
365
+ false
366
+ ];
367
+ }
18
368
 
19
369
  //# sourceMappingURL=errors.js.map
@@ -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":["getErrorMessage","error","isObject","hasProperty","message","String"],"mappings":";;;;+BAWgBA;;;eAAAA;;;uBAXsB;AAW/B,SAASA,gBAAgBC,KAAc;IAC5C,IACEC,IAAAA,eAAQ,EAACD,UACTE,IAAAA,kBAAW,EAACF,OAAO,cACnB,OAAOA,MAAMG,OAAO,KAAK,UACzB;QACA,OAAOH,MAAMG,OAAO;IACtB;IAEA,OAAOC,OAAOJ;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":["getErrorMessage","getErrorStack","getErrorCode","getErrorData","SNAP_ERROR_WRAPPER_CODE","SNAP_ERROR_WRAPPER_MESSAGE","SNAP_ERROR_CODE","SNAP_ERROR_MESSAGE","WrappedSnapError","SnapError","isSnapError","isSerializedSnapError","isWrappedSnapError","unwrapError","error","isObject","hasProperty","message","String","stack","undefined","code","Number","isInteger","errorCodes","rpc","internal","data","isValidJson","Array","isArray","Error","name","toJSON","cause","serialize","serializeCause","constructor","serialized","isJsonRpcError","getJsonRpcError","RpcError"],"mappings":"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"}
@@ -27,6 +27,7 @@ var HandlerType;
27
27
  HandlerType["OnInstall"] = 'onInstall';
28
28
  HandlerType["OnUpdate"] = 'onUpdate';
29
29
  HandlerType["OnNameLookup"] = 'onNameLookup';
30
+ HandlerType["OnKeyringRequest"] = 'onKeyringRequest';
30
31
  })(HandlerType || (HandlerType = {}));
31
32
  const SNAP_EXPORTS = {
32
33
  [HandlerType.OnRpcRequest]: {
@@ -70,6 +71,13 @@ const SNAP_EXPORTS = {
70
71
  validator: (snapExport)=>{
71
72
  return typeof snapExport === 'function';
72
73
  }
74
+ },
75
+ [HandlerType.OnKeyringRequest]: {
76
+ type: HandlerType.OnKeyringRequest,
77
+ required: true,
78
+ validator: (snapExport)=>{
79
+ return typeof snapExport === 'function';
80
+ }
73
81
  }
74
82
  };
75
83
  var SeverityLevel;
@@ -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":["SNAP_EXPORTS","HandlerType","OnRpcRequest","OnTransaction","OnCronjob","OnInstall","OnUpdate","OnNameLookup","type","required","validator","snapExport","SeverityLevel","Critical"],"mappings":";;;;;;;;;;;;;;;;;IAuCaA,YAAY;eAAZA;;;IAjCN;UAAKC,WAAW;IAAXA,YACVC,kBAAe;IADLD,YAEVE,mBAAgB;IAFNF,YAGVG,eAAY;IAHFH,YAIVI,eAAY;IAJFJ,YAKVK,cAAW;IALDL,YAMVM,kBAAe;GANLN,gBAAAA;AAiCL,MAAMD,eAAe;IAC1B,CAACC,YAAYC,YAAY,CAAC,EAAE;QAC1BM,MAAMP,YAAYC,YAAY;QAC9BO,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACV,YAAYE,aAAa,CAAC,EAAE;QAC3BK,MAAMP,YAAYE,aAAa;QAC/BM,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACV,YAAYG,SAAS,CAAC,EAAE;QACvBI,MAAMP,YAAYG,SAAS;QAC3BK,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACV,YAAYM,YAAY,CAAC,EAAE;QAC1BC,MAAMP,YAAYM,YAAY;QAC9BE,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACV,YAAYI,SAAS,CAAC,EAAE;QACvBG,MAAMP,YAAYI,SAAS;QAC3BI,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACV,YAAYK,QAAQ,CAAC,EAAE;QACtBE,MAAMP,YAAYK,QAAQ;QAC1BG,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;AACF;IAqBO;UAAKC,aAAa;IAAbA,cACVC,cAAW;GADDD,kBAAAA"}
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":["SNAP_EXPORTS","HandlerType","OnRpcRequest","OnTransaction","OnCronjob","OnInstall","OnUpdate","OnNameLookup","OnKeyringRequest","type","required","validator","snapExport","SeverityLevel","Critical"],"mappings":";;;;;;;;;;;;;;;;;IAwCaA,YAAY;eAAZA;;;IAlCN;UAAKC,WAAW;IAAXA,YACVC,kBAAe;IADLD,YAEVE,mBAAgB;IAFNF,YAGVG,eAAY;IAHFH,YAIVI,eAAY;IAJFJ,YAKVK,cAAW;IALDL,YAMVM,kBAAe;IANLN,YAOVO,sBAAmB;GAPTP,gBAAAA;AAkCL,MAAMD,eAAe;IAC1B,CAACC,YAAYC,YAAY,CAAC,EAAE;QAC1BO,MAAMR,YAAYC,YAAY;QAC9BQ,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACX,YAAYE,aAAa,CAAC,EAAE;QAC3BM,MAAMR,YAAYE,aAAa;QAC/BO,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACX,YAAYG,SAAS,CAAC,EAAE;QACvBK,MAAMR,YAAYG,SAAS;QAC3BM,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACX,YAAYM,YAAY,CAAC,EAAE;QAC1BE,MAAMR,YAAYM,YAAY;QAC9BG,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACX,YAAYI,SAAS,CAAC,EAAE;QACvBI,MAAMR,YAAYI,SAAS;QAC3BK,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACX,YAAYK,QAAQ,CAAC,EAAE;QACtBG,MAAMR,YAAYK,QAAQ;QAC1BI,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;IACA,CAACX,YAAYO,gBAAgB,CAAC,EAAE;QAC9BC,MAAMR,YAAYO,gBAAgB;QAClCE,UAAU;QACVC,WAAW,CAACC;YACV,OAAO,OAAOA,eAAe;QAC/B;IACF;AACF;IAqBO;UAAKC,aAAa;IAAbA,cACVC,cAAW;GADDD,kBAAAA"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  _export_star(require("./array"), exports);
6
+ _export_star(require("./auxiliary-files"), exports);
6
7
  _export_star(require("./caveats"), exports);
7
8
  _export_star(require("./checksum"), exports);
8
9
  _export_star(require("./cronjob"), exports);
@@ -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":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
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":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ _export_star(require("./errors"), exports);
6
7
  _export_star(require("./handlers"), exports);
7
8
  _export_star(require("./logging"), exports);
8
9
  _export_star(require("./namespace"), exports);
@@ -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;;;;;qBAC5D;qBACA;qBACA;qBACA"}
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;;;;;qBAC5D;qBACA;qBACA;qBACA;qBACA"}
package/dist/cjs/index.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  _export_star(require("./array"), exports);
6
+ _export_star(require("./auxiliary-files"), exports);
6
7
  _export_star(require("./caveats"), exports);
7
8
  _export_star(require("./cronjob"), exports);
8
9
  _export_star(require("./checksum"), exports);
@@ -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":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
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":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}