@metamask/snaps-rpc-methods 8.1.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -1
- package/dist/{chunk-MXCJWR45.mjs → chunk-2CTOCP34.mjs} +8 -8
- package/dist/chunk-2CTOCP34.mjs.map +1 -0
- package/dist/{chunk-TKXU7ZXP.mjs → chunk-2L2ATCIK.mjs} +2 -2
- package/dist/{chunk-YG7W4CDT.js → chunk-33MTKZ4H.js} +11 -4
- package/dist/chunk-33MTKZ4H.js.map +1 -0
- package/dist/{chunk-LGUJMQC7.js → chunk-4BPNRCZJ.js} +5 -4
- package/dist/chunk-4BPNRCZJ.js.map +1 -0
- package/dist/{chunk-VNH2GKLV.mjs → chunk-CJPFADO7.mjs} +3 -3
- package/dist/{chunk-IDZGMGIB.js → chunk-DLVPMPRZ.js} +8 -8
- package/dist/chunk-DLVPMPRZ.js.map +1 -0
- package/dist/{chunk-AOWUGDER.js → chunk-E27BGHCR.js} +3 -3
- package/dist/{chunk-Y4LNTDZ2.mjs → chunk-FR26QD3N.mjs} +3 -3
- package/dist/{chunk-PG32JMWC.mjs → chunk-I3QG3QZL.mjs} +5 -5
- package/dist/{chunk-S7AR3ROH.js → chunk-IE6EHYEG.js} +3 -3
- package/dist/{chunk-Q5W3YGEB.js → chunk-IVD2ORDS.js} +3 -3
- package/dist/{chunk-IBV23QOX.mjs → chunk-KIXPIIY5.mjs} +2 -2
- package/dist/{chunk-AYJK7MSH.js → chunk-LLH2T5NT.js} +5 -5
- package/dist/{chunk-TNRH2LRU.mjs → chunk-LXJBBRQ4.mjs} +2 -2
- package/dist/{chunk-R2M4YLJ7.js → chunk-M2JQCKR7.js} +3 -3
- package/dist/{chunk-RIALLTR7.js → chunk-O2VSIMDY.js} +9 -9
- package/dist/{chunk-RX7WZZ32.js → chunk-QAKSH24Z.js} +8 -8
- package/dist/{chunk-6WUIFFMQ.mjs → chunk-R3DRYUNH.mjs} +5 -4
- package/dist/chunk-R3DRYUNH.mjs.map +1 -0
- package/dist/{chunk-3W4SMZFD.mjs → chunk-S46RTIDR.mjs} +3 -3
- package/dist/{chunk-NESDQ4PF.mjs → chunk-TE4W25CA.mjs} +2 -2
- package/dist/{chunk-L675SYPP.mjs → chunk-TUIJOZXZ.mjs} +4 -4
- package/dist/{chunk-GP6TDVNT.js → chunk-VBCE6VHM.js} +5 -5
- package/dist/{chunk-SGQXD5K7.mjs → chunk-W33UWNA2.mjs} +11 -4
- package/dist/chunk-W33UWNA2.mjs.map +1 -0
- package/dist/{chunk-INB4AX37.js → chunk-XXSAESE7.js} +5 -5
- package/dist/index.js +13 -13
- package/dist/index.mjs +12 -12
- package/dist/permissions.js +9 -9
- package/dist/permissions.mjs +8 -8
- package/dist/permitted/handlers.js +4 -4
- package/dist/permitted/handlers.mjs +3 -3
- package/dist/permitted/index.js +6 -6
- package/dist/permitted/index.mjs +5 -5
- package/dist/permitted/invokeKeyring.js +3 -3
- package/dist/permitted/invokeKeyring.mjs +2 -2
- package/dist/permitted/invokeSnapSugar.js +2 -2
- package/dist/permitted/invokeSnapSugar.mjs +1 -1
- package/dist/permitted/middleware.js +6 -6
- package/dist/permitted/middleware.mjs +5 -5
- package/dist/restricted/caveats/index.js +5 -5
- package/dist/restricted/caveats/index.mjs +4 -4
- package/dist/restricted/getBip32Entropy.js +3 -3
- package/dist/restricted/getBip32Entropy.mjs +2 -2
- package/dist/restricted/getBip32PublicKey.js +3 -3
- package/dist/restricted/getBip32PublicKey.mjs +2 -2
- package/dist/restricted/getEntropy.js +3 -3
- package/dist/restricted/getEntropy.mjs +2 -2
- package/dist/restricted/index.js +8 -8
- package/dist/restricted/index.mjs +7 -7
- package/dist/restricted/manageState.js +3 -3
- package/dist/restricted/manageState.mjs +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/permitted/handlers.d.ts +2 -2
- package/dist/types/permitted/invokeSnapSugar.d.ts +12 -7
- package/dist/types/restricted/getBip32PublicKey.d.ts +2 -5
- package/dist/types/utils.d.ts +7 -5
- package/dist/utils.js +2 -2
- package/dist/utils.mjs +1 -1
- package/package.json +4 -4
- package/dist/chunk-6WUIFFMQ.mjs.map +0 -1
- package/dist/chunk-IDZGMGIB.js.map +0 -1
- package/dist/chunk-LGUJMQC7.js.map +0 -1
- package/dist/chunk-MXCJWR45.mjs.map +0 -1
- package/dist/chunk-SGQXD5K7.mjs.map +0 -1
- package/dist/chunk-YG7W4CDT.js.map +0 -1
- /package/dist/{chunk-TKXU7ZXP.mjs.map → chunk-2L2ATCIK.mjs.map} +0 -0
- /package/dist/{chunk-VNH2GKLV.mjs.map → chunk-CJPFADO7.mjs.map} +0 -0
- /package/dist/{chunk-AOWUGDER.js.map → chunk-E27BGHCR.js.map} +0 -0
- /package/dist/{chunk-Y4LNTDZ2.mjs.map → chunk-FR26QD3N.mjs.map} +0 -0
- /package/dist/{chunk-PG32JMWC.mjs.map → chunk-I3QG3QZL.mjs.map} +0 -0
- /package/dist/{chunk-S7AR3ROH.js.map → chunk-IE6EHYEG.js.map} +0 -0
- /package/dist/{chunk-Q5W3YGEB.js.map → chunk-IVD2ORDS.js.map} +0 -0
- /package/dist/{chunk-IBV23QOX.mjs.map → chunk-KIXPIIY5.mjs.map} +0 -0
- /package/dist/{chunk-AYJK7MSH.js.map → chunk-LLH2T5NT.js.map} +0 -0
- /package/dist/{chunk-TNRH2LRU.mjs.map → chunk-LXJBBRQ4.mjs.map} +0 -0
- /package/dist/{chunk-R2M4YLJ7.js.map → chunk-M2JQCKR7.js.map} +0 -0
- /package/dist/{chunk-RIALLTR7.js.map → chunk-O2VSIMDY.js.map} +0 -0
- /package/dist/{chunk-RX7WZZ32.js.map → chunk-QAKSH24Z.js.map} +0 -0
- /package/dist/{chunk-3W4SMZFD.mjs.map → chunk-S46RTIDR.mjs.map} +0 -0
- /package/dist/{chunk-NESDQ4PF.mjs.map → chunk-TE4W25CA.mjs.map} +0 -0
- /package/dist/{chunk-L675SYPP.mjs.map → chunk-TUIJOZXZ.mjs.map} +0 -0
- /package/dist/{chunk-GP6TDVNT.js.map → chunk-VBCE6VHM.js.map} +0 -0
- /package/dist/{chunk-INB4AX37.js.map → chunk-XXSAESE7.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [9.0.0]
|
|
10
|
+
### Added
|
|
11
|
+
- Add support for BIP-32-Ed25519 / CIP-3 key derivation ([#2408](https://github.com/MetaMask/snaps/pull/2408))
|
|
12
|
+
- The `ed25519Bip32` curve is now supported for `snap_getBip32Entropy` and `snap_getBip32PublicKey`
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
- **BREAKING:** Use hooks in `wallet_invokeSnap` instead of remapping the request to `wallet_snap` ([#2406](https://github.com/MetaMask/snaps/pull/2406))
|
|
16
|
+
|
|
9
17
|
## [8.1.0]
|
|
10
18
|
### Added
|
|
11
19
|
- Add JSX support for custom UI ([#2258](https://github.com/MetaMask/snaps/pull/2258))
|
|
@@ -134,7 +142,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
134
142
|
- The version of the package no longer needs to match the version of all other
|
|
135
143
|
MetaMask Snaps packages.
|
|
136
144
|
|
|
137
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@
|
|
145
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@9.0.0...HEAD
|
|
146
|
+
[9.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@8.1.0...@metamask/snaps-rpc-methods@9.0.0
|
|
138
147
|
[8.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@8.0.0...@metamask/snaps-rpc-methods@8.1.0
|
|
139
148
|
[8.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@7.0.2...@metamask/snaps-rpc-methods@8.0.0
|
|
140
149
|
[7.0.2]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@7.0.1...@metamask/snaps-rpc-methods@7.0.2
|
|
@@ -4,18 +4,18 @@ import { isObject } from "@metamask/utils";
|
|
|
4
4
|
var invokeSnapSugarHandler = {
|
|
5
5
|
methodNames: ["wallet_invokeSnap"],
|
|
6
6
|
implementation: invokeSnapSugar,
|
|
7
|
-
hookNames:
|
|
7
|
+
hookNames: {
|
|
8
|
+
invokeSnap: true
|
|
9
|
+
}
|
|
8
10
|
};
|
|
9
|
-
function invokeSnapSugar(req,
|
|
10
|
-
let params;
|
|
11
|
+
async function invokeSnapSugar(req, res, _next, end, { invokeSnap }) {
|
|
11
12
|
try {
|
|
12
|
-
params = getValidatedParams(req.params);
|
|
13
|
+
const params = getValidatedParams(req.params);
|
|
14
|
+
res.result = await invokeSnap(params);
|
|
13
15
|
} catch (error) {
|
|
14
16
|
return end(error);
|
|
15
17
|
}
|
|
16
|
-
|
|
17
|
-
req.params = params;
|
|
18
|
-
return next();
|
|
18
|
+
return end();
|
|
19
19
|
}
|
|
20
20
|
function getValidatedParams(params) {
|
|
21
21
|
if (!isObject(params)) {
|
|
@@ -42,4 +42,4 @@ export {
|
|
|
42
42
|
invokeSnapSugar,
|
|
43
43
|
getValidatedParams
|
|
44
44
|
};
|
|
45
|
-
//# sourceMappingURL=chunk-
|
|
45
|
+
//# sourceMappingURL=chunk-2CTOCP34.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/permitted/invokeSnapSugar.ts"],"sourcesContent":["import type {\n JsonRpcEngineEndCallback,\n JsonRpcEngineNextCallback,\n} from '@metamask/json-rpc-engine';\nimport type { PermittedHandlerExport } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type { InvokeSnapParams, InvokeSnapResult } from '@metamask/snaps-sdk';\nimport type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';\nimport { isObject } from '@metamask/utils';\n\n/**\n * `wallet_invokeSnap` attempts to invoke an RPC method of the specified Snap.\n */\nexport const invokeSnapSugarHandler: PermittedHandlerExport<\n InvokeSnapSugarHooks,\n InvokeSnapParams,\n InvokeSnapResult\n> = {\n methodNames: ['wallet_invokeSnap'],\n implementation: invokeSnapSugar,\n hookNames: {\n invokeSnap: true,\n },\n};\n\nexport type InvokeSnapSugarHooks = {\n invokeSnap: (params: InvokeSnapParams) => Promise<InvokeSnapResult>;\n};\n\n/**\n * The `wallet_invokeSnap` method implementation.\n * Effectively calls `wallet_snap` under the hood.\n *\n * @param req - The JSON-RPC request object.\n * @param res - The JSON-RPC response object.\n * @param _next - The `json-rpc-engine` \"next\" callback.\n * @param end - The `json-rpc-engine` \"end\" callback.\n * @param hooks - The RPC method hooks.\n * @param hooks.invokeSnap - A function to invoke a snap designated by its parameters,\n * bound to the requesting origin.\n * @returns Nothing.\n * @throws If the params are invalid.\n */\nexport async function invokeSnapSugar(\n req: JsonRpcRequest<InvokeSnapParams>,\n res: PendingJsonRpcResponse<InvokeSnapResult>,\n _next: JsonRpcEngineNextCallback,\n end: JsonRpcEngineEndCallback,\n { invokeSnap }: InvokeSnapSugarHooks,\n): Promise<void> {\n try {\n const params = getValidatedParams(req.params);\n res.result = await invokeSnap(params);\n } catch (error) {\n return end(error);\n }\n return end();\n}\n\n/**\n * Validates the wallet_invokeSnap method `params` and returns them cast to the correct\n * type. Throws if validation fails.\n *\n * @param params - The unvalidated params object from the method request.\n * @returns The validated method parameter object.\n */\nexport function getValidatedParams(params: unknown): InvokeSnapParams {\n if (!isObject(params)) {\n throw rpcErrors.invalidParams({\n message: 'Expected params to be a single object.',\n });\n }\n\n const { snapId, request } = params;\n\n if (!snapId || typeof snapId !== 'string' || snapId === '') {\n throw rpcErrors.invalidParams({\n message: 'Must specify a valid snap ID.',\n });\n }\n\n if (!isObject(request)) {\n throw rpcErrors.invalidParams({\n message: 'Expected request to be a single object.',\n });\n }\n\n return params as InvokeSnapParams;\n}\n"],"mappings":";AAKA,SAAS,iBAAiB;AAG1B,SAAS,gBAAgB;AAKlB,IAAM,yBAIT;AAAA,EACF,aAAa,CAAC,mBAAmB;AAAA,EACjC,gBAAgB;AAAA,EAChB,WAAW;AAAA,IACT,YAAY;AAAA,EACd;AACF;AAoBA,eAAsB,gBACpB,KACA,KACA,OACA,KACA,EAAE,WAAW,GACE;AACf,MAAI;AACF,UAAM,SAAS,mBAAmB,IAAI,MAAM;AAC5C,QAAI,SAAS,MAAM,WAAW,MAAM;AAAA,EACtC,SAAS,OAAO;AACd,WAAO,IAAI,KAAK;AAAA,EAClB;AACA,SAAO,IAAI;AACb;AASO,SAAS,mBAAmB,QAAmC;AACpE,MAAI,CAAC,SAAS,MAAM,GAAG;AACrB,UAAM,UAAU,cAAc;AAAA,MAC5B,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAEA,QAAM,EAAE,QAAQ,QAAQ,IAAI;AAE5B,MAAI,CAAC,UAAU,OAAO,WAAW,YAAY,WAAW,IAAI;AAC1D,UAAM,UAAU,cAAc;AAAA,MAC5B,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAEA,MAAI,CAAC,SAAS,OAAO,GAAG;AACtB,UAAM,UAAU,cAAc;AAAA,MAC5B,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getValidatedParams
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2CTOCP34.mjs";
|
|
4
4
|
|
|
5
5
|
// src/permitted/invokeKeyring.ts
|
|
6
6
|
import { rpcErrors } from "@metamask/rpc-errors";
|
|
@@ -75,4 +75,4 @@ async function invokeKeyringImplementation(req, res, _next, end, {
|
|
|
75
75
|
export {
|
|
76
76
|
invokeKeyringHandler
|
|
77
77
|
};
|
|
78
|
-
//# sourceMappingURL=chunk-
|
|
78
|
+
//# sourceMappingURL=chunk-2L2ATCIK.mjs.map
|
|
@@ -6,6 +6,7 @@ var _keytree = require('@metamask/key-tree');
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
|
|
9
10
|
var _utils = require('@metamask/utils');
|
|
10
11
|
var _sha3 = require('@noble/hashes/sha3');
|
|
11
12
|
var HARDENED_VALUE = 2147483648;
|
|
@@ -54,10 +55,16 @@ async function deriveEntropy({
|
|
|
54
55
|
return _utils.add0x.call(void 0, privateKey);
|
|
55
56
|
}
|
|
56
57
|
function getPathPrefix(curve) {
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
switch (curve) {
|
|
59
|
+
case "secp256k1":
|
|
60
|
+
return "bip32";
|
|
61
|
+
case "ed25519":
|
|
62
|
+
return "slip10";
|
|
63
|
+
case "ed25519Bip32":
|
|
64
|
+
return "cip3";
|
|
65
|
+
default:
|
|
66
|
+
return _utils.assertExhaustive.call(void 0, curve);
|
|
59
67
|
}
|
|
60
|
-
return "slip10";
|
|
61
68
|
}
|
|
62
69
|
async function getNode({
|
|
63
70
|
curve,
|
|
@@ -80,4 +87,4 @@ async function getNode({
|
|
|
80
87
|
|
|
81
88
|
|
|
82
89
|
exports.selectHooks = selectHooks; exports.deriveEntropy = deriveEntropy; exports.getPathPrefix = getPathPrefix; exports.getNode = getNode;
|
|
83
|
-
//# sourceMappingURL=chunk-
|
|
90
|
+
//# sourceMappingURL=chunk-33MTKZ4H.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils.ts"],"names":[],"mappings":";AAMA,SAAS,kBAAkB;AAG3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc,iBAAiB;AAExC,IAAM,iBAAiB;AAuBhB,SAAS,YAId,OACA,WACmC;AACnC,MAAI,WAAW;AACb,WAAO,OAAO,KAAK,SAAS,EAAE;AAAA,MAC5B,CAAC,YAAY,cAAc;AACzB,cAAM,WAAW;AACjB,mBAAW,QAAQ,IAAI,MAAM,QAAQ;AACrC,eAAO;AAAA,MACT;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AACA,SAAO;AACT;AASA,SAAS,uBAAuB,MAAuC;AACrE,QAAM,QAA6B,CAAC;AACpC,QAAM,OAAO,eAAe,IAAI;AAEhC,WAAS,QAAQ,GAAG,QAAQ,GAAG,SAAS;AACtC,UAAM,SAAS,KAAK,UAAU,QAAQ,CAAC;AAMvC,UAAM,aAAa,SAAS,oBAAoB;AAChD,UAAM,KAAK,SAAS,YAAY,cAAc,GAAY;AAAA,EAC5D;AAEA,SAAO;AACT;AAwCA,eAAsB,cAAc;AAAA,EAClC;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AACF,GAAuC;AACrC,QAAM,aAAa,cAAc,KAAK;AACtC,QAAM,YAAY,cAAc,IAAI;AAGpC,QAAM,OAAO,UAAU,YAAY,CAAC,YAAY,UAAU,SAAS,CAAC,CAAC,CAAC;AACtE,QAAM,yBAAyB,uBAAuB,IAAI;AAG1D,QAAM,EAAE,WAAW,IAAI,MAAM,WAAW,mBAAmB;AAAA,IACzD,gBAAgB;AAAA,MACd;AAAA,MACA,SAAS,KAAK;AAAA,MACd,GAAG;AAAA,IACL;AAAA,IACA,OAAO;AAAA,EACT,CAAC;AAGD,SAAO,YAAY,+BAA+B;AAElD,SAAO,MAAM,UAAU;AACzB;AAiBO,SAAS,cACd,OAC6B;AAC7B,UAAQ,OAAO;AAAA,IACb,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO,iBAAiB,KAAK;AAAA,EACjC;AACF;AAqBA,eAAsB,QAAQ;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AACF,GAAgB;AACd,QAAM,SAAS,cAAc,KAAK;AAElC,SAAO,MAAM,WAAW,mBAAmB;AAAA,IACzC;AAAA,IACA,gBAAgB;AAAA,MACd;AAAA,MACA,GAAI,KAAK,MAAM,CAAC,EAAE,IAAI,CAAC,UAAU,GAAG,MAAM,IAAI,KAAK,EAAE;AAAA,IAGvD;AAAA,EACF,CAAC;AACH","sourcesContent":["import type {\n HardenedBIP32Node,\n BIP32Node,\n SLIP10PathNode,\n SupportedCurve,\n} from '@metamask/key-tree';\nimport { SLIP10Node } from '@metamask/key-tree';\nimport type { MagicValue } from '@metamask/snaps-utils';\nimport type { Hex } from '@metamask/utils';\nimport {\n assertExhaustive,\n add0x,\n assert,\n concatBytes,\n createDataView,\n stringToBytes,\n} from '@metamask/utils';\nimport { keccak_256 as keccak256 } from '@noble/hashes/sha3';\n\nconst HARDENED_VALUE = 0x80000000;\n\n/**\n * Maps an interface with method hooks to an object, using the keys of the\n * interface, and `true` as value. This ensures that the `methodHooks` object\n * has the same values as the interface.\n */\nexport type MethodHooksObject<HooksType extends Record<string, unknown>> = {\n [Key in keyof HooksType]: true;\n};\n\n/**\n * Returns the subset of the specified `hooks` that are included in the\n * `hookNames` object. This is a Principle of Least Authority (POLA) measure\n * to ensure that each RPC method implementation only has access to the\n * API \"hooks\" it needs to do its job.\n *\n * @param hooks - The hooks to select from.\n * @param hookNames - The names of the hooks to select.\n * @returns The selected hooks.\n * @template Hooks - The hooks to select from.\n * @template HookName - The names of the hooks to select.\n */\nexport function selectHooks<\n Hooks extends Record<string, unknown>,\n HookName extends keyof Hooks,\n>(\n hooks: Hooks,\n hookNames?: Record<HookName, boolean>,\n): Pick<Hooks, HookName> | undefined {\n if (hookNames) {\n return Object.keys(hookNames).reduce<Partial<Pick<Hooks, HookName>>>(\n (hookSubset, _hookName) => {\n const hookName = _hookName as HookName;\n hookSubset[hookName] = hooks[hookName];\n return hookSubset;\n },\n {},\n ) as Pick<Hooks, HookName>;\n }\n return undefined;\n}\n\n/**\n * Get a BIP-32 derivation path array from a hash, which is compatible with\n * `@metamask/key-tree`. The hash is assumed to be 32 bytes long.\n *\n * @param hash - The hash to derive indices from.\n * @returns The derived indices as a {@link HardenedBIP32Node} array.\n */\nfunction getDerivationPathArray(hash: Uint8Array): HardenedBIP32Node[] {\n const array: HardenedBIP32Node[] = [];\n const view = createDataView(hash);\n\n for (let index = 0; index < 8; index++) {\n const uint32 = view.getUint32(index * 4);\n\n // This is essentially `index | 0x80000000`. Because JavaScript numbers are\n // signed, we use the bitwise unsigned right shift operator to ensure that\n // the result is a positive number.\n // eslint-disable-next-line no-bitwise\n const pathIndex = (uint32 | HARDENED_VALUE) >>> 0;\n array.push(`bip32:${pathIndex - HARDENED_VALUE}'` as const);\n }\n\n return array;\n}\n\ntype DeriveEntropyOptions = {\n /**\n * The input value to derive entropy from.\n */\n input: string;\n\n /**\n * An optional salt to use when deriving entropy.\n */\n salt?: string;\n\n /**\n * The mnemonic phrase to use for entropy derivation.\n */\n mnemonicPhrase: Uint8Array;\n\n /**\n * A hardened BIP-32 index, which is used to derive the root key from the\n * mnemonic phrase.\n */\n magic: MagicValue;\n};\n\n/**\n * Derive entropy from the given mnemonic phrase and salt.\n *\n * This is based on the reference implementation of\n * [SIP-6](https://metamask.github.io/SIPs/SIPS/sip-6).\n *\n * @param options - The options for entropy derivation.\n * @param options.input - The input value to derive entropy from.\n * @param options.salt - An optional salt to use when deriving entropy.\n * @param options.mnemonicPhrase - The mnemonic phrase to use for entropy\n * derivation.\n * @param options.magic - A hardened BIP-32 index, which is used to derive the\n * root key from the mnemonic phrase.\n * @returns The derived entropy.\n */\nexport async function deriveEntropy({\n input,\n salt = '',\n mnemonicPhrase,\n magic,\n}: DeriveEntropyOptions): Promise<Hex> {\n const inputBytes = stringToBytes(input);\n const saltBytes = stringToBytes(salt);\n\n // Get the derivation path from the snap ID.\n const hash = keccak256(concatBytes([inputBytes, keccak256(saltBytes)]));\n const computedDerivationPath = getDerivationPathArray(hash);\n\n // Derive the private key using BIP-32.\n const { privateKey } = await SLIP10Node.fromDerivationPath({\n derivationPath: [\n mnemonicPhrase,\n `bip32:${magic}`,\n ...computedDerivationPath,\n ],\n curve: 'secp256k1',\n });\n\n // This should never happen, but this keeps TypeScript happy.\n assert(privateKey, 'Failed to derive the entropy.');\n\n return add0x(privateKey);\n}\n\n/**\n * Get the path prefix to use for key derivation in `key-tree`. This assumes the\n * following:\n *\n * - The Secp256k1 curve always uses the BIP-32 specification.\n * - The Ed25519 curve always uses the SLIP-10 specification.\n * - The BIP-32-Ed25519 curve always uses the CIP-3 specification.\n *\n * While this does not matter in most situations (no known case at the time of\n * writing), `key-tree` requires a specific specification to be used.\n *\n * @param curve - The curve to get the path prefix for. The curve is NOT\n * validated by this function.\n * @returns The path prefix, i.e., `bip32` or `slip10`.\n */\nexport function getPathPrefix(\n curve: SupportedCurve,\n): 'bip32' | 'slip10' | 'cip3' {\n switch (curve) {\n case 'secp256k1':\n return 'bip32';\n case 'ed25519':\n return 'slip10';\n case 'ed25519Bip32':\n return 'cip3';\n default:\n return assertExhaustive(curve);\n }\n}\n\ntype GetNodeArgs = {\n curve: SupportedCurve;\n secretRecoveryPhrase: Uint8Array;\n path: string[];\n};\n\n/**\n * Get a `key-tree`-compatible node.\n *\n * Note: This function assumes that all the parameters have been validated\n * beforehand.\n *\n * @param options - The derivation options.\n * @param options.curve - The curve to use for derivation.\n * @param options.secretRecoveryPhrase - The secret recovery phrase to use for\n * derivation.\n * @param options.path - The derivation path to use as array, starting with an\n * \"m\" as the first item.\n */\nexport async function getNode({\n curve,\n secretRecoveryPhrase,\n path,\n}: GetNodeArgs) {\n const prefix = getPathPrefix(curve);\n\n return await SLIP10Node.fromDerivationPath({\n curve,\n derivationPath: [\n secretRecoveryPhrase,\n ...(path.slice(1).map((index) => `${prefix}:${index}`) as\n | BIP32Node[]\n | SLIP10PathNode[]),\n ],\n });\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk33MTKZ4Hjs = require('./chunk-33MTKZ4H.js');
|
|
4
4
|
|
|
5
5
|
// src/restricted/getBip32PublicKey.ts
|
|
6
6
|
var _permissioncontroller = require('@metamask/permission-controller');
|
|
@@ -9,6 +9,7 @@ var _rpcerrors = require('@metamask/rpc-errors');
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
|
|
12
13
|
var _snapsutils = require('@metamask/snaps-utils');
|
|
13
14
|
var _utils = require('@metamask/utils');
|
|
14
15
|
var _superstruct = require('superstruct');
|
|
@@ -16,7 +17,7 @@ var targetName = "snap_getBip32PublicKey";
|
|
|
16
17
|
var Bip32PublicKeyArgsStruct = _snapsutils.bip32entropy.call(void 0,
|
|
17
18
|
_superstruct.object.call(void 0, {
|
|
18
19
|
path: _snapsutils.Bip32PathStruct,
|
|
19
|
-
curve:
|
|
20
|
+
curve: _snapsutils.CurveStruct,
|
|
20
21
|
compressed: _superstruct.optional.call(void 0, _superstruct.boolean.call(void 0, ))
|
|
21
22
|
})
|
|
22
23
|
);
|
|
@@ -58,7 +59,7 @@ function getBip32PublicKeyImplementation({
|
|
|
58
59
|
_rpcerrors.rpcErrors.invalidParams
|
|
59
60
|
);
|
|
60
61
|
const { params } = args;
|
|
61
|
-
const node = await
|
|
62
|
+
const node = await _chunk33MTKZ4Hjs.getNode.call(void 0, {
|
|
62
63
|
curve: params.curve,
|
|
63
64
|
path: params.path,
|
|
64
65
|
secretRecoveryPhrase: await getMnemonic()
|
|
@@ -75,4 +76,4 @@ function getBip32PublicKeyImplementation({
|
|
|
75
76
|
|
|
76
77
|
|
|
77
78
|
exports.Bip32PublicKeyArgsStruct = Bip32PublicKeyArgsStruct; exports.getBip32PublicKeyBuilder = getBip32PublicKeyBuilder; exports.getBip32PublicKeyImplementation = getBip32PublicKeyImplementation;
|
|
78
|
-
//# sourceMappingURL=chunk-
|
|
79
|
+
//# sourceMappingURL=chunk-4BPNRCZJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/restricted/getBip32PublicKey.ts"],"names":["methodHooks"],"mappings":";;;;;AAMA,SAAS,gBAAgB,mBAAmB;AAC5C,SAAS,iBAAiB;AAK1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,oBAAoB;AAC7B,SAAS,SAAS,QAAQ,gBAAgB;AAK1C,IAAM,aAAa;AA4BZ,IAAM,2BAA2B;AAAA,EACtC,OAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,YAAY,SAAS,QAAQ,CAAC;AAAA,EAChC,CAAC;AACH;AAWA,IAAM,uBAIF,CAAC,EAAE,aAAAA,aAAY,MAAoD;AACrE,SAAO;AAAA,IACL,gBAAgB,eAAe;AAAA,IAC/B;AAAA,IACA,gBAAgB,CAAC,eAAe,wBAAwB;AAAA,IACxD,sBAAsB,gCAAgCA,YAAW;AAAA,IACjE,WAAW,CAAC,EAAE,QAAQ,MAAM;AAC1B,UACE,SAAS,WAAW,KACpB,QAAQ,CAAC,EAAE,SAAS,eAAe,0BACnC;AACA,cAAM,UAAU,cAAc;AAAA,UAC5B,SAAS,sBAAsB,eAAe,wBAAwB;AAAA,QACxE,CAAC;AAAA,MACH;AAAA,IACF;AAAA,IACA,cAAc,CAAC,YAAY,IAAI;AAAA,EACjC;AACF;AAEA,IAAM,cAA+D;AAAA,EACnE,aAAa;AAAA,EACb,kBAAkB;AACpB;AAEO,IAAM,2BAA2B,OAAO,OAAO;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AACF,CAAU;AAYH,SAAS,gCAAgC;AAAA,EAC9C;AAAA,EACA;AACF,GAAiC;AAC/B,SAAO,eAAe,kBACpB,MACkC;AAClC,UAAM,iBAAiB,IAAI;AAE3B;AAAA,MACE,KAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA,UAAU;AAAA,IACZ;AAEA,UAAM,EAAE,OAAO,IAAI;AACnB,UAAM,OAAO,MAAM,QAAQ;AAAA,MACzB,OAAO,OAAO;AAAA,MACd,MAAM,OAAO;AAAA,MACb,sBAAsB,MAAM,YAAY;AAAA,IAC1C,CAAC;AAED,QAAI,OAAO,YAAY;AACrB,aAAO,KAAK;AAAA,IACd;AAEA,WAAO,KAAK;AAAA,EACd;AACF","sourcesContent":["import type {\n PermissionSpecificationBuilder,\n PermissionValidatorConstraint,\n RestrictedMethodOptions,\n ValidPermissionSpecification,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type {\n GetBip32PublicKeyParams,\n GetBip32PublicKeyResult,\n} from '@metamask/snaps-sdk';\nimport {\n bip32entropy,\n Bip32PathStruct,\n CurveStruct,\n SnapCaveatType,\n} from '@metamask/snaps-utils';\nimport type { NonEmptyArray } from '@metamask/utils';\nimport { assertStruct } from '@metamask/utils';\nimport { boolean, object, optional } from 'superstruct';\n\nimport type { MethodHooksObject } from '../utils';\nimport { getNode } from '../utils';\n\nconst targetName = 'snap_getBip32PublicKey';\n\nexport type GetBip32PublicKeyMethodHooks = {\n /**\n * @returns The mnemonic of the user's primary keyring.\n */\n getMnemonic: () => Promise<Uint8Array>;\n\n /**\n * Waits for the extension to be unlocked.\n *\n * @returns A promise that resolves once the extension is unlocked.\n */\n getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;\n};\n\ntype GetBip32PublicKeySpecificationBuilderOptions = {\n methodHooks: GetBip32PublicKeyMethodHooks;\n};\n\ntype GetBip32PublicKeySpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof targetName;\n methodImplementation: ReturnType<typeof getBip32PublicKeyImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n validator: PermissionValidatorConstraint;\n}>;\n\nexport const Bip32PublicKeyArgsStruct = bip32entropy(\n object({\n path: Bip32PathStruct,\n curve: CurveStruct,\n compressed: optional(boolean()),\n }),\n);\n\n/**\n * The specification builder for the `snap_getBip32PublicKey` permission.\n * `snap_getBip32PublicKey` lets the Snap retrieve public keys for a particular\n * BIP-32 node.\n *\n * @param options - The specification builder options.\n * @param options.methodHooks - The RPC method hooks needed by the method implementation.\n * @returns The specification for the `snap_getBip32PublicKey` permission.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n GetBip32PublicKeySpecificationBuilderOptions,\n GetBip32PublicKeySpecification\n> = ({ methodHooks }: GetBip32PublicKeySpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName,\n allowedCaveats: [SnapCaveatType.PermittedDerivationPaths],\n methodImplementation: getBip32PublicKeyImplementation(methodHooks),\n validator: ({ caveats }) => {\n if (\n caveats?.length !== 1 ||\n caveats[0].type !== SnapCaveatType.PermittedDerivationPaths\n ) {\n throw rpcErrors.invalidParams({\n message: `Expected a single \"${SnapCaveatType.PermittedDerivationPaths}\" caveat.`,\n });\n }\n },\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<GetBip32PublicKeyMethodHooks> = {\n getMnemonic: true,\n getUnlockPromise: true,\n};\n\nexport const getBip32PublicKeyBuilder = Object.freeze({\n targetName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_getBip32PublicKey`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getMnemonic - A function to retrieve the Secret Recovery Phrase of the user.\n * @param hooks.getUnlockPromise - A function that resolves once the MetaMask extension is unlocked\n * and prompts the user to unlock their MetaMask if it is locked.\n * @returns The method implementation which returns a public key.\n * @throws If the params are invalid.\n */\nexport function getBip32PublicKeyImplementation({\n getMnemonic,\n getUnlockPromise,\n}: GetBip32PublicKeyMethodHooks) {\n return async function getBip32PublicKey(\n args: RestrictedMethodOptions<GetBip32PublicKeyParams>,\n ): Promise<GetBip32PublicKeyResult> {\n await getUnlockPromise(true);\n\n assertStruct(\n args.params,\n Bip32PublicKeyArgsStruct,\n 'Invalid BIP-32 public key params',\n rpcErrors.invalidParams,\n );\n\n const { params } = args;\n const node = await getNode({\n curve: params.curve,\n path: params.path,\n secretRecoveryPhrase: await getMnemonic(),\n });\n\n if (params.compressed) {\n return node.compressedPublicKey;\n }\n\n return node.publicKey;\n };\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
methodHandlers
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-S46RTIDR.mjs";
|
|
4
4
|
import {
|
|
5
5
|
selectHooks
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-W33UWNA2.mjs";
|
|
7
7
|
|
|
8
8
|
// src/permitted/middleware.ts
|
|
9
9
|
import { rpcErrors } from "@metamask/rpc-errors";
|
|
@@ -36,4 +36,4 @@ function createSnapsMethodMiddleware(isSnap, hooks) {
|
|
|
36
36
|
export {
|
|
37
37
|
createSnapsMethodMiddleware
|
|
38
38
|
};
|
|
39
|
-
//# sourceMappingURL=chunk-
|
|
39
|
+
//# sourceMappingURL=chunk-CJPFADO7.mjs.map
|
|
@@ -4,18 +4,18 @@ var _utils = require('@metamask/utils');
|
|
|
4
4
|
var invokeSnapSugarHandler = {
|
|
5
5
|
methodNames: ["wallet_invokeSnap"],
|
|
6
6
|
implementation: invokeSnapSugar,
|
|
7
|
-
hookNames:
|
|
7
|
+
hookNames: {
|
|
8
|
+
invokeSnap: true
|
|
9
|
+
}
|
|
8
10
|
};
|
|
9
|
-
function invokeSnapSugar(req,
|
|
10
|
-
let params;
|
|
11
|
+
async function invokeSnapSugar(req, res, _next, end, { invokeSnap }) {
|
|
11
12
|
try {
|
|
12
|
-
params = getValidatedParams(req.params);
|
|
13
|
+
const params = getValidatedParams(req.params);
|
|
14
|
+
res.result = await invokeSnap(params);
|
|
13
15
|
} catch (error) {
|
|
14
16
|
return end(error);
|
|
15
17
|
}
|
|
16
|
-
|
|
17
|
-
req.params = params;
|
|
18
|
-
return next();
|
|
18
|
+
return end();
|
|
19
19
|
}
|
|
20
20
|
function getValidatedParams(params) {
|
|
21
21
|
if (!_utils.isObject.call(void 0, params)) {
|
|
@@ -42,4 +42,4 @@ function getValidatedParams(params) {
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
exports.invokeSnapSugarHandler = invokeSnapSugarHandler; exports.invokeSnapSugar = invokeSnapSugar; exports.getValidatedParams = getValidatedParams;
|
|
45
|
-
//# sourceMappingURL=chunk-
|
|
45
|
+
//# sourceMappingURL=chunk-DLVPMPRZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/permitted/invokeSnapSugar.ts"],"names":[],"mappings":";AAKA,SAAS,iBAAiB;AAG1B,SAAS,gBAAgB;AAKlB,IAAM,yBAIT;AAAA,EACF,aAAa,CAAC,mBAAmB;AAAA,EACjC,gBAAgB;AAAA,EAChB,WAAW;AAAA,IACT,YAAY;AAAA,EACd;AACF;AAoBA,eAAsB,gBACpB,KACA,KACA,OACA,KACA,EAAE,WAAW,GACE;AACf,MAAI;AACF,UAAM,SAAS,mBAAmB,IAAI,MAAM;AAC5C,QAAI,SAAS,MAAM,WAAW,MAAM;AAAA,EACtC,SAAS,OAAO;AACd,WAAO,IAAI,KAAK;AAAA,EAClB;AACA,SAAO,IAAI;AACb;AASO,SAAS,mBAAmB,QAAmC;AACpE,MAAI,CAAC,SAAS,MAAM,GAAG;AACrB,UAAM,UAAU,cAAc;AAAA,MAC5B,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAEA,QAAM,EAAE,QAAQ,QAAQ,IAAI;AAE5B,MAAI,CAAC,UAAU,OAAO,WAAW,YAAY,WAAW,IAAI;AAC1D,UAAM,UAAU,cAAc;AAAA,MAC5B,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAEA,MAAI,CAAC,SAAS,OAAO,GAAG;AACtB,UAAM,UAAU,cAAc;AAAA,MAC5B,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAEA,SAAO;AACT","sourcesContent":["import type {\n JsonRpcEngineEndCallback,\n JsonRpcEngineNextCallback,\n} from '@metamask/json-rpc-engine';\nimport type { PermittedHandlerExport } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type { InvokeSnapParams, InvokeSnapResult } from '@metamask/snaps-sdk';\nimport type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';\nimport { isObject } from '@metamask/utils';\n\n/**\n * `wallet_invokeSnap` attempts to invoke an RPC method of the specified Snap.\n */\nexport const invokeSnapSugarHandler: PermittedHandlerExport<\n InvokeSnapSugarHooks,\n InvokeSnapParams,\n InvokeSnapResult\n> = {\n methodNames: ['wallet_invokeSnap'],\n implementation: invokeSnapSugar,\n hookNames: {\n invokeSnap: true,\n },\n};\n\nexport type InvokeSnapSugarHooks = {\n invokeSnap: (params: InvokeSnapParams) => Promise<InvokeSnapResult>;\n};\n\n/**\n * The `wallet_invokeSnap` method implementation.\n * Effectively calls `wallet_snap` under the hood.\n *\n * @param req - The JSON-RPC request object.\n * @param res - The JSON-RPC response object.\n * @param _next - The `json-rpc-engine` \"next\" callback.\n * @param end - The `json-rpc-engine` \"end\" callback.\n * @param hooks - The RPC method hooks.\n * @param hooks.invokeSnap - A function to invoke a snap designated by its parameters,\n * bound to the requesting origin.\n * @returns Nothing.\n * @throws If the params are invalid.\n */\nexport async function invokeSnapSugar(\n req: JsonRpcRequest<InvokeSnapParams>,\n res: PendingJsonRpcResponse<InvokeSnapResult>,\n _next: JsonRpcEngineNextCallback,\n end: JsonRpcEngineEndCallback,\n { invokeSnap }: InvokeSnapSugarHooks,\n): Promise<void> {\n try {\n const params = getValidatedParams(req.params);\n res.result = await invokeSnap(params);\n } catch (error) {\n return end(error);\n }\n return end();\n}\n\n/**\n * Validates the wallet_invokeSnap method `params` and returns them cast to the correct\n * type. Throws if validation fails.\n *\n * @param params - The unvalidated params object from the method request.\n * @returns The validated method parameter object.\n */\nexport function getValidatedParams(params: unknown): InvokeSnapParams {\n if (!isObject(params)) {\n throw rpcErrors.invalidParams({\n message: 'Expected params to be a single object.',\n });\n }\n\n const { snapId, request } = params;\n\n if (!snapId || typeof snapId !== 'string' || snapId === '') {\n throw rpcErrors.invalidParams({\n message: 'Must specify a valid snap ID.',\n });\n }\n\n if (!isObject(request)) {\n throw rpcErrors.invalidParams({\n message: 'Expected request to be a single object.',\n });\n }\n\n return params as InvokeSnapParams;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkDLVPMPRZjs = require('./chunk-DLVPMPRZ.js');
|
|
4
4
|
|
|
5
5
|
// src/permitted/invokeKeyring.ts
|
|
6
6
|
var _rpcerrors = require('@metamask/rpc-errors');
|
|
@@ -25,7 +25,7 @@ async function invokeKeyringImplementation(req, res, _next, end, {
|
|
|
25
25
|
}) {
|
|
26
26
|
let params;
|
|
27
27
|
try {
|
|
28
|
-
params =
|
|
28
|
+
params = _chunkDLVPMPRZjs.getValidatedParams.call(void 0, req.params);
|
|
29
29
|
} catch (error) {
|
|
30
30
|
return end(error);
|
|
31
31
|
}
|
|
@@ -75,4 +75,4 @@ async function invokeKeyringImplementation(req, res, _next, end, {
|
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
exports.invokeKeyringHandler = invokeKeyringHandler;
|
|
78
|
-
//# sourceMappingURL=chunk-
|
|
78
|
+
//# sourceMappingURL=chunk-E27BGHCR.js.map
|
|
@@ -15,10 +15,10 @@ import {
|
|
|
15
15
|
} from "./chunk-LR7UR4YU.mjs";
|
|
16
16
|
import {
|
|
17
17
|
getBip32EntropyBuilder
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-LXJBBRQ4.mjs";
|
|
19
19
|
import {
|
|
20
20
|
getBip32PublicKeyBuilder
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-R3DRYUNH.mjs";
|
|
22
22
|
import {
|
|
23
23
|
invokeSnapBuilder
|
|
24
24
|
} from "./chunk-VVBTXSID.mjs";
|
|
@@ -40,4 +40,4 @@ export {
|
|
|
40
40
|
caveatSpecifications,
|
|
41
41
|
caveatMappers
|
|
42
42
|
};
|
|
43
|
-
//# sourceMappingURL=chunk-
|
|
43
|
+
//# sourceMappingURL=chunk-FR26QD3N.mjs.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-LR7UR4YU.mjs";
|
|
4
4
|
import {
|
|
5
5
|
getEntropyBuilder
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-KIXPIIY5.mjs";
|
|
7
7
|
import {
|
|
8
8
|
getLocaleBuilder
|
|
9
9
|
} from "./chunk-IZYMBIBD.mjs";
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "./chunk-E6WUMFQT.mjs";
|
|
13
13
|
import {
|
|
14
14
|
manageStateBuilder
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-TE4W25CA.mjs";
|
|
16
16
|
import {
|
|
17
17
|
notifyBuilder
|
|
18
18
|
} from "./chunk-JWDQUKKU.mjs";
|
|
@@ -21,10 +21,10 @@ import {
|
|
|
21
21
|
} from "./chunk-X247BMMW.mjs";
|
|
22
22
|
import {
|
|
23
23
|
getBip32EntropyBuilder
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-LXJBBRQ4.mjs";
|
|
25
25
|
import {
|
|
26
26
|
getBip32PublicKeyBuilder
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-R3DRYUNH.mjs";
|
|
28
28
|
import {
|
|
29
29
|
invokeSnapBuilder
|
|
30
30
|
} from "./chunk-VVBTXSID.mjs";
|
|
@@ -46,4 +46,4 @@ var restrictedMethodPermissionBuilders = {
|
|
|
46
46
|
export {
|
|
47
47
|
restrictedMethodPermissionBuilders
|
|
48
48
|
};
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
49
|
+
//# sourceMappingURL=chunk-I3QG3QZL.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk33MTKZ4Hjs = require('./chunk-33MTKZ4H.js');
|
|
4
4
|
|
|
5
5
|
// src/restricted/getBip32Entropy.ts
|
|
6
6
|
var _permissioncontroller = require('@metamask/permission-controller');
|
|
@@ -41,7 +41,7 @@ function getBip32EntropyImplementation({
|
|
|
41
41
|
await getUnlockPromise(true);
|
|
42
42
|
const { params } = args;
|
|
43
43
|
_utils.assert.call(void 0, params);
|
|
44
|
-
const node = await
|
|
44
|
+
const node = await _chunk33MTKZ4Hjs.getNode.call(void 0, {
|
|
45
45
|
curve: params.curve,
|
|
46
46
|
path: params.path,
|
|
47
47
|
secretRecoveryPhrase: await getMnemonic()
|
|
@@ -54,4 +54,4 @@ function getBip32EntropyImplementation({
|
|
|
54
54
|
|
|
55
55
|
|
|
56
56
|
exports.getBip32EntropyBuilder = getBip32EntropyBuilder; exports.getBip32EntropyImplementation = getBip32EntropyImplementation;
|
|
57
|
-
//# sourceMappingURL=chunk-
|
|
57
|
+
//# sourceMappingURL=chunk-IE6EHYEG.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk33MTKZ4Hjs = require('./chunk-33MTKZ4H.js');
|
|
4
4
|
|
|
5
5
|
// src/restricted/getEntropy.ts
|
|
6
6
|
var _permissioncontroller = require('@metamask/permission-controller');
|
|
@@ -51,7 +51,7 @@ function getEntropyImplementation({
|
|
|
51
51
|
);
|
|
52
52
|
await getUnlockPromise(true);
|
|
53
53
|
const mnemonicPhrase = await getMnemonic();
|
|
54
|
-
return
|
|
54
|
+
return _chunk33MTKZ4Hjs.deriveEntropy.call(void 0, {
|
|
55
55
|
input: origin,
|
|
56
56
|
salt: params.salt,
|
|
57
57
|
mnemonicPhrase,
|
|
@@ -64,4 +64,4 @@ function getEntropyImplementation({
|
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
exports.GetEntropyArgsStruct = GetEntropyArgsStruct; exports.getEntropyBuilder = getEntropyBuilder;
|
|
67
|
-
//# sourceMappingURL=chunk-
|
|
67
|
+
//# sourceMappingURL=chunk-IVD2ORDS.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
deriveEntropy
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-W33UWNA2.mjs";
|
|
4
4
|
|
|
5
5
|
// src/restricted/getEntropy.ts
|
|
6
6
|
import { PermissionType, SubjectType } from "@metamask/permission-controller";
|
|
@@ -64,4 +64,4 @@ export {
|
|
|
64
64
|
GetEntropyArgsStruct,
|
|
65
65
|
getEntropyBuilder
|
|
66
66
|
};
|
|
67
|
-
//# sourceMappingURL=chunk-
|
|
67
|
+
//# sourceMappingURL=chunk-KIXPIIY5.mjs.map
|
|
@@ -15,10 +15,10 @@ var _chunkZPK4THX4js = require('./chunk-ZPK4THX4.js');
|
|
|
15
15
|
var _chunkVUA6ICJOjs = require('./chunk-VUA6ICJO.js');
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _chunkIE6EHYEGjs = require('./chunk-IE6EHYEG.js');
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunk4BPNRCZJjs = require('./chunk-4BPNRCZJ.js');
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
var _chunkFFHVA6PPjs = require('./chunk-FFHVA6PP.js');
|
|
@@ -30,8 +30,8 @@ var caveatSpecifications = {
|
|
|
30
30
|
..._chunkZPK4THX4js.SnapIdsCaveatSpecification
|
|
31
31
|
};
|
|
32
32
|
var caveatMappers = {
|
|
33
|
-
[
|
|
34
|
-
[
|
|
33
|
+
[_chunkIE6EHYEGjs.getBip32EntropyBuilder.targetName]: _chunkVHY3NATPjs.permittedDerivationPathsCaveatMapper,
|
|
34
|
+
[_chunk4BPNRCZJjs.getBip32PublicKeyBuilder.targetName]: _chunkVHY3NATPjs.permittedDerivationPathsCaveatMapper,
|
|
35
35
|
[_chunkVUA6ICJOjs.getBip44EntropyBuilder.targetName]: _chunk2KTJCF3Cjs.permittedCoinTypesCaveatMapper,
|
|
36
36
|
[_chunkFFHVA6PPjs.invokeSnapBuilder.targetName]: _chunkZPK4THX4js.snapIdsCaveatMapper
|
|
37
37
|
};
|
|
@@ -40,4 +40,4 @@ var caveatMappers = {
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
exports.caveatSpecifications = caveatSpecifications; exports.caveatMappers = caveatMappers;
|
|
43
|
-
//# sourceMappingURL=chunk-
|
|
43
|
+
//# sourceMappingURL=chunk-LLH2T5NT.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getNode
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-W33UWNA2.mjs";
|
|
4
4
|
|
|
5
5
|
// src/restricted/getBip32Entropy.ts
|
|
6
6
|
import { PermissionType, SubjectType } from "@metamask/permission-controller";
|
|
@@ -54,4 +54,4 @@ export {
|
|
|
54
54
|
getBip32EntropyBuilder,
|
|
55
55
|
getBip32EntropyImplementation
|
|
56
56
|
};
|
|
57
|
-
//# sourceMappingURL=chunk-
|
|
57
|
+
//# sourceMappingURL=chunk-LXJBBRQ4.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk33MTKZ4Hjs = require('./chunk-33MTKZ4H.js');
|
|
4
4
|
|
|
5
5
|
// src/restricted/manageState.ts
|
|
6
6
|
var _permissioncontroller = require('@metamask/permission-controller');
|
|
@@ -38,7 +38,7 @@ async function getEncryptionEntropy({
|
|
|
38
38
|
mnemonicPhrase,
|
|
39
39
|
snapId
|
|
40
40
|
}) {
|
|
41
|
-
return await
|
|
41
|
+
return await _chunk33MTKZ4Hjs.deriveEntropy.call(void 0, {
|
|
42
42
|
mnemonicPhrase,
|
|
43
43
|
input: snapId,
|
|
44
44
|
salt: STATE_ENCRYPTION_SALT,
|
|
@@ -140,4 +140,4 @@ function getValidatedParams(params, method, storageSizeLimit = STORAGE_SIZE_LIMI
|
|
|
140
140
|
|
|
141
141
|
|
|
142
142
|
exports.STATE_ENCRYPTION_SALT = STATE_ENCRYPTION_SALT; exports.specificationBuilder = specificationBuilder; exports.manageStateBuilder = manageStateBuilder; exports.STORAGE_SIZE_LIMIT = STORAGE_SIZE_LIMIT; exports.getEncryptionEntropy = getEncryptionEntropy; exports.getManageStateImplementation = getManageStateImplementation; exports.getValidatedParams = getValidatedParams;
|
|
143
|
-
//# sourceMappingURL=chunk-
|
|
143
|
+
//# sourceMappingURL=chunk-M2JQCKR7.js.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunkVUA6ICJOjs = require('./chunk-VUA6ICJO.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkIVD2ORDSjs = require('./chunk-IVD2ORDS.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkSYUGPLEPjs = require('./chunk-SYUGPLEP.js');
|
|
@@ -12,7 +12,7 @@ var _chunkSYUGPLEPjs = require('./chunk-SYUGPLEP.js');
|
|
|
12
12
|
var _chunkP74WXDY4js = require('./chunk-P74WXDY4.js');
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkM2JQCKR7js = require('./chunk-M2JQCKR7.js');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
var _chunkQDZAWH6Fjs = require('./chunk-QDZAWH6F.js');
|
|
@@ -21,10 +21,10 @@ var _chunkQDZAWH6Fjs = require('./chunk-QDZAWH6F.js');
|
|
|
21
21
|
var _chunkI7DR6BFOjs = require('./chunk-I7DR6BFO.js');
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _chunkIE6EHYEGjs = require('./chunk-IE6EHYEG.js');
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var _chunk4BPNRCZJjs = require('./chunk-4BPNRCZJ.js');
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
var _chunkFFHVA6PPjs = require('./chunk-FFHVA6PP.js');
|
|
@@ -32,12 +32,12 @@ var _chunkFFHVA6PPjs = require('./chunk-FFHVA6PP.js');
|
|
|
32
32
|
// src/restricted/index.ts
|
|
33
33
|
var restrictedMethodPermissionBuilders = {
|
|
34
34
|
[_chunkI7DR6BFOjs.dialogBuilder.targetName]: _chunkI7DR6BFOjs.dialogBuilder,
|
|
35
|
-
[
|
|
36
|
-
[
|
|
35
|
+
[_chunkIE6EHYEGjs.getBip32EntropyBuilder.targetName]: _chunkIE6EHYEGjs.getBip32EntropyBuilder,
|
|
36
|
+
[_chunk4BPNRCZJjs.getBip32PublicKeyBuilder.targetName]: _chunk4BPNRCZJjs.getBip32PublicKeyBuilder,
|
|
37
37
|
[_chunkVUA6ICJOjs.getBip44EntropyBuilder.targetName]: _chunkVUA6ICJOjs.getBip44EntropyBuilder,
|
|
38
|
-
[
|
|
38
|
+
[_chunkIVD2ORDSjs.getEntropyBuilder.targetName]: _chunkIVD2ORDSjs.getEntropyBuilder,
|
|
39
39
|
[_chunkFFHVA6PPjs.invokeSnapBuilder.targetName]: _chunkFFHVA6PPjs.invokeSnapBuilder,
|
|
40
|
-
[
|
|
40
|
+
[_chunkM2JQCKR7js.manageStateBuilder.targetName]: _chunkM2JQCKR7js.manageStateBuilder,
|
|
41
41
|
[_chunkQDZAWH6Fjs.notifyBuilder.targetName]: _chunkQDZAWH6Fjs.notifyBuilder,
|
|
42
42
|
[_chunkP74WXDY4js.manageAccountsBuilder.targetName]: _chunkP74WXDY4js.manageAccountsBuilder,
|
|
43
43
|
[_chunkSYUGPLEPjs.getLocaleBuilder.targetName]: _chunkSYUGPLEPjs.getLocaleBuilder
|
|
@@ -46,4 +46,4 @@ var restrictedMethodPermissionBuilders = {
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
exports.restrictedMethodPermissionBuilders = restrictedMethodPermissionBuilders;
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
49
|
+
//# sourceMappingURL=chunk-O2VSIMDY.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkO2VSIMDYjs = require('./chunk-O2VSIMDY.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkLLH2T5NTjs = require('./chunk-LLH2T5NT.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunk33MTKZ4Hjs = require('./chunk-33MTKZ4H.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
@@ -17,8 +17,8 @@ var _utils = require('@metamask/utils');
|
|
|
17
17
|
function processSnapPermissions(initialPermissions) {
|
|
18
18
|
return Object.fromEntries(
|
|
19
19
|
Object.entries(initialPermissions).map(([initialPermission, value]) => {
|
|
20
|
-
if (_utils.hasProperty.call(void 0,
|
|
21
|
-
return [initialPermission,
|
|
20
|
+
if (_utils.hasProperty.call(void 0, _chunkLLH2T5NTjs.caveatMappers, initialPermission)) {
|
|
21
|
+
return [initialPermission, _chunkLLH2T5NTjs.caveatMappers[initialPermission](value)];
|
|
22
22
|
} else if (_utils.hasProperty.call(void 0, _chunkJRSPKOFGjs.endowmentCaveatMappers, initialPermission)) {
|
|
23
23
|
return [
|
|
24
24
|
initialPermission,
|
|
@@ -38,11 +38,11 @@ var buildSnapEndowmentSpecifications = (excludedEndowments) => Object.values(_ch
|
|
|
38
38
|
}
|
|
39
39
|
return allSpecifications;
|
|
40
40
|
}, {});
|
|
41
|
-
var buildSnapRestrictedMethodSpecifications = (excludedPermissions, hooks) => Object.values(
|
|
41
|
+
var buildSnapRestrictedMethodSpecifications = (excludedPermissions, hooks) => Object.values(_chunkO2VSIMDYjs.restrictedMethodPermissionBuilders).reduce((specifications, { targetName, specificationBuilder, methodHooks }) => {
|
|
42
42
|
if (!excludedPermissions.includes(targetName)) {
|
|
43
43
|
specifications[targetName] = specificationBuilder({
|
|
44
44
|
// @ts-expect-error The selectHooks type is wonky
|
|
45
|
-
methodHooks:
|
|
45
|
+
methodHooks: _chunk33MTKZ4Hjs.selectHooks.call(void 0,
|
|
46
46
|
hooks,
|
|
47
47
|
methodHooks
|
|
48
48
|
)
|
|
@@ -56,4 +56,4 @@ var buildSnapRestrictedMethodSpecifications = (excludedPermissions, hooks) => Ob
|
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
exports.processSnapPermissions = processSnapPermissions; exports.buildSnapEndowmentSpecifications = buildSnapEndowmentSpecifications; exports.buildSnapRestrictedMethodSpecifications = buildSnapRestrictedMethodSpecifications;
|
|
59
|
-
//# sourceMappingURL=chunk-
|
|
59
|
+
//# sourceMappingURL=chunk-QAKSH24Z.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getNode
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-W33UWNA2.mjs";
|
|
4
4
|
|
|
5
5
|
// src/restricted/getBip32PublicKey.ts
|
|
6
6
|
import { PermissionType, SubjectType } from "@metamask/permission-controller";
|
|
@@ -8,15 +8,16 @@ import { rpcErrors } from "@metamask/rpc-errors";
|
|
|
8
8
|
import {
|
|
9
9
|
bip32entropy,
|
|
10
10
|
Bip32PathStruct,
|
|
11
|
+
CurveStruct,
|
|
11
12
|
SnapCaveatType
|
|
12
13
|
} from "@metamask/snaps-utils";
|
|
13
14
|
import { assertStruct } from "@metamask/utils";
|
|
14
|
-
import { boolean,
|
|
15
|
+
import { boolean, object, optional } from "superstruct";
|
|
15
16
|
var targetName = "snap_getBip32PublicKey";
|
|
16
17
|
var Bip32PublicKeyArgsStruct = bip32entropy(
|
|
17
18
|
object({
|
|
18
19
|
path: Bip32PathStruct,
|
|
19
|
-
curve:
|
|
20
|
+
curve: CurveStruct,
|
|
20
21
|
compressed: optional(boolean())
|
|
21
22
|
})
|
|
22
23
|
);
|
|
@@ -75,4 +76,4 @@ export {
|
|
|
75
76
|
getBip32PublicKeyBuilder,
|
|
76
77
|
getBip32PublicKeyImplementation
|
|
77
78
|
};
|
|
78
|
-
//# sourceMappingURL=chunk-
|
|
79
|
+
//# sourceMappingURL=chunk-R3DRYUNH.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/restricted/getBip32PublicKey.ts"],"sourcesContent":["import type {\n PermissionSpecificationBuilder,\n PermissionValidatorConstraint,\n RestrictedMethodOptions,\n ValidPermissionSpecification,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type {\n GetBip32PublicKeyParams,\n GetBip32PublicKeyResult,\n} from '@metamask/snaps-sdk';\nimport {\n bip32entropy,\n Bip32PathStruct,\n CurveStruct,\n SnapCaveatType,\n} from '@metamask/snaps-utils';\nimport type { NonEmptyArray } from '@metamask/utils';\nimport { assertStruct } from '@metamask/utils';\nimport { boolean, object, optional } from 'superstruct';\n\nimport type { MethodHooksObject } from '../utils';\nimport { getNode } from '../utils';\n\nconst targetName = 'snap_getBip32PublicKey';\n\nexport type GetBip32PublicKeyMethodHooks = {\n /**\n * @returns The mnemonic of the user's primary keyring.\n */\n getMnemonic: () => Promise<Uint8Array>;\n\n /**\n * Waits for the extension to be unlocked.\n *\n * @returns A promise that resolves once the extension is unlocked.\n */\n getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;\n};\n\ntype GetBip32PublicKeySpecificationBuilderOptions = {\n methodHooks: GetBip32PublicKeyMethodHooks;\n};\n\ntype GetBip32PublicKeySpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof targetName;\n methodImplementation: ReturnType<typeof getBip32PublicKeyImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n validator: PermissionValidatorConstraint;\n}>;\n\nexport const Bip32PublicKeyArgsStruct = bip32entropy(\n object({\n path: Bip32PathStruct,\n curve: CurveStruct,\n compressed: optional(boolean()),\n }),\n);\n\n/**\n * The specification builder for the `snap_getBip32PublicKey` permission.\n * `snap_getBip32PublicKey` lets the Snap retrieve public keys for a particular\n * BIP-32 node.\n *\n * @param options - The specification builder options.\n * @param options.methodHooks - The RPC method hooks needed by the method implementation.\n * @returns The specification for the `snap_getBip32PublicKey` permission.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n GetBip32PublicKeySpecificationBuilderOptions,\n GetBip32PublicKeySpecification\n> = ({ methodHooks }: GetBip32PublicKeySpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName,\n allowedCaveats: [SnapCaveatType.PermittedDerivationPaths],\n methodImplementation: getBip32PublicKeyImplementation(methodHooks),\n validator: ({ caveats }) => {\n if (\n caveats?.length !== 1 ||\n caveats[0].type !== SnapCaveatType.PermittedDerivationPaths\n ) {\n throw rpcErrors.invalidParams({\n message: `Expected a single \"${SnapCaveatType.PermittedDerivationPaths}\" caveat.`,\n });\n }\n },\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<GetBip32PublicKeyMethodHooks> = {\n getMnemonic: true,\n getUnlockPromise: true,\n};\n\nexport const getBip32PublicKeyBuilder = Object.freeze({\n targetName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_getBip32PublicKey`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getMnemonic - A function to retrieve the Secret Recovery Phrase of the user.\n * @param hooks.getUnlockPromise - A function that resolves once the MetaMask extension is unlocked\n * and prompts the user to unlock their MetaMask if it is locked.\n * @returns The method implementation which returns a public key.\n * @throws If the params are invalid.\n */\nexport function getBip32PublicKeyImplementation({\n getMnemonic,\n getUnlockPromise,\n}: GetBip32PublicKeyMethodHooks) {\n return async function getBip32PublicKey(\n args: RestrictedMethodOptions<GetBip32PublicKeyParams>,\n ): Promise<GetBip32PublicKeyResult> {\n await getUnlockPromise(true);\n\n assertStruct(\n args.params,\n Bip32PublicKeyArgsStruct,\n 'Invalid BIP-32 public key params',\n rpcErrors.invalidParams,\n );\n\n const { params } = args;\n const node = await getNode({\n curve: params.curve,\n path: params.path,\n secretRecoveryPhrase: await getMnemonic(),\n });\n\n if (params.compressed) {\n return node.compressedPublicKey;\n }\n\n return node.publicKey;\n };\n}\n"],"mappings":";;;;;AAMA,SAAS,gBAAgB,mBAAmB;AAC5C,SAAS,iBAAiB;AAK1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,oBAAoB;AAC7B,SAAS,SAAS,QAAQ,gBAAgB;AAK1C,IAAM,aAAa;AA4BZ,IAAM,2BAA2B;AAAA,EACtC,OAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,YAAY,SAAS,QAAQ,CAAC;AAAA,EAChC,CAAC;AACH;AAWA,IAAM,uBAIF,CAAC,EAAE,aAAAA,aAAY,MAAoD;AACrE,SAAO;AAAA,IACL,gBAAgB,eAAe;AAAA,IAC/B;AAAA,IACA,gBAAgB,CAAC,eAAe,wBAAwB;AAAA,IACxD,sBAAsB,gCAAgCA,YAAW;AAAA,IACjE,WAAW,CAAC,EAAE,QAAQ,MAAM;AAC1B,UACE,SAAS,WAAW,KACpB,QAAQ,CAAC,EAAE,SAAS,eAAe,0BACnC;AACA,cAAM,UAAU,cAAc;AAAA,UAC5B,SAAS,sBAAsB,eAAe,wBAAwB;AAAA,QACxE,CAAC;AAAA,MACH;AAAA,IACF;AAAA,IACA,cAAc,CAAC,YAAY,IAAI;AAAA,EACjC;AACF;AAEA,IAAM,cAA+D;AAAA,EACnE,aAAa;AAAA,EACb,kBAAkB;AACpB;AAEO,IAAM,2BAA2B,OAAO,OAAO;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AACF,CAAU;AAYH,SAAS,gCAAgC;AAAA,EAC9C;AAAA,EACA;AACF,GAAiC;AAC/B,SAAO,eAAe,kBACpB,MACkC;AAClC,UAAM,iBAAiB,IAAI;AAE3B;AAAA,MACE,KAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA,UAAU;AAAA,IACZ;AAEA,UAAM,EAAE,OAAO,IAAI;AACnB,UAAM,OAAO,MAAM,QAAQ;AAAA,MACzB,OAAO,OAAO;AAAA,MACd,MAAM,OAAO;AAAA,MACb,sBAAsB,MAAM,YAAY;AAAA,IAC1C,CAAC;AAED,QAAI,OAAO,YAAY;AACrB,aAAO,KAAK;AAAA,IACd;AAEA,WAAO,KAAK;AAAA,EACd;AACF;","names":["methodHooks"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
invokeKeyringHandler
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2L2ATCIK.mjs";
|
|
4
4
|
import {
|
|
5
5
|
invokeSnapSugarHandler
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-2CTOCP34.mjs";
|
|
7
7
|
import {
|
|
8
8
|
requestSnapsHandler
|
|
9
9
|
} from "./chunk-MXPVC2XP.mjs";
|
|
@@ -48,4 +48,4 @@ export {
|
|
|
48
48
|
methodHandlers,
|
|
49
49
|
handlers
|
|
50
50
|
};
|
|
51
|
-
//# sourceMappingURL=chunk-
|
|
51
|
+
//# sourceMappingURL=chunk-S46RTIDR.mjs.map
|