@metamask/snaps-rpc-methods 5.0.0 → 7.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 +21 -3
- package/dist/chunk-2A5M65V3.js +21 -0
- package/dist/chunk-2A5M65V3.js.map +1 -0
- package/dist/chunk-2IL6T3EX.js +18 -0
- package/dist/chunk-2IL6T3EX.js.map +1 -0
- package/dist/chunk-2N2PZJDJ.mjs +105 -0
- package/dist/chunk-2N2PZJDJ.mjs.map +1 -0
- package/dist/chunk-2QEA2YZM.mjs +23 -0
- package/dist/chunk-2QEA2YZM.mjs.map +1 -0
- package/dist/chunk-2TYDIMR6.js +78 -0
- package/dist/chunk-2TYDIMR6.js.map +1 -0
- package/dist/chunk-2WCLK3LN.mjs +115 -0
- package/dist/chunk-2WCLK3LN.mjs.map +1 -0
- package/dist/chunk-3CSLIOIY.mjs +43 -0
- package/dist/chunk-3CSLIOIY.mjs.map +1 -0
- package/dist/chunk-3DWRS3YG.mjs +49 -0
- package/dist/chunk-3DWRS3YG.mjs.map +1 -0
- package/dist/chunk-3FKD2O7M.js +151 -0
- package/dist/chunk-3FKD2O7M.js.map +1 -0
- package/dist/chunk-4ALFLY5D.js +105 -0
- package/dist/chunk-4ALFLY5D.js.map +1 -0
- package/dist/chunk-4Z4X6EJP.mjs +67 -0
- package/dist/chunk-4Z4X6EJP.mjs.map +1 -0
- package/dist/chunk-5HIIIAIS.mjs +57 -0
- package/dist/chunk-5HIIIAIS.mjs.map +1 -0
- package/dist/chunk-632BZ6JY.js +83 -0
- package/dist/{cjs/utils.js.map → chunk-632BZ6JY.js.map} +1 -1
- package/dist/chunk-6DUTJBD2.mjs +82 -0
- package/dist/chunk-6DUTJBD2.mjs.map +1 -0
- package/dist/chunk-6PXDUIXN.js +67 -0
- package/dist/chunk-6PXDUIXN.js.map +1 -0
- package/dist/chunk-72V4CPGO.mjs +23 -0
- package/dist/chunk-72V4CPGO.mjs.map +1 -0
- package/dist/chunk-7O63CIBT.js +42 -0
- package/dist/chunk-7O63CIBT.js.map +1 -0
- package/dist/chunk-ABFJRV6Q.js +68 -0
- package/dist/chunk-ABFJRV6Q.js.map +1 -0
- package/dist/chunk-BZIPLSKM.mjs +39 -0
- package/dist/chunk-BZIPLSKM.mjs.map +1 -0
- package/dist/chunk-CIIMO4C2.js +45 -0
- package/dist/chunk-CIIMO4C2.js.map +1 -0
- package/dist/chunk-DBYI25UR.js +23 -0
- package/dist/chunk-DBYI25UR.js.map +1 -0
- package/dist/chunk-DDGDVWAW.js +45 -0
- package/dist/chunk-DDGDVWAW.js.map +1 -0
- package/dist/chunk-DR63Z4PV.mjs +83 -0
- package/dist/chunk-DR63Z4PV.mjs.map +1 -0
- package/dist/chunk-E2G25QVG.js +119 -0
- package/dist/chunk-E2G25QVG.js.map +1 -0
- package/dist/chunk-E4HGQWSS.js +43 -0
- package/dist/chunk-E4HGQWSS.js.map +1 -0
- package/dist/chunk-EAL6AH74.js +67 -0
- package/dist/chunk-EAL6AH74.js.map +1 -0
- package/dist/chunk-EB6OXVFN.mjs +52 -0
- package/dist/chunk-EB6OXVFN.mjs.map +1 -0
- package/dist/chunk-EKB7QNFO.mjs +54 -0
- package/dist/chunk-EKB7QNFO.mjs.map +1 -0
- package/dist/chunk-EPNGNDRH.mjs +80 -0
- package/dist/chunk-EPNGNDRH.mjs.map +1 -0
- package/dist/chunk-F5BEVZOB.js +47 -0
- package/dist/chunk-F5BEVZOB.js.map +1 -0
- package/dist/chunk-FMUQOZIO.js +57 -0
- package/dist/chunk-FMUQOZIO.js.map +1 -0
- package/dist/chunk-H45CGE4Z.js +23 -0
- package/dist/chunk-H45CGE4Z.js.map +1 -0
- package/dist/chunk-HIYXSQ6K.mjs +188 -0
- package/dist/chunk-HIYXSQ6K.mjs.map +1 -0
- package/dist/chunk-HLF4WCE4.mjs +20 -0
- package/dist/chunk-HLF4WCE4.mjs.map +1 -0
- package/dist/chunk-HODDBRLQ.js +75 -0
- package/dist/chunk-HODDBRLQ.js.map +1 -0
- package/dist/chunk-HOXOD5RL.mjs +68 -0
- package/dist/chunk-HOXOD5RL.mjs.map +1 -0
- package/dist/chunk-I5H5ZZRC.js +80 -0
- package/dist/chunk-I5H5ZZRC.js.map +1 -0
- package/dist/chunk-IDRDPYAN.js +70 -0
- package/dist/chunk-IDRDPYAN.js.map +1 -0
- package/dist/chunk-JEEKFTAL.mjs +59 -0
- package/dist/chunk-JEEKFTAL.mjs.map +1 -0
- package/dist/chunk-JPUJWFBS.js +115 -0
- package/dist/chunk-JPUJWFBS.js.map +1 -0
- package/dist/chunk-JURJUHQB.mjs +70 -0
- package/dist/chunk-JURJUHQB.mjs.map +1 -0
- package/dist/chunk-JV26U22G.js +52 -0
- package/dist/chunk-JV26U22G.js.map +1 -0
- package/dist/chunk-K73RKHXA.js +20 -0
- package/dist/chunk-K73RKHXA.js.map +1 -0
- package/dist/chunk-KDLWQGV3.js +74 -0
- package/dist/chunk-KDLWQGV3.js.map +1 -0
- package/dist/chunk-KE74K2JM.js +59 -0
- package/dist/chunk-KE74K2JM.js.map +1 -0
- package/dist/chunk-KVHYDTGR.js +1 -0
- package/dist/chunk-KVHYDTGR.js.map +1 -0
- package/dist/chunk-L7MGGL7Q.mjs +43 -0
- package/dist/chunk-L7MGGL7Q.mjs.map +1 -0
- package/dist/chunk-LITIVHN4.js +73 -0
- package/dist/chunk-LITIVHN4.js.map +1 -0
- package/dist/chunk-LU3J2EYE.js +51 -0
- package/dist/chunk-LU3J2EYE.js.map +1 -0
- package/dist/chunk-LX37AMSK.mjs +78 -0
- package/dist/chunk-LX37AMSK.mjs.map +1 -0
- package/dist/chunk-LYOKCYHO.mjs +1 -0
- package/dist/chunk-LYOKCYHO.mjs.map +1 -0
- package/dist/chunk-MDJZ4K3U.mjs +45 -0
- package/dist/chunk-MDJZ4K3U.mjs.map +1 -0
- package/dist/chunk-MVPKNRLA.mjs +21 -0
- package/dist/chunk-MVPKNRLA.mjs.map +1 -0
- package/dist/chunk-MYMH4S2N.mjs +23 -0
- package/dist/chunk-MYMH4S2N.mjs.map +1 -0
- package/dist/chunk-NE2GDZGZ.mjs +67 -0
- package/dist/chunk-NE2GDZGZ.mjs.map +1 -0
- package/dist/chunk-NTDD6M3B.mjs +32 -0
- package/dist/chunk-NTDD6M3B.mjs.map +1 -0
- package/dist/chunk-NUKEBOOL.js +78 -0
- package/dist/chunk-NUKEBOOL.js.map +1 -0
- package/dist/chunk-OMP4SFLK.js +1 -0
- package/dist/chunk-OMP4SFLK.js.map +1 -0
- package/dist/chunk-OU3QPU6E.mjs +45 -0
- package/dist/chunk-OU3QPU6E.mjs.map +1 -0
- package/dist/chunk-OUD66G6O.mjs +74 -0
- package/dist/chunk-OUD66G6O.mjs.map +1 -0
- package/dist/chunk-PEMZWIHQ.js +39 -0
- package/dist/chunk-PEMZWIHQ.js.map +1 -0
- package/dist/chunk-PSAM7MJM.mjs +78 -0
- package/dist/chunk-PSAM7MJM.mjs.map +1 -0
- package/dist/chunk-RC7LBS3H.js +35 -0
- package/dist/chunk-RC7LBS3H.js.map +1 -0
- package/dist/chunk-RHGOSBUT.js +21 -0
- package/dist/chunk-RHGOSBUT.js.map +1 -0
- package/dist/chunk-RKCEAMYH.mjs +18 -0
- package/dist/chunk-RKCEAMYH.mjs.map +1 -0
- package/dist/chunk-RWLBQVYX.mjs +73 -0
- package/dist/chunk-RWLBQVYX.mjs.map +1 -0
- package/dist/chunk-RZDRHJXI.js +23 -0
- package/dist/chunk-RZDRHJXI.js.map +1 -0
- package/dist/chunk-SCXW3FQO.js +49 -0
- package/dist/chunk-SCXW3FQO.js.map +1 -0
- package/dist/chunk-SMWKMPHG.mjs +35 -0
- package/dist/chunk-SMWKMPHG.mjs.map +1 -0
- package/dist/chunk-SXSNJEE7.js +18 -0
- package/dist/chunk-SXSNJEE7.js.map +1 -0
- package/dist/chunk-TNIGT6KN.js +32 -0
- package/dist/chunk-TNIGT6KN.js.map +1 -0
- package/dist/chunk-TRB2LS4N.js +54 -0
- package/dist/chunk-TRB2LS4N.js.map +1 -0
- package/dist/chunk-TZRCALSV.mjs +54 -0
- package/dist/chunk-TZRCALSV.mjs.map +1 -0
- package/dist/chunk-UJZ3HNXS.mjs +23 -0
- package/dist/chunk-UJZ3HNXS.mjs.map +1 -0
- package/dist/chunk-UXVJ7HYO.js +78 -0
- package/dist/{cjs/restricted/getBip32PublicKey.js.map → chunk-UXVJ7HYO.js.map} +1 -1
- package/dist/chunk-UYSXSKML.js +82 -0
- package/dist/chunk-UYSXSKML.js.map +1 -0
- package/dist/chunk-VFI5FR5U.mjs +119 -0
- package/dist/chunk-VFI5FR5U.mjs.map +1 -0
- package/dist/chunk-VRDGSBXX.mjs +78 -0
- package/dist/chunk-VRDGSBXX.mjs.map +1 -0
- package/dist/chunk-VSVVWO3W.mjs +42 -0
- package/dist/chunk-VSVVWO3W.mjs.map +1 -0
- package/dist/chunk-VZBSLVVA.js +23 -0
- package/dist/chunk-VZBSLVVA.js.map +1 -0
- package/dist/chunk-W2VJ5TWL.js +54 -0
- package/dist/chunk-W2VJ5TWL.js.map +1 -0
- package/dist/chunk-WHWFVRFH.js +69 -0
- package/dist/chunk-WHWFVRFH.js.map +1 -0
- package/dist/chunk-WI23VKOX.mjs +21 -0
- package/dist/chunk-WI23VKOX.mjs.map +1 -0
- package/dist/chunk-XAQ2P3BY.js +188 -0
- package/dist/chunk-XAQ2P3BY.js.map +1 -0
- package/dist/chunk-Y5ENHOIY.mjs +47 -0
- package/dist/chunk-Y5ENHOIY.mjs.map +1 -0
- package/dist/chunk-Y6EL5DBH.mjs +75 -0
- package/dist/chunk-Y6EL5DBH.mjs.map +1 -0
- package/dist/chunk-Y7DF3ZHO.mjs +1 -0
- package/dist/chunk-Y7DF3ZHO.mjs.map +1 -0
- package/dist/chunk-YJ3ZFIA7.mjs +51 -0
- package/dist/chunk-YJ3ZFIA7.mjs.map +1 -0
- package/dist/chunk-YK6IFDRN.mjs +151 -0
- package/dist/chunk-YK6IFDRN.mjs.map +1 -0
- package/dist/chunk-YN3OMGA5.mjs +69 -0
- package/dist/chunk-YN3OMGA5.mjs.map +1 -0
- package/dist/chunk-ZLLV3F4G.js +43 -0
- package/dist/chunk-ZLLV3F4G.js.map +1 -0
- package/dist/chunk-ZP3L7LAQ.mjs +18 -0
- package/dist/chunk-ZP3L7LAQ.mjs.map +1 -0
- package/dist/endowments/caveats/generic.js +7 -0
- package/dist/endowments/caveats/generic.js.map +1 -0
- package/dist/endowments/caveats/generic.mjs +7 -0
- package/dist/endowments/caveats/generic.mjs.map +1 -0
- package/dist/endowments/caveats/index.js +18 -0
- package/dist/endowments/caveats/index.js.map +1 -0
- package/dist/endowments/caveats/index.mjs +18 -0
- package/dist/endowments/caveats/index.mjs.map +1 -0
- package/dist/endowments/caveats/requestTime.js +13 -0
- package/dist/endowments/caveats/requestTime.js.map +1 -0
- package/dist/endowments/caveats/requestTime.mjs +13 -0
- package/dist/endowments/caveats/requestTime.mjs.map +1 -0
- package/dist/endowments/cronjob.js +16 -0
- package/dist/endowments/cronjob.js.map +1 -0
- package/dist/endowments/cronjob.mjs +16 -0
- package/dist/endowments/cronjob.mjs.map +1 -0
- package/dist/endowments/enum.js +7 -0
- package/dist/endowments/enum.js.map +1 -0
- package/dist/endowments/enum.mjs +7 -0
- package/dist/endowments/enum.mjs.map +1 -0
- package/dist/endowments/ethereum-provider.js +8 -0
- package/dist/endowments/ethereum-provider.js.map +1 -0
- package/dist/endowments/ethereum-provider.mjs +8 -0
- package/dist/endowments/ethereum-provider.mjs.map +1 -0
- package/dist/endowments/home-page.js +8 -0
- package/dist/endowments/home-page.js.map +1 -0
- package/dist/endowments/home-page.mjs +8 -0
- package/dist/endowments/home-page.mjs.map +1 -0
- package/dist/endowments/index.js +54 -0
- package/dist/endowments/index.js.map +1 -0
- package/dist/endowments/index.mjs +54 -0
- package/dist/endowments/index.mjs.map +1 -0
- package/dist/endowments/keyring.js +17 -0
- package/dist/endowments/keyring.js.map +1 -0
- package/dist/endowments/keyring.mjs +17 -0
- package/dist/endowments/keyring.mjs.map +1 -0
- package/dist/endowments/lifecycle-hooks.js +8 -0
- package/dist/endowments/lifecycle-hooks.js.map +1 -0
- package/dist/endowments/lifecycle-hooks.mjs +8 -0
- package/dist/endowments/lifecycle-hooks.mjs.map +1 -0
- package/dist/endowments/name-lookup.js +19 -0
- package/dist/endowments/name-lookup.js.map +1 -0
- package/dist/endowments/name-lookup.mjs +19 -0
- package/dist/endowments/name-lookup.mjs.map +1 -0
- package/dist/endowments/network-access.js +8 -0
- package/dist/endowments/network-access.js.map +1 -0
- package/dist/endowments/network-access.mjs +8 -0
- package/dist/endowments/network-access.mjs.map +1 -0
- package/dist/endowments/rpc.js +17 -0
- package/dist/endowments/rpc.js.map +1 -0
- package/dist/endowments/rpc.mjs +17 -0
- package/dist/endowments/rpc.mjs.map +1 -0
- package/dist/endowments/signature-insight.js +17 -0
- package/dist/endowments/signature-insight.js.map +1 -0
- package/dist/endowments/signature-insight.mjs +17 -0
- package/dist/endowments/signature-insight.mjs.map +1 -0
- package/dist/endowments/transaction-insight.js +17 -0
- package/dist/endowments/transaction-insight.js.map +1 -0
- package/dist/endowments/transaction-insight.mjs +17 -0
- package/dist/endowments/transaction-insight.mjs.map +1 -0
- package/dist/endowments/web-assembly.js +8 -0
- package/dist/endowments/web-assembly.js.map +1 -0
- package/dist/endowments/web-assembly.mjs +8 -0
- package/dist/endowments/web-assembly.mjs.map +1 -0
- package/dist/index.js +118 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +118 -0
- package/dist/index.mjs.map +1 -0
- package/dist/permissions.js +43 -0
- package/dist/permissions.js.map +1 -0
- package/dist/permissions.mjs +43 -0
- package/dist/permissions.mjs.map +1 -0
- package/dist/permitted/createInterface.js +7 -0
- package/dist/permitted/createInterface.js.map +1 -0
- package/dist/permitted/createInterface.mjs +7 -0
- package/dist/permitted/createInterface.mjs.map +1 -0
- package/dist/permitted/getAllSnaps.js +7 -0
- package/dist/permitted/getAllSnaps.js.map +1 -0
- package/dist/permitted/getAllSnaps.mjs +7 -0
- package/dist/permitted/getAllSnaps.mjs.map +1 -0
- package/dist/permitted/getClientStatus.js +7 -0
- package/dist/permitted/getClientStatus.js.map +1 -0
- package/dist/permitted/getClientStatus.mjs +7 -0
- package/dist/permitted/getClientStatus.mjs.map +1 -0
- package/dist/permitted/getFile.js +9 -0
- package/dist/permitted/getFile.js.map +1 -0
- package/dist/permitted/getFile.mjs +9 -0
- package/dist/permitted/getFile.mjs.map +1 -0
- package/dist/permitted/getInterfaceState.js +7 -0
- package/dist/permitted/getInterfaceState.js.map +1 -0
- package/dist/permitted/getInterfaceState.mjs +7 -0
- package/dist/permitted/getInterfaceState.mjs.map +1 -0
- package/dist/permitted/getSnaps.js +7 -0
- package/dist/permitted/getSnaps.js.map +1 -0
- package/dist/permitted/getSnaps.mjs +7 -0
- package/dist/permitted/getSnaps.mjs.map +1 -0
- package/dist/permitted/handlers.js +20 -0
- package/dist/permitted/handlers.js.map +1 -0
- package/dist/permitted/handlers.mjs +20 -0
- package/dist/permitted/handlers.mjs.map +1 -0
- package/dist/permitted/index.js +26 -0
- package/dist/permitted/index.js.map +1 -0
- package/dist/permitted/index.mjs +26 -0
- package/dist/permitted/index.mjs.map +1 -0
- package/dist/permitted/invokeKeyring.js +8 -0
- package/dist/permitted/invokeKeyring.js.map +1 -0
- package/dist/permitted/invokeKeyring.mjs +8 -0
- package/dist/permitted/invokeKeyring.mjs.map +1 -0
- package/dist/permitted/invokeSnapSugar.js +11 -0
- package/dist/permitted/invokeSnapSugar.js.map +1 -0
- package/dist/permitted/invokeSnapSugar.mjs +11 -0
- package/dist/permitted/invokeSnapSugar.mjs.map +1 -0
- package/dist/permitted/middleware.js +20 -0
- package/dist/permitted/middleware.js.map +1 -0
- package/dist/permitted/middleware.mjs +20 -0
- package/dist/permitted/middleware.mjs.map +1 -0
- package/dist/permitted/requestSnaps.js +12 -0
- package/dist/permitted/requestSnaps.js.map +1 -0
- package/dist/permitted/requestSnaps.mjs +12 -0
- package/dist/permitted/requestSnaps.mjs.map +1 -0
- package/dist/permitted/updateInterface.js +7 -0
- package/dist/permitted/updateInterface.js.map +1 -0
- package/dist/permitted/updateInterface.mjs +7 -0
- package/dist/permitted/updateInterface.mjs.map +1 -0
- package/dist/restricted/caveats/index.js +17 -0
- package/dist/restricted/caveats/index.js.map +1 -0
- package/dist/restricted/caveats/index.mjs +17 -0
- package/dist/restricted/caveats/index.mjs.map +1 -0
- package/dist/restricted/caveats/permittedCoinTypes.js +13 -0
- package/dist/restricted/caveats/permittedCoinTypes.js.map +1 -0
- package/dist/restricted/caveats/permittedCoinTypes.mjs +13 -0
- package/dist/restricted/caveats/permittedCoinTypes.mjs.map +1 -0
- package/dist/restricted/caveats/permittedDerivationPaths.js +13 -0
- package/dist/restricted/caveats/permittedDerivationPaths.js.map +1 -0
- package/dist/restricted/caveats/permittedDerivationPaths.mjs +13 -0
- package/dist/restricted/caveats/permittedDerivationPaths.mjs.map +1 -0
- package/dist/restricted/caveats/snapIds.js +11 -0
- package/dist/restricted/caveats/snapIds.js.map +1 -0
- package/dist/restricted/caveats/snapIds.mjs +11 -0
- package/dist/restricted/caveats/snapIds.mjs.map +1 -0
- package/dist/restricted/dialog.js +9 -0
- package/dist/restricted/dialog.js.map +1 -0
- package/dist/restricted/dialog.mjs +9 -0
- package/dist/restricted/dialog.mjs.map +1 -0
- package/dist/restricted/getBip32Entropy.js +10 -0
- package/dist/restricted/getBip32Entropy.js.map +1 -0
- package/dist/restricted/getBip32Entropy.mjs +10 -0
- package/dist/restricted/getBip32Entropy.mjs.map +1 -0
- package/dist/restricted/getBip32PublicKey.js +12 -0
- package/dist/restricted/getBip32PublicKey.js.map +1 -0
- package/dist/restricted/getBip32PublicKey.mjs +12 -0
- package/dist/restricted/getBip32PublicKey.mjs.map +1 -0
- package/dist/restricted/getBip44Entropy.js +9 -0
- package/dist/restricted/getBip44Entropy.js.map +1 -0
- package/dist/restricted/getBip44Entropy.mjs +9 -0
- package/dist/restricted/getBip44Entropy.mjs.map +1 -0
- package/dist/restricted/getEntropy.js +10 -0
- package/dist/restricted/getEntropy.js.map +1 -0
- package/dist/restricted/getEntropy.mjs +10 -0
- package/dist/restricted/getEntropy.mjs.map +1 -0
- package/dist/restricted/getLocale.js +11 -0
- package/dist/restricted/getLocale.js.map +1 -0
- package/dist/restricted/getLocale.mjs +11 -0
- package/dist/restricted/getLocale.mjs.map +1 -0
- package/dist/restricted/index.js +33 -0
- package/dist/restricted/index.js.map +1 -0
- package/dist/restricted/index.mjs +33 -0
- package/dist/restricted/index.mjs.map +1 -0
- package/dist/restricted/invokeSnap.js +13 -0
- package/dist/restricted/invokeSnap.js.map +1 -0
- package/dist/restricted/invokeSnap.mjs +13 -0
- package/dist/restricted/invokeSnap.mjs.map +1 -0
- package/dist/restricted/manageAccounts.js +13 -0
- package/dist/restricted/manageAccounts.js.map +1 -0
- package/dist/restricted/manageAccounts.mjs +13 -0
- package/dist/restricted/manageAccounts.mjs.map +1 -0
- package/dist/restricted/manageState.js +20 -0
- package/dist/restricted/manageState.js.map +1 -0
- package/dist/restricted/manageState.mjs +20 -0
- package/dist/restricted/manageState.mjs.map +1 -0
- package/dist/restricted/notify.js +13 -0
- package/dist/restricted/notify.js.map +1 -0
- package/dist/restricted/notify.mjs +13 -0
- package/dist/restricted/notify.mjs.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/endowments/caveats/generic.d.ts +19 -0
- package/dist/types/endowments/caveats/index.d.ts +2 -0
- package/dist/types/endowments/caveats/requestTime.d.ts +29 -0
- package/dist/types/endowments/cronjob.d.ts +51 -0
- package/dist/types/endowments/enum.d.ts +13 -0
- package/dist/types/endowments/ethereum-provider.d.ts +14 -0
- package/dist/types/endowments/home-page.d.ts +15 -0
- package/dist/types/endowments/index.d.ts +131 -0
- package/dist/types/endowments/keyring.d.ts +39 -0
- package/dist/types/endowments/lifecycle-hooks.d.ts +15 -0
- package/dist/types/endowments/name-lookup.d.ts +49 -0
- package/dist/types/endowments/network-access.d.ts +14 -0
- package/dist/types/endowments/rpc.d.ts +38 -0
- package/dist/types/endowments/signature-insight.d.ts +39 -0
- package/dist/types/endowments/transaction-insight.d.ts +39 -0
- package/dist/types/endowments/web-assembly.d.ts +14 -0
- package/dist/types/index.d.ts +4 -2
- package/dist/types/permissions.d.ts +16 -0
- package/dist/types/permitted/createInterface.d.ts +150 -0
- package/dist/types/permitted/getInterfaceState.d.ts +18 -0
- package/dist/types/permitted/handlers.d.ts +4 -1
- package/dist/types/permitted/index.d.ts +4 -1
- package/dist/types/permitted/updateInterface.d.ts +152 -0
- package/dist/types/restricted/dialog.d.ts +776 -14
- package/dist/utils.js +13 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.mjs +13 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +22 -19
- package/dist/cjs/index.js +0 -43
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/permitted/getAllSnaps.js +0 -44
- package/dist/cjs/permitted/getAllSnaps.js.map +0 -1
- package/dist/cjs/permitted/getClientStatus.js +0 -40
- package/dist/cjs/permitted/getClientStatus.js.map +0 -1
- package/dist/cjs/permitted/getFile.js +0 -63
- package/dist/cjs/permitted/getFile.js.map +0 -1
- package/dist/cjs/permitted/getSnaps.js +0 -39
- package/dist/cjs/permitted/getSnaps.js.map +0 -1
- package/dist/cjs/permitted/handlers.js +0 -37
- package/dist/cjs/permitted/handlers.js.map +0 -1
- package/dist/cjs/permitted/index.js +0 -21
- package/dist/cjs/permitted/index.js.map +0 -1
- package/dist/cjs/permitted/invokeKeyring.js +0 -87
- package/dist/cjs/permitted/invokeKeyring.js.map +0 -1
- package/dist/cjs/permitted/invokeSnapSugar.js +0 -62
- package/dist/cjs/permitted/invokeSnapSugar.js.map +0 -1
- package/dist/cjs/permitted/middleware.js +0 -38
- package/dist/cjs/permitted/middleware.js.map +0 -1
- package/dist/cjs/permitted/requestSnaps.js +0 -123
- package/dist/cjs/permitted/requestSnaps.js.map +0 -1
- package/dist/cjs/restricted/caveats/index.js +0 -38
- package/dist/cjs/restricted/caveats/index.js.map +0 -1
- package/dist/cjs/restricted/caveats/permittedCoinTypes.js +0 -83
- package/dist/cjs/restricted/caveats/permittedCoinTypes.js.map +0 -1
- package/dist/cjs/restricted/caveats/permittedDerivationPaths.js +0 -67
- package/dist/cjs/restricted/caveats/permittedDerivationPaths.js.map +0 -1
- package/dist/cjs/restricted/caveats/snapIds.js +0 -59
- package/dist/cjs/restricted/caveats/snapIds.js.map +0 -1
- package/dist/cjs/restricted/dialog.js +0 -145
- package/dist/cjs/restricted/dialog.js.map +0 -1
- package/dist/cjs/restricted/getBip32Entropy.js +0 -76
- package/dist/cjs/restricted/getBip32Entropy.js.map +0 -1
- package/dist/cjs/restricted/getBip32PublicKey.js +0 -91
- package/dist/cjs/restricted/getBip44Entropy.js +0 -76
- package/dist/cjs/restricted/getBip44Entropy.js.map +0 -1
- package/dist/cjs/restricted/getEntropy.js +0 -76
- package/dist/cjs/restricted/getEntropy.js.map +0 -1
- package/dist/cjs/restricted/getLocale.js +0 -49
- package/dist/cjs/restricted/getLocale.js.map +0 -1
- package/dist/cjs/restricted/index.js +0 -59
- package/dist/cjs/restricted/index.js.map +0 -1
- package/dist/cjs/restricted/invokeSnap.js +0 -99
- package/dist/cjs/restricted/invokeSnap.js.map +0 -1
- package/dist/cjs/restricted/manageAccounts.js +0 -68
- package/dist/cjs/restricted/manageAccounts.js.map +0 -1
- package/dist/cjs/restricted/manageState.js +0 -208
- package/dist/cjs/restricted/manageState.js.map +0 -1
- package/dist/cjs/restricted/notify.js +0 -92
- package/dist/cjs/restricted/notify.js.map +0 -1
- package/dist/cjs/utils.js +0 -98
- package/dist/esm/index.js +0 -6
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/permitted/getAllSnaps.js +0 -37
- package/dist/esm/permitted/getAllSnaps.js.map +0 -1
- package/dist/esm/permitted/getClientStatus.js +0 -32
- package/dist/esm/permitted/getClientStatus.js.map +0 -1
- package/dist/esm/permitted/getFile.js +0 -45
- package/dist/esm/permitted/getFile.js.map +0 -1
- package/dist/esm/permitted/getSnaps.js +0 -31
- package/dist/esm/permitted/getSnaps.js.map +0 -1
- package/dist/esm/permitted/handlers.js +0 -19
- package/dist/esm/permitted/handlers.js.map +0 -1
- package/dist/esm/permitted/index.js +0 -4
- package/dist/esm/permitted/index.js.map +0 -1
- package/dist/esm/permitted/invokeKeyring.js +0 -79
- package/dist/esm/permitted/invokeKeyring.js.map +0 -1
- package/dist/esm/permitted/invokeSnapSugar.js +0 -60
- package/dist/esm/permitted/invokeSnapSugar.js.map +0 -1
- package/dist/esm/permitted/middleware.js +0 -34
- package/dist/esm/permitted/middleware.js.map +0 -1
- package/dist/esm/permitted/requestSnaps.js +0 -118
- package/dist/esm/permitted/requestSnaps.js.map +0 -1
- package/dist/esm/restricted/caveats/index.js +0 -20
- package/dist/esm/restricted/caveats/index.js.map +0 -1
- package/dist/esm/restricted/caveats/permittedCoinTypes.js +0 -77
- package/dist/esm/restricted/caveats/permittedCoinTypes.js.map +0 -1
- package/dist/esm/restricted/caveats/permittedDerivationPaths.js +0 -64
- package/dist/esm/restricted/caveats/permittedDerivationPaths.js.map +0 -1
- package/dist/esm/restricted/caveats/snapIds.js +0 -50
- package/dist/esm/restricted/caveats/snapIds.js.map +0 -1
- package/dist/esm/restricted/dialog.js +0 -138
- package/dist/esm/restricted/dialog.js.map +0 -1
- package/dist/esm/restricted/getBip32Entropy.js +0 -67
- package/dist/esm/restricted/getBip32Entropy.js.map +0 -1
- package/dist/esm/restricted/getBip32PublicKey.js +0 -79
- package/dist/esm/restricted/getBip32PublicKey.js.map +0 -1
- package/dist/esm/restricted/getBip44Entropy.js +0 -69
- package/dist/esm/restricted/getBip44Entropy.js.map +0 -1
- package/dist/esm/restricted/getEntropy.js +0 -58
- package/dist/esm/restricted/getEntropy.js.map +0 -1
- package/dist/esm/restricted/getLocale.js +0 -42
- package/dist/esm/restricted/getLocale.js.map +0 -1
- package/dist/esm/restricted/index.js +0 -27
- package/dist/esm/restricted/index.js.map +0 -1
- package/dist/esm/restricted/invokeSnap.js +0 -89
- package/dist/esm/restricted/invokeSnap.js.map +0 -1
- package/dist/esm/restricted/manageAccounts.js +0 -60
- package/dist/esm/restricted/manageAccounts.js.map +0 -1
- package/dist/esm/restricted/manageState.js +0 -225
- package/dist/esm/restricted/manageState.js.map +0 -1
- package/dist/esm/restricted/notify.js +0 -92
- package/dist/esm/restricted/notify.js.map +0 -1
- package/dist/esm/utils.js +0 -124
- package/dist/esm/utils.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/restricted/dialog.ts"],"sourcesContent":["import type {\n PermissionSpecificationBuilder,\n RestrictedMethodOptions,\n ValidPermissionSpecification,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport { DialogType, ComponentStruct, enumValue } from '@metamask/snaps-sdk';\nimport type { DialogParams, EnumToUnion, Component } from '@metamask/snaps-sdk';\nimport { validateComponentLinks } from '@metamask/snaps-utils';\nimport type { InferMatching } from '@metamask/snaps-utils';\nimport type { NonEmptyArray } from '@metamask/utils';\nimport type { Infer, Struct } from 'superstruct';\nimport {\n create,\n enums,\n object,\n optional,\n size,\n string,\n StructError,\n type,\n union,\n} from 'superstruct';\n\nimport { type MethodHooksObject } from '../utils';\n\nconst methodName = 'snap_dialog';\n\nconst PlaceholderStruct = optional(size(string(), 1, 40));\n\nexport type Placeholder = Infer<typeof PlaceholderStruct>;\n\ntype ShowDialog = (\n snapId: string,\n type: EnumToUnion<DialogType>,\n content: Component,\n placeholder?: Placeholder,\n) => Promise<null | boolean | string>;\n\ntype MaybeUpdatePhisingList = () => Promise<void>;\ntype IsOnPhishingList = (url: string) => boolean;\n\nexport type DialogMethodHooks = {\n /**\n * @param snapId - The ID of the Snap that created the alert.\n * @param type - The dialog type.\n * @param content - The dialog custom UI.\n * @param placeholder - The placeholder for the Prompt dialog input.\n */\n showDialog: ShowDialog;\n\n maybeUpdatePhishingList: MaybeUpdatePhisingList;\n\n /**\n * @param url - The URL to check against the phishing list.\n */\n isOnPhishingList: IsOnPhishingList;\n};\n\ntype DialogSpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: DialogMethodHooks;\n};\n\ntype DialogSpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof methodName;\n methodImplementation: ReturnType<typeof getDialogImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n}>;\n\n/**\n * The specification builder for the `snap_dialog` permission. `snap_dialog`\n * lets the Snap display one of the following dialogs to the user:\n * - An alert, for displaying information.\n * - A confirmation, for accepting or rejecting some action.\n * - A prompt, for inputting some information.\n *\n * @param options - The specification builder options.\n * @param options.allowedCaveats - The optional allowed caveats for the\n * permission.\n * @param options.methodHooks - The RPC method hooks needed by the method\n * implementation.\n * @returns The specification for the `snap_dialog` permission.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n DialogSpecificationBuilderOptions,\n DialogSpecification\n> = ({\n allowedCaveats = null,\n methodHooks,\n}: DialogSpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName: methodName,\n allowedCaveats,\n methodImplementation: getDialogImplementation(methodHooks),\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<DialogMethodHooks> = {\n showDialog: true,\n isOnPhishingList: true,\n maybeUpdatePhishingList: true,\n};\n\nexport const dialogBuilder = Object.freeze({\n targetName: methodName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n// Note: We use `type` here instead of `object` because `type` does not validate\n// the keys of the object, which is what we want.\nconst BaseParamsStruct = type({\n type: enums([DialogType.Alert, DialogType.Confirmation, DialogType.Prompt]),\n});\n\nconst AlertParametersStruct = object({\n type: enumValue(DialogType.Alert),\n content: ComponentStruct,\n});\n\nconst ConfirmationParametersStruct = object({\n type: enumValue(DialogType.Confirmation),\n content: ComponentStruct,\n});\n\nconst PromptParametersStruct = object({\n type: enumValue(DialogType.Prompt),\n content: ComponentStruct,\n placeholder: PlaceholderStruct,\n});\n\nconst DialogParametersStruct = union([\n AlertParametersStruct,\n ConfirmationParametersStruct,\n PromptParametersStruct,\n]);\n\nexport type DialogParameters = InferMatching<\n typeof DialogParametersStruct,\n DialogParams\n>;\n\nconst structs = {\n [DialogType.Alert]: AlertParametersStruct,\n [DialogType.Confirmation]: ConfirmationParametersStruct,\n [DialogType.Prompt]: PromptParametersStruct,\n};\n\n/**\n * Builds the method implementation for `snap_dialog`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.showDialog - A function that shows the specified dialog in the\n * MetaMask UI and returns the appropriate value for the dialog type.\n * @param hooks.isOnPhishingList - A function that checks a link against the\n * phishing list and return true if it's in, otherwise false.\n * @param hooks.maybeUpdatePhishingList - A function that updates the phishing list if needed.\n * @returns The method implementation which return value depends on the dialog\n * type, valid return types are: string, boolean, null.\n */\nexport function getDialogImplementation({\n showDialog,\n isOnPhishingList,\n maybeUpdatePhishingList,\n}: DialogMethodHooks) {\n return async function dialogImplementation(\n args: RestrictedMethodOptions<DialogParameters>,\n ): Promise<boolean | null | string> {\n const {\n params,\n context: { origin },\n } = args;\n\n const validatedType = getValidatedType(params);\n const validatedParams = getValidatedParams(params, structs[validatedType]);\n\n const { content } = validatedParams;\n\n await maybeUpdatePhishingList();\n\n validateComponentLinks(content, isOnPhishingList);\n\n const placeholder =\n validatedParams.type === DialogType.Prompt\n ? validatedParams.placeholder\n : undefined;\n\n return showDialog(origin, validatedType, content, placeholder);\n };\n}\n\n/**\n * Get the validated type of the dialog parameters. Throws an error if the type\n * is invalid.\n *\n * @param params - The parameters to validate.\n * @returns The validated type of the dialog parameters.\n */\nfunction getValidatedType(params: unknown): DialogType {\n try {\n return create(params, BaseParamsStruct).type;\n } catch (error) {\n throw rpcErrors.invalidParams({\n message: `The \"type\" property must be one of: ${Object.values(\n DialogType,\n ).join(', ')}.`,\n });\n }\n}\n\n/**\n * Validates the confirm 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 * @param struct - The struct to validate the params against.\n * @returns The validated confirm method parameter object.\n */\nfunction getValidatedParams(\n params: unknown,\n struct: Struct<any>,\n): DialogParameters {\n try {\n return create(params, struct);\n } catch (error) {\n if (error instanceof StructError) {\n const { key, type: errorType } = error;\n\n if (key === 'placeholder' && errorType === 'never') {\n throw rpcErrors.invalidParams({\n message:\n 'Invalid params: Alerts or confirmations may not specify a \"placeholder\" field.',\n });\n }\n\n throw rpcErrors.invalidParams({\n message: `Invalid params: ${error.message}.`,\n });\n }\n\n /* istanbul ignore next */\n throw rpcErrors.internal();\n }\n}\n"],"names":["dialogBuilder","getDialogImplementation","methodName","PlaceholderStruct","optional","size","string","specificationBuilder","allowedCaveats","methodHooks","permissionType","PermissionType","RestrictedMethod","targetName","methodImplementation","subjectTypes","SubjectType","Snap","showDialog","isOnPhishingList","maybeUpdatePhishingList","Object","freeze","BaseParamsStruct","type","enums","DialogType","Alert","Confirmation","Prompt","AlertParametersStruct","object","enumValue","content","ComponentStruct","ConfirmationParametersStruct","PromptParametersStruct","placeholder","DialogParametersStruct","union","structs","dialogImplementation","args","params","context","origin","validatedType","getValidatedType","validatedParams","getValidatedParams","validateComponentLinks","undefined","create","error","rpcErrors","invalidParams","message","values","join","struct","StructError","key","errorType","internal"],"mappings":";;;;;;;;;;;IA6GaA,aAAa;eAAbA;;IAyDGC,uBAAuB;eAAvBA;;;sCAjK4B;2BAClB;0BAC6B;4BAEhB;6BAchC;AAIP,MAAMC,aAAa;AAEnB,MAAMC,oBAAoBC,IAAAA,qBAAQ,EAACC,IAAAA,iBAAI,EAACC,IAAAA,mBAAM,KAAI,GAAG;AA2CrD;;;;;;;;;;;;;CAaC,GACD,MAAMC,uBAIF,CAAC,EACHC,iBAAiB,IAAI,EACrBC,WAAW,EACuB;IAClC,OAAO;QACLC,gBAAgBC,oCAAc,CAACC,gBAAgB;QAC/CC,YAAYX;QACZM;QACAM,sBAAsBb,wBAAwBQ;QAC9CM,cAAc;YAACC,iCAAW,CAACC,IAAI;SAAC;IAClC;AACF;AAEA,MAAMR,cAAoD;IACxDS,YAAY;IACZC,kBAAkB;IAClBC,yBAAyB;AAC3B;AAEO,MAAMpB,gBAAgBqB,OAAOC,MAAM,CAAC;IACzCT,YAAYX;IACZK;IACAE;AACF;AAEA,gFAAgF;AAChF,iDAAiD;AACjD,MAAMc,mBAAmBC,IAAAA,iBAAI,EAAC;IAC5BA,MAAMC,IAAAA,kBAAK,EAAC;QAACC,oBAAU,CAACC,KAAK;QAAED,oBAAU,CAACE,YAAY;QAAEF,oBAAU,CAACG,MAAM;KAAC;AAC5E;AAEA,MAAMC,wBAAwBC,IAAAA,mBAAM,EAAC;IACnCP,MAAMQ,IAAAA,mBAAS,EAACN,oBAAU,CAACC,KAAK;IAChCM,SAASC,yBAAe;AAC1B;AAEA,MAAMC,+BAA+BJ,IAAAA,mBAAM,EAAC;IAC1CP,MAAMQ,IAAAA,mBAAS,EAACN,oBAAU,CAACE,YAAY;IACvCK,SAASC,yBAAe;AAC1B;AAEA,MAAME,yBAAyBL,IAAAA,mBAAM,EAAC;IACpCP,MAAMQ,IAAAA,mBAAS,EAACN,oBAAU,CAACG,MAAM;IACjCI,SAASC,yBAAe;IACxBG,aAAalC;AACf;AAEA,MAAMmC,yBAAyBC,IAAAA,kBAAK,EAAC;IACnCT;IACAK;IACAC;CACD;AAOD,MAAMI,UAAU;IACd,CAACd,oBAAU,CAACC,KAAK,CAAC,EAAEG;IACpB,CAACJ,oBAAU,CAACE,YAAY,CAAC,EAAEO;IAC3B,CAACT,oBAAU,CAACG,MAAM,CAAC,EAAEO;AACvB;AAcO,SAASnC,wBAAwB,EACtCiB,UAAU,EACVC,gBAAgB,EAChBC,uBAAuB,EACL;IAClB,OAAO,eAAeqB,qBACpBC,IAA+C;QAE/C,MAAM,EACJC,MAAM,EACNC,SAAS,EAAEC,MAAM,EAAE,EACpB,GAAGH;QAEJ,MAAMI,gBAAgBC,iBAAiBJ;QACvC,MAAMK,kBAAkBC,mBAAmBN,QAAQH,OAAO,CAACM,cAAc;QAEzE,MAAM,EAAEb,OAAO,EAAE,GAAGe;QAEpB,MAAM5B;QAEN8B,IAAAA,kCAAsB,EAACjB,SAASd;QAEhC,MAAMkB,cACJW,gBAAgBxB,IAAI,KAAKE,oBAAU,CAACG,MAAM,GACtCmB,gBAAgBX,WAAW,GAC3Bc;QAEN,OAAOjC,WAAW2B,QAAQC,eAAeb,SAASI;IACpD;AACF;AAEA;;;;;;CAMC,GACD,SAASU,iBAAiBJ,MAAe;IACvC,IAAI;QACF,OAAOS,IAAAA,mBAAM,EAACT,QAAQpB,kBAAkBC,IAAI;IAC9C,EAAE,OAAO6B,OAAO;QACd,MAAMC,oBAAS,CAACC,aAAa,CAAC;YAC5BC,SAAS,CAAC,oCAAoC,EAAEnC,OAAOoC,MAAM,CAC3D/B,oBAAU,EACVgC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjB;IACF;AACF;AAEA;;;;;;;CAOC,GACD,SAAST,mBACPN,MAAe,EACfgB,MAAmB;IAEnB,IAAI;QACF,OAAOP,IAAAA,mBAAM,EAACT,QAAQgB;IACxB,EAAE,OAAON,OAAO;QACd,IAAIA,iBAAiBO,wBAAW,EAAE;YAChC,MAAM,EAAEC,GAAG,EAAErC,MAAMsC,SAAS,EAAE,GAAGT;YAEjC,IAAIQ,QAAQ,iBAAiBC,cAAc,SAAS;gBAClD,MAAMR,oBAAS,CAACC,aAAa,CAAC;oBAC5BC,SACE;gBACJ;YACF;YAEA,MAAMF,oBAAS,CAACC,aAAa,CAAC;gBAC5BC,SAAS,CAAC,gBAAgB,EAAEH,MAAMG,OAAO,CAAC,CAAC,CAAC;YAC9C;QACF;QAEA,wBAAwB,GACxB,MAAMF,oBAAS,CAACS,QAAQ;IAC1B;AACF"}
|
|
@@ -1,76 +0,0 @@
|
|
|
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
|
-
getBip32EntropyBuilder: function() {
|
|
13
|
-
return getBip32EntropyBuilder;
|
|
14
|
-
},
|
|
15
|
-
getBip32EntropyImplementation: function() {
|
|
16
|
-
return getBip32EntropyImplementation;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _permissioncontroller = require("@metamask/permission-controller");
|
|
20
|
-
const _rpcerrors = require("@metamask/rpc-errors");
|
|
21
|
-
const _snapsutils = require("@metamask/snaps-utils");
|
|
22
|
-
const _utils = require("@metamask/utils");
|
|
23
|
-
const _utils1 = require("../utils");
|
|
24
|
-
const targetName = 'snap_getBip32Entropy';
|
|
25
|
-
/**
|
|
26
|
-
* The specification builder for the `snap_getBip32Entropy` permission.
|
|
27
|
-
* `snap_getBip32Entropy` lets the Snap control private keys for a particular
|
|
28
|
-
* BIP-32 node.
|
|
29
|
-
*
|
|
30
|
-
* @param options - The specification builder options.
|
|
31
|
-
* @param options.methodHooks - The RPC method hooks needed by the method implementation.
|
|
32
|
-
* @returns The specification for the `snap_getBip32Entropy` permission.
|
|
33
|
-
*/ const specificationBuilder = ({ methodHooks })=>{
|
|
34
|
-
return {
|
|
35
|
-
permissionType: _permissioncontroller.PermissionType.RestrictedMethod,
|
|
36
|
-
targetName,
|
|
37
|
-
allowedCaveats: [
|
|
38
|
-
_snapsutils.SnapCaveatType.PermittedDerivationPaths
|
|
39
|
-
],
|
|
40
|
-
methodImplementation: getBip32EntropyImplementation(methodHooks),
|
|
41
|
-
validator: ({ caveats })=>{
|
|
42
|
-
if (caveats?.length !== 1 || caveats[0].type !== _snapsutils.SnapCaveatType.PermittedDerivationPaths) {
|
|
43
|
-
throw _rpcerrors.rpcErrors.invalidParams({
|
|
44
|
-
message: `Expected a single "${_snapsutils.SnapCaveatType.PermittedDerivationPaths}" caveat.`
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
subjectTypes: [
|
|
49
|
-
_permissioncontroller.SubjectType.Snap
|
|
50
|
-
]
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
const methodHooks = {
|
|
54
|
-
getMnemonic: true,
|
|
55
|
-
getUnlockPromise: true
|
|
56
|
-
};
|
|
57
|
-
const getBip32EntropyBuilder = Object.freeze({
|
|
58
|
-
targetName,
|
|
59
|
-
specificationBuilder,
|
|
60
|
-
methodHooks
|
|
61
|
-
});
|
|
62
|
-
function getBip32EntropyImplementation({ getMnemonic, getUnlockPromise }) {
|
|
63
|
-
return async function getBip32Entropy(args) {
|
|
64
|
-
await getUnlockPromise(true);
|
|
65
|
-
const { params } = args;
|
|
66
|
-
(0, _utils.assert)(params);
|
|
67
|
-
const node = await (0, _utils1.getNode)({
|
|
68
|
-
curve: params.curve,
|
|
69
|
-
path: params.path,
|
|
70
|
-
secretRecoveryPhrase: await getMnemonic()
|
|
71
|
-
});
|
|
72
|
-
return node.toJSON();
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
//# sourceMappingURL=getBip32Entropy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/restricted/getBip32Entropy.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 GetBip32EntropyParams,\n GetBip32EntropyResult,\n} from '@metamask/snaps-sdk';\nimport { SnapCaveatType } from '@metamask/snaps-utils';\nimport type { NonEmptyArray } from '@metamask/utils';\nimport { assert } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\nimport { getNode } from '../utils';\n\nconst targetName = 'snap_getBip32Entropy';\n\nexport type GetBip32EntropyMethodHooks = {\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 GetBip32EntropySpecificationBuilderOptions = {\n methodHooks: GetBip32EntropyMethodHooks;\n};\n\ntype GetBip32EntropySpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof targetName;\n methodImplementation: ReturnType<typeof getBip32EntropyImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n validator: PermissionValidatorConstraint;\n}>;\n\n/**\n * The specification builder for the `snap_getBip32Entropy` permission.\n * `snap_getBip32Entropy` lets the Snap control private 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_getBip32Entropy` permission.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n GetBip32EntropySpecificationBuilderOptions,\n GetBip32EntropySpecification\n> = ({ methodHooks }: GetBip32EntropySpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName,\n allowedCaveats: [SnapCaveatType.PermittedDerivationPaths],\n methodImplementation: getBip32EntropyImplementation(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<GetBip32EntropyMethodHooks> = {\n getMnemonic: true,\n getUnlockPromise: true,\n};\n\nexport const getBip32EntropyBuilder = Object.freeze({\n targetName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_getBip32Entropy`.\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 `JsonSLIP10Node`.\n * @throws If the params are invalid.\n */\nexport function getBip32EntropyImplementation({\n getMnemonic,\n getUnlockPromise,\n}: GetBip32EntropyMethodHooks) {\n return async function getBip32Entropy(\n args: RestrictedMethodOptions<GetBip32EntropyParams>,\n ): Promise<GetBip32EntropyResult> {\n await getUnlockPromise(true);\n\n const { params } = args;\n assert(params);\n\n const node = await getNode({\n curve: params.curve,\n path: params.path,\n secretRecoveryPhrase: await getMnemonic(),\n });\n\n return node.toJSON();\n };\n}\n"],"names":["getBip32EntropyBuilder","getBip32EntropyImplementation","targetName","specificationBuilder","methodHooks","permissionType","PermissionType","RestrictedMethod","allowedCaveats","SnapCaveatType","PermittedDerivationPaths","methodImplementation","validator","caveats","length","type","rpcErrors","invalidParams","message","subjectTypes","SubjectType","Snap","getMnemonic","getUnlockPromise","Object","freeze","getBip32Entropy","args","params","assert","node","getNode","curve","path","secretRecoveryPhrase","toJSON"],"mappings":";;;;;;;;;;;IAqFaA,sBAAsB;eAAtBA;;IAgBGC,6BAA6B;eAA7BA;;;sCA/F4B;2BAClB;4BAKK;uBAER;wBAGC;AAExB,MAAMC,aAAa;AA4BnB;;;;;;;;CAQC,GACD,MAAMC,uBAIF,CAAC,EAAEC,WAAW,EAA8C;IAC9D,OAAO;QACLC,gBAAgBC,oCAAc,CAACC,gBAAgB;QAC/CL;QACAM,gBAAgB;YAACC,0BAAc,CAACC,wBAAwB;SAAC;QACzDC,sBAAsBV,8BAA8BG;QACpDQ,WAAW,CAAC,EAAEC,OAAO,EAAE;YACrB,IACEA,SAASC,WAAW,KACpBD,OAAO,CAAC,EAAE,CAACE,IAAI,KAAKN,0BAAc,CAACC,wBAAwB,EAC3D;gBACA,MAAMM,oBAAS,CAACC,aAAa,CAAC;oBAC5BC,SAAS,CAAC,mBAAmB,EAAET,0BAAc,CAACC,wBAAwB,CAAC,SAAS,CAAC;gBACnF;YACF;QACF;QACAS,cAAc;YAACC,iCAAW,CAACC,IAAI;SAAC;IAClC;AACF;AAEA,MAAMjB,cAA6D;IACjEkB,aAAa;IACbC,kBAAkB;AACpB;AAEO,MAAMvB,yBAAyBwB,OAAOC,MAAM,CAAC;IAClDvB;IACAC;IACAC;AACF;AAYO,SAASH,8BAA8B,EAC5CqB,WAAW,EACXC,gBAAgB,EACW;IAC3B,OAAO,eAAeG,gBACpBC,IAAoD;QAEpD,MAAMJ,iBAAiB;QAEvB,MAAM,EAAEK,MAAM,EAAE,GAAGD;QACnBE,IAAAA,aAAM,EAACD;QAEP,MAAME,OAAO,MAAMC,IAAAA,eAAO,EAAC;YACzBC,OAAOJ,OAAOI,KAAK;YACnBC,MAAML,OAAOK,IAAI;YACjBC,sBAAsB,MAAMZ;QAC9B;QAEA,OAAOQ,KAAKK,MAAM;IACpB;AACF"}
|
|
@@ -1,91 +0,0 @@
|
|
|
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
|
-
Bip32PublicKeyArgsStruct: function() {
|
|
13
|
-
return Bip32PublicKeyArgsStruct;
|
|
14
|
-
},
|
|
15
|
-
getBip32PublicKeyBuilder: function() {
|
|
16
|
-
return getBip32PublicKeyBuilder;
|
|
17
|
-
},
|
|
18
|
-
getBip32PublicKeyImplementation: function() {
|
|
19
|
-
return getBip32PublicKeyImplementation;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
const _permissioncontroller = require("@metamask/permission-controller");
|
|
23
|
-
const _rpcerrors = require("@metamask/rpc-errors");
|
|
24
|
-
const _snapsutils = require("@metamask/snaps-utils");
|
|
25
|
-
const _utils = require("@metamask/utils");
|
|
26
|
-
const _superstruct = require("superstruct");
|
|
27
|
-
const _utils1 = require("../utils");
|
|
28
|
-
const targetName = 'snap_getBip32PublicKey';
|
|
29
|
-
const Bip32PublicKeyArgsStruct = (0, _snapsutils.bip32entropy)((0, _superstruct.object)({
|
|
30
|
-
path: _snapsutils.Bip32PathStruct,
|
|
31
|
-
curve: (0, _superstruct.enums)([
|
|
32
|
-
'ed25519',
|
|
33
|
-
'secp256k1'
|
|
34
|
-
]),
|
|
35
|
-
compressed: (0, _superstruct.optional)((0, _superstruct.boolean)())
|
|
36
|
-
}));
|
|
37
|
-
/**
|
|
38
|
-
* The specification builder for the `snap_getBip32PublicKey` permission.
|
|
39
|
-
* `snap_getBip32PublicKey` lets the Snap retrieve public keys for a particular
|
|
40
|
-
* BIP-32 node.
|
|
41
|
-
*
|
|
42
|
-
* @param options - The specification builder options.
|
|
43
|
-
* @param options.methodHooks - The RPC method hooks needed by the method implementation.
|
|
44
|
-
* @returns The specification for the `snap_getBip32PublicKey` permission.
|
|
45
|
-
*/ const specificationBuilder = ({ methodHooks })=>{
|
|
46
|
-
return {
|
|
47
|
-
permissionType: _permissioncontroller.PermissionType.RestrictedMethod,
|
|
48
|
-
targetName,
|
|
49
|
-
allowedCaveats: [
|
|
50
|
-
_snapsutils.SnapCaveatType.PermittedDerivationPaths
|
|
51
|
-
],
|
|
52
|
-
methodImplementation: getBip32PublicKeyImplementation(methodHooks),
|
|
53
|
-
validator: ({ caveats })=>{
|
|
54
|
-
if (caveats?.length !== 1 || caveats[0].type !== _snapsutils.SnapCaveatType.PermittedDerivationPaths) {
|
|
55
|
-
throw _rpcerrors.rpcErrors.invalidParams({
|
|
56
|
-
message: `Expected a single "${_snapsutils.SnapCaveatType.PermittedDerivationPaths}" caveat.`
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
subjectTypes: [
|
|
61
|
-
_permissioncontroller.SubjectType.Snap
|
|
62
|
-
]
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
const methodHooks = {
|
|
66
|
-
getMnemonic: true,
|
|
67
|
-
getUnlockPromise: true
|
|
68
|
-
};
|
|
69
|
-
const getBip32PublicKeyBuilder = Object.freeze({
|
|
70
|
-
targetName,
|
|
71
|
-
specificationBuilder,
|
|
72
|
-
methodHooks
|
|
73
|
-
});
|
|
74
|
-
function getBip32PublicKeyImplementation({ getMnemonic, getUnlockPromise }) {
|
|
75
|
-
return async function getBip32PublicKey(args) {
|
|
76
|
-
await getUnlockPromise(true);
|
|
77
|
-
(0, _utils.assertStruct)(args.params, Bip32PublicKeyArgsStruct, 'Invalid BIP-32 public key params', _rpcerrors.rpcErrors.invalidParams);
|
|
78
|
-
const { params } = args;
|
|
79
|
-
const node = await (0, _utils1.getNode)({
|
|
80
|
-
curve: params.curve,
|
|
81
|
-
path: params.path,
|
|
82
|
-
secretRecoveryPhrase: await getMnemonic()
|
|
83
|
-
});
|
|
84
|
-
if (params.compressed) {
|
|
85
|
-
return node.compressedPublicKey;
|
|
86
|
-
}
|
|
87
|
-
return node.publicKey;
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
//# sourceMappingURL=getBip32PublicKey.js.map
|
|
@@ -1,76 +0,0 @@
|
|
|
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
|
-
getBip44EntropyBuilder: function() {
|
|
13
|
-
return getBip44EntropyBuilder;
|
|
14
|
-
},
|
|
15
|
-
getBip44EntropyImplementation: function() {
|
|
16
|
-
return getBip44EntropyImplementation;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _keytree = require("@metamask/key-tree");
|
|
20
|
-
const _permissioncontroller = require("@metamask/permission-controller");
|
|
21
|
-
const _rpcerrors = require("@metamask/rpc-errors");
|
|
22
|
-
const _snapsutils = require("@metamask/snaps-utils");
|
|
23
|
-
const targetName = 'snap_getBip44Entropy';
|
|
24
|
-
/**
|
|
25
|
-
* The specification builder for the `snap_getBip44Entropy` permission.
|
|
26
|
-
* `snap_getBip44Entropy_*` lets the Snap control private keys for a particular
|
|
27
|
-
* BIP-32 coin type.
|
|
28
|
-
*
|
|
29
|
-
* @param options - The specification builder options.
|
|
30
|
-
* @param options.methodHooks - The RPC method hooks needed by the method
|
|
31
|
-
* implementation.
|
|
32
|
-
* @returns The specification for the `snap_getBip44Entropy` permission.
|
|
33
|
-
*/ const specificationBuilder = ({ methodHooks })=>{
|
|
34
|
-
return {
|
|
35
|
-
permissionType: _permissioncontroller.PermissionType.RestrictedMethod,
|
|
36
|
-
targetName,
|
|
37
|
-
allowedCaveats: [
|
|
38
|
-
_snapsutils.SnapCaveatType.PermittedCoinTypes
|
|
39
|
-
],
|
|
40
|
-
methodImplementation: getBip44EntropyImplementation(methodHooks),
|
|
41
|
-
validator: ({ caveats })=>{
|
|
42
|
-
if (caveats?.length !== 1 || caveats[0].type !== _snapsutils.SnapCaveatType.PermittedCoinTypes) {
|
|
43
|
-
throw _rpcerrors.rpcErrors.invalidParams({
|
|
44
|
-
message: `Expected a single "${_snapsutils.SnapCaveatType.PermittedCoinTypes}" caveat.`
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
subjectTypes: [
|
|
49
|
-
_permissioncontroller.SubjectType.Snap
|
|
50
|
-
]
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
const methodHooks = {
|
|
54
|
-
getMnemonic: true,
|
|
55
|
-
getUnlockPromise: true
|
|
56
|
-
};
|
|
57
|
-
const getBip44EntropyBuilder = Object.freeze({
|
|
58
|
-
targetName,
|
|
59
|
-
specificationBuilder,
|
|
60
|
-
methodHooks
|
|
61
|
-
});
|
|
62
|
-
function getBip44EntropyImplementation({ getMnemonic, getUnlockPromise }) {
|
|
63
|
-
return async function getBip44Entropy(args) {
|
|
64
|
-
await getUnlockPromise(true);
|
|
65
|
-
// `args.params` is validated by the decorator, so it's safe to assert here.
|
|
66
|
-
const params = args.params;
|
|
67
|
-
const node = await _keytree.BIP44CoinTypeNode.fromDerivationPath([
|
|
68
|
-
await getMnemonic(),
|
|
69
|
-
`bip32:44'`,
|
|
70
|
-
`bip32:${params.coinType}'`
|
|
71
|
-
]);
|
|
72
|
-
return node.toJSON();
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
//# sourceMappingURL=getBip44Entropy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/restricted/getBip44Entropy.ts"],"sourcesContent":["import { BIP44CoinTypeNode } from '@metamask/key-tree';\nimport 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 GetBip44EntropyParams,\n GetBip44EntropyResult,\n} from '@metamask/snaps-sdk';\nimport { SnapCaveatType } from '@metamask/snaps-utils';\nimport type { NonEmptyArray } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nconst targetName = 'snap_getBip44Entropy';\n\nexport type GetBip44EntropyMethodHooks = {\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 GetBip44EntropySpecificationBuilderOptions = {\n methodHooks: GetBip44EntropyMethodHooks;\n};\n\ntype GetBip44EntropySpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof targetName;\n methodImplementation: ReturnType<typeof getBip44EntropyImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n validator: PermissionValidatorConstraint;\n}>;\n\n/**\n * The specification builder for the `snap_getBip44Entropy` permission.\n * `snap_getBip44Entropy_*` lets the Snap control private keys for a particular\n * BIP-32 coin type.\n *\n * @param options - The specification builder options.\n * @param options.methodHooks - The RPC method hooks needed by the method\n * implementation.\n * @returns The specification for the `snap_getBip44Entropy` permission.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n GetBip44EntropySpecificationBuilderOptions,\n GetBip44EntropySpecification\n> = ({ methodHooks }: GetBip44EntropySpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName,\n allowedCaveats: [SnapCaveatType.PermittedCoinTypes],\n methodImplementation: getBip44EntropyImplementation(methodHooks),\n validator: ({ caveats }) => {\n if (\n caveats?.length !== 1 ||\n caveats[0].type !== SnapCaveatType.PermittedCoinTypes\n ) {\n throw rpcErrors.invalidParams({\n message: `Expected a single \"${SnapCaveatType.PermittedCoinTypes}\" caveat.`,\n });\n }\n },\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<GetBip44EntropyMethodHooks> = {\n getMnemonic: true,\n getUnlockPromise: true,\n};\n\nexport const getBip44EntropyBuilder = Object.freeze({\n targetName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_getBip44Entropy`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getMnemonic - A function to retrieve the Secret Recovery Phrase\n * of the user.\n * @param hooks.getUnlockPromise - A function that resolves once the MetaMask\n * extension is unlocked and prompts the user to unlock their MetaMask if it is\n * locked.\n * @returns The method implementation which returns a `BIP44CoinTypeNode`.\n * @throws If the params are invalid.\n */\nexport function getBip44EntropyImplementation({\n getMnemonic,\n getUnlockPromise,\n}: GetBip44EntropyMethodHooks) {\n return async function getBip44Entropy(\n args: RestrictedMethodOptions<GetBip44EntropyParams>,\n ): Promise<GetBip44EntropyResult> {\n await getUnlockPromise(true);\n\n // `args.params` is validated by the decorator, so it's safe to assert here.\n const params = args.params as GetBip44EntropyParams;\n\n const node = await BIP44CoinTypeNode.fromDerivationPath([\n await getMnemonic(),\n `bip32:44'`,\n `bip32:${params.coinType}'`,\n ]);\n\n return node.toJSON();\n };\n}\n"],"names":["getBip44EntropyBuilder","getBip44EntropyImplementation","targetName","specificationBuilder","methodHooks","permissionType","PermissionType","RestrictedMethod","allowedCaveats","SnapCaveatType","PermittedCoinTypes","methodImplementation","validator","caveats","length","type","rpcErrors","invalidParams","message","subjectTypes","SubjectType","Snap","getMnemonic","getUnlockPromise","Object","freeze","getBip44Entropy","args","params","node","BIP44CoinTypeNode","fromDerivationPath","coinType","toJSON"],"mappings":";;;;;;;;;;;IAqFaA,sBAAsB;eAAtBA;;IAkBGC,6BAA6B;eAA7BA;;;yBAvGkB;sCAOU;2BAClB;4BAKK;AAK/B,MAAMC,aAAa;AA4BnB;;;;;;;;;CASC,GACD,MAAMC,uBAIF,CAAC,EAAEC,WAAW,EAA8C;IAC9D,OAAO;QACLC,gBAAgBC,oCAAc,CAACC,gBAAgB;QAC/CL;QACAM,gBAAgB;YAACC,0BAAc,CAACC,kBAAkB;SAAC;QACnDC,sBAAsBV,8BAA8BG;QACpDQ,WAAW,CAAC,EAAEC,OAAO,EAAE;YACrB,IACEA,SAASC,WAAW,KACpBD,OAAO,CAAC,EAAE,CAACE,IAAI,KAAKN,0BAAc,CAACC,kBAAkB,EACrD;gBACA,MAAMM,oBAAS,CAACC,aAAa,CAAC;oBAC5BC,SAAS,CAAC,mBAAmB,EAAET,0BAAc,CAACC,kBAAkB,CAAC,SAAS,CAAC;gBAC7E;YACF;QACF;QACAS,cAAc;YAACC,iCAAW,CAACC,IAAI;SAAC;IAClC;AACF;AAEA,MAAMjB,cAA6D;IACjEkB,aAAa;IACbC,kBAAkB;AACpB;AAEO,MAAMvB,yBAAyBwB,OAAOC,MAAM,CAAC;IAClDvB;IACAC;IACAC;AACF;AAcO,SAASH,8BAA8B,EAC5CqB,WAAW,EACXC,gBAAgB,EACW;IAC3B,OAAO,eAAeG,gBACpBC,IAAoD;QAEpD,MAAMJ,iBAAiB;QAEvB,4EAA4E;QAC5E,MAAMK,SAASD,KAAKC,MAAM;QAE1B,MAAMC,OAAO,MAAMC,0BAAiB,CAACC,kBAAkB,CAAC;YACtD,MAAMT;YACN,CAAC,SAAS,CAAC;YACX,CAAC,MAAM,EAAEM,OAAOI,QAAQ,CAAC,CAAC,CAAC;SAC5B;QAED,OAAOH,KAAKI,MAAM;IACpB;AACF"}
|
|
@@ -1,76 +0,0 @@
|
|
|
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
|
-
GetEntropyArgsStruct: function() {
|
|
13
|
-
return GetEntropyArgsStruct;
|
|
14
|
-
},
|
|
15
|
-
getEntropyBuilder: function() {
|
|
16
|
-
return getEntropyBuilder;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _permissioncontroller = require("@metamask/permission-controller");
|
|
20
|
-
const _rpcerrors = require("@metamask/rpc-errors");
|
|
21
|
-
const _snapsutils = require("@metamask/snaps-utils");
|
|
22
|
-
const _utils = require("@metamask/utils");
|
|
23
|
-
const _superstruct = require("superstruct");
|
|
24
|
-
const _utils1 = require("../utils");
|
|
25
|
-
const targetName = 'snap_getEntropy';
|
|
26
|
-
const GetEntropyArgsStruct = (0, _superstruct.object)({
|
|
27
|
-
version: (0, _superstruct.literal)(1),
|
|
28
|
-
salt: (0, _superstruct.optional)((0, _superstruct.string)())
|
|
29
|
-
});
|
|
30
|
-
const specificationBuilder = ({ allowedCaveats = null, methodHooks })=>{
|
|
31
|
-
return {
|
|
32
|
-
permissionType: _permissioncontroller.PermissionType.RestrictedMethod,
|
|
33
|
-
targetName,
|
|
34
|
-
allowedCaveats,
|
|
35
|
-
methodImplementation: getEntropyImplementation(methodHooks),
|
|
36
|
-
subjectTypes: [
|
|
37
|
-
_permissioncontroller.SubjectType.Snap
|
|
38
|
-
]
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
const methodHooks = {
|
|
42
|
-
getMnemonic: true,
|
|
43
|
-
getUnlockPromise: true
|
|
44
|
-
};
|
|
45
|
-
const getEntropyBuilder = Object.freeze({
|
|
46
|
-
targetName,
|
|
47
|
-
specificationBuilder,
|
|
48
|
-
methodHooks
|
|
49
|
-
});
|
|
50
|
-
/**
|
|
51
|
-
* Builds the method implementation for `snap_getEntropy`. The implementation
|
|
52
|
-
* is based on the reference implementation of
|
|
53
|
-
* [SIP-6](https://metamask.github.io/SIPs/SIPS/sip-6).
|
|
54
|
-
*
|
|
55
|
-
* @param hooks - The RPC method hooks.
|
|
56
|
-
* @param hooks.getMnemonic - The method to get the mnemonic of the user's
|
|
57
|
-
* primary keyring.
|
|
58
|
-
* @param hooks.getUnlockPromise - The method to get a promise that resolves
|
|
59
|
-
* once the extension is unlocked.
|
|
60
|
-
* @returns The method implementation.
|
|
61
|
-
*/ function getEntropyImplementation({ getMnemonic, getUnlockPromise }) {
|
|
62
|
-
return async function getEntropy(options) {
|
|
63
|
-
const { params, context: { origin } } = options;
|
|
64
|
-
(0, _utils.assertStruct)(params, GetEntropyArgsStruct, 'Invalid "snap_getEntropy" parameters', _rpcerrors.rpcErrors.invalidParams);
|
|
65
|
-
await getUnlockPromise(true);
|
|
66
|
-
const mnemonicPhrase = await getMnemonic();
|
|
67
|
-
return (0, _utils1.deriveEntropy)({
|
|
68
|
-
input: origin,
|
|
69
|
-
salt: params.salt,
|
|
70
|
-
mnemonicPhrase,
|
|
71
|
-
magic: _snapsutils.SIP_6_MAGIC_VALUE
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
//# sourceMappingURL=getEntropy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/restricted/getEntropy.ts"],"sourcesContent":["import type {\n PermissionSpecificationBuilder,\n RestrictedMethodOptions,\n ValidPermissionSpecification,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type { GetEntropyParams, GetEntropyResult } from '@metamask/snaps-sdk';\nimport { SIP_6_MAGIC_VALUE } from '@metamask/snaps-utils';\nimport type { NonEmptyArray } from '@metamask/utils';\nimport { assertStruct } from '@metamask/utils';\nimport type { Infer } from 'superstruct';\nimport { literal, object, optional, string } from 'superstruct';\n\nimport type { MethodHooksObject } from '../utils';\nimport { deriveEntropy } from '../utils';\n\nconst targetName = 'snap_getEntropy';\n\ntype GetEntropySpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: GetEntropyHooks;\n};\n\ntype GetEntropySpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof targetName;\n methodImplementation: ReturnType<typeof getEntropyImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n}>;\n\nexport const GetEntropyArgsStruct = object({\n version: literal(1),\n salt: optional(string()),\n});\n\n/**\n * @property version - The version of the `snap_getEntropy` method. This must be\n * the numeric literal `1`.\n * @property salt - A string to use as the salt when deriving the entropy. If\n * omitted, the salt will be an empty string.\n */\nexport type GetEntropyArgs = Infer<typeof GetEntropyArgsStruct>;\n\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n GetEntropySpecificationBuilderOptions,\n GetEntropySpecification\n> = ({\n allowedCaveats = null,\n methodHooks,\n}: GetEntropySpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName,\n allowedCaveats,\n methodImplementation: getEntropyImplementation(methodHooks),\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<GetEntropyHooks> = {\n getMnemonic: true,\n getUnlockPromise: true,\n};\n\nexport const getEntropyBuilder = Object.freeze({\n targetName,\n specificationBuilder,\n methodHooks,\n} as const);\n\nexport type GetEntropyHooks = {\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\n/**\n * Builds the method implementation for `snap_getEntropy`. The implementation\n * is based on the reference implementation of\n * [SIP-6](https://metamask.github.io/SIPs/SIPS/sip-6).\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getMnemonic - The method to get the mnemonic of the user's\n * primary keyring.\n * @param hooks.getUnlockPromise - The method to get a promise that resolves\n * once the extension is unlocked.\n * @returns The method implementation.\n */\nfunction getEntropyImplementation({\n getMnemonic,\n getUnlockPromise,\n}: GetEntropyHooks) {\n return async function getEntropy(\n options: RestrictedMethodOptions<GetEntropyParams>,\n ): Promise<GetEntropyResult> {\n const {\n params,\n context: { origin },\n } = options;\n\n assertStruct(\n params,\n GetEntropyArgsStruct,\n 'Invalid \"snap_getEntropy\" parameters',\n rpcErrors.invalidParams,\n );\n\n await getUnlockPromise(true);\n const mnemonicPhrase = await getMnemonic();\n\n return deriveEntropy({\n input: origin,\n salt: params.salt,\n mnemonicPhrase,\n magic: SIP_6_MAGIC_VALUE,\n });\n };\n}\n"],"names":["GetEntropyArgsStruct","getEntropyBuilder","targetName","object","version","literal","salt","optional","string","specificationBuilder","allowedCaveats","methodHooks","permissionType","PermissionType","RestrictedMethod","methodImplementation","getEntropyImplementation","subjectTypes","SubjectType","Snap","getMnemonic","getUnlockPromise","Object","freeze","getEntropy","options","params","context","origin","assertStruct","rpcErrors","invalidParams","mnemonicPhrase","deriveEntropy","input","magic","SIP_6_MAGIC_VALUE"],"mappings":";;;;;;;;;;;IA+BaA,oBAAoB;eAApBA;;IAmCAC,iBAAiB;eAAjBA;;;sCA7D+B;2BAClB;4BAEQ;uBAEL;6BAEqB;wBAGpB;AAE9B,MAAMC,aAAa;AAcZ,MAAMF,uBAAuBG,IAAAA,mBAAM,EAAC;IACzCC,SAASC,IAAAA,oBAAO,EAAC;IACjBC,MAAMC,IAAAA,qBAAQ,EAACC,IAAAA,mBAAM;AACvB;AAUA,MAAMC,uBAIF,CAAC,EACHC,iBAAiB,IAAI,EACrBC,WAAW,EAC2B;IACtC,OAAO;QACLC,gBAAgBC,oCAAc,CAACC,gBAAgB;QAC/CZ;QACAQ;QACAK,sBAAsBC,yBAAyBL;QAC/CM,cAAc;YAACC,iCAAW,CAACC,IAAI;SAAC;IAClC;AACF;AAEA,MAAMR,cAAkD;IACtDS,aAAa;IACbC,kBAAkB;AACpB;AAEO,MAAMpB,oBAAoBqB,OAAOC,MAAM,CAAC;IAC7CrB;IACAO;IACAE;AACF;AAgBA;;;;;;;;;;;CAWC,GACD,SAASK,yBAAyB,EAChCI,WAAW,EACXC,gBAAgB,EACA;IAChB,OAAO,eAAeG,WACpBC,OAAkD;QAElD,MAAM,EACJC,MAAM,EACNC,SAAS,EAAEC,MAAM,EAAE,EACpB,GAAGH;QAEJI,IAAAA,mBAAY,EACVH,QACA1B,sBACA,wCACA8B,oBAAS,CAACC,aAAa;QAGzB,MAAMV,iBAAiB;QACvB,MAAMW,iBAAiB,MAAMZ;QAE7B,OAAOa,IAAAA,qBAAa,EAAC;YACnBC,OAAON;YACPtB,MAAMoB,OAAOpB,IAAI;YACjB0B;YACAG,OAAOC,6BAAiB;QAC1B;IACF;AACF"}
|
|
@@ -1,49 +0,0 @@
|
|
|
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
|
-
specificationBuilder: function() {
|
|
13
|
-
return specificationBuilder;
|
|
14
|
-
},
|
|
15
|
-
getLocaleBuilder: function() {
|
|
16
|
-
return getLocaleBuilder;
|
|
17
|
-
},
|
|
18
|
-
getImplementation: function() {
|
|
19
|
-
return getImplementation;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
const _permissioncontroller = require("@metamask/permission-controller");
|
|
23
|
-
const methodName = 'snap_getLocale';
|
|
24
|
-
const specificationBuilder = ({ allowedCaveats = null, methodHooks })=>{
|
|
25
|
-
return {
|
|
26
|
-
permissionType: _permissioncontroller.PermissionType.RestrictedMethod,
|
|
27
|
-
targetName: methodName,
|
|
28
|
-
allowedCaveats,
|
|
29
|
-
methodImplementation: getImplementation(methodHooks),
|
|
30
|
-
subjectTypes: [
|
|
31
|
-
_permissioncontroller.SubjectType.Snap
|
|
32
|
-
]
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
const methodHooks = {
|
|
36
|
-
getLocale: true
|
|
37
|
-
};
|
|
38
|
-
const getLocaleBuilder = Object.freeze({
|
|
39
|
-
targetName: methodName,
|
|
40
|
-
specificationBuilder,
|
|
41
|
-
methodHooks
|
|
42
|
-
});
|
|
43
|
-
function getImplementation({ getLocale }) {
|
|
44
|
-
return async function implementation(_args) {
|
|
45
|
-
return getLocale();
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
//# sourceMappingURL=getLocale.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/restricted/getLocale.ts"],"sourcesContent":["import type {\n PermissionSpecificationBuilder,\n ValidPermissionSpecification,\n RestrictedMethodOptions,\n RestrictedMethodParameters,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport type { GetLocaleResult } from '@metamask/snaps-sdk';\nimport type { NonEmptyArray } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nconst methodName = 'snap_getLocale';\n\nexport type GetLocaleMethodHooks = {\n getLocale: () => Promise<string>;\n};\n\ntype SpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: GetLocaleMethodHooks;\n};\n\ntype Specification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof methodName;\n methodImplementation: ReturnType<typeof getImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n}>;\n\n/**\n * The specification builder for the `snap_getLocale` permission.\n * `snap_getLocale` allows snaps to get the user selected locale.\n *\n * @param options - The specification builder options.\n * @param options.allowedCaveats - The optional allowed caveats for the permission.\n * @param options.methodHooks - The RPC method hooks needed by the method implementation.\n * @returns The specification for the `snap_getLocale` permission.\n */\nexport const specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n SpecificationBuilderOptions,\n Specification\n> = ({ allowedCaveats = null, methodHooks }: SpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName: methodName,\n allowedCaveats,\n methodImplementation: getImplementation(methodHooks),\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<GetLocaleMethodHooks> = {\n getLocale: true,\n};\n\nexport const getLocaleBuilder = Object.freeze({\n targetName: methodName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_getLocale`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getLocale - A function that returns the user selected locale.\n * @returns The user selected locale.\n */\nexport function getImplementation({ getLocale }: GetLocaleMethodHooks) {\n return async function implementation(\n _args: RestrictedMethodOptions<RestrictedMethodParameters>,\n ): Promise<GetLocaleResult> {\n return getLocale();\n };\n}\n"],"names":["specificationBuilder","getLocaleBuilder","getImplementation","methodName","allowedCaveats","methodHooks","permissionType","PermissionType","RestrictedMethod","targetName","methodImplementation","subjectTypes","SubjectType","Snap","getLocale","Object","freeze","implementation","_args"],"mappings":";;;;;;;;;;;IAuCaA,oBAAoB;eAApBA;;IAkBAC,gBAAgB;eAAhBA;;IAaGC,iBAAiB;eAAjBA;;;sCAhE4B;AAM5C,MAAMC,aAAa;AA2BZ,MAAMH,uBAIT,CAAC,EAAEI,iBAAiB,IAAI,EAAEC,WAAW,EAA+B;IACtE,OAAO;QACLC,gBAAgBC,oCAAc,CAACC,gBAAgB;QAC/CC,YAAYN;QACZC;QACAM,sBAAsBR,kBAAkBG;QACxCM,cAAc;YAACC,iCAAW,CAACC,IAAI;SAAC;IAClC;AACF;AAEA,MAAMR,cAAuD;IAC3DS,WAAW;AACb;AAEO,MAAMb,mBAAmBc,OAAOC,MAAM,CAAC;IAC5CP,YAAYN;IACZH;IACAK;AACF;AASO,SAASH,kBAAkB,EAAEY,SAAS,EAAwB;IACnE,OAAO,eAAeG,eACpBC,KAA0D;QAE1D,OAAOJ;IACT;AACF"}
|
|
@@ -1,59 +0,0 @@
|
|
|
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
|
-
WALLET_SNAP_PERMISSION_KEY: function() {
|
|
13
|
-
return _invokeSnap.WALLET_SNAP_PERMISSION_KEY;
|
|
14
|
-
},
|
|
15
|
-
getEncryptionKey: function() {
|
|
16
|
-
return _manageState.getEncryptionKey;
|
|
17
|
-
},
|
|
18
|
-
restrictedMethodPermissionBuilders: function() {
|
|
19
|
-
return restrictedMethodPermissionBuilders;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
const _dialog = require("./dialog");
|
|
23
|
-
const _getBip32Entropy = require("./getBip32Entropy");
|
|
24
|
-
const _getBip32PublicKey = require("./getBip32PublicKey");
|
|
25
|
-
const _getBip44Entropy = require("./getBip44Entropy");
|
|
26
|
-
const _getEntropy = require("./getEntropy");
|
|
27
|
-
const _getLocale = require("./getLocale");
|
|
28
|
-
const _invokeSnap = require("./invokeSnap");
|
|
29
|
-
const _manageAccounts = require("./manageAccounts");
|
|
30
|
-
const _manageState = require("./manageState");
|
|
31
|
-
const _notify = require("./notify");
|
|
32
|
-
_export_star(require("./caveats"), exports);
|
|
33
|
-
function _export_star(from, to) {
|
|
34
|
-
Object.keys(from).forEach(function(k) {
|
|
35
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
36
|
-
Object.defineProperty(to, k, {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function() {
|
|
39
|
-
return from[k];
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
return from;
|
|
45
|
-
}
|
|
46
|
-
const restrictedMethodPermissionBuilders = {
|
|
47
|
-
[_dialog.dialogBuilder.targetName]: _dialog.dialogBuilder,
|
|
48
|
-
[_getBip32Entropy.getBip32EntropyBuilder.targetName]: _getBip32Entropy.getBip32EntropyBuilder,
|
|
49
|
-
[_getBip32PublicKey.getBip32PublicKeyBuilder.targetName]: _getBip32PublicKey.getBip32PublicKeyBuilder,
|
|
50
|
-
[_getBip44Entropy.getBip44EntropyBuilder.targetName]: _getBip44Entropy.getBip44EntropyBuilder,
|
|
51
|
-
[_getEntropy.getEntropyBuilder.targetName]: _getEntropy.getEntropyBuilder,
|
|
52
|
-
[_invokeSnap.invokeSnapBuilder.targetName]: _invokeSnap.invokeSnapBuilder,
|
|
53
|
-
[_manageState.manageStateBuilder.targetName]: _manageState.manageStateBuilder,
|
|
54
|
-
[_notify.notifyBuilder.targetName]: _notify.notifyBuilder,
|
|
55
|
-
[_manageAccounts.manageAccountsBuilder.targetName]: _manageAccounts.manageAccountsBuilder,
|
|
56
|
-
[_getLocale.getLocaleBuilder.targetName]: _getLocale.getLocaleBuilder
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/restricted/index.ts"],"sourcesContent":["import type { DialogMethodHooks } from './dialog';\nimport { dialogBuilder } from './dialog';\nimport type { GetBip32EntropyMethodHooks } from './getBip32Entropy';\nimport { getBip32EntropyBuilder } from './getBip32Entropy';\nimport type { GetBip32PublicKeyMethodHooks } from './getBip32PublicKey';\nimport { getBip32PublicKeyBuilder } from './getBip32PublicKey';\nimport type { GetBip44EntropyMethodHooks } from './getBip44Entropy';\nimport { getBip44EntropyBuilder } from './getBip44Entropy';\nimport type { GetEntropyHooks } from './getEntropy';\nimport { getEntropyBuilder } from './getEntropy';\nimport type { GetLocaleMethodHooks } from './getLocale';\nimport { getLocaleBuilder } from './getLocale';\nimport type { InvokeSnapMethodHooks } from './invokeSnap';\nimport { invokeSnapBuilder } from './invokeSnap';\nimport type { ManageAccountsMethodHooks } from './manageAccounts';\nimport { manageAccountsBuilder } from './manageAccounts';\nimport type { ManageStateMethodHooks } from './manageState';\nimport { manageStateBuilder } from './manageState';\nimport type { NotifyMethodHooks } from './notify';\nimport { notifyBuilder } from './notify';\n\nexport { WALLET_SNAP_PERMISSION_KEY } from './invokeSnap';\nexport { getEncryptionKey } from './manageState';\n\nexport type RestrictedMethodHooks = DialogMethodHooks &\n GetBip32EntropyMethodHooks &\n GetBip32PublicKeyMethodHooks &\n GetBip44EntropyMethodHooks &\n GetEntropyHooks &\n InvokeSnapMethodHooks &\n ManageStateMethodHooks &\n NotifyMethodHooks &\n ManageAccountsMethodHooks &\n GetLocaleMethodHooks;\n\nexport const restrictedMethodPermissionBuilders = {\n [dialogBuilder.targetName]: dialogBuilder,\n [getBip32EntropyBuilder.targetName]: getBip32EntropyBuilder,\n [getBip32PublicKeyBuilder.targetName]: getBip32PublicKeyBuilder,\n [getBip44EntropyBuilder.targetName]: getBip44EntropyBuilder,\n [getEntropyBuilder.targetName]: getEntropyBuilder,\n [invokeSnapBuilder.targetName]: invokeSnapBuilder,\n [manageStateBuilder.targetName]: manageStateBuilder,\n [notifyBuilder.targetName]: notifyBuilder,\n [manageAccountsBuilder.targetName]: manageAccountsBuilder,\n [getLocaleBuilder.targetName]: getLocaleBuilder,\n} as const;\n\nexport * from './caveats';\n"],"names":["WALLET_SNAP_PERMISSION_KEY","getEncryptionKey","restrictedMethodPermissionBuilders","dialogBuilder","targetName","getBip32EntropyBuilder","getBip32PublicKeyBuilder","getBip44EntropyBuilder","getEntropyBuilder","invokeSnapBuilder","manageStateBuilder","notifyBuilder","manageAccountsBuilder","getLocaleBuilder"],"mappings":";;;;;;;;;;;IAqBSA,0BAA0B;eAA1BA,sCAA0B;;IAC1BC,gBAAgB;eAAhBA,6BAAgB;;IAaZC,kCAAkC;eAAlCA;;;wBAlCiB;iCAES;mCAEE;iCAEF;4BAEL;2BAED;4BAEC;gCAEI;6BAEH;wBAEL;qBA6BhB;;;;;;;;;;;;;;AAbP,MAAMA,qCAAqC;IAChD,CAACC,qBAAa,CAACC,UAAU,CAAC,EAAED,qBAAa;IACzC,CAACE,uCAAsB,CAACD,UAAU,CAAC,EAAEC,uCAAsB;IAC3D,CAACC,2CAAwB,CAACF,UAAU,CAAC,EAAEE,2CAAwB;IAC/D,CAACC,uCAAsB,CAACH,UAAU,CAAC,EAAEG,uCAAsB;IAC3D,CAACC,6BAAiB,CAACJ,UAAU,CAAC,EAAEI,6BAAiB;IACjD,CAACC,6BAAiB,CAACL,UAAU,CAAC,EAAEK,6BAAiB;IACjD,CAACC,+BAAkB,CAACN,UAAU,CAAC,EAAEM,+BAAkB;IACnD,CAACC,qBAAa,CAACP,UAAU,CAAC,EAAEO,qBAAa;IACzC,CAACC,qCAAqB,CAACR,UAAU,CAAC,EAAEQ,qCAAqB;IACzD,CAACC,2BAAgB,CAACT,UAAU,CAAC,EAAES,2BAAgB;AACjD"}
|
|
@@ -1,99 +0,0 @@
|
|
|
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
|
-
WALLET_SNAP_PERMISSION_KEY: function() {
|
|
13
|
-
return WALLET_SNAP_PERMISSION_KEY;
|
|
14
|
-
},
|
|
15
|
-
handleSnapInstall: function() {
|
|
16
|
-
return handleSnapInstall;
|
|
17
|
-
},
|
|
18
|
-
invokeSnapBuilder: function() {
|
|
19
|
-
return invokeSnapBuilder;
|
|
20
|
-
},
|
|
21
|
-
getInvokeSnapImplementation: function() {
|
|
22
|
-
return getInvokeSnapImplementation;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
const _permissioncontroller = require("@metamask/permission-controller");
|
|
26
|
-
const _rpcerrors = require("@metamask/rpc-errors");
|
|
27
|
-
const _snapsutils = require("@metamask/snaps-utils");
|
|
28
|
-
const WALLET_SNAP_PERMISSION_KEY = 'wallet_snap';
|
|
29
|
-
const handleSnapInstall = async ({ requestData, messagingSystem })=>{
|
|
30
|
-
const snaps = requestData.permissions[WALLET_SNAP_PERMISSION_KEY].caveats?.[0].value;
|
|
31
|
-
const permittedSnaps = messagingSystem.call(`SnapController:getPermitted`, requestData.metadata.origin);
|
|
32
|
-
const dedupedSnaps = Object.keys(snaps).reduce((filteredSnaps, snap)=>{
|
|
33
|
-
if (!permittedSnaps[snap]) {
|
|
34
|
-
filteredSnaps[snap] = snaps[snap];
|
|
35
|
-
}
|
|
36
|
-
return filteredSnaps;
|
|
37
|
-
}, {});
|
|
38
|
-
return messagingSystem.call(`SnapController:install`, requestData.metadata.origin, dedupedSnaps);
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* The specification builder for the `wallet_snap_*` permission.
|
|
42
|
-
*
|
|
43
|
-
* `wallet_snap_*` attempts to invoke an RPC method of the specified Snap.
|
|
44
|
-
*
|
|
45
|
-
* Requesting its corresponding permission will attempt to connect to the Snap,
|
|
46
|
-
* and install it if it's not available yet.
|
|
47
|
-
*
|
|
48
|
-
* @param options - The specification builder options.
|
|
49
|
-
* @param options.methodHooks - The RPC method hooks needed by the method implementation.
|
|
50
|
-
* @returns The specification for the `wallet_snap_*` permission.
|
|
51
|
-
*/ const specificationBuilder = ({ methodHooks })=>{
|
|
52
|
-
return {
|
|
53
|
-
permissionType: _permissioncontroller.PermissionType.RestrictedMethod,
|
|
54
|
-
targetName: WALLET_SNAP_PERMISSION_KEY,
|
|
55
|
-
allowedCaveats: [
|
|
56
|
-
_snapsutils.SnapCaveatType.SnapIds
|
|
57
|
-
],
|
|
58
|
-
methodImplementation: getInvokeSnapImplementation(methodHooks),
|
|
59
|
-
validator: ({ caveats })=>{
|
|
60
|
-
if (caveats?.length !== 1 || caveats[0].type !== _snapsutils.SnapCaveatType.SnapIds) {
|
|
61
|
-
throw _rpcerrors.rpcErrors.invalidParams({
|
|
62
|
-
message: `Expected a single "${_snapsutils.SnapCaveatType.SnapIds}" caveat.`
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
sideEffect: {
|
|
67
|
-
onPermitted: handleSnapInstall
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
const methodHooks = {
|
|
72
|
-
getSnap: true,
|
|
73
|
-
handleSnapRpcRequest: true
|
|
74
|
-
};
|
|
75
|
-
const invokeSnapBuilder = Object.freeze({
|
|
76
|
-
targetName: WALLET_SNAP_PERMISSION_KEY,
|
|
77
|
-
specificationBuilder,
|
|
78
|
-
methodHooks
|
|
79
|
-
});
|
|
80
|
-
function getInvokeSnapImplementation({ getSnap, handleSnapRpcRequest }) {
|
|
81
|
-
return async function invokeSnap(options) {
|
|
82
|
-
const { params = {}, context } = options;
|
|
83
|
-
const { snapId, request } = params;
|
|
84
|
-
if (!getSnap(snapId)) {
|
|
85
|
-
throw _rpcerrors.rpcErrors.invalidRequest({
|
|
86
|
-
message: `The snap "${snapId}" is not installed. Please install it first, before invoking the snap.`
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
const { origin } = context;
|
|
90
|
-
return await handleSnapRpcRequest({
|
|
91
|
-
snapId,
|
|
92
|
-
origin,
|
|
93
|
-
request,
|
|
94
|
-
handler: _snapsutils.HandlerType.OnRpcRequest
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
//# sourceMappingURL=invokeSnap.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/restricted/invokeSnap.ts"],"sourcesContent":["import type {\n PermissionSpecificationBuilder,\n RestrictedMethodOptions,\n ValidPermissionSpecification,\n PermissionValidatorConstraint,\n PermissionSideEffect,\n} from '@metamask/permission-controller';\nimport { PermissionType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type {\n InvokeSnapResult,\n RequestSnapsParams,\n RequestSnapsResult,\n} from '@metamask/snaps-sdk';\nimport type { Snap, SnapRpcHookArgs } from '@metamask/snaps-utils';\nimport { HandlerType, SnapCaveatType } from '@metamask/snaps-utils';\nimport type { Json, NonEmptyArray } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nexport const WALLET_SNAP_PERMISSION_KEY = 'wallet_snap';\n\n// Redeclare installSnaps action type to avoid circular dependencies\nexport type InstallSnaps = {\n type: `SnapController:install`;\n handler: (\n origin: string,\n requestedSnaps: RequestSnapsParams,\n ) => Promise<RequestSnapsResult>;\n};\n\nexport type GetPermittedSnaps = {\n type: `SnapController:getPermitted`;\n handler: (origin: string) => RequestSnapsResult;\n};\n\ntype AllowedActions = InstallSnaps | GetPermittedSnaps;\n\nexport type InvokeSnapMethodHooks = {\n getSnap: (snapId: string) => Snap | undefined;\n handleSnapRpcRequest: ({\n snapId,\n origin,\n handler,\n request,\n }: SnapRpcHookArgs & { snapId: string }) => Promise<unknown>;\n};\n\ntype InvokeSnapSpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: InvokeSnapMethodHooks;\n};\n\ntype InvokeSnapSpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof WALLET_SNAP_PERMISSION_KEY;\n methodImplementation: ReturnType<typeof getInvokeSnapImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n validator: PermissionValidatorConstraint;\n sideEffect: {\n onPermitted: PermissionSideEffect<AllowedActions, never>['onPermitted'];\n };\n}>;\n\nexport type InvokeSnapParams = {\n snapId: string;\n request: Record<string, Json>;\n};\n\n/**\n * The side-effect method to handle the snap install.\n *\n * @param params - The side-effect params.\n * @param params.requestData - The request data associated to the requested permission.\n * @param params.messagingSystem - The messenger to call an action.\n */\nexport const handleSnapInstall: PermissionSideEffect<\n AllowedActions,\n never\n>['onPermitted'] = async ({ requestData, messagingSystem }) => {\n const snaps = requestData.permissions[WALLET_SNAP_PERMISSION_KEY].caveats?.[0]\n .value as RequestSnapsParams;\n\n const permittedSnaps = messagingSystem.call(\n `SnapController:getPermitted`,\n requestData.metadata.origin,\n );\n\n const dedupedSnaps = Object.keys(snaps).reduce<RequestSnapsParams>(\n (filteredSnaps, snap) => {\n if (!permittedSnaps[snap]) {\n filteredSnaps[snap] = snaps[snap];\n }\n return filteredSnaps;\n },\n {},\n );\n\n return messagingSystem.call(\n `SnapController:install`,\n requestData.metadata.origin,\n dedupedSnaps,\n );\n};\n/**\n * The specification builder for the `wallet_snap_*` permission.\n *\n * `wallet_snap_*` attempts to invoke an RPC method of the specified Snap.\n *\n * Requesting its corresponding permission will attempt to connect to the Snap,\n * and install it if it's not available yet.\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 `wallet_snap_*` permission.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n InvokeSnapSpecificationBuilderOptions,\n InvokeSnapSpecification\n> = ({ methodHooks }: InvokeSnapSpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName: WALLET_SNAP_PERMISSION_KEY,\n allowedCaveats: [SnapCaveatType.SnapIds],\n methodImplementation: getInvokeSnapImplementation(methodHooks),\n validator: ({ caveats }) => {\n if (caveats?.length !== 1 || caveats[0].type !== SnapCaveatType.SnapIds) {\n throw rpcErrors.invalidParams({\n message: `Expected a single \"${SnapCaveatType.SnapIds}\" caveat.`,\n });\n }\n },\n sideEffect: {\n onPermitted: handleSnapInstall,\n },\n };\n};\n\nconst methodHooks: MethodHooksObject<InvokeSnapMethodHooks> = {\n getSnap: true,\n handleSnapRpcRequest: true,\n};\n\nexport const invokeSnapBuilder = Object.freeze({\n targetName: WALLET_SNAP_PERMISSION_KEY,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `wallet_snap_*`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getSnap - A function that retrieves all information stored about a snap.\n * @param hooks.handleSnapRpcRequest - A function that sends an RPC request to a snap's RPC handler or throws if that fails.\n * @returns The method implementation which returns the result of `handleSnapRpcRequest`.\n * @throws If the params are invalid.\n */\nexport function getInvokeSnapImplementation({\n getSnap,\n handleSnapRpcRequest,\n}: InvokeSnapMethodHooks) {\n return async function invokeSnap(\n options: RestrictedMethodOptions<InvokeSnapParams>,\n ): Promise<InvokeSnapResult> {\n const { params = {}, context } = options;\n\n const { snapId, request } = params as InvokeSnapParams;\n\n if (!getSnap(snapId)) {\n throw rpcErrors.invalidRequest({\n message: `The snap \"${snapId}\" is not installed. Please install it first, before invoking the snap.`,\n });\n }\n\n const { origin } = context;\n\n return (await handleSnapRpcRequest({\n snapId,\n origin,\n request,\n handler: HandlerType.OnRpcRequest,\n })) as Json;\n };\n}\n"],"names":["WALLET_SNAP_PERMISSION_KEY","handleSnapInstall","invokeSnapBuilder","getInvokeSnapImplementation","requestData","messagingSystem","snaps","permissions","caveats","value","permittedSnaps","call","metadata","origin","dedupedSnaps","Object","keys","reduce","filteredSnaps","snap","specificationBuilder","methodHooks","permissionType","PermissionType","RestrictedMethod","targetName","allowedCaveats","SnapCaveatType","SnapIds","methodImplementation","validator","length","type","rpcErrors","invalidParams","message","sideEffect","onPermitted","getSnap","handleSnapRpcRequest","freeze","invokeSnap","options","params","context","snapId","request","invalidRequest","handler","HandlerType","OnRpcRequest"],"mappings":";;;;;;;;;;;IAoBaA,0BAA0B;eAA1BA;;IAwDAC,iBAAiB;eAAjBA;;IAoEAC,iBAAiB;eAAjBA;;IAeGC,2BAA2B;eAA3BA;;;sCAxJe;2BACL;4BAOkB;AAKrC,MAAMH,6BAA6B;AAwDnC,MAAMC,oBAGM,OAAO,EAAEG,WAAW,EAAEC,eAAe,EAAE;IACxD,MAAMC,QAAQF,YAAYG,WAAW,CAACP,2BAA2B,CAACQ,OAAO,EAAE,CAAC,EAAE,CAC3EC;IAEH,MAAMC,iBAAiBL,gBAAgBM,IAAI,CACzC,CAAC,2BAA2B,CAAC,EAC7BP,YAAYQ,QAAQ,CAACC,MAAM;IAG7B,MAAMC,eAAeC,OAAOC,IAAI,CAACV,OAAOW,MAAM,CAC5C,CAACC,eAAeC;QACd,IAAI,CAACT,cAAc,CAACS,KAAK,EAAE;YACzBD,aAAa,CAACC,KAAK,GAAGb,KAAK,CAACa,KAAK;QACnC;QACA,OAAOD;IACT,GACA,CAAC;IAGH,OAAOb,gBAAgBM,IAAI,CACzB,CAAC,sBAAsB,CAAC,EACxBP,YAAYQ,QAAQ,CAACC,MAAM,EAC3BC;AAEJ;AACA;;;;;;;;;;;CAWC,GACD,MAAMM,uBAIF,CAAC,EAAEC,WAAW,EAAyC;IACzD,OAAO;QACLC,gBAAgBC,oCAAc,CAACC,gBAAgB;QAC/CC,YAAYzB;QACZ0B,gBAAgB;YAACC,0BAAc,CAACC,OAAO;SAAC;QACxCC,sBAAsB1B,4BAA4BkB;QAClDS,WAAW,CAAC,EAAEtB,OAAO,EAAE;YACrB,IAAIA,SAASuB,WAAW,KAAKvB,OAAO,CAAC,EAAE,CAACwB,IAAI,KAAKL,0BAAc,CAACC,OAAO,EAAE;gBACvE,MAAMK,oBAAS,CAACC,aAAa,CAAC;oBAC5BC,SAAS,CAAC,mBAAmB,EAAER,0BAAc,CAACC,OAAO,CAAC,SAAS,CAAC;gBAClE;YACF;QACF;QACAQ,YAAY;YACVC,aAAapC;QACf;IACF;AACF;AAEA,MAAMoB,cAAwD;IAC5DiB,SAAS;IACTC,sBAAsB;AACxB;AAEO,MAAMrC,oBAAoBa,OAAOyB,MAAM,CAAC;IAC7Cf,YAAYzB;IACZoB;IACAC;AACF;AAWO,SAASlB,4BAA4B,EAC1CmC,OAAO,EACPC,oBAAoB,EACE;IACtB,OAAO,eAAeE,WACpBC,OAAkD;QAElD,MAAM,EAAEC,SAAS,CAAC,CAAC,EAAEC,OAAO,EAAE,GAAGF;QAEjC,MAAM,EAAEG,MAAM,EAAEC,OAAO,EAAE,GAAGH;QAE5B,IAAI,CAACL,QAAQO,SAAS;YACpB,MAAMZ,oBAAS,CAACc,cAAc,CAAC;gBAC7BZ,SAAS,CAAC,UAAU,EAAEU,OAAO,sEAAsE,CAAC;YACtG;QACF;QAEA,MAAM,EAAEhC,MAAM,EAAE,GAAG+B;QAEnB,OAAQ,MAAML,qBAAqB;YACjCM;YACAhC;YACAiC;YACAE,SAASC,uBAAW,CAACC,YAAY;QACnC;IACF;AACF"}
|