@metamask/snaps-rpc-methods 6.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 +8 -2
- 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/{cjs/endowments/web-assembly.js.map → chunk-RZDRHJXI.js.map} +1 -1
- 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/{cjs/endowments/ethereum-provider.js.map → chunk-VZBSLVVA.js.map} +1 -1
- 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/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 +21 -18
- package/dist/cjs/endowments/caveats/generic.js +0 -40
- package/dist/cjs/endowments/caveats/generic.js.map +0 -1
- package/dist/cjs/endowments/caveats/index.js +0 -21
- package/dist/cjs/endowments/caveats/index.js.map +0 -1
- package/dist/cjs/endowments/caveats/requestTime.js +0 -99
- package/dist/cjs/endowments/caveats/requestTime.js.map +0 -1
- package/dist/cjs/endowments/cronjob.js +0 -100
- package/dist/cjs/endowments/cronjob.js.map +0 -1
- package/dist/cjs/endowments/enum.js +0 -26
- package/dist/cjs/endowments/enum.js.map +0 -1
- package/dist/cjs/endowments/ethereum-provider.js +0 -43
- package/dist/cjs/endowments/home-page.js +0 -37
- package/dist/cjs/endowments/home-page.js.map +0 -1
- package/dist/cjs/endowments/index.js +0 -121
- package/dist/cjs/endowments/index.js.map +0 -1
- package/dist/cjs/endowments/keyring.js +0 -104
- package/dist/cjs/endowments/keyring.js.map +0 -1
- package/dist/cjs/endowments/lifecycle-hooks.js +0 -37
- package/dist/cjs/endowments/lifecycle-hooks.js.map +0 -1
- package/dist/cjs/endowments/name-lookup.js +0 -148
- package/dist/cjs/endowments/name-lookup.js.map +0 -1
- package/dist/cjs/endowments/network-access.js +0 -44
- package/dist/cjs/endowments/network-access.js.map +0 -1
- package/dist/cjs/endowments/rpc.js +0 -103
- package/dist/cjs/endowments/rpc.js.map +0 -1
- package/dist/cjs/endowments/signature-insight.js +0 -110
- package/dist/cjs/endowments/signature-insight.js.map +0 -1
- package/dist/cjs/endowments/transaction-insight.js +0 -111
- package/dist/cjs/endowments/transaction-insight.js.map +0 -1
- package/dist/cjs/endowments/web-assembly.js +0 -42
- package/dist/cjs/index.js +0 -45
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/permissions.js +0 -62
- package/dist/cjs/permissions.js.map +0 -1
- package/dist/cjs/permitted/createInterface.js +0 -68
- package/dist/cjs/permitted/createInterface.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/getInterfaceState.js +0 -67
- package/dist/cjs/permitted/getInterfaceState.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 -43
- 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/permitted/updateInterface.js +0 -70
- package/dist/cjs/permitted/updateInterface.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 -172
- 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/endowments/caveats/generic.js +0 -40
- package/dist/esm/endowments/caveats/generic.js.map +0 -1
- package/dist/esm/endowments/caveats/index.js +0 -4
- package/dist/esm/endowments/caveats/index.js.map +0 -1
- package/dist/esm/endowments/caveats/requestTime.js +0 -93
- package/dist/esm/endowments/caveats/requestTime.js.map +0 -1
- package/dist/esm/endowments/cronjob.js +0 -99
- package/dist/esm/endowments/cronjob.js.map +0 -1
- package/dist/esm/endowments/enum.js +0 -16
- package/dist/esm/endowments/enum.js.map +0 -1
- package/dist/esm/endowments/ethereum-provider.js +0 -33
- package/dist/esm/endowments/ethereum-provider.js.map +0 -1
- package/dist/esm/endowments/home-page.js +0 -27
- package/dist/esm/endowments/home-page.js.map +0 -1
- package/dist/esm/endowments/index.js +0 -68
- package/dist/esm/endowments/index.js.map +0 -1
- package/dist/esm/endowments/keyring.js +0 -95
- package/dist/esm/endowments/keyring.js.map +0 -1
- package/dist/esm/endowments/lifecycle-hooks.js +0 -27
- package/dist/esm/endowments/lifecycle-hooks.js.map +0 -1
- package/dist/esm/endowments/name-lookup.js +0 -146
- package/dist/esm/endowments/name-lookup.js.map +0 -1
- package/dist/esm/endowments/network-access.js +0 -34
- package/dist/esm/endowments/network-access.js.map +0 -1
- package/dist/esm/endowments/rpc.js +0 -92
- package/dist/esm/endowments/rpc.js.map +0 -1
- package/dist/esm/endowments/signature-insight.js +0 -103
- package/dist/esm/endowments/signature-insight.js.map +0 -1
- package/dist/esm/endowments/transaction-insight.js +0 -104
- package/dist/esm/endowments/transaction-insight.js.map +0 -1
- package/dist/esm/endowments/web-assembly.js +0 -32
- package/dist/esm/endowments/web-assembly.js.map +0 -1
- package/dist/esm/index.js +0 -8
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/permissions.js +0 -51
- package/dist/esm/permissions.js.map +0 -1
- package/dist/esm/permitted/createInterface.js +0 -58
- package/dist/esm/permitted/createInterface.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/getInterfaceState.js +0 -57
- package/dist/esm/permitted/getInterfaceState.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 -25
- 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/permitted/updateInterface.js +0 -60
- package/dist/esm/permitted/updateInterface.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 -164
- 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/manageState.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 { ManageStateParams, ManageStateResult } from '@metamask/snaps-sdk';\nimport { ManageStateOperation } from '@metamask/snaps-sdk';\nimport { STATE_ENCRYPTION_MAGIC_VALUE, parseJson } from '@metamask/snaps-utils';\nimport type { Json, NonEmptyArray, Hex } from '@metamask/utils';\nimport { isObject, getJsonSize, assert, isValidJson } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\nimport { deriveEntropy } from '../utils';\n\n// The salt used for SIP-6-based entropy derivation.\nexport const STATE_ENCRYPTION_SALT = 'snap_manageState encryption';\n\nconst methodName = 'snap_manageState';\n\nexport type ManageStateMethodHooks = {\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 * A function that clears the state of the requesting Snap.\n */\n clearSnapState: (snapId: string, encrypted: boolean) => void;\n\n /**\n * A function that gets the encrypted state of the requesting Snap.\n *\n * @returns The current state of the Snap.\n */\n getSnapState: (snapId: string, encrypted: boolean) => string;\n\n /**\n * A function that updates the state of the requesting Snap.\n *\n * @param newState - The new state of the Snap.\n */\n updateSnapState: (\n snapId: string,\n newState: string,\n encrypted: boolean,\n ) => void;\n\n /**\n * Encrypts data with a key. This is assumed to perform symmetric encryption.\n *\n * @param key - The key to use for encryption, in hexadecimal format.\n * @param data - The JSON data to encrypt.\n * @returns The ciphertext as a string. The format for this string is\n * dependent on the implementation, but MUST be a string.\n */\n encrypt: (key: string, data: Json) => Promise<string>;\n\n /**\n * Decrypts data with a key. This is assumed to perform symmetric decryption.\n *\n * @param key - The key to use for decryption, in hexadecimal format.\n * @param cipherText - The ciphertext to decrypt. The format for this string\n * is dependent on the implementation, but MUST be a string.\n * @returns The decrypted data as a JSON object.\n */\n decrypt: (key: Hex, cipherText: string) => Promise<unknown>;\n};\n\ntype ManageStateSpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: ManageStateMethodHooks;\n};\n\ntype ManageStateSpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof methodName;\n methodImplementation: ReturnType<typeof getManageStateImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n}>;\n\n/**\n * The specification builder for the `snap_manageState` permission.\n * `snap_manageState` lets the Snap store and manage some of its state on\n * your device.\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_manageState` permission.\n */\nexport const specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n ManageStateSpecificationBuilderOptions,\n ManageStateSpecification\n> = ({\n allowedCaveats = null,\n methodHooks,\n}: ManageStateSpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName: methodName,\n allowedCaveats,\n methodImplementation: getManageStateImplementation(methodHooks),\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<ManageStateMethodHooks> = {\n getMnemonic: true,\n getUnlockPromise: true,\n clearSnapState: true,\n getSnapState: true,\n updateSnapState: true,\n encrypt: true,\n decrypt: true,\n};\n\nexport const manageStateBuilder = Object.freeze({\n targetName: methodName,\n specificationBuilder,\n methodHooks,\n} as const);\n\nexport const STORAGE_SIZE_LIMIT = 104857600; // In bytes (100MB)\n\ntype GetEncryptionKeyArgs = {\n snapId: string;\n mnemonicPhrase: Uint8Array;\n};\n\n/**\n * Get a deterministic encryption key to use for encrypting and decrypting the\n * state.\n *\n * This key should only be used for state encryption using `snap_manageState`.\n * To get other encryption keys, a different salt can be used.\n *\n * @param args - The encryption key args.\n * @param args.snapId - The ID of the snap to get the encryption key for.\n * @param args.mnemonicPhrase - The mnemonic phrase to derive the encryption key\n * from.\n * @returns The state encryption key.\n */\nexport async function getEncryptionKey({\n mnemonicPhrase,\n snapId,\n}: GetEncryptionKeyArgs) {\n return await deriveEntropy({\n mnemonicPhrase,\n input: snapId,\n salt: STATE_ENCRYPTION_SALT,\n magic: STATE_ENCRYPTION_MAGIC_VALUE,\n });\n}\n\ntype EncryptStateArgs = GetEncryptionKeyArgs & {\n state: Json;\n encryptFunction: ManageStateMethodHooks['encrypt'];\n};\n\n/**\n * Encrypt the state using a deterministic encryption algorithm, based on the\n * snap ID and mnemonic phrase.\n *\n * @param args - The encryption args.\n * @param args.state - The state to encrypt.\n * @param args.encryptFunction - The function to use for encrypting the state.\n * @param args.snapId - The ID of the snap to get the encryption key for.\n * @param args.mnemonicPhrase - The mnemonic phrase to derive the encryption key\n * from.\n * @returns The encrypted state.\n */\nasync function encryptState({\n state,\n encryptFunction,\n ...keyArgs\n}: EncryptStateArgs) {\n const encryptionKey = await getEncryptionKey(keyArgs);\n return await encryptFunction(encryptionKey, state);\n}\n\ntype DecryptStateArgs = GetEncryptionKeyArgs & {\n state: string;\n decryptFunction: ManageStateMethodHooks['decrypt'];\n};\n\n/**\n * Decrypt the state using a deterministic decryption algorithm, based on the\n * snap ID and mnemonic phrase.\n *\n * @param args - The encryption args.\n * @param args.state - The state to decrypt.\n * @param args.decryptFunction - The function to use for decrypting the state.\n * @param args.snapId - The ID of the snap to get the encryption key for.\n * @param args.mnemonicPhrase - The mnemonic phrase to derive the encryption key\n * from.\n * @returns The encrypted state.\n */\nasync function decryptState({\n state,\n decryptFunction,\n ...keyArgs\n}: DecryptStateArgs) {\n try {\n const encryptionKey = await getEncryptionKey(keyArgs);\n const decryptedState = await decryptFunction(encryptionKey, state);\n\n assert(isValidJson(decryptedState));\n\n return decryptedState as Record<string, Json>;\n } catch {\n throw rpcErrors.internal({\n message: 'Failed to decrypt snap state, the state must be corrupted.',\n });\n }\n}\n\n/**\n * Builds the method implementation for `snap_manageState`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.clearSnapState - A function that clears the state stored for a\n * snap.\n * @param hooks.getSnapState - A function that fetches the persisted decrypted\n * state for a snap.\n * @param hooks.updateSnapState - A function that updates the state stored for a\n * snap.\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 * @param hooks.encrypt - A function that encrypts the given state.\n * @param hooks.decrypt - A function that decrypts the given state.\n * @returns The method implementation which either returns `null` for a\n * successful state update/deletion or returns the decrypted state.\n * @throws If the params are invalid.\n */\nexport function getManageStateImplementation({\n getMnemonic,\n getUnlockPromise,\n clearSnapState,\n getSnapState,\n updateSnapState,\n encrypt,\n decrypt,\n}: ManageStateMethodHooks) {\n return async function manageState(\n options: RestrictedMethodOptions<ManageStateParams>,\n ): Promise<ManageStateResult> {\n const {\n params = {},\n method,\n context: { origin },\n } = options;\n const validatedParams = getValidatedParams(params, method);\n\n // If the encrypted param is undefined or null we default to true.\n const shouldEncrypt = validatedParams.encrypted ?? true;\n\n // We only need to prompt the user when the mnemonic is needed\n // which it isn't for the clear operation or unencrypted storage.\n if (\n shouldEncrypt &&\n validatedParams.operation !== ManageStateOperation.ClearState\n ) {\n await getUnlockPromise(true);\n }\n\n switch (validatedParams.operation) {\n case ManageStateOperation.ClearState:\n clearSnapState(origin, shouldEncrypt);\n return null;\n\n case ManageStateOperation.GetState: {\n const state = getSnapState(origin, shouldEncrypt);\n if (state === null) {\n return state;\n }\n return shouldEncrypt\n ? await decryptState({\n state,\n decryptFunction: decrypt,\n mnemonicPhrase: await getMnemonic(),\n snapId: origin,\n })\n : parseJson<Record<string, Json>>(state);\n }\n\n case ManageStateOperation.UpdateState: {\n const finalizedState = shouldEncrypt\n ? await encryptState({\n state: validatedParams.newState,\n encryptFunction: encrypt,\n mnemonicPhrase: await getMnemonic(),\n snapId: origin,\n })\n : JSON.stringify(validatedParams.newState);\n\n updateSnapState(origin, finalizedState, shouldEncrypt);\n return null;\n }\n\n default:\n throw rpcErrors.invalidParams(\n `Invalid ${method} operation: \"${\n validatedParams.operation as string\n }\"`,\n );\n }\n };\n}\n\n/**\n * Validates the manageState 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 method - RPC method name used for debugging errors.\n * @param storageSizeLimit - Maximum allowed size (in bytes) of a new state object.\n * @returns The validated method parameter object.\n */\nexport function getValidatedParams(\n params: unknown,\n method: string,\n storageSizeLimit = STORAGE_SIZE_LIMIT,\n): ManageStateParams {\n if (!isObject(params)) {\n throw rpcErrors.invalidParams({\n message: 'Expected params to be a single object.',\n });\n }\n\n const { operation, newState, encrypted } = params;\n\n if (\n !operation ||\n typeof operation !== 'string' ||\n !Object.values(ManageStateOperation).includes(\n operation as ManageStateOperation,\n )\n ) {\n throw rpcErrors.invalidParams({\n message: 'Must specify a valid manage state \"operation\".',\n });\n }\n\n if (encrypted !== undefined && typeof encrypted !== 'boolean') {\n throw rpcErrors.invalidParams({\n message: '\"encrypted\" parameter must be a boolean if specified.',\n });\n }\n\n if (operation === ManageStateOperation.UpdateState) {\n if (!isObject(newState)) {\n throw rpcErrors.invalidParams({\n message: `Invalid ${method} \"updateState\" parameter: The new state must be a plain object.`,\n data: {\n receivedNewState:\n typeof newState === 'undefined' ? 'undefined' : newState,\n },\n });\n }\n\n let size;\n try {\n // `getJsonSize` will throw if the state is not JSON serializable.\n size = getJsonSize(newState);\n } catch {\n throw rpcErrors.invalidParams({\n message: `Invalid ${method} \"updateState\" parameter: The new state must be JSON serializable.`,\n data: {\n receivedNewState:\n typeof newState === 'undefined' ? 'undefined' : newState,\n },\n });\n }\n\n if (size > storageSizeLimit) {\n throw rpcErrors.invalidParams({\n message: `Invalid ${method} \"updateState\" parameter: The new state must not exceed ${storageSizeLimit} bytes in size.`,\n data: {\n receivedNewState:\n typeof newState === 'undefined' ? 'undefined' : newState,\n },\n });\n }\n }\n\n return params as ManageStateParams;\n}\n"],"names":["STATE_ENCRYPTION_SALT","specificationBuilder","manageStateBuilder","STORAGE_SIZE_LIMIT","getEncryptionKey","getManageStateImplementation","getValidatedParams","methodName","allowedCaveats","methodHooks","permissionType","PermissionType","RestrictedMethod","targetName","methodImplementation","subjectTypes","SubjectType","Snap","getMnemonic","getUnlockPromise","clearSnapState","getSnapState","updateSnapState","encrypt","decrypt","Object","freeze","mnemonicPhrase","snapId","deriveEntropy","input","salt","magic","STATE_ENCRYPTION_MAGIC_VALUE","encryptState","state","encryptFunction","keyArgs","encryptionKey","decryptState","decryptFunction","decryptedState","assert","isValidJson","rpcErrors","internal","message","manageState","options","params","method","context","origin","validatedParams","shouldEncrypt","encrypted","operation","ManageStateOperation","ClearState","GetState","parseJson","UpdateState","finalizedState","newState","JSON","stringify","invalidParams","storageSizeLimit","isObject","values","includes","undefined","data","receivedNewState","size","getJsonSize"],"mappings":";;;;;;;;;;;IAiBaA,qBAAqB;eAArBA;;IAmFAC,oBAAoB;eAApBA;;IA2BAC,kBAAkB;eAAlBA;;IAMAC,kBAAkB;eAAlBA;;IAoBSC,gBAAgB;eAAhBA;;IA+FNC,4BAA4B;eAA5BA;;IAoFAC,kBAAkB;eAAlBA;;;sCAvU4B;2BAClB;0BAEW;4BACmB;uBAEG;wBAG7B;AAGvB,MAAMN,wBAAwB;AAErC,MAAMO,aAAa;AAiFZ,MAAMN,uBAIT,CAAC,EACHO,iBAAiB,IAAI,EACrBC,WAAW,EAC4B;IACvC,OAAO;QACLC,gBAAgBC,oCAAc,CAACC,gBAAgB;QAC/CC,YAAYN;QACZC;QACAM,sBAAsBT,6BAA6BI;QACnDM,cAAc;YAACC,iCAAW,CAACC,IAAI;SAAC;IAClC;AACF;AAEA,MAAMR,cAAyD;IAC7DS,aAAa;IACbC,kBAAkB;IAClBC,gBAAgB;IAChBC,cAAc;IACdC,iBAAiB;IACjBC,SAAS;IACTC,SAAS;AACX;AAEO,MAAMtB,qBAAqBuB,OAAOC,MAAM,CAAC;IAC9Cb,YAAYN;IACZN;IACAQ;AACF;AAEO,MAAMN,qBAAqB,WAAW,mBAAmB;AAoBzD,eAAeC,iBAAiB,EACrCuB,cAAc,EACdC,MAAM,EACe;IACrB,OAAO,MAAMC,IAAAA,qBAAa,EAAC;QACzBF;QACAG,OAAOF;QACPG,MAAM/B;QACNgC,OAAOC,wCAA4B;IACrC;AACF;AAOA;;;;;;;;;;;CAWC,GACD,eAAeC,aAAa,EAC1BC,KAAK,EACLC,eAAe,EACf,GAAGC,SACc;IACjB,MAAMC,gBAAgB,MAAMlC,iBAAiBiC;IAC7C,OAAO,MAAMD,gBAAgBE,eAAeH;AAC9C;AAOA;;;;;;;;;;;CAWC,GACD,eAAeI,aAAa,EAC1BJ,KAAK,EACLK,eAAe,EACf,GAAGH,SACc;IACjB,IAAI;QACF,MAAMC,gBAAgB,MAAMlC,iBAAiBiC;QAC7C,MAAMI,iBAAiB,MAAMD,gBAAgBF,eAAeH;QAE5DO,IAAAA,aAAM,EAACC,IAAAA,kBAAW,EAACF;QAEnB,OAAOA;IACT,EAAE,OAAM;QACN,MAAMG,oBAAS,CAACC,QAAQ,CAAC;YACvBC,SAAS;QACX;IACF;AACF;AAuBO,SAASzC,6BAA6B,EAC3Ca,WAAW,EACXC,gBAAgB,EAChBC,cAAc,EACdC,YAAY,EACZC,eAAe,EACfC,OAAO,EACPC,OAAO,EACgB;IACvB,OAAO,eAAeuB,YACpBC,OAAmD;QAEnD,MAAM,EACJC,SAAS,CAAC,CAAC,EACXC,MAAM,EACNC,SAAS,EAAEC,MAAM,EAAE,EACpB,GAAGJ;QACJ,MAAMK,kBAAkB/C,mBAAmB2C,QAAQC;QAEnD,kEAAkE;QAClE,MAAMI,gBAAgBD,gBAAgBE,SAAS,IAAI;QAEnD,8DAA8D;QAC9D,iEAAiE;QACjE,IACED,iBACAD,gBAAgBG,SAAS,KAAKC,8BAAoB,CAACC,UAAU,EAC7D;YACA,MAAMvC,iBAAiB;QACzB;QAEA,OAAQkC,gBAAgBG,SAAS;YAC/B,KAAKC,8BAAoB,CAACC,UAAU;gBAClCtC,eAAegC,QAAQE;gBACvB,OAAO;YAET,KAAKG,8BAAoB,CAACE,QAAQ;gBAAE;oBAClC,MAAMxB,QAAQd,aAAa+B,QAAQE;oBACnC,IAAInB,UAAU,MAAM;wBAClB,OAAOA;oBACT;oBACA,OAAOmB,gBACH,MAAMf,aAAa;wBACjBJ;wBACAK,iBAAiBhB;wBACjBG,gBAAgB,MAAMT;wBACtBU,QAAQwB;oBACV,KACAQ,IAAAA,qBAAS,EAAuBzB;gBACtC;YAEA,KAAKsB,8BAAoB,CAACI,WAAW;gBAAE;oBACrC,MAAMC,iBAAiBR,gBACnB,MAAMpB,aAAa;wBACjBC,OAAOkB,gBAAgBU,QAAQ;wBAC/B3B,iBAAiBb;wBACjBI,gBAAgB,MAAMT;wBACtBU,QAAQwB;oBACV,KACAY,KAAKC,SAAS,CAACZ,gBAAgBU,QAAQ;oBAE3CzC,gBAAgB8B,QAAQU,gBAAgBR;oBACxC,OAAO;gBACT;YAEA;gBACE,MAAMV,oBAAS,CAACsB,aAAa,CAC3B,CAAC,QAAQ,EAAEhB,OAAO,aAAa,EAC7BG,gBAAgBG,SAAS,CAC1B,CAAC,CAAC;QAET;IACF;AACF;AAWO,SAASlD,mBACd2C,MAAe,EACfC,MAAc,EACdiB,mBAAmBhE,kBAAkB;IAErC,IAAI,CAACiE,IAAAA,eAAQ,EAACnB,SAAS;QACrB,MAAML,oBAAS,CAACsB,aAAa,CAAC;YAC5BpB,SAAS;QACX;IACF;IAEA,MAAM,EAAEU,SAAS,EAAEO,QAAQ,EAAER,SAAS,EAAE,GAAGN;IAE3C,IACE,CAACO,aACD,OAAOA,cAAc,YACrB,CAAC/B,OAAO4C,MAAM,CAACZ,8BAAoB,EAAEa,QAAQ,CAC3Cd,YAEF;QACA,MAAMZ,oBAAS,CAACsB,aAAa,CAAC;YAC5BpB,SAAS;QACX;IACF;IAEA,IAAIS,cAAcgB,aAAa,OAAOhB,cAAc,WAAW;QAC7D,MAAMX,oBAAS,CAACsB,aAAa,CAAC;YAC5BpB,SAAS;QACX;IACF;IAEA,IAAIU,cAAcC,8BAAoB,CAACI,WAAW,EAAE;QAClD,IAAI,CAACO,IAAAA,eAAQ,EAACL,WAAW;YACvB,MAAMnB,oBAAS,CAACsB,aAAa,CAAC;gBAC5BpB,SAAS,CAAC,QAAQ,EAAEI,OAAO,+DAA+D,CAAC;gBAC3FsB,MAAM;oBACJC,kBACE,OAAOV,aAAa,cAAc,cAAcA;gBACpD;YACF;QACF;QAEA,IAAIW;QACJ,IAAI;YACF,kEAAkE;YAClEA,OAAOC,IAAAA,kBAAW,EAACZ;QACrB,EAAE,OAAM;YACN,MAAMnB,oBAAS,CAACsB,aAAa,CAAC;gBAC5BpB,SAAS,CAAC,QAAQ,EAAEI,OAAO,kEAAkE,CAAC;gBAC9FsB,MAAM;oBACJC,kBACE,OAAOV,aAAa,cAAc,cAAcA;gBACpD;YACF;QACF;QAEA,IAAIW,OAAOP,kBAAkB;YAC3B,MAAMvB,oBAAS,CAACsB,aAAa,CAAC;gBAC5BpB,SAAS,CAAC,QAAQ,EAAEI,OAAO,wDAAwD,EAAEiB,iBAAiB,eAAe,CAAC;gBACtHK,MAAM;oBACJC,kBACE,OAAOV,aAAa,cAAc,cAAcA;gBACpD;YACF;QACF;IACF;IAEA,OAAOd;AACT"}
|
|
@@ -1,92 +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
|
-
notifyBuilder: function() {
|
|
16
|
-
return notifyBuilder;
|
|
17
|
-
},
|
|
18
|
-
getImplementation: function() {
|
|
19
|
-
return getImplementation;
|
|
20
|
-
},
|
|
21
|
-
getValidatedParams: function() {
|
|
22
|
-
return getValidatedParams;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
const _permissioncontroller = require("@metamask/permission-controller");
|
|
26
|
-
const _rpcerrors = require("@metamask/rpc-errors");
|
|
27
|
-
const _snapssdk = require("@metamask/snaps-sdk");
|
|
28
|
-
const _snapsutils = require("@metamask/snaps-utils");
|
|
29
|
-
const _utils = require("@metamask/utils");
|
|
30
|
-
const methodName = 'snap_notify';
|
|
31
|
-
const specificationBuilder = ({ allowedCaveats = null, methodHooks })=>{
|
|
32
|
-
return {
|
|
33
|
-
permissionType: _permissioncontroller.PermissionType.RestrictedMethod,
|
|
34
|
-
targetName: methodName,
|
|
35
|
-
allowedCaveats,
|
|
36
|
-
methodImplementation: getImplementation(methodHooks),
|
|
37
|
-
subjectTypes: [
|
|
38
|
-
_permissioncontroller.SubjectType.Snap
|
|
39
|
-
]
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
const methodHooks = {
|
|
43
|
-
showNativeNotification: true,
|
|
44
|
-
showInAppNotification: true,
|
|
45
|
-
isOnPhishingList: true,
|
|
46
|
-
maybeUpdatePhishingList: true
|
|
47
|
-
};
|
|
48
|
-
const notifyBuilder = Object.freeze({
|
|
49
|
-
targetName: methodName,
|
|
50
|
-
specificationBuilder,
|
|
51
|
-
methodHooks
|
|
52
|
-
});
|
|
53
|
-
function getImplementation({ showNativeNotification, showInAppNotification, isOnPhishingList, maybeUpdatePhishingList }) {
|
|
54
|
-
return async function implementation(args) {
|
|
55
|
-
const { params, context: { origin } } = args;
|
|
56
|
-
const validatedParams = getValidatedParams(params);
|
|
57
|
-
await maybeUpdatePhishingList();
|
|
58
|
-
(0, _snapsutils.validateTextLinks)(validatedParams.message, isOnPhishingList);
|
|
59
|
-
switch(validatedParams.type){
|
|
60
|
-
case _snapssdk.NotificationType.Native:
|
|
61
|
-
return await showNativeNotification(origin, validatedParams);
|
|
62
|
-
case _snapssdk.NotificationType.InApp:
|
|
63
|
-
return await showInAppNotification(origin, validatedParams);
|
|
64
|
-
default:
|
|
65
|
-
throw _rpcerrors.rpcErrors.invalidParams({
|
|
66
|
-
message: 'Must specify a valid notification "type".'
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function getValidatedParams(params) {
|
|
72
|
-
if (!(0, _utils.isObject)(params)) {
|
|
73
|
-
throw _rpcerrors.rpcErrors.invalidParams({
|
|
74
|
-
message: 'Expected params to be a single object.'
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
const { type, message } = params;
|
|
78
|
-
if (!type || typeof type !== 'string' || !Object.values(_snapssdk.NotificationType).includes(type)) {
|
|
79
|
-
throw _rpcerrors.rpcErrors.invalidParams({
|
|
80
|
-
message: 'Must specify a valid notification "type".'
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
// Set to the max message length on a Mac notification for now.
|
|
84
|
-
if (!message || typeof message !== 'string' || message.length >= 50) {
|
|
85
|
-
throw _rpcerrors.rpcErrors.invalidParams({
|
|
86
|
-
message: 'Must specify a non-empty string "message" less than 50 characters long.'
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
return params;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
//# sourceMappingURL=notify.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/restricted/notify.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 { NotificationType } from '@metamask/snaps-sdk';\nimport type {\n NotifyParams,\n NotifyResult,\n EnumToUnion,\n} from '@metamask/snaps-sdk';\nimport { validateTextLinks } from '@metamask/snaps-utils';\nimport type { NonEmptyArray } from '@metamask/utils';\nimport { isObject } from '@metamask/utils';\n\nimport { type MethodHooksObject } from '../utils';\n\nconst methodName = 'snap_notify';\n\nexport type NotificationArgs = {\n /**\n * Enum type to determine notification type.\n */\n type: EnumToUnion<NotificationType>;\n\n /**\n * A message to show on the notification.\n */\n message: string;\n};\n\nexport type NotifyMethodHooks = {\n /**\n * @param snapId - The ID of the Snap that created the notification.\n * @param args - The notification arguments.\n */\n showNativeNotification: (\n snapId: string,\n args: NotificationArgs,\n ) => Promise<null>;\n\n /**\n * @param snapId - The ID of the Snap that created the notification.\n * @param args - The notification arguments.\n */\n showInAppNotification: (\n snapId: string,\n args: NotificationArgs,\n ) => Promise<null>;\n\n isOnPhishingList: (url: string) => boolean;\n\n maybeUpdatePhishingList: () => Promise<void>;\n};\n\ntype SpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: NotifyMethodHooks;\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_notify` permission.\n * `snap_notify` allows snaps to send multiple types of notifications to its users.\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_notify` 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<NotifyMethodHooks> = {\n showNativeNotification: true,\n showInAppNotification: true,\n isOnPhishingList: true,\n maybeUpdatePhishingList: true,\n};\n\nexport const notifyBuilder = Object.freeze({\n targetName: methodName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_notify`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.showNativeNotification - A function that shows a native browser notification.\n * @param hooks.showInAppNotification - A function that shows a notification in the MetaMask UI.\n * @param hooks.isOnPhishingList - A function that checks for links against the phishing list.\n * @param hooks.maybeUpdatePhishingList - A function that updates the phishing list if needed.\n * @returns The method implementation which returns `null` on success.\n * @throws If the params are invalid.\n */\nexport function getImplementation({\n showNativeNotification,\n showInAppNotification,\n isOnPhishingList,\n maybeUpdatePhishingList,\n}: NotifyMethodHooks) {\n return async function implementation(\n args: RestrictedMethodOptions<NotifyParams>,\n ): Promise<NotifyResult> {\n const {\n params,\n context: { origin },\n } = args;\n\n const validatedParams = getValidatedParams(params);\n\n await maybeUpdatePhishingList();\n\n validateTextLinks(validatedParams.message, isOnPhishingList);\n\n switch (validatedParams.type) {\n case NotificationType.Native:\n return await showNativeNotification(origin, validatedParams);\n case NotificationType.InApp:\n return await showInAppNotification(origin, validatedParams);\n default:\n throw rpcErrors.invalidParams({\n message: 'Must specify a valid notification \"type\".',\n });\n }\n };\n}\n\n/**\n * Validates the notify 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): NotifyParams {\n if (!isObject(params)) {\n throw rpcErrors.invalidParams({\n message: 'Expected params to be a single object.',\n });\n }\n\n const { type, message } = params;\n\n if (\n !type ||\n typeof type !== 'string' ||\n !Object.values(NotificationType).includes(type as NotificationType)\n ) {\n throw rpcErrors.invalidParams({\n message: 'Must specify a valid notification \"type\".',\n });\n }\n\n // Set to the max message length on a Mac notification for now.\n if (!message || typeof message !== 'string' || message.length >= 50) {\n throw rpcErrors.invalidParams({\n message:\n 'Must specify a non-empty string \"message\" less than 50 characters long.',\n });\n }\n\n return params as NotificationArgs;\n}\n"],"names":["specificationBuilder","notifyBuilder","getImplementation","getValidatedParams","methodName","allowedCaveats","methodHooks","permissionType","PermissionType","RestrictedMethod","targetName","methodImplementation","subjectTypes","SubjectType","Snap","showNativeNotification","showInAppNotification","isOnPhishingList","maybeUpdatePhishingList","Object","freeze","implementation","args","params","context","origin","validatedParams","validateTextLinks","message","type","NotificationType","Native","InApp","rpcErrors","invalidParams","isObject","values","includes","length"],"mappings":";;;;;;;;;;;IA8EaA,oBAAoB;eAApBA;;IAqBAC,aAAa;eAAbA;;IAiBGC,iBAAiB;eAAjBA;;IAwCAC,kBAAkB;eAAlBA;;;sCAvJ4B;2BAClB;0BACO;4BAMC;uBAET;AAIzB,MAAMC,aAAa;AA2DZ,MAAMJ,uBAIT,CAAC,EAAEK,iBAAiB,IAAI,EAAEC,WAAW,EAA+B;IACtE,OAAO;QACLC,gBAAgBC,oCAAc,CAACC,gBAAgB;QAC/CC,YAAYN;QACZC;QACAM,sBAAsBT,kBAAkBI;QACxCM,cAAc;YAACC,iCAAW,CAACC,IAAI;SAAC;IAClC;AACF;AAEA,MAAMR,cAAoD;IACxDS,wBAAwB;IACxBC,uBAAuB;IACvBC,kBAAkB;IAClBC,yBAAyB;AAC3B;AAEO,MAAMjB,gBAAgBkB,OAAOC,MAAM,CAAC;IACzCV,YAAYN;IACZJ;IACAM;AACF;AAaO,SAASJ,kBAAkB,EAChCa,sBAAsB,EACtBC,qBAAqB,EACrBC,gBAAgB,EAChBC,uBAAuB,EACL;IAClB,OAAO,eAAeG,eACpBC,IAA2C;QAE3C,MAAM,EACJC,MAAM,EACNC,SAAS,EAAEC,MAAM,EAAE,EACpB,GAAGH;QAEJ,MAAMI,kBAAkBvB,mBAAmBoB;QAE3C,MAAML;QAENS,IAAAA,6BAAiB,EAACD,gBAAgBE,OAAO,EAAEX;QAE3C,OAAQS,gBAAgBG,IAAI;YAC1B,KAAKC,0BAAgB,CAACC,MAAM;gBAC1B,OAAO,MAAMhB,uBAAuBU,QAAQC;YAC9C,KAAKI,0BAAgB,CAACE,KAAK;gBACzB,OAAO,MAAMhB,sBAAsBS,QAAQC;YAC7C;gBACE,MAAMO,oBAAS,CAACC,aAAa,CAAC;oBAC5BN,SAAS;gBACX;QACJ;IACF;AACF;AASO,SAASzB,mBAAmBoB,MAAe;IAChD,IAAI,CAACY,IAAAA,eAAQ,EAACZ,SAAS;QACrB,MAAMU,oBAAS,CAACC,aAAa,CAAC;YAC5BN,SAAS;QACX;IACF;IAEA,MAAM,EAAEC,IAAI,EAAED,OAAO,EAAE,GAAGL;IAE1B,IACE,CAACM,QACD,OAAOA,SAAS,YAChB,CAACV,OAAOiB,MAAM,CAACN,0BAAgB,EAAEO,QAAQ,CAACR,OAC1C;QACA,MAAMI,oBAAS,CAACC,aAAa,CAAC;YAC5BN,SAAS;QACX;IACF;IAEA,+DAA+D;IAC/D,IAAI,CAACA,WAAW,OAAOA,YAAY,YAAYA,QAAQU,MAAM,IAAI,IAAI;QACnE,MAAML,oBAAS,CAACC,aAAa,CAAC;YAC5BN,SACE;QACJ;IACF;IAEA,OAAOL;AACT"}
|
package/dist/cjs/utils.js
DELETED
|
@@ -1,98 +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
|
-
selectHooks: function() {
|
|
13
|
-
return selectHooks;
|
|
14
|
-
},
|
|
15
|
-
deriveEntropy: function() {
|
|
16
|
-
return deriveEntropy;
|
|
17
|
-
},
|
|
18
|
-
getPathPrefix: function() {
|
|
19
|
-
return getPathPrefix;
|
|
20
|
-
},
|
|
21
|
-
getNode: function() {
|
|
22
|
-
return getNode;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
const _keytree = require("@metamask/key-tree");
|
|
26
|
-
const _utils = require("@metamask/utils");
|
|
27
|
-
const _sha3 = require("@noble/hashes/sha3");
|
|
28
|
-
const HARDENED_VALUE = 0x80000000;
|
|
29
|
-
function selectHooks(hooks, hookNames) {
|
|
30
|
-
if (hookNames) {
|
|
31
|
-
return Object.keys(hookNames).reduce((hookSubset, _hookName)=>{
|
|
32
|
-
const hookName = _hookName;
|
|
33
|
-
hookSubset[hookName] = hooks[hookName];
|
|
34
|
-
return hookSubset;
|
|
35
|
-
}, {});
|
|
36
|
-
}
|
|
37
|
-
return undefined;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Get a BIP-32 derivation path array from a hash, which is compatible with
|
|
41
|
-
* `@metamask/key-tree`. The hash is assumed to be 32 bytes long.
|
|
42
|
-
*
|
|
43
|
-
* @param hash - The hash to derive indices from.
|
|
44
|
-
* @returns The derived indices as a {@link HardenedBIP32Node} array.
|
|
45
|
-
*/ function getDerivationPathArray(hash) {
|
|
46
|
-
const array = [];
|
|
47
|
-
const view = (0, _utils.createDataView)(hash);
|
|
48
|
-
for(let index = 0; index < 8; index++){
|
|
49
|
-
const uint32 = view.getUint32(index * 4);
|
|
50
|
-
// This is essentially `index | 0x80000000`. Because JavaScript numbers are
|
|
51
|
-
// signed, we use the bitwise unsigned right shift operator to ensure that
|
|
52
|
-
// the result is a positive number.
|
|
53
|
-
// eslint-disable-next-line no-bitwise
|
|
54
|
-
const pathIndex = (uint32 | HARDENED_VALUE) >>> 0;
|
|
55
|
-
array.push(`bip32:${pathIndex - HARDENED_VALUE}'`);
|
|
56
|
-
}
|
|
57
|
-
return array;
|
|
58
|
-
}
|
|
59
|
-
async function deriveEntropy({ input, salt = '', mnemonicPhrase, magic }) {
|
|
60
|
-
const inputBytes = (0, _utils.stringToBytes)(input);
|
|
61
|
-
const saltBytes = (0, _utils.stringToBytes)(salt);
|
|
62
|
-
// Get the derivation path from the snap ID.
|
|
63
|
-
const hash = (0, _sha3.keccak_256)((0, _utils.concatBytes)([
|
|
64
|
-
inputBytes,
|
|
65
|
-
(0, _sha3.keccak_256)(saltBytes)
|
|
66
|
-
]));
|
|
67
|
-
const computedDerivationPath = getDerivationPathArray(hash);
|
|
68
|
-
// Derive the private key using BIP-32.
|
|
69
|
-
const { privateKey } = await _keytree.SLIP10Node.fromDerivationPath({
|
|
70
|
-
derivationPath: [
|
|
71
|
-
mnemonicPhrase,
|
|
72
|
-
`bip32:${magic}`,
|
|
73
|
-
...computedDerivationPath
|
|
74
|
-
],
|
|
75
|
-
curve: 'secp256k1'
|
|
76
|
-
});
|
|
77
|
-
// This should never happen, but this keeps TypeScript happy.
|
|
78
|
-
(0, _utils.assert)(privateKey, 'Failed to derive the entropy.');
|
|
79
|
-
return (0, _utils.add0x)(privateKey);
|
|
80
|
-
}
|
|
81
|
-
function getPathPrefix(curve) {
|
|
82
|
-
if (curve === 'secp256k1') {
|
|
83
|
-
return 'bip32';
|
|
84
|
-
}
|
|
85
|
-
return 'slip10';
|
|
86
|
-
}
|
|
87
|
-
async function getNode({ curve, secretRecoveryPhrase, path }) {
|
|
88
|
-
const prefix = getPathPrefix(curve);
|
|
89
|
-
return await _keytree.SLIP10Node.fromDerivationPath({
|
|
90
|
-
curve,
|
|
91
|
-
derivationPath: [
|
|
92
|
-
secretRecoveryPhrase,
|
|
93
|
-
...path.slice(1).map((index)=>`${prefix}:${index}`)
|
|
94
|
-
]
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { rpcErrors } from '@metamask/rpc-errors';
|
|
2
|
-
/**
|
|
3
|
-
* Create a generic permission validator that validates the presence of certain caveats.
|
|
4
|
-
*
|
|
5
|
-
* This validator only validates the types of the caveats, not the values.
|
|
6
|
-
*
|
|
7
|
-
* @param caveatsToValidate - A list of objects that represent caveats.
|
|
8
|
-
* @param caveatsToValidate.type - The string defining the caveat type.
|
|
9
|
-
* @param caveatsToValidate.optional - An optional boolean flag that defines
|
|
10
|
-
* whether the caveat is optional or not.
|
|
11
|
-
* @returns A function that validates a permission.
|
|
12
|
-
*/ export function createGenericPermissionValidator(caveatsToValidate) {
|
|
13
|
-
const validCaveatTypes = new Set(caveatsToValidate.map((caveat)=>caveat.type));
|
|
14
|
-
const requiredCaveats = caveatsToValidate.filter((caveat)=>!caveat.optional);
|
|
15
|
-
return function({ caveats }) {
|
|
16
|
-
const actualCaveats = caveats ?? [];
|
|
17
|
-
const passedCaveatTypes = actualCaveats.map((caveat)=>caveat.type);
|
|
18
|
-
const passedCaveatsSet = new Set(passedCaveatTypes);
|
|
19
|
-
// Disallow duplicates
|
|
20
|
-
if (passedCaveatsSet.size !== passedCaveatTypes.length) {
|
|
21
|
-
throw rpcErrors.invalidParams({
|
|
22
|
-
message: 'Duplicate caveats are not allowed.'
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
// Disallow caveats that don't match expected types
|
|
26
|
-
if (!actualCaveats.every((caveat)=>validCaveatTypes.has(caveat.type))) {
|
|
27
|
-
throw rpcErrors.invalidParams({
|
|
28
|
-
message: `Expected the following caveats: ${caveatsToValidate.map((caveat)=>`"${caveat.type}"`).join(', ')}, received ${actualCaveats.map((caveat)=>`"${caveat.type}"`).join(', ')}.`
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
// Fail if not all required caveats are specified
|
|
32
|
-
if (!requiredCaveats.every((caveat)=>passedCaveatsSet.has(caveat.type))) {
|
|
33
|
-
throw rpcErrors.invalidParams({
|
|
34
|
-
message: `Expected the following caveats: ${requiredCaveats.map((caveat)=>`"${caveat.type}"`).join(', ')}.`
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
//# sourceMappingURL=generic.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/endowments/caveats/generic.ts"],"sourcesContent":["import type {\n PermissionConstraint,\n PermissionValidatorConstraint,\n} from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type { Json } from '@metamask/utils';\n\nexport type CaveatMapperReturnValue = Pick<PermissionConstraint, 'caveats'>;\n\nexport type CaveatMapperFunction = (value: Json) => CaveatMapperReturnValue;\n\n/**\n * Create a generic permission validator that validates the presence of certain caveats.\n *\n * This validator only validates the types of the caveats, not the values.\n *\n * @param caveatsToValidate - A list of objects that represent caveats.\n * @param caveatsToValidate.type - The string defining the caveat type.\n * @param caveatsToValidate.optional - An optional boolean flag that defines\n * whether the caveat is optional or not.\n * @returns A function that validates a permission.\n */\nexport function createGenericPermissionValidator(\n caveatsToValidate: {\n type: string;\n optional?: boolean;\n }[],\n): PermissionValidatorConstraint {\n const validCaveatTypes = new Set(\n caveatsToValidate.map((caveat) => caveat.type),\n );\n const requiredCaveats = caveatsToValidate.filter(\n (caveat) => !caveat.optional,\n );\n\n return function ({ caveats }) {\n const actualCaveats = caveats ?? [];\n const passedCaveatTypes = actualCaveats.map((caveat) => caveat.type);\n const passedCaveatsSet = new Set(passedCaveatTypes);\n\n // Disallow duplicates\n if (passedCaveatsSet.size !== passedCaveatTypes.length) {\n throw rpcErrors.invalidParams({\n message: 'Duplicate caveats are not allowed.',\n });\n }\n\n // Disallow caveats that don't match expected types\n if (!actualCaveats.every((caveat) => validCaveatTypes.has(caveat.type))) {\n throw rpcErrors.invalidParams({\n message: `Expected the following caveats: ${caveatsToValidate\n .map((caveat) => `\"${caveat.type}\"`)\n .join(', ')}, received ${actualCaveats\n .map((caveat) => `\"${caveat.type}\"`)\n .join(', ')}.`,\n });\n }\n\n // Fail if not all required caveats are specified\n if (!requiredCaveats.every((caveat) => passedCaveatsSet.has(caveat.type))) {\n throw rpcErrors.invalidParams({\n message: `Expected the following caveats: ${requiredCaveats\n .map((caveat) => `\"${caveat.type}\"`)\n .join(', ')}.`,\n });\n }\n };\n}\n"],"names":["rpcErrors","createGenericPermissionValidator","caveatsToValidate","validCaveatTypes","Set","map","caveat","type","requiredCaveats","filter","optional","caveats","actualCaveats","passedCaveatTypes","passedCaveatsSet","size","length","invalidParams","message","every","has","join"],"mappings":"AAIA,SAASA,SAAS,QAAQ,uBAAuB;AAOjD;;;;;;;;;;CAUC,GACD,OAAO,SAASC,iCACdC,iBAGG;IAEH,MAAMC,mBAAmB,IAAIC,IAC3BF,kBAAkBG,GAAG,CAAC,CAACC,SAAWA,OAAOC,IAAI;IAE/C,MAAMC,kBAAkBN,kBAAkBO,MAAM,CAC9C,CAACH,SAAW,CAACA,OAAOI,QAAQ;IAG9B,OAAO,SAAU,EAAEC,OAAO,EAAE;QAC1B,MAAMC,gBAAgBD,WAAW,EAAE;QACnC,MAAME,oBAAoBD,cAAcP,GAAG,CAAC,CAACC,SAAWA,OAAOC,IAAI;QACnE,MAAMO,mBAAmB,IAAIV,IAAIS;QAEjC,sBAAsB;QACtB,IAAIC,iBAAiBC,IAAI,KAAKF,kBAAkBG,MAAM,EAAE;YACtD,MAAMhB,UAAUiB,aAAa,CAAC;gBAC5BC,SAAS;YACX;QACF;QAEA,mDAAmD;QACnD,IAAI,CAACN,cAAcO,KAAK,CAAC,CAACb,SAAWH,iBAAiBiB,GAAG,CAACd,OAAOC,IAAI,IAAI;YACvE,MAAMP,UAAUiB,aAAa,CAAC;gBAC5BC,SAAS,CAAC,gCAAgC,EAAEhB,kBACzCG,GAAG,CAAC,CAACC,SAAW,CAAC,CAAC,EAAEA,OAAOC,IAAI,CAAC,CAAC,CAAC,EAClCc,IAAI,CAAC,MAAM,WAAW,EAAET,cACxBP,GAAG,CAAC,CAACC,SAAW,CAAC,CAAC,EAAEA,OAAOC,IAAI,CAAC,CAAC,CAAC,EAClCc,IAAI,CAAC,MAAM,CAAC,CAAC;YAClB;QACF;QAEA,iDAAiD;QACjD,IAAI,CAACb,gBAAgBW,KAAK,CAAC,CAACb,SAAWQ,iBAAiBM,GAAG,CAACd,OAAOC,IAAI,IAAI;YACzE,MAAMP,UAAUiB,aAAa,CAAC;gBAC5BC,SAAS,CAAC,gCAAgC,EAAEV,gBACzCH,GAAG,CAAC,CAACC,SAAW,CAAC,CAAC,EAAEA,OAAOC,IAAI,CAAC,CAAC,CAAC,EAClCc,IAAI,CAAC,MAAM,CAAC,CAAC;YAClB;QACF;IACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/endowments/caveats/index.ts"],"sourcesContent":["export * from './generic';\nexport * from './requestTime';\n"],"names":[],"mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,gBAAgB"}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { rpcErrors } from '@metamask/rpc-errors';
|
|
2
|
-
import { MaxRequestTimeStruct, SnapCaveatType } from '@metamask/snaps-utils';
|
|
3
|
-
import { assertStruct, hasProperty, isObject } from '@metamask/utils';
|
|
4
|
-
/**
|
|
5
|
-
* Asserts that the given value is a valid `maxRequestTime` value.
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to assert.
|
|
8
|
-
* @param ErrorWrapper - An optional error wrapper to use. Defaults to
|
|
9
|
-
* {@link AssertionError}.
|
|
10
|
-
* @throws If the value is not a valid `maxRequestTime` value.
|
|
11
|
-
*/ function assertIsMaxRequestTime(value, ErrorWrapper) {
|
|
12
|
-
assertStruct(value, MaxRequestTimeStruct, 'Invalid maxRequestTime', ErrorWrapper);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Validate the value of a caveat. This does not validate the type of the
|
|
16
|
-
* caveat itself, only the value of the caveat.
|
|
17
|
-
*
|
|
18
|
-
* @param caveat - The caveat to validate.
|
|
19
|
-
* @throws If the caveat value is invalid.
|
|
20
|
-
*/ function validateMaxRequestTimeCaveat(caveat) {
|
|
21
|
-
if (!hasProperty(caveat, 'value')) {
|
|
22
|
-
throw rpcErrors.invalidParams({
|
|
23
|
-
message: 'Invalid maxRequestTime caveat.'
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
const { value } = caveat;
|
|
27
|
-
assertIsMaxRequestTime(value, rpcErrors.invalidParams);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Map a raw value from the `initialPermissions` to a caveat specification.
|
|
31
|
-
* Note that this function does not do any validation, that's handled by the
|
|
32
|
-
* PermissionsController when the permission is requested.
|
|
33
|
-
*
|
|
34
|
-
* @param value - The raw value from the `initialPermissions`.
|
|
35
|
-
* @returns The caveat specification.
|
|
36
|
-
*/ export function getMaxRequestTimeCaveatMapper(value) {
|
|
37
|
-
if (!value || !isObject(value) || isObject(value) && !hasProperty(value, 'maxRequestTime')) {
|
|
38
|
-
return {
|
|
39
|
-
caveats: null
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
caveats: [
|
|
44
|
-
{
|
|
45
|
-
type: SnapCaveatType.MaxRequestTime,
|
|
46
|
-
value: value.maxRequestTime
|
|
47
|
-
}
|
|
48
|
-
]
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Creates a wrapping caveat mapper that creates the `maxRequestTime` caveat
|
|
53
|
-
* and merges it with any other caveats created by the mapper function.
|
|
54
|
-
*
|
|
55
|
-
* @param mapper - Another caveat mapper function.
|
|
56
|
-
* @returns The caveat specification.
|
|
57
|
-
*/ export function createMaxRequestTimeMapper(mapper) {
|
|
58
|
-
return function(value) {
|
|
59
|
-
// We assume this to be used only with caveats of this type
|
|
60
|
-
const { maxRequestTime, ...rest } = value;
|
|
61
|
-
const mapperResult = mapper(rest);
|
|
62
|
-
if (!maxRequestTime) {
|
|
63
|
-
return mapperResult;
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
...mapperResult,
|
|
67
|
-
caveats: [
|
|
68
|
-
...mapperResult.caveats ?? [],
|
|
69
|
-
{
|
|
70
|
-
type: SnapCaveatType.MaxRequestTime,
|
|
71
|
-
value: maxRequestTime
|
|
72
|
-
}
|
|
73
|
-
]
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Getter function to get the {@link MaxRequestTime} caveat value from a permission if specified.
|
|
79
|
-
*
|
|
80
|
-
* @param permission - The permission to get the caveat value from.
|
|
81
|
-
* @returns The caveat value if present, otherwise null.
|
|
82
|
-
*/ export function getMaxRequestTimeCaveat(permission) {
|
|
83
|
-
const foundCaveat = permission?.caveats?.find((caveat)=>caveat.type === SnapCaveatType.MaxRequestTime);
|
|
84
|
-
return (foundCaveat?.value) ?? null;
|
|
85
|
-
}
|
|
86
|
-
export const maxRequestTimeCaveatSpecifications = {
|
|
87
|
-
[SnapCaveatType.MaxRequestTime]: Object.freeze({
|
|
88
|
-
type: SnapCaveatType.MaxRequestTime,
|
|
89
|
-
validator: (caveat)=>validateMaxRequestTimeCaveat(caveat)
|
|
90
|
-
})
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
//# sourceMappingURL=requestTime.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/endowments/caveats/requestTime.ts"],"sourcesContent":["import type {\n Caveat,\n CaveatSpecificationConstraint,\n PermissionConstraint,\n} from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport { MaxRequestTimeStruct, SnapCaveatType } from '@metamask/snaps-utils';\nimport type { AssertionErrorConstructor, Json } from '@metamask/utils';\nimport { assertStruct, hasProperty, isObject } from '@metamask/utils';\n\nimport type { CaveatMapperFunction, CaveatMapperReturnValue } from './generic';\n\n/**\n * Asserts that the given value is a valid `maxRequestTime` value.\n *\n * @param value - The value to assert.\n * @param ErrorWrapper - An optional error wrapper to use. Defaults to\n * {@link AssertionError}.\n * @throws If the value is not a valid `maxRequestTime` value.\n */\nfunction assertIsMaxRequestTime(\n value: unknown, // eslint-disable-next-line @typescript-eslint/naming-convention\n ErrorWrapper?: AssertionErrorConstructor,\n): asserts value is number {\n assertStruct(\n value,\n MaxRequestTimeStruct,\n 'Invalid maxRequestTime',\n ErrorWrapper,\n );\n}\n\n/**\n * Validate the value of a caveat. This does not validate the type of the\n * caveat itself, only the value of the caveat.\n *\n * @param caveat - The caveat to validate.\n * @throws If the caveat value is invalid.\n */\nfunction validateMaxRequestTimeCaveat(caveat: Caveat<string, any>) {\n if (!hasProperty(caveat, 'value')) {\n throw rpcErrors.invalidParams({\n message: 'Invalid maxRequestTime caveat.',\n });\n }\n\n const { value } = caveat;\n assertIsMaxRequestTime(value, rpcErrors.invalidParams);\n}\n\n/**\n * Map a raw value from the `initialPermissions` to a caveat specification.\n * Note that this function does not do any validation, that's handled by the\n * PermissionsController when the permission is requested.\n *\n * @param value - The raw value from the `initialPermissions`.\n * @returns The caveat specification.\n */\nexport function getMaxRequestTimeCaveatMapper(\n value: Json,\n): CaveatMapperReturnValue {\n if (\n !value ||\n !isObject(value) ||\n (isObject(value) && !hasProperty(value, 'maxRequestTime'))\n ) {\n return { caveats: null };\n }\n return {\n caveats: [\n {\n type: SnapCaveatType.MaxRequestTime,\n value: value.maxRequestTime,\n },\n ],\n };\n}\n\n/**\n * Creates a wrapping caveat mapper that creates the `maxRequestTime` caveat\n * and merges it with any other caveats created by the mapper function.\n *\n * @param mapper - Another caveat mapper function.\n * @returns The caveat specification.\n */\nexport function createMaxRequestTimeMapper(\n mapper: CaveatMapperFunction,\n): CaveatMapperFunction {\n return function (value: Json) {\n // We assume this to be used only with caveats of this type\n const { maxRequestTime, ...rest } = value as Record<string, Json>;\n\n const mapperResult = mapper(rest);\n\n if (!maxRequestTime) {\n return mapperResult;\n }\n\n return {\n ...mapperResult,\n caveats: [\n ...(mapperResult.caveats ?? []),\n {\n type: SnapCaveatType.MaxRequestTime,\n value: maxRequestTime,\n },\n ],\n };\n };\n}\n\n/**\n * Getter function to get the {@link MaxRequestTime} caveat value from a permission if specified.\n *\n * @param permission - The permission to get the caveat value from.\n * @returns The caveat value if present, otherwise null.\n */\nexport function getMaxRequestTimeCaveat(\n permission?: PermissionConstraint,\n): number | null {\n const foundCaveat = permission?.caveats?.find(\n (caveat) => caveat.type === SnapCaveatType.MaxRequestTime,\n );\n return (foundCaveat?.value as number) ?? null;\n}\n\nexport const maxRequestTimeCaveatSpecifications: Record<\n SnapCaveatType.MaxRequestTime,\n CaveatSpecificationConstraint\n> = {\n [SnapCaveatType.MaxRequestTime]: Object.freeze({\n type: SnapCaveatType.MaxRequestTime,\n validator: (caveat: Caveat<string, any>) =>\n validateMaxRequestTimeCaveat(caveat),\n }),\n};\n"],"names":["rpcErrors","MaxRequestTimeStruct","SnapCaveatType","assertStruct","hasProperty","isObject","assertIsMaxRequestTime","value","ErrorWrapper","validateMaxRequestTimeCaveat","caveat","invalidParams","message","getMaxRequestTimeCaveatMapper","caveats","type","MaxRequestTime","maxRequestTime","createMaxRequestTimeMapper","mapper","rest","mapperResult","getMaxRequestTimeCaveat","permission","foundCaveat","find","maxRequestTimeCaveatSpecifications","Object","freeze","validator"],"mappings":"AAKA,SAASA,SAAS,QAAQ,uBAAuB;AACjD,SAASC,oBAAoB,EAAEC,cAAc,QAAQ,wBAAwB;AAE7E,SAASC,YAAY,EAAEC,WAAW,EAAEC,QAAQ,QAAQ,kBAAkB;AAItE;;;;;;;CAOC,GACD,SAASC,uBACPC,KAAc,EACdC,YAAwC;IAExCL,aACEI,OACAN,sBACA,0BACAO;AAEJ;AAEA;;;;;;CAMC,GACD,SAASC,6BAA6BC,MAA2B;IAC/D,IAAI,CAACN,YAAYM,QAAQ,UAAU;QACjC,MAAMV,UAAUW,aAAa,CAAC;YAC5BC,SAAS;QACX;IACF;IAEA,MAAM,EAAEL,KAAK,EAAE,GAAGG;IAClBJ,uBAAuBC,OAAOP,UAAUW,aAAa;AACvD;AAEA;;;;;;;CAOC,GACD,OAAO,SAASE,8BACdN,KAAW;IAEX,IACE,CAACA,SACD,CAACF,SAASE,UACTF,SAASE,UAAU,CAACH,YAAYG,OAAO,mBACxC;QACA,OAAO;YAAEO,SAAS;QAAK;IACzB;IACA,OAAO;QACLA,SAAS;YACP;gBACEC,MAAMb,eAAec,cAAc;gBACnCT,OAAOA,MAAMU,cAAc;YAC7B;SACD;IACH;AACF;AAEA;;;;;;CAMC,GACD,OAAO,SAASC,2BACdC,MAA4B;IAE5B,OAAO,SAAUZ,KAAW;QAC1B,2DAA2D;QAC3D,MAAM,EAAEU,cAAc,EAAE,GAAGG,MAAM,GAAGb;QAEpC,MAAMc,eAAeF,OAAOC;QAE5B,IAAI,CAACH,gBAAgB;YACnB,OAAOI;QACT;QAEA,OAAO;YACL,GAAGA,YAAY;YACfP,SAAS;mBACHO,aAAaP,OAAO,IAAI,EAAE;gBAC9B;oBACEC,MAAMb,eAAec,cAAc;oBACnCT,OAAOU;gBACT;aACD;QACH;IACF;AACF;AAEA;;;;;CAKC,GACD,OAAO,SAASK,wBACdC,UAAiC;IAEjC,MAAMC,cAAcD,YAAYT,SAASW,KACvC,CAACf,SAAWA,OAAOK,IAAI,KAAKb,eAAec,cAAc;IAE3D,OAAO,CAACQ,aAAajB,KAAe,KAAK;AAC3C;AAEA,OAAO,MAAMmB,qCAGT;IACF,CAACxB,eAAec,cAAc,CAAC,EAAEW,OAAOC,MAAM,CAAC;QAC7Cb,MAAMb,eAAec,cAAc;QACnCa,WAAW,CAACnB,SACVD,6BAA6BC;IACjC;AACF,EAAE"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { PermissionType, SubjectType } from '@metamask/permission-controller';
|
|
2
|
-
import { rpcErrors } from '@metamask/rpc-errors';
|
|
3
|
-
import { SnapCaveatType, isCronjobSpecificationArray } from '@metamask/snaps-utils';
|
|
4
|
-
import { assert, hasProperty, isPlainObject } from '@metamask/utils';
|
|
5
|
-
import { SnapEndowments } from './enum';
|
|
6
|
-
const permissionName = SnapEndowments.Cronjob;
|
|
7
|
-
/**
|
|
8
|
-
* `endowment:cronjob` returns nothing; it is intended to be used as a flag to determine whether the snap wants to run cronjobs.
|
|
9
|
-
*
|
|
10
|
-
* @param _builderOptions - Optional specification builder options.
|
|
11
|
-
* @returns The specification for the cronjob endowment.
|
|
12
|
-
*/ const specificationBuilder = (_builderOptions)=>{
|
|
13
|
-
return {
|
|
14
|
-
permissionType: PermissionType.Endowment,
|
|
15
|
-
targetName: permissionName,
|
|
16
|
-
allowedCaveats: [
|
|
17
|
-
SnapCaveatType.SnapCronjob
|
|
18
|
-
],
|
|
19
|
-
endowmentGetter: (_getterOptions)=>undefined,
|
|
20
|
-
subjectTypes: [
|
|
21
|
-
SubjectType.Snap
|
|
22
|
-
]
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
export const cronjobEndowmentBuilder = Object.freeze({
|
|
26
|
-
targetName: permissionName,
|
|
27
|
-
specificationBuilder
|
|
28
|
-
});
|
|
29
|
-
/**
|
|
30
|
-
* Map a raw value from the `initialPermissions` to a caveat specification.
|
|
31
|
-
* Note that this function does not do any validation, that's handled by the
|
|
32
|
-
* PermissionsController when the permission is requested.
|
|
33
|
-
*
|
|
34
|
-
* @param value - The raw value from the `initialPermissions`.
|
|
35
|
-
* @returns The caveat specification.
|
|
36
|
-
*/ export function getCronjobCaveatMapper(value) {
|
|
37
|
-
return {
|
|
38
|
-
caveats: [
|
|
39
|
-
{
|
|
40
|
-
type: SnapCaveatType.SnapCronjob,
|
|
41
|
-
value
|
|
42
|
-
}
|
|
43
|
-
]
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Getter function to get the cronjobs from a permission.
|
|
48
|
-
*
|
|
49
|
-
* This does basic validation of the caveat, but does not validate the type or
|
|
50
|
-
* value of the namespaces object itself, as this is handled by the
|
|
51
|
-
* `PermissionsController` when the permission is requested.
|
|
52
|
-
*
|
|
53
|
-
* @param permission - The permission to get the keyring namespaces from.
|
|
54
|
-
* @returns The cronjobs, or `null` if the permission does not have a
|
|
55
|
-
* cronjob caveat.
|
|
56
|
-
*/ export function getCronjobCaveatJobs(permission) {
|
|
57
|
-
if (!permission?.caveats) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
assert(permission.caveats.length === 1);
|
|
61
|
-
assert(permission.caveats[0].type === SnapCaveatType.SnapCronjob);
|
|
62
|
-
const caveat = permission.caveats[0];
|
|
63
|
-
return (caveat.value?.jobs) ?? null;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Validate the cronjob specification values associated with a caveat.
|
|
67
|
-
* This validates that the value is a non-empty array with valid
|
|
68
|
-
* cronjob expression and request object.
|
|
69
|
-
*
|
|
70
|
-
* @param caveat - The caveat to validate.
|
|
71
|
-
* @throws If the value is invalid.
|
|
72
|
-
*/ export function validateCronjobCaveat(caveat) {
|
|
73
|
-
if (!hasProperty(caveat, 'value') || !isPlainObject(caveat.value)) {
|
|
74
|
-
throw rpcErrors.invalidParams({
|
|
75
|
-
message: 'Expected a plain object.'
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
const { value } = caveat;
|
|
79
|
-
if (!hasProperty(value, 'jobs') || !isPlainObject(value)) {
|
|
80
|
-
throw rpcErrors.invalidParams({
|
|
81
|
-
message: 'Expected a plain object.'
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
if (!isCronjobSpecificationArray(value.jobs)) {
|
|
85
|
-
throw rpcErrors.invalidParams({
|
|
86
|
-
message: 'Expected a valid cronjob specification array.'
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Caveat specification for the Cronjob.
|
|
92
|
-
*/ export const cronjobCaveatSpecifications = {
|
|
93
|
-
[SnapCaveatType.SnapCronjob]: Object.freeze({
|
|
94
|
-
type: SnapCaveatType.SnapCronjob,
|
|
95
|
-
validator: (caveat)=>validateCronjobCaveat(caveat)
|
|
96
|
-
})
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
//# sourceMappingURL=cronjob.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/endowments/cronjob.ts"],"sourcesContent":["import type {\n PermissionSpecificationBuilder,\n EndowmentGetterParams,\n ValidPermissionSpecification,\n PermissionConstraint,\n Caveat,\n CaveatSpecificationConstraint,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type { CronjobSpecification } from '@metamask/snaps-utils';\nimport {\n SnapCaveatType,\n isCronjobSpecificationArray,\n} from '@metamask/snaps-utils';\nimport type { Json, NonEmptyArray } from '@metamask/utils';\nimport { assert, hasProperty, isPlainObject } from '@metamask/utils';\n\nimport { SnapEndowments } from './enum';\n\nconst permissionName = SnapEndowments.Cronjob;\n\ntype CronjobEndowmentSpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.Endowment;\n targetName: typeof permissionName;\n endowmentGetter: (_options?: any) => undefined;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n}>;\n\n/**\n * `endowment:cronjob` returns nothing; it is intended to be used as a flag to determine whether the snap wants to run cronjobs.\n *\n * @param _builderOptions - Optional specification builder options.\n * @returns The specification for the cronjob endowment.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.Endowment,\n any,\n CronjobEndowmentSpecification\n> = (_builderOptions?: any) => {\n return {\n permissionType: PermissionType.Endowment,\n targetName: permissionName,\n allowedCaveats: [SnapCaveatType.SnapCronjob],\n endowmentGetter: (_getterOptions?: EndowmentGetterParams) => undefined,\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nexport const cronjobEndowmentBuilder = Object.freeze({\n targetName: permissionName,\n specificationBuilder,\n} as const);\n\n/**\n * Map a raw value from the `initialPermissions` to a caveat specification.\n * Note that this function does not do any validation, that's handled by the\n * PermissionsController when the permission is requested.\n *\n * @param value - The raw value from the `initialPermissions`.\n * @returns The caveat specification.\n */\nexport function getCronjobCaveatMapper(\n value: Json,\n): Pick<PermissionConstraint, 'caveats'> {\n return {\n caveats: [\n {\n type: SnapCaveatType.SnapCronjob,\n value,\n },\n ],\n };\n}\n\n/**\n * Getter function to get the cronjobs from a permission.\n *\n * This does basic validation of the caveat, but does not validate the type or\n * value of the namespaces object itself, as this is handled by the\n * `PermissionsController` when the permission is requested.\n *\n * @param permission - The permission to get the keyring namespaces from.\n * @returns The cronjobs, or `null` if the permission does not have a\n * cronjob caveat.\n */\nexport function getCronjobCaveatJobs(\n permission?: PermissionConstraint,\n): CronjobSpecification[] | null {\n if (!permission?.caveats) {\n return null;\n }\n\n assert(permission.caveats.length === 1);\n assert(permission.caveats[0].type === SnapCaveatType.SnapCronjob);\n\n const caveat = permission.caveats[0] as Caveat<string, { jobs: Json[] }>;\n\n return (caveat.value?.jobs as CronjobSpecification[]) ?? null;\n}\n\n/**\n * Validate the cronjob specification values associated with a caveat.\n * This validates that the value is a non-empty array with valid\n * cronjob expression and request object.\n *\n * @param caveat - The caveat to validate.\n * @throws If the value is invalid.\n */\nexport function validateCronjobCaveat(caveat: Caveat<string, any>) {\n if (!hasProperty(caveat, 'value') || !isPlainObject(caveat.value)) {\n throw rpcErrors.invalidParams({\n message: 'Expected a plain object.',\n });\n }\n\n const { value } = caveat;\n\n if (!hasProperty(value, 'jobs') || !isPlainObject(value)) {\n throw rpcErrors.invalidParams({\n message: 'Expected a plain object.',\n });\n }\n\n if (!isCronjobSpecificationArray(value.jobs)) {\n throw rpcErrors.invalidParams({\n message: 'Expected a valid cronjob specification array.',\n });\n }\n}\n\n/**\n * Caveat specification for the Cronjob.\n */\nexport const cronjobCaveatSpecifications: Record<\n SnapCaveatType.SnapCronjob,\n CaveatSpecificationConstraint\n> = {\n [SnapCaveatType.SnapCronjob]: Object.freeze({\n type: SnapCaveatType.SnapCronjob,\n validator: (caveat) => validateCronjobCaveat(caveat),\n }),\n};\n"],"names":["PermissionType","SubjectType","rpcErrors","SnapCaveatType","isCronjobSpecificationArray","assert","hasProperty","isPlainObject","SnapEndowments","permissionName","Cronjob","specificationBuilder","_builderOptions","permissionType","Endowment","targetName","allowedCaveats","SnapCronjob","endowmentGetter","_getterOptions","undefined","subjectTypes","Snap","cronjobEndowmentBuilder","Object","freeze","getCronjobCaveatMapper","value","caveats","type","getCronjobCaveatJobs","permission","length","caveat","jobs","validateCronjobCaveat","invalidParams","message","cronjobCaveatSpecifications","validator"],"mappings":"AAQA,SAASA,cAAc,EAAEC,WAAW,QAAQ,kCAAkC;AAC9E,SAASC,SAAS,QAAQ,uBAAuB;AAEjD,SACEC,cAAc,EACdC,2BAA2B,QACtB,wBAAwB;AAE/B,SAASC,MAAM,EAAEC,WAAW,EAAEC,aAAa,QAAQ,kBAAkB;AAErE,SAASC,cAAc,QAAQ,SAAS;AAExC,MAAMC,iBAAiBD,eAAeE,OAAO;AAS7C;;;;;CAKC,GACD,MAAMC,uBAIF,CAACC;IACH,OAAO;QACLC,gBAAgBb,eAAec,SAAS;QACxCC,YAAYN;QACZO,gBAAgB;YAACb,eAAec,WAAW;SAAC;QAC5CC,iBAAiB,CAACC,iBAA2CC;QAC7DC,cAAc;YAACpB,YAAYqB,IAAI;SAAC;IAClC;AACF;AAEA,OAAO,MAAMC,0BAA0BC,OAAOC,MAAM,CAAC;IACnDV,YAAYN;IACZE;AACF,GAAY;AAEZ;;;;;;;CAOC,GACD,OAAO,SAASe,uBACdC,KAAW;IAEX,OAAO;QACLC,SAAS;YACP;gBACEC,MAAM1B,eAAec,WAAW;gBAChCU;YACF;SACD;IACH;AACF;AAEA;;;;;;;;;;CAUC,GACD,OAAO,SAASG,qBACdC,UAAiC;IAEjC,IAAI,CAACA,YAAYH,SAAS;QACxB,OAAO;IACT;IAEAvB,OAAO0B,WAAWH,OAAO,CAACI,MAAM,KAAK;IACrC3B,OAAO0B,WAAWH,OAAO,CAAC,EAAE,CAACC,IAAI,KAAK1B,eAAec,WAAW;IAEhE,MAAMgB,SAASF,WAAWH,OAAO,CAAC,EAAE;IAEpC,OAAO,CAACK,OAAON,KAAK,EAAEO,IAA8B,KAAK;AAC3D;AAEA;;;;;;;CAOC,GACD,OAAO,SAASC,sBAAsBF,MAA2B;IAC/D,IAAI,CAAC3B,YAAY2B,QAAQ,YAAY,CAAC1B,cAAc0B,OAAON,KAAK,GAAG;QACjE,MAAMzB,UAAUkC,aAAa,CAAC;YAC5BC,SAAS;QACX;IACF;IAEA,MAAM,EAAEV,KAAK,EAAE,GAAGM;IAElB,IAAI,CAAC3B,YAAYqB,OAAO,WAAW,CAACpB,cAAcoB,QAAQ;QACxD,MAAMzB,UAAUkC,aAAa,CAAC;YAC5BC,SAAS;QACX;IACF;IAEA,IAAI,CAACjC,4BAA4BuB,MAAMO,IAAI,GAAG;QAC5C,MAAMhC,UAAUkC,aAAa,CAAC;YAC5BC,SAAS;QACX;IACF;AACF;AAEA;;CAEC,GACD,OAAO,MAAMC,8BAGT;IACF,CAACnC,eAAec,WAAW,CAAC,EAAEO,OAAOC,MAAM,CAAC;QAC1CI,MAAM1B,eAAec,WAAW;QAChCsB,WAAW,CAACN,SAAWE,sBAAsBF;IAC/C;AACF,EAAE"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export var SnapEndowments;
|
|
2
|
-
(function(SnapEndowments) {
|
|
3
|
-
SnapEndowments["NetworkAccess"] = 'endowment:network-access';
|
|
4
|
-
SnapEndowments["SignatureInsight"] = 'endowment:signature-insight';
|
|
5
|
-
SnapEndowments["TransactionInsight"] = 'endowment:transaction-insight';
|
|
6
|
-
SnapEndowments["Cronjob"] = 'endowment:cronjob';
|
|
7
|
-
SnapEndowments["EthereumProvider"] = 'endowment:ethereum-provider';
|
|
8
|
-
SnapEndowments["Rpc"] = 'endowment:rpc';
|
|
9
|
-
SnapEndowments["WebAssemblyAccess"] = 'endowment:webassembly';
|
|
10
|
-
SnapEndowments["NameLookup"] = 'endowment:name-lookup';
|
|
11
|
-
SnapEndowments["LifecycleHooks"] = 'endowment:lifecycle-hooks';
|
|
12
|
-
SnapEndowments["Keyring"] = 'endowment:keyring';
|
|
13
|
-
SnapEndowments["HomePage"] = 'endowment:page-home';
|
|
14
|
-
})(SnapEndowments || (SnapEndowments = {}));
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=enum.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/endowments/enum.ts"],"sourcesContent":["export enum SnapEndowments {\n NetworkAccess = 'endowment:network-access',\n SignatureInsight = 'endowment:signature-insight',\n TransactionInsight = 'endowment:transaction-insight',\n Cronjob = 'endowment:cronjob',\n EthereumProvider = 'endowment:ethereum-provider',\n Rpc = 'endowment:rpc',\n WebAssemblyAccess = 'endowment:webassembly',\n NameLookup = 'endowment:name-lookup',\n LifecycleHooks = 'endowment:lifecycle-hooks',\n Keyring = 'endowment:keyring',\n HomePage = 'endowment:page-home',\n}\n"],"names":["SnapEndowments","NetworkAccess","SignatureInsight","TransactionInsight","Cronjob","EthereumProvider","Rpc","WebAssemblyAccess","NameLookup","LifecycleHooks","Keyring","HomePage"],"mappings":"WAAO;UAAKA,cAAc;IAAdA,eACVC,mBAAgB;IADND,eAEVE,sBAAmB;IAFTF,eAGVG,wBAAqB;IAHXH,eAIVI,aAAU;IAJAJ,eAKVK,sBAAmB;IALTL,eAMVM,SAAM;IANIN,eAOVO,uBAAoB;IAPVP,eAQVQ,gBAAa;IARHR,eASVS,oBAAiB;IATPT,eAUVU,aAAU;IAVAV,eAWVW,cAAW;GAXDX,mBAAAA"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { PermissionType, SubjectType } from '@metamask/permission-controller';
|
|
2
|
-
import { SnapEndowments } from './enum';
|
|
3
|
-
const permissionName = SnapEndowments.EthereumProvider;
|
|
4
|
-
/**
|
|
5
|
-
* `endowment:ethereum-provider` returns the name of the ethereum global browser API.
|
|
6
|
-
* This is intended to populate the endowments of the
|
|
7
|
-
* SES Compartment in which a Snap executes.
|
|
8
|
-
*
|
|
9
|
-
* This populates the global scope with an EIP-1193 provider, which DOES NOT implement all legacy functionality exposed to dapps.
|
|
10
|
-
*
|
|
11
|
-
* @param _builderOptions - Optional specification builder options.
|
|
12
|
-
* @returns The specification for the network endowment.
|
|
13
|
-
*/ const specificationBuilder = (_builderOptions)=>{
|
|
14
|
-
return {
|
|
15
|
-
permissionType: PermissionType.Endowment,
|
|
16
|
-
targetName: permissionName,
|
|
17
|
-
allowedCaveats: null,
|
|
18
|
-
endowmentGetter: (_getterOptions)=>{
|
|
19
|
-
return [
|
|
20
|
-
'ethereum'
|
|
21
|
-
];
|
|
22
|
-
},
|
|
23
|
-
subjectTypes: [
|
|
24
|
-
SubjectType.Snap
|
|
25
|
-
]
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
export const ethereumProviderEndowmentBuilder = Object.freeze({
|
|
29
|
-
targetName: permissionName,
|
|
30
|
-
specificationBuilder
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
//# sourceMappingURL=ethereum-provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/endowments/ethereum-provider.ts"],"sourcesContent":["import type {\n EndowmentGetterParams,\n PermissionSpecificationBuilder,\n ValidPermissionSpecification,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\n\nimport { SnapEndowments } from './enum';\n\nconst permissionName = SnapEndowments.EthereumProvider;\n\ntype EthereumProviderEndowmentSpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.Endowment;\n targetName: typeof permissionName;\n endowmentGetter: (_options?: any) => ['ethereum'];\n allowedCaveats: null;\n}>;\n\n/**\n * `endowment:ethereum-provider` returns the name of the ethereum global browser API.\n * This is intended to populate the endowments of the\n * SES Compartment in which a Snap executes.\n *\n * This populates the global scope with an EIP-1193 provider, which DOES NOT implement all legacy functionality exposed to dapps.\n *\n * @param _builderOptions - Optional specification builder options.\n * @returns The specification for the network endowment.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.Endowment,\n any,\n EthereumProviderEndowmentSpecification\n> = (_builderOptions?: any) => {\n return {\n permissionType: PermissionType.Endowment,\n targetName: permissionName,\n allowedCaveats: null,\n endowmentGetter: (_getterOptions?: EndowmentGetterParams) => {\n return ['ethereum'];\n },\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nexport const ethereumProviderEndowmentBuilder = Object.freeze({\n targetName: permissionName,\n specificationBuilder,\n} as const);\n"],"names":["PermissionType","SubjectType","SnapEndowments","permissionName","EthereumProvider","specificationBuilder","_builderOptions","permissionType","Endowment","targetName","allowedCaveats","endowmentGetter","_getterOptions","subjectTypes","Snap","ethereumProviderEndowmentBuilder","Object","freeze"],"mappings":"AAKA,SAASA,cAAc,EAAEC,WAAW,QAAQ,kCAAkC;AAE9E,SAASC,cAAc,QAAQ,SAAS;AAExC,MAAMC,iBAAiBD,eAAeE,gBAAgB;AAStD;;;;;;;;;CASC,GACD,MAAMC,uBAIF,CAACC;IACH,OAAO;QACLC,gBAAgBP,eAAeQ,SAAS;QACxCC,YAAYN;QACZO,gBAAgB;QAChBC,iBAAiB,CAACC;YAChB,OAAO;gBAAC;aAAW;QACrB;QACAC,cAAc;YAACZ,YAAYa,IAAI;SAAC;IAClC;AACF;AAEA,OAAO,MAAMC,mCAAmCC,OAAOC,MAAM,CAAC;IAC5DR,YAAYN;IACZE;AACF,GAAY"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { PermissionType, SubjectType } from '@metamask/permission-controller';
|
|
2
|
-
import { SnapEndowments } from './enum';
|
|
3
|
-
const permissionName = SnapEndowments.HomePage;
|
|
4
|
-
/**
|
|
5
|
-
* `endowment:page-home` returns nothing; it is intended to be used as a
|
|
6
|
-
* flag by the snap controller to detect whether the snap has the capability to
|
|
7
|
-
* use the snap home page feature.
|
|
8
|
-
*
|
|
9
|
-
* @param _builderOptions - Optional specification builder options.
|
|
10
|
-
* @returns The specification for the `snap-pages` endowment.
|
|
11
|
-
*/ const specificationBuilder = (_builderOptions)=>{
|
|
12
|
-
return {
|
|
13
|
-
permissionType: PermissionType.Endowment,
|
|
14
|
-
targetName: permissionName,
|
|
15
|
-
allowedCaveats: null,
|
|
16
|
-
endowmentGetter: (_getterOptions)=>undefined,
|
|
17
|
-
subjectTypes: [
|
|
18
|
-
SubjectType.Snap
|
|
19
|
-
]
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
export const homePageEndowmentBuilder = Object.freeze({
|
|
23
|
-
targetName: permissionName,
|
|
24
|
-
specificationBuilder
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
//# sourceMappingURL=home-page.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/endowments/home-page.ts"],"sourcesContent":["import type {\n PermissionSpecificationBuilder,\n EndowmentGetterParams,\n ValidPermissionSpecification,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport type { NonEmptyArray } from '@metamask/utils';\n\nimport { SnapEndowments } from './enum';\n\nconst permissionName = SnapEndowments.HomePage;\n\ntype HomePageEndowmentSpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.Endowment;\n targetName: typeof permissionName;\n endowmentGetter: (_options?: EndowmentGetterParams) => undefined;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n}>;\n\n/**\n * `endowment:page-home` returns nothing; it is intended to be used as a\n * flag by the snap controller to detect whether the snap has the capability to\n * use the snap home page feature.\n *\n * @param _builderOptions - Optional specification builder options.\n * @returns The specification for the `snap-pages` endowment.\n */\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.Endowment,\n any,\n HomePageEndowmentSpecification\n> = (_builderOptions?: unknown) => {\n return {\n permissionType: PermissionType.Endowment,\n targetName: permissionName,\n allowedCaveats: null,\n endowmentGetter: (_getterOptions?: EndowmentGetterParams) => undefined,\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nexport const homePageEndowmentBuilder = Object.freeze({\n targetName: permissionName,\n specificationBuilder,\n} as const);\n"],"names":["PermissionType","SubjectType","SnapEndowments","permissionName","HomePage","specificationBuilder","_builderOptions","permissionType","Endowment","targetName","allowedCaveats","endowmentGetter","_getterOptions","undefined","subjectTypes","Snap","homePageEndowmentBuilder","Object","freeze"],"mappings":"AAKA,SAASA,cAAc,EAAEC,WAAW,QAAQ,kCAAkC;AAG9E,SAASC,cAAc,QAAQ,SAAS;AAExC,MAAMC,iBAAiBD,eAAeE,QAAQ;AAS9C;;;;;;;CAOC,GACD,MAAMC,uBAIF,CAACC;IACH,OAAO;QACLC,gBAAgBP,eAAeQ,SAAS;QACxCC,YAAYN;QACZO,gBAAgB;QAChBC,iBAAiB,CAACC,iBAA2CC;QAC7DC,cAAc;YAACb,YAAYc,IAAI;SAAC;IAClC;AACF;AAEA,OAAO,MAAMC,2BAA2BC,OAAOC,MAAM,CAAC;IACpDT,YAAYN;IACZE;AACF,GAAY"}
|