@metamask/snaps-controllers 5.0.1 → 6.0.1
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 +18 -1
- package/dist/chunk-36YC4Z3T.mjs +109 -0
- package/dist/chunk-36YC4Z3T.mjs.map +1 -0
- package/dist/chunk-3RNW7OKG.mjs +1 -0
- package/dist/chunk-3RNW7OKG.mjs.map +1 -0
- package/dist/chunk-43ODL57R.js +39 -0
- package/dist/chunk-43ODL57R.js.map +1 -0
- package/dist/chunk-4HVWEABQ.mjs +9 -0
- package/dist/chunk-4HVWEABQ.mjs.map +1 -0
- package/dist/chunk-4LGL4A3M.js +105 -0
- package/dist/chunk-4LGL4A3M.js.map +1 -0
- package/dist/chunk-4URGXJP7.js +1 -0
- package/dist/chunk-4URGXJP7.js.map +1 -0
- package/dist/chunk-5R4ENIDN.mjs +2307 -0
- package/dist/chunk-5R4ENIDN.mjs.map +1 -0
- package/dist/chunk-5YBORD3A.js +19 -0
- package/dist/chunk-5YBORD3A.js.map +1 -0
- package/dist/chunk-6EZSNS4O.mjs +59 -0
- package/dist/chunk-6EZSNS4O.mjs.map +1 -0
- package/dist/chunk-6GMWL4JR.mjs +92 -0
- package/dist/chunk-6GMWL4JR.mjs.map +1 -0
- package/dist/chunk-6N6KZYVD.js +12 -0
- package/dist/chunk-6N6KZYVD.js.map +1 -0
- package/dist/chunk-6NYC5VNK.mjs +354 -0
- package/dist/chunk-6NYC5VNK.mjs.map +1 -0
- package/dist/chunk-6XGUJ27X.js +72 -0
- package/dist/chunk-6XGUJ27X.js.map +1 -0
- package/dist/chunk-6YVCFPP6.mjs +58 -0
- package/dist/chunk-6YVCFPP6.mjs.map +1 -0
- package/dist/chunk-7JY5VENP.js +273 -0
- package/dist/chunk-7JY5VENP.js.map +1 -0
- package/dist/chunk-7PZECZV3.mjs +38 -0
- package/dist/chunk-7PZECZV3.mjs.map +1 -0
- package/dist/chunk-7WOG63YY.js +40 -0
- package/dist/chunk-7WOG63YY.js.map +1 -0
- package/dist/chunk-7Y6P5FRN.js +60 -0
- package/dist/chunk-7Y6P5FRN.js.map +1 -0
- package/dist/chunk-A6WJEA3C.js +1 -0
- package/dist/chunk-A6WJEA3C.js.map +1 -0
- package/dist/chunk-AP7CJ6DA.js +47 -0
- package/dist/chunk-AP7CJ6DA.js.map +1 -0
- package/dist/chunk-B3UTLNYS.mjs +48 -0
- package/dist/chunk-B3UTLNYS.mjs.map +1 -0
- package/dist/chunk-B67RDBZ4.mjs +40 -0
- package/dist/chunk-B67RDBZ4.mjs.map +1 -0
- package/dist/chunk-B7R3EWM3.mjs +1 -0
- package/dist/chunk-B7R3EWM3.mjs.map +1 -0
- package/dist/chunk-BAEXVO3U.mjs +1 -0
- package/dist/chunk-BAEXVO3U.mjs.map +1 -0
- package/dist/chunk-BO2ZDPWV.js +59 -0
- package/dist/chunk-BO2ZDPWV.js.map +1 -0
- package/dist/chunk-C4D6GBMY.js +71 -0
- package/dist/chunk-C4D6GBMY.js.map +1 -0
- package/dist/chunk-D74XJG2L.js +1 -0
- package/dist/chunk-D74XJG2L.js.map +1 -0
- package/dist/chunk-DSQYZGBH.mjs +273 -0
- package/dist/chunk-DSQYZGBH.mjs.map +1 -0
- package/dist/chunk-ESQPQNEF.mjs +1 -0
- package/dist/chunk-ESQPQNEF.mjs.map +1 -0
- package/dist/chunk-EXN2TFDJ.js +38 -0
- package/dist/chunk-EXN2TFDJ.js.map +1 -0
- package/dist/chunk-FX5AADOV.mjs +1 -0
- package/dist/chunk-FX5AADOV.mjs.map +1 -0
- package/dist/chunk-FZY2Z5NP.js +38 -0
- package/dist/chunk-FZY2Z5NP.js.map +1 -0
- package/dist/chunk-G66GQJS6.js +1 -0
- package/dist/chunk-G66GQJS6.js.map +1 -0
- package/dist/chunk-G7U6WKWS.mjs +1 -0
- package/dist/chunk-G7U6WKWS.mjs.map +1 -0
- package/dist/chunk-HOY6NKQR.js +1 -0
- package/dist/chunk-HOY6NKQR.js.map +1 -0
- package/dist/chunk-HWJE3SDW.mjs +1 -0
- package/dist/chunk-HWJE3SDW.mjs.map +1 -0
- package/dist/chunk-IABOI7TW.mjs +1 -0
- package/dist/chunk-IABOI7TW.mjs.map +1 -0
- package/dist/chunk-IGC4E7PI.mjs +71 -0
- package/dist/chunk-IGC4E7PI.mjs.map +1 -0
- package/dist/chunk-IMBPDTVN.mjs +72 -0
- package/dist/chunk-IMBPDTVN.mjs.map +1 -0
- package/dist/chunk-J4PGHMLL.js +38 -0
- package/dist/chunk-J4PGHMLL.js.map +1 -0
- package/dist/chunk-JAUAKTUL.js +1 -0
- package/dist/chunk-JAUAKTUL.js.map +1 -0
- package/dist/chunk-JDHKH5YU.js +354 -0
- package/dist/chunk-JDHKH5YU.js.map +1 -0
- package/dist/chunk-JW7WBUL7.js +1 -0
- package/dist/chunk-JW7WBUL7.js.map +1 -0
- package/dist/chunk-K276CM3B.mjs +197 -0
- package/dist/chunk-K276CM3B.mjs.map +1 -0
- package/dist/chunk-KBVG3CL2.js +58 -0
- package/dist/chunk-KBVG3CL2.js.map +1 -0
- package/dist/chunk-KCMULJ2M.mjs +1 -0
- package/dist/chunk-KCMULJ2M.mjs.map +1 -0
- package/dist/chunk-KF4PCKG7.mjs +74 -0
- package/dist/chunk-KF4PCKG7.mjs.map +1 -0
- package/dist/chunk-KLK7ZRMH.js +55 -0
- package/dist/chunk-KLK7ZRMH.js.map +1 -0
- package/dist/chunk-LWBPKSU2.js +48 -0
- package/dist/chunk-LWBPKSU2.js.map +1 -0
- package/dist/chunk-MYWDTEX2.js +283 -0
- package/dist/chunk-MYWDTEX2.js.map +1 -0
- package/dist/chunk-NC5PBDKD.mjs +47 -0
- package/dist/chunk-NC5PBDKD.mjs.map +1 -0
- package/dist/chunk-NOLPMHXS.js +101 -0
- package/dist/chunk-NOLPMHXS.js.map +1 -0
- package/dist/chunk-NXZVKBSV.js +9 -0
- package/dist/chunk-NXZVKBSV.js.map +1 -0
- package/dist/chunk-OHMCPTOI.js +1 -0
- package/dist/chunk-OHMCPTOI.js.map +1 -0
- package/dist/chunk-OIEUL55W.js +1 -0
- package/dist/chunk-OIEUL55W.js.map +1 -0
- package/dist/chunk-P7Y6MIZW.mjs +7 -0
- package/dist/chunk-P7Y6MIZW.mjs.map +1 -0
- package/dist/chunk-PGKMKSAR.mjs +105 -0
- package/dist/chunk-PGKMKSAR.mjs.map +1 -0
- package/dist/chunk-PXECEHH7.mjs +39 -0
- package/dist/chunk-PXECEHH7.mjs.map +1 -0
- package/dist/chunk-Q2ON6SMV.js +197 -0
- package/dist/chunk-Q2ON6SMV.js.map +1 -0
- package/dist/chunk-QL3QGUTM.mjs +1 -0
- package/dist/chunk-QL3QGUTM.mjs.map +1 -0
- package/dist/chunk-RDBT3ZJQ.js +92 -0
- package/dist/chunk-RDBT3ZJQ.js.map +1 -0
- package/dist/chunk-RIU3ZIXZ.mjs +55 -0
- package/dist/chunk-RIU3ZIXZ.mjs.map +1 -0
- package/dist/chunk-RU67JKBV.mjs +12 -0
- package/dist/chunk-RU67JKBV.mjs.map +1 -0
- package/dist/chunk-TG6OXBLR.js +1 -0
- package/dist/chunk-TG6OXBLR.js.map +1 -0
- package/dist/chunk-TMWMIQV4.js +1 -0
- package/dist/chunk-TMWMIQV4.js.map +1 -0
- package/dist/chunk-U6T2MPXT.js +74 -0
- package/dist/chunk-U6T2MPXT.js.map +1 -0
- package/dist/chunk-U74FML7Z.mjs +1 -0
- package/dist/chunk-U74FML7Z.mjs.map +1 -0
- package/dist/chunk-V6NFZ47P.mjs +1 -0
- package/dist/chunk-V6NFZ47P.mjs.map +1 -0
- package/dist/chunk-VNOCJWOK.js +1 -0
- package/dist/chunk-VNOCJWOK.js.map +1 -0
- package/dist/chunk-VOZOZKRC.mjs +101 -0
- package/dist/chunk-VOZOZKRC.mjs.map +1 -0
- package/dist/chunk-WEY7ICES.js +1 -0
- package/dist/chunk-WEY7ICES.js.map +1 -0
- package/dist/chunk-WKQRCGUW.mjs +331 -0
- package/dist/chunk-WKQRCGUW.mjs.map +1 -0
- package/dist/chunk-XE5IWVNV.js +109 -0
- package/dist/chunk-XE5IWVNV.js.map +1 -0
- package/dist/chunk-XWDEGRM5.js +331 -0
- package/dist/chunk-XWDEGRM5.js.map +1 -0
- package/dist/chunk-YIQM6ZKA.mjs +19 -0
- package/dist/chunk-YIQM6ZKA.mjs.map +1 -0
- package/dist/chunk-YRZVIDCF.mjs +38 -0
- package/dist/chunk-YRZVIDCF.mjs.map +1 -0
- package/dist/chunk-YYPUPKQY.js +7 -0
- package/dist/chunk-YYPUPKQY.js.map +1 -0
- package/dist/chunk-ZAMIT33L.js +2307 -0
- package/dist/chunk-ZAMIT33L.js.map +1 -0
- package/dist/chunk-ZETJVFUS.mjs +283 -0
- package/dist/chunk-ZETJVFUS.mjs.map +1 -0
- package/dist/chunk-ZQAGLOXD.mjs +1 -0
- package/dist/chunk-ZQAGLOXD.mjs.map +1 -0
- package/dist/chunk-ZRS2VVUV.mjs +38 -0
- package/dist/chunk-ZRS2VVUV.mjs.map +1 -0
- package/dist/chunk-ZVOYOZFT.mjs +60 -0
- package/dist/chunk-ZVOYOZFT.mjs.map +1 -0
- package/dist/cronjob/CronjobController.js +41 -0
- package/dist/cronjob/CronjobController.js.map +1 -0
- package/dist/cronjob/CronjobController.mjs +41 -0
- package/dist/cronjob/CronjobController.mjs.map +1 -0
- package/dist/cronjob/index.js +41 -0
- package/dist/cronjob/index.js.map +1 -0
- package/dist/cronjob/index.mjs +41 -0
- package/dist/cronjob/index.mjs.map +1 -0
- package/dist/fsm.js +10 -0
- package/dist/fsm.js.map +1 -0
- package/dist/fsm.mjs +10 -0
- package/dist/fsm.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/interface/SnapInterfaceController.js +9 -0
- package/dist/interface/SnapInterfaceController.js.map +1 -0
- package/dist/interface/SnapInterfaceController.mjs +9 -0
- package/dist/interface/SnapInterfaceController.mjs.map +1 -0
- package/dist/interface/index.js +10 -0
- package/dist/interface/index.js.map +1 -0
- package/dist/interface/index.mjs +10 -0
- package/dist/interface/index.mjs.map +1 -0
- package/dist/interface/utils.js +14 -0
- package/dist/interface/utils.js.map +1 -0
- package/dist/interface/utils.mjs +14 -0
- package/dist/interface/utils.mjs.map +1 -0
- package/dist/logging.js +8 -0
- package/dist/logging.js.map +1 -0
- package/dist/logging.mjs +8 -0
- package/dist/logging.mjs.map +1 -0
- package/dist/node.js +128 -0
- package/dist/node.js.map +1 -0
- package/dist/node.mjs +128 -0
- package/dist/node.mjs.map +1 -0
- package/dist/react-native.js +125 -0
- package/dist/react-native.js.map +1 -0
- package/dist/react-native.mjs +125 -0
- package/dist/react-native.mjs.map +1 -0
- package/dist/services/AbstractExecutionService.js +13 -0
- package/dist/services/AbstractExecutionService.js.map +1 -0
- package/dist/services/AbstractExecutionService.mjs +13 -0
- package/dist/services/AbstractExecutionService.mjs.map +1 -0
- package/dist/services/ExecutionService.js +2 -0
- package/dist/services/ExecutionService.js.map +1 -0
- package/dist/services/ExecutionService.mjs +2 -0
- package/dist/services/ExecutionService.mjs.map +1 -0
- package/dist/services/ProxyPostMessageStream.js +8 -0
- package/dist/services/ProxyPostMessageStream.js.map +1 -0
- package/dist/services/ProxyPostMessageStream.mjs +8 -0
- package/dist/services/ProxyPostMessageStream.mjs.map +1 -0
- package/dist/services/browser.js +40 -0
- package/dist/services/browser.js.map +1 -0
- package/dist/services/browser.mjs +40 -0
- package/dist/services/browser.mjs.map +1 -0
- package/dist/services/iframe/IframeExecutionService.js +12 -0
- package/dist/services/iframe/IframeExecutionService.js.map +1 -0
- package/dist/services/iframe/IframeExecutionService.mjs +12 -0
- package/dist/services/iframe/IframeExecutionService.mjs.map +1 -0
- package/dist/services/iframe/index.js +13 -0
- package/dist/services/iframe/index.js.map +1 -0
- package/dist/services/iframe/index.mjs +13 -0
- package/dist/services/iframe/index.mjs.map +1 -0
- package/dist/services/index.js +35 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/index.mjs +35 -0
- package/dist/services/index.mjs.map +1 -0
- package/dist/services/node-js/NodeProcessExecutionService.js +22 -0
- package/dist/services/node-js/NodeProcessExecutionService.js.map +1 -0
- package/dist/services/node-js/NodeProcessExecutionService.mjs +22 -0
- package/dist/services/node-js/NodeProcessExecutionService.mjs.map +1 -0
- package/dist/services/node-js/NodeThreadExecutionService.js +22 -0
- package/dist/services/node-js/NodeThreadExecutionService.js.map +1 -0
- package/dist/services/node-js/NodeThreadExecutionService.mjs +22 -0
- package/dist/services/node-js/NodeThreadExecutionService.mjs.map +1 -0
- package/dist/services/node-js/index.js +27 -0
- package/dist/services/node-js/index.js.map +1 -0
- package/dist/services/node-js/index.mjs +27 -0
- package/dist/services/node-js/index.mjs.map +1 -0
- package/dist/services/node.js +45 -0
- package/dist/services/node.js.map +1 -0
- package/dist/services/node.mjs +45 -0
- package/dist/services/node.mjs.map +1 -0
- package/dist/services/offscreen/OffscreenExecutionService.js +14 -0
- package/dist/services/offscreen/OffscreenExecutionService.js.map +1 -0
- package/dist/services/offscreen/OffscreenExecutionService.mjs +14 -0
- package/dist/services/offscreen/OffscreenExecutionService.mjs.map +1 -0
- package/dist/services/offscreen/index.js +15 -0
- package/dist/services/offscreen/index.js.map +1 -0
- package/dist/services/offscreen/index.mjs +15 -0
- package/dist/services/offscreen/index.mjs.map +1 -0
- package/dist/services/proxy/ProxyExecutionService.js +13 -0
- package/dist/services/proxy/ProxyExecutionService.js.map +1 -0
- package/dist/services/proxy/ProxyExecutionService.mjs +13 -0
- package/dist/services/proxy/ProxyExecutionService.mjs.map +1 -0
- package/dist/services/react-native.js +42 -0
- package/dist/services/react-native.js.map +1 -0
- package/dist/services/react-native.mjs +42 -0
- package/dist/services/react-native.mjs.map +1 -0
- package/dist/services/webview/WebViewExecutionService.js +15 -0
- package/dist/services/webview/WebViewExecutionService.js.map +1 -0
- package/dist/services/webview/WebViewExecutionService.mjs +15 -0
- package/dist/services/webview/WebViewExecutionService.mjs.map +1 -0
- package/dist/services/webview/WebViewMessageStream.js +8 -0
- package/dist/services/webview/WebViewMessageStream.js.map +1 -0
- package/dist/services/webview/WebViewMessageStream.mjs +8 -0
- package/dist/services/webview/WebViewMessageStream.mjs.map +1 -0
- package/dist/services/webview/index.js +16 -0
- package/dist/services/webview/index.js.map +1 -0
- package/dist/services/webview/index.mjs +16 -0
- package/dist/services/webview/index.mjs.map +1 -0
- package/dist/services/webworker/WebWorkerExecutionService.js +15 -0
- package/dist/services/webworker/WebWorkerExecutionService.js.map +1 -0
- package/dist/services/webworker/WebWorkerExecutionService.mjs +15 -0
- package/dist/services/webworker/WebWorkerExecutionService.mjs.map +1 -0
- package/dist/services/webworker/index.js +16 -0
- package/dist/services/webworker/index.js.map +1 -0
- package/dist/services/webworker/index.mjs +16 -0
- package/dist/services/webworker/index.mjs.map +1 -0
- package/dist/snaps/RequestQueue.js +8 -0
- package/dist/snaps/RequestQueue.js.map +1 -0
- package/dist/snaps/RequestQueue.mjs +8 -0
- package/dist/snaps/RequestQueue.mjs.map +1 -0
- package/dist/snaps/SnapController.js +30 -0
- package/dist/snaps/SnapController.js.map +1 -0
- package/dist/snaps/SnapController.mjs +30 -0
- package/dist/snaps/SnapController.mjs.map +1 -0
- package/dist/snaps/Timer.js +8 -0
- package/dist/snaps/Timer.js.map +1 -0
- package/dist/snaps/Timer.mjs +8 -0
- package/dist/snaps/Timer.mjs.map +1 -0
- package/dist/snaps/constants.js +8 -0
- package/dist/snaps/constants.js.map +1 -0
- package/dist/snaps/constants.mjs +8 -0
- package/dist/snaps/constants.mjs.map +1 -0
- package/dist/snaps/index.js +63 -0
- package/dist/snaps/index.js.map +1 -0
- package/dist/snaps/index.mjs +63 -0
- package/dist/snaps/index.mjs.map +1 -0
- package/dist/snaps/location/http.js +8 -0
- package/dist/snaps/location/http.js.map +1 -0
- package/dist/snaps/location/http.mjs +8 -0
- package/dist/snaps/location/http.mjs.map +1 -0
- package/dist/snaps/location/index.js +31 -0
- package/dist/snaps/location/index.js.map +1 -0
- package/dist/snaps/location/index.mjs +31 -0
- package/dist/snaps/location/index.mjs.map +1 -0
- package/dist/snaps/location/local.js +9 -0
- package/dist/snaps/location/local.js.map +1 -0
- package/dist/snaps/location/local.mjs +9 -0
- package/dist/snaps/location/local.mjs.map +1 -0
- package/dist/snaps/location/location.js +11 -0
- package/dist/snaps/location/location.js.map +1 -0
- package/dist/snaps/location/location.mjs +11 -0
- package/dist/snaps/location/location.mjs.map +1 -0
- package/dist/snaps/location/npm.js +18 -0
- package/dist/snaps/location/npm.js.map +1 -0
- package/dist/snaps/location/npm.mjs +18 -0
- package/dist/snaps/location/npm.mjs.map +1 -0
- package/dist/snaps/registry/index.js +13 -0
- package/dist/snaps/registry/index.js.map +1 -0
- package/dist/snaps/registry/index.mjs +13 -0
- package/dist/snaps/registry/index.mjs.map +1 -0
- package/dist/snaps/registry/json.js +9 -0
- package/dist/snaps/registry/json.js.map +1 -0
- package/dist/snaps/registry/json.mjs +9 -0
- package/dist/snaps/registry/json.mjs.map +1 -0
- package/dist/snaps/registry/registry.js +8 -0
- package/dist/snaps/registry/registry.js.map +1 -0
- package/dist/snaps/registry/registry.mjs +8 -0
- package/dist/snaps/registry/registry.mjs.map +1 -0
- package/dist/snaps/selectors.js +8 -0
- package/dist/snaps/selectors.js.map +1 -0
- package/dist/snaps/selectors.mjs +8 -0
- package/dist/snaps/selectors.mjs.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/node.d.ts +2 -0
- package/dist/types/react-native.d.ts +2 -0
- package/dist/types/services/index.d.ts +0 -2
- package/dist/types/services/node.d.ts +2 -0
- package/dist/types/services/react-native.d.ts +2 -0
- package/dist/types/utils.d.ts +1 -1
- package/dist/types/vendor/global.d.js +1 -0
- package/dist/types/vendor/global.d.js.map +1 -0
- package/dist/types/vendor/global.d.mjs +1 -0
- package/dist/types/vendor/global.d.mjs.map +1 -0
- package/dist/types/vendor/readable-stream.d.js +1 -0
- package/dist/types/vendor/readable-stream.d.js.map +1 -0
- package/dist/types/vendor/readable-stream.d.mjs +1 -0
- package/dist/types/vendor/readable-stream.d.mjs.map +1 -0
- package/dist/types/vendor/zlib.d.js +1 -0
- package/dist/types/vendor/zlib.d.js.map +1 -0
- package/dist/types/vendor/zlib.d.mjs +1 -0
- package/dist/types/vendor/zlib.d.mjs.map +1 -0
- package/dist/utils.js +21 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.mjs +21 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +31 -22
- package/dist/cjs/cronjob/CronjobController.js +0 -296
- package/dist/cjs/cronjob/CronjobController.js.map +0 -1
- package/dist/cjs/cronjob/index.js +0 -20
- package/dist/cjs/cronjob/index.js.map +0 -1
- package/dist/cjs/fsm.js +0 -69
- package/dist/cjs/fsm.js.map +0 -1
- package/dist/cjs/index.js +0 -24
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/interface/SnapInterfaceController.js +0 -166
- package/dist/cjs/interface/SnapInterfaceController.js.map +0 -1
- package/dist/cjs/interface/index.js +0 -20
- package/dist/cjs/interface/index.js.map +0 -1
- package/dist/cjs/interface/utils.js +0 -59
- package/dist/cjs/interface/utils.js.map +0 -1
- package/dist/cjs/logging.js +0 -15
- package/dist/cjs/logging.js.map +0 -1
- package/dist/cjs/services/AbstractExecutionService.js +0 -387
- package/dist/cjs/services/AbstractExecutionService.js.map +0 -1
- package/dist/cjs/services/ExecutionService.js +0 -7
- package/dist/cjs/services/ExecutionService.js.map +0 -1
- package/dist/cjs/services/ProxyPostMessageStream.js +0 -109
- package/dist/cjs/services/ProxyPostMessageStream.js.map +0 -1
- package/dist/cjs/services/browser.js +0 -33
- package/dist/cjs/services/browser.js.map +0 -1
- package/dist/cjs/services/iframe/IframeExecutionService.js +0 -54
- package/dist/cjs/services/iframe/IframeExecutionService.js.map +0 -1
- package/dist/cjs/services/iframe/index.js +0 -20
- package/dist/cjs/services/iframe/index.js.map +0 -1
- package/dist/cjs/services/index.js +0 -33
- package/dist/cjs/services/index.js.map +0 -1
- package/dist/cjs/services/node/NodeProcessExecutionService.js +0 -42
- package/dist/cjs/services/node/NodeProcessExecutionService.js.map +0 -1
- package/dist/cjs/services/node/NodeThreadExecutionService.js +0 -43
- package/dist/cjs/services/node/NodeThreadExecutionService.js.map +0 -1
- package/dist/cjs/services/node/index.js +0 -21
- package/dist/cjs/services/node/index.js.map +0 -1
- package/dist/cjs/services/offscreen/OffscreenExecutionService.js +0 -96
- package/dist/cjs/services/offscreen/OffscreenExecutionService.js.map +0 -1
- package/dist/cjs/services/offscreen/index.js +0 -20
- package/dist/cjs/services/offscreen/index.js.map +0 -1
- package/dist/cjs/services/proxy/ProxyExecutionService.js +0 -110
- package/dist/cjs/services/proxy/ProxyExecutionService.js.map +0 -1
- package/dist/cjs/services/webview/WebViewExecutionService.js +0 -99
- package/dist/cjs/services/webview/WebViewExecutionService.js.map +0 -1
- package/dist/cjs/services/webview/WebViewMessageStream.js +0 -127
- package/dist/cjs/services/webview/WebViewMessageStream.js.map +0 -1
- package/dist/cjs/services/webview/index.js +0 -20
- package/dist/cjs/services/webview/index.js.map +0 -1
- package/dist/cjs/services/webworker/WebWorkerExecutionService.js +0 -148
- package/dist/cjs/services/webworker/WebWorkerExecutionService.js.map +0 -1
- package/dist/cjs/services/webworker/index.js +0 -20
- package/dist/cjs/services/webworker/index.js.map +0 -1
- package/dist/cjs/snaps/RequestQueue.js +0 -63
- package/dist/cjs/snaps/RequestQueue.js.map +0 -1
- package/dist/cjs/snaps/SnapController.js +0 -1968
- package/dist/cjs/snaps/SnapController.js.map +0 -1
- package/dist/cjs/snaps/Timer.js +0 -117
- package/dist/cjs/snaps/Timer.js.map +0 -1
- package/dist/cjs/snaps/constants.js +0 -25
- package/dist/cjs/snaps/constants.js.map +0 -1
- package/dist/cjs/snaps/index.js +0 -23
- package/dist/cjs/snaps/index.js.map +0 -1
- package/dist/cjs/snaps/location/http.js +0 -106
- package/dist/cjs/snaps/location/http.js.map +0 -1
- package/dist/cjs/snaps/location/index.js +0 -23
- package/dist/cjs/snaps/location/index.js.map +0 -1
- package/dist/cjs/snaps/location/local.js +0 -93
- package/dist/cjs/snaps/location/local.js.map +0 -1
- package/dist/cjs/snaps/location/location.js +0 -34
- package/dist/cjs/snaps/location/location.js.map +0 -1
- package/dist/cjs/snaps/location/npm.js +0 -389
- package/dist/cjs/snaps/location/npm.js.map +0 -1
- package/dist/cjs/snaps/registry/index.js +0 -21
- package/dist/cjs/snaps/registry/index.js.map +0 -1
- package/dist/cjs/snaps/registry/json.js +0 -311
- package/dist/cjs/snaps/registry/json.js.map +0 -1
- package/dist/cjs/snaps/registry/registry.js +0 -18
- package/dist/cjs/snaps/registry/registry.js.map +0 -1
- package/dist/cjs/snaps/selectors.js +0 -13
- package/dist/cjs/snaps/selectors.js.map +0 -1
- package/dist/cjs/utils.js +0 -111
- package/dist/cjs/utils.js.map +0 -1
- package/dist/esm/cronjob/CronjobController.js +0 -281
- package/dist/esm/cronjob/CronjobController.js.map +0 -1
- package/dist/esm/cronjob/index.js +0 -3
- package/dist/esm/cronjob/index.js.map +0 -1
- package/dist/esm/fsm.js +0 -70
- package/dist/esm/fsm.js.map +0 -1
- package/dist/esm/index.js +0 -7
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/interface/SnapInterfaceController.js +0 -158
- package/dist/esm/interface/SnapInterfaceController.js.map +0 -1
- package/dist/esm/interface/index.js +0 -3
- package/dist/esm/interface/index.js.map +0 -1
- package/dist/esm/interface/utils.js +0 -62
- package/dist/esm/interface/utils.js.map +0 -1
- package/dist/esm/logging.js +0 -10
- package/dist/esm/logging.js.map +0 -1
- package/dist/esm/services/AbstractExecutionService.js +0 -370
- package/dist/esm/services/AbstractExecutionService.js.map +0 -1
- package/dist/esm/services/ExecutionService.js +0 -4
- package/dist/esm/services/ExecutionService.js.map +0 -1
- package/dist/esm/services/ProxyPostMessageStream.js +0 -102
- package/dist/esm/services/ProxyPostMessageStream.js.map +0 -1
- package/dist/esm/services/browser.js +0 -10
- package/dist/esm/services/browser.js.map +0 -1
- package/dist/esm/services/iframe/IframeExecutionService.js +0 -44
- package/dist/esm/services/iframe/IframeExecutionService.js.map +0 -1
- package/dist/esm/services/iframe/index.js +0 -3
- package/dist/esm/services/iframe/index.js.map +0 -1
- package/dist/esm/services/index.js +0 -10
- package/dist/esm/services/index.js.map +0 -1
- package/dist/esm/services/node/NodeProcessExecutionService.js +0 -32
- package/dist/esm/services/node/NodeProcessExecutionService.js.map +0 -1
- package/dist/esm/services/node/NodeThreadExecutionService.js +0 -34
- package/dist/esm/services/node/NodeThreadExecutionService.js.map +0 -1
- package/dist/esm/services/node/index.js +0 -4
- package/dist/esm/services/node/index.js.map +0 -1
- package/dist/esm/services/offscreen/OffscreenExecutionService.js +0 -86
- package/dist/esm/services/offscreen/OffscreenExecutionService.js.map +0 -1
- package/dist/esm/services/offscreen/index.js +0 -3
- package/dist/esm/services/offscreen/index.js.map +0 -1
- package/dist/esm/services/proxy/ProxyExecutionService.js +0 -100
- package/dist/esm/services/proxy/ProxyExecutionService.js.map +0 -1
- package/dist/esm/services/webview/WebViewExecutionService.js +0 -89
- package/dist/esm/services/webview/WebViewExecutionService.js.map +0 -1
- package/dist/esm/services/webview/WebViewMessageStream.js +0 -119
- package/dist/esm/services/webview/WebViewMessageStream.js.map +0 -1
- package/dist/esm/services/webview/index.js +0 -3
- package/dist/esm/services/webview/index.js.map +0 -1
- package/dist/esm/services/webworker/WebWorkerExecutionService.js +0 -130
- package/dist/esm/services/webworker/WebWorkerExecutionService.js.map +0 -1
- package/dist/esm/services/webworker/index.js +0 -3
- package/dist/esm/services/webworker/index.js.map +0 -1
- package/dist/esm/snaps/RequestQueue.js +0 -53
- package/dist/esm/snaps/RequestQueue.js.map +0 -1
- package/dist/esm/snaps/SnapController.js +0 -1947
- package/dist/esm/snaps/SnapController.js.map +0 -1
- package/dist/esm/snaps/Timer.js +0 -107
- package/dist/esm/snaps/Timer.js.map +0 -1
- package/dist/esm/snaps/constants.js +0 -16
- package/dist/esm/snaps/constants.js.map +0 -1
- package/dist/esm/snaps/index.js +0 -6
- package/dist/esm/snaps/index.js.map +0 -1
- package/dist/esm/snaps/location/http.js +0 -96
- package/dist/esm/snaps/location/http.js.map +0 -1
- package/dist/esm/snaps/location/index.js +0 -6
- package/dist/esm/snaps/location/index.js.map +0 -1
- package/dist/esm/snaps/location/local.js +0 -83
- package/dist/esm/snaps/location/local.js.map +0 -1
- package/dist/esm/snaps/location/location.js +0 -30
- package/dist/esm/snaps/location/location.js.map +0 -1
- package/dist/esm/snaps/location/npm.js +0 -373
- package/dist/esm/snaps/location/npm.js.map +0 -1
- package/dist/esm/snaps/registry/index.js +0 -4
- package/dist/esm/snaps/registry/index.js.map +0 -1
- package/dist/esm/snaps/registry/json.js +0 -301
- package/dist/esm/snaps/registry/json.js.map +0 -1
- package/dist/esm/snaps/registry/registry.js +0 -8
- package/dist/esm/snaps/registry/registry.js.map +0 -1
- package/dist/esm/snaps/selectors.js +0 -3
- package/dist/esm/snaps/selectors.js.map +0 -1
- package/dist/esm/utils.js +0 -132
- package/dist/esm/utils.js.map +0 -1
- /package/dist/types/services/{node → node-js}/NodeProcessExecutionService.d.ts +0 -0
- /package/dist/types/services/{node → node-js}/NodeThreadExecutionService.d.ts +0 -0
- /package/dist/types/services/{node → node-js}/index.d.ts +0 -0
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
function _define_property(obj, key, value) {
|
|
2
|
-
if (key in obj) {
|
|
3
|
-
Object.defineProperty(obj, key, {
|
|
4
|
-
value: value,
|
|
5
|
-
enumerable: true,
|
|
6
|
-
configurable: true,
|
|
7
|
-
writable: true
|
|
8
|
-
});
|
|
9
|
-
} else {
|
|
10
|
-
obj[key] = value;
|
|
11
|
-
}
|
|
12
|
-
return obj;
|
|
13
|
-
}
|
|
14
|
-
import { VirtualFile, HttpSnapIdStruct, NpmSnapFileNames, createSnapManifest, normalizeRelative, parseJson } from '@metamask/snaps-utils';
|
|
15
|
-
import { assert, assertStruct } from '@metamask/utils';
|
|
16
|
-
export class HttpLocation {
|
|
17
|
-
async manifest() {
|
|
18
|
-
if (this.validatedManifest) {
|
|
19
|
-
return this.validatedManifest.clone();
|
|
20
|
-
}
|
|
21
|
-
// jest-fetch-mock doesn't handle new URL(), we need to convert .toString()
|
|
22
|
-
const canonicalPath = new URL(NpmSnapFileNames.Manifest, this.url).toString();
|
|
23
|
-
const response = await this.fetchFn(canonicalPath, this.fetchOptions);
|
|
24
|
-
if (!response.ok) {
|
|
25
|
-
throw new Error(`Failed to fetch "${canonicalPath}". Status code: ${response.status}.`);
|
|
26
|
-
}
|
|
27
|
-
const contents = await response.text();
|
|
28
|
-
const manifest = parseJson(contents);
|
|
29
|
-
const vfile = new VirtualFile({
|
|
30
|
-
value: contents,
|
|
31
|
-
result: createSnapManifest(manifest),
|
|
32
|
-
path: NpmSnapFileNames.Manifest,
|
|
33
|
-
data: {
|
|
34
|
-
canonicalPath
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
this.validatedManifest = vfile;
|
|
38
|
-
return this.manifest();
|
|
39
|
-
}
|
|
40
|
-
async fetch(path) {
|
|
41
|
-
const relativePath = normalizeRelative(path);
|
|
42
|
-
const cached = this.cache.get(relativePath);
|
|
43
|
-
if (cached !== undefined) {
|
|
44
|
-
const { file, contents } = cached;
|
|
45
|
-
const value = new Uint8Array(await contents.arrayBuffer());
|
|
46
|
-
const vfile = file.clone();
|
|
47
|
-
vfile.value = value;
|
|
48
|
-
return vfile;
|
|
49
|
-
}
|
|
50
|
-
const canonicalPath = this.toCanonical(relativePath).toString();
|
|
51
|
-
const response = await this.fetchFn(canonicalPath, this.fetchOptions);
|
|
52
|
-
if (!response.ok) {
|
|
53
|
-
throw new Error(`Failed to fetch "${canonicalPath}". Status code: ${response.status}.`);
|
|
54
|
-
}
|
|
55
|
-
const vfile = new VirtualFile({
|
|
56
|
-
value: '',
|
|
57
|
-
path: relativePath,
|
|
58
|
-
data: {
|
|
59
|
-
canonicalPath
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
const blob = await response.blob();
|
|
63
|
-
assert(!this.cache.has(relativePath), 'Corrupted cache, multiple files with same path.');
|
|
64
|
-
this.cache.set(relativePath, {
|
|
65
|
-
file: vfile,
|
|
66
|
-
contents: blob
|
|
67
|
-
});
|
|
68
|
-
return this.fetch(relativePath);
|
|
69
|
-
}
|
|
70
|
-
get root() {
|
|
71
|
-
return new URL(this.url);
|
|
72
|
-
}
|
|
73
|
-
toCanonical(path) {
|
|
74
|
-
assert(!path.startsWith('/'), 'Tried to parse absolute path.');
|
|
75
|
-
return new URL(path, this.url);
|
|
76
|
-
}
|
|
77
|
-
constructor(url, opts = {}){
|
|
78
|
-
// We keep contents separate because then we can use only one Blob in cache,
|
|
79
|
-
// which we convert to Uint8Array when actually returning the file.
|
|
80
|
-
//
|
|
81
|
-
// That avoids deepCloning file contents.
|
|
82
|
-
// I imagine ArrayBuffers are copy-on-write optimized, meaning
|
|
83
|
-
// in most often case we'll only have one file contents in common case.
|
|
84
|
-
_define_property(this, "cache", new Map());
|
|
85
|
-
_define_property(this, "validatedManifest", void 0);
|
|
86
|
-
_define_property(this, "url", void 0);
|
|
87
|
-
_define_property(this, "fetchFn", void 0);
|
|
88
|
-
_define_property(this, "fetchOptions", void 0);
|
|
89
|
-
assertStruct(url.toString(), HttpSnapIdStruct, 'Invalid Snap Id: ');
|
|
90
|
-
this.fetchFn = opts.fetch ?? globalThis.fetch.bind(globalThis);
|
|
91
|
-
this.fetchOptions = opts.fetchOptions;
|
|
92
|
-
this.url = url;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
//# sourceMappingURL=http.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/snaps/location/http.ts"],"sourcesContent":["import type { SnapManifest } from '@metamask/snaps-utils';\nimport {\n VirtualFile,\n HttpSnapIdStruct,\n NpmSnapFileNames,\n createSnapManifest,\n normalizeRelative,\n parseJson,\n} from '@metamask/snaps-utils';\nimport { assert, assertStruct } from '@metamask/utils';\n\nimport type { SnapLocation } from './location';\n\nexport interface HttpOptions {\n /**\n * @default fetch\n */\n fetch?: typeof fetch;\n fetchOptions?: RequestInit;\n}\n\nexport class HttpLocation implements SnapLocation {\n // We keep contents separate because then we can use only one Blob in cache,\n // which we convert to Uint8Array when actually returning the file.\n //\n // That avoids deepCloning file contents.\n // I imagine ArrayBuffers are copy-on-write optimized, meaning\n // in most often case we'll only have one file contents in common case.\n private readonly cache = new Map<\n string,\n { file: VirtualFile; contents: Blob }\n >();\n\n private validatedManifest?: VirtualFile<SnapManifest>;\n\n private readonly url: URL;\n\n private readonly fetchFn: typeof fetch;\n\n private readonly fetchOptions?: RequestInit;\n\n constructor(url: URL, opts: HttpOptions = {}) {\n assertStruct(url.toString(), HttpSnapIdStruct, 'Invalid Snap Id: ');\n this.fetchFn = opts.fetch ?? globalThis.fetch.bind(globalThis);\n this.fetchOptions = opts.fetchOptions;\n this.url = url;\n }\n\n async manifest(): Promise<VirtualFile<SnapManifest>> {\n if (this.validatedManifest) {\n return this.validatedManifest.clone();\n }\n\n // jest-fetch-mock doesn't handle new URL(), we need to convert .toString()\n const canonicalPath = new URL(\n NpmSnapFileNames.Manifest,\n this.url,\n ).toString();\n\n const response = await this.fetchFn(canonicalPath, this.fetchOptions);\n if (!response.ok) {\n throw new Error(\n `Failed to fetch \"${canonicalPath}\". Status code: ${response.status}.`,\n );\n }\n const contents = await response.text();\n const manifest = parseJson(contents);\n const vfile = new VirtualFile<SnapManifest>({\n value: contents,\n result: createSnapManifest(manifest),\n path: NpmSnapFileNames.Manifest,\n data: { canonicalPath },\n });\n this.validatedManifest = vfile;\n\n return this.manifest();\n }\n\n async fetch(path: string): Promise<VirtualFile> {\n const relativePath = normalizeRelative(path);\n const cached = this.cache.get(relativePath);\n if (cached !== undefined) {\n const { file, contents } = cached;\n const value = new Uint8Array(await contents.arrayBuffer());\n const vfile = file.clone();\n vfile.value = value;\n return vfile;\n }\n\n const canonicalPath = this.toCanonical(relativePath).toString();\n const response = await this.fetchFn(canonicalPath, this.fetchOptions);\n if (!response.ok) {\n throw new Error(\n `Failed to fetch \"${canonicalPath}\". Status code: ${response.status}.`,\n );\n }\n const vfile = new VirtualFile({\n value: '',\n path: relativePath,\n data: { canonicalPath },\n });\n const blob = await response.blob();\n assert(\n !this.cache.has(relativePath),\n 'Corrupted cache, multiple files with same path.',\n );\n this.cache.set(relativePath, { file: vfile, contents: blob });\n\n return this.fetch(relativePath);\n }\n\n get root(): URL {\n return new URL(this.url);\n }\n\n private toCanonical(path: string): URL {\n assert(!path.startsWith('/'), 'Tried to parse absolute path.');\n return new URL(path, this.url);\n }\n}\n"],"names":["VirtualFile","HttpSnapIdStruct","NpmSnapFileNames","createSnapManifest","normalizeRelative","parseJson","assert","assertStruct","HttpLocation","manifest","validatedManifest","clone","canonicalPath","URL","Manifest","url","toString","response","fetchFn","fetchOptions","ok","Error","status","contents","text","vfile","value","result","path","data","fetch","relativePath","cached","cache","get","undefined","file","Uint8Array","arrayBuffer","toCanonical","blob","has","set","root","startsWith","constructor","opts","Map","globalThis","bind"],"mappings":";;;;;;;;;;;;;AACA,SACEA,WAAW,EACXC,gBAAgB,EAChBC,gBAAgB,EAChBC,kBAAkB,EAClBC,iBAAiB,EACjBC,SAAS,QACJ,wBAAwB;AAC/B,SAASC,MAAM,EAAEC,YAAY,QAAQ,kBAAkB;AAYvD,OAAO,MAAMC;IA2BX,MAAMC,WAA+C;QACnD,IAAI,IAAI,CAACC,iBAAiB,EAAE;YAC1B,OAAO,IAAI,CAACA,iBAAiB,CAACC,KAAK;QACrC;QAEA,2EAA2E;QAC3E,MAAMC,gBAAgB,IAAIC,IACxBX,iBAAiBY,QAAQ,EACzB,IAAI,CAACC,GAAG,EACRC,QAAQ;QAEV,MAAMC,WAAW,MAAM,IAAI,CAACC,OAAO,CAACN,eAAe,IAAI,CAACO,YAAY;QACpE,IAAI,CAACF,SAASG,EAAE,EAAE;YAChB,MAAM,IAAIC,MACR,CAAC,iBAAiB,EAAET,cAAc,gBAAgB,EAAEK,SAASK,MAAM,CAAC,CAAC,CAAC;QAE1E;QACA,MAAMC,WAAW,MAAMN,SAASO,IAAI;QACpC,MAAMf,WAAWJ,UAAUkB;QAC3B,MAAME,QAAQ,IAAIzB,YAA0B;YAC1C0B,OAAOH;YACPI,QAAQxB,mBAAmBM;YAC3BmB,MAAM1B,iBAAiBY,QAAQ;YAC/Be,MAAM;gBAAEjB;YAAc;QACxB;QACA,IAAI,CAACF,iBAAiB,GAAGe;QAEzB,OAAO,IAAI,CAAChB,QAAQ;IACtB;IAEA,MAAMqB,MAAMF,IAAY,EAAwB;QAC9C,MAAMG,eAAe3B,kBAAkBwB;QACvC,MAAMI,SAAS,IAAI,CAACC,KAAK,CAACC,GAAG,CAACH;QAC9B,IAAIC,WAAWG,WAAW;YACxB,MAAM,EAAEC,IAAI,EAAEb,QAAQ,EAAE,GAAGS;YAC3B,MAAMN,QAAQ,IAAIW,WAAW,MAAMd,SAASe,WAAW;YACvD,MAAMb,QAAQW,KAAKzB,KAAK;YACxBc,MAAMC,KAAK,GAAGA;YACd,OAAOD;QACT;QAEA,MAAMb,gBAAgB,IAAI,CAAC2B,WAAW,CAACR,cAAcf,QAAQ;QAC7D,MAAMC,WAAW,MAAM,IAAI,CAACC,OAAO,CAACN,eAAe,IAAI,CAACO,YAAY;QACpE,IAAI,CAACF,SAASG,EAAE,EAAE;YAChB,MAAM,IAAIC,MACR,CAAC,iBAAiB,EAAET,cAAc,gBAAgB,EAAEK,SAASK,MAAM,CAAC,CAAC,CAAC;QAE1E;QACA,MAAMG,QAAQ,IAAIzB,YAAY;YAC5B0B,OAAO;YACPE,MAAMG;YACNF,MAAM;gBAAEjB;YAAc;QACxB;QACA,MAAM4B,OAAO,MAAMvB,SAASuB,IAAI;QAChClC,OACE,CAAC,IAAI,CAAC2B,KAAK,CAACQ,GAAG,CAACV,eAChB;QAEF,IAAI,CAACE,KAAK,CAACS,GAAG,CAACX,cAAc;YAAEK,MAAMX;YAAOF,UAAUiB;QAAK;QAE3D,OAAO,IAAI,CAACV,KAAK,CAACC;IACpB;IAEA,IAAIY,OAAY;QACd,OAAO,IAAI9B,IAAI,IAAI,CAACE,GAAG;IACzB;IAEQwB,YAAYX,IAAY,EAAO;QACrCtB,OAAO,CAACsB,KAAKgB,UAAU,CAAC,MAAM;QAC9B,OAAO,IAAI/B,IAAIe,MAAM,IAAI,CAACb,GAAG;IAC/B;IA7EA8B,YAAY9B,GAAQ,EAAE+B,OAAoB,CAAC,CAAC,CAAE;QAnB9C,4EAA4E;QAC5E,mEAAmE;QACnE,EAAE;QACF,yCAAyC;QACzC,8DAA8D;QAC9D,uEAAuE;QACvE,uBAAiBb,SAAQ,IAAIc;QAK7B,uBAAQrC,qBAAR,KAAA;QAEA,uBAAiBK,OAAjB,KAAA;QAEA,uBAAiBG,WAAjB,KAAA;QAEA,uBAAiBC,gBAAjB,KAAA;QAGEZ,aAAaQ,IAAIC,QAAQ,IAAIf,kBAAkB;QAC/C,IAAI,CAACiB,OAAO,GAAG4B,KAAKhB,KAAK,IAAIkB,WAAWlB,KAAK,CAACmB,IAAI,CAACD;QACnD,IAAI,CAAC7B,YAAY,GAAG2B,KAAK3B,YAAY;QACrC,IAAI,CAACJ,GAAG,GAAGA;IACb;AAyEF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/snaps/location/index.ts"],"sourcesContent":["export * from './location';\nexport * from './npm';\nexport * from './local';\nexport * from './http';\n"],"names":[],"mappings":"AAAA,cAAc,aAAa;AAC3B,cAAc,QAAQ;AACtB,cAAc,UAAU;AACxB,cAAc,SAAS"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
function _check_private_redeclaration(obj, privateCollection) {
|
|
2
|
-
if (privateCollection.has(obj)) {
|
|
3
|
-
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
7
|
-
if (descriptor.get) {
|
|
8
|
-
return descriptor.get.call(receiver);
|
|
9
|
-
}
|
|
10
|
-
return descriptor.value;
|
|
11
|
-
}
|
|
12
|
-
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
13
|
-
if (descriptor.set) {
|
|
14
|
-
descriptor.set.call(receiver, value);
|
|
15
|
-
} else {
|
|
16
|
-
if (!descriptor.writable) {
|
|
17
|
-
throw new TypeError("attempted to set read only private field");
|
|
18
|
-
}
|
|
19
|
-
descriptor.value = value;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
23
|
-
if (!privateMap.has(receiver)) {
|
|
24
|
-
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
25
|
-
}
|
|
26
|
-
return privateMap.get(receiver);
|
|
27
|
-
}
|
|
28
|
-
function _class_private_field_get(receiver, privateMap) {
|
|
29
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
30
|
-
return _class_apply_descriptor_get(receiver, descriptor);
|
|
31
|
-
}
|
|
32
|
-
function _class_private_field_init(obj, privateMap, value) {
|
|
33
|
-
_check_private_redeclaration(obj, privateMap);
|
|
34
|
-
privateMap.set(obj, value);
|
|
35
|
-
}
|
|
36
|
-
function _class_private_field_set(receiver, privateMap, value) {
|
|
37
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
38
|
-
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
import { LocalSnapIdStruct, SnapIdPrefixes } from '@metamask/snaps-utils';
|
|
42
|
-
import { assert, assertStruct } from '@metamask/utils';
|
|
43
|
-
import { HttpLocation } from './http';
|
|
44
|
-
var _http = /*#__PURE__*/ new WeakMap();
|
|
45
|
-
export class LocalLocation {
|
|
46
|
-
async manifest() {
|
|
47
|
-
const vfile = await _class_private_field_get(this, _http).manifest();
|
|
48
|
-
return convertCanonical(vfile);
|
|
49
|
-
}
|
|
50
|
-
async fetch(path) {
|
|
51
|
-
return convertCanonical(await _class_private_field_get(this, _http).fetch(path));
|
|
52
|
-
}
|
|
53
|
-
get shouldAlwaysReload() {
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
constructor(url, opts = {}){
|
|
57
|
-
_class_private_field_init(this, _http, {
|
|
58
|
-
writable: true,
|
|
59
|
-
value: void 0
|
|
60
|
-
});
|
|
61
|
-
assertStruct(url.toString(), LocalSnapIdStruct, 'Invalid Snap Id');
|
|
62
|
-
// TODO(ritave): Write deepMerge() which merges fetchOptions.
|
|
63
|
-
assert(opts.fetchOptions === undefined, 'Currently adding fetch options to local: is unsupported.');
|
|
64
|
-
_class_private_field_set(this, _http, new HttpLocation(new URL(url.toString().slice(SnapIdPrefixes.local.length)), {
|
|
65
|
-
...opts,
|
|
66
|
-
fetchOptions: {
|
|
67
|
-
cache: 'no-cache'
|
|
68
|
-
}
|
|
69
|
-
}));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Converts vfiles with canonical `http:` paths into `local:` paths.
|
|
74
|
-
*
|
|
75
|
-
* @param vfile - The {@link VirtualFile} to convert.
|
|
76
|
-
* @returns The same object with updated `.data.canonicalPath`.
|
|
77
|
-
*/ function convertCanonical(vfile) {
|
|
78
|
-
assert(vfile.data.canonicalPath !== undefined);
|
|
79
|
-
vfile.data.canonicalPath = `local:${vfile.data.canonicalPath}`;
|
|
80
|
-
return vfile;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
//# sourceMappingURL=local.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/snaps/location/local.ts"],"sourcesContent":["import type { SnapManifest, VirtualFile } from '@metamask/snaps-utils';\nimport { LocalSnapIdStruct, SnapIdPrefixes } from '@metamask/snaps-utils';\nimport { assert, assertStruct } from '@metamask/utils';\n\nimport type { HttpOptions } from './http';\nimport { HttpLocation } from './http';\nimport type { SnapLocation } from './location';\n\nexport class LocalLocation implements SnapLocation {\n readonly #http: HttpLocation;\n\n constructor(url: URL, opts: HttpOptions = {}) {\n assertStruct(url.toString(), LocalSnapIdStruct, 'Invalid Snap Id');\n // TODO(ritave): Write deepMerge() which merges fetchOptions.\n assert(\n opts.fetchOptions === undefined,\n 'Currently adding fetch options to local: is unsupported.',\n );\n\n this.#http = new HttpLocation(\n new URL(url.toString().slice(SnapIdPrefixes.local.length)),\n { ...opts, fetchOptions: { cache: 'no-cache' } },\n );\n }\n\n async manifest(): Promise<VirtualFile<SnapManifest>> {\n const vfile = await this.#http.manifest();\n\n return convertCanonical(vfile);\n }\n\n async fetch(path: string): Promise<VirtualFile> {\n return convertCanonical(await this.#http.fetch(path));\n }\n\n get shouldAlwaysReload() {\n return true;\n }\n}\n\n/**\n * Converts vfiles with canonical `http:` paths into `local:` paths.\n *\n * @param vfile - The {@link VirtualFile} to convert.\n * @returns The same object with updated `.data.canonicalPath`.\n */\nfunction convertCanonical<Result>(\n vfile: VirtualFile<Result>,\n): VirtualFile<Result> {\n assert(vfile.data.canonicalPath !== undefined);\n vfile.data.canonicalPath = `local:${vfile.data.canonicalPath}`;\n return vfile;\n}\n"],"names":["LocalSnapIdStruct","SnapIdPrefixes","assert","assertStruct","HttpLocation","LocalLocation","manifest","vfile","http","convertCanonical","fetch","path","shouldAlwaysReload","constructor","url","opts","toString","fetchOptions","undefined","URL","slice","local","length","cache","data","canonicalPath"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAASA,iBAAiB,EAAEC,cAAc,QAAQ,wBAAwB;AAC1E,SAASC,MAAM,EAAEC,YAAY,QAAQ,kBAAkB;AAGvD,SAASC,YAAY,QAAQ,SAAS;IAI3B;AADX,OAAO,MAAMC;IAiBX,MAAMC,WAA+C;QACnD,MAAMC,QAAQ,MAAM,yBAAA,IAAI,EAAEC,OAAKF,QAAQ;QAEvC,OAAOG,iBAAiBF;IAC1B;IAEA,MAAMG,MAAMC,IAAY,EAAwB;QAC9C,OAAOF,iBAAiB,MAAM,yBAAA,IAAI,EAAED,OAAKE,KAAK,CAACC;IACjD;IAEA,IAAIC,qBAAqB;QACvB,OAAO;IACT;IA1BAC,YAAYC,GAAQ,EAAEC,OAAoB,CAAC,CAAC,CAAE;QAF9C,gCAAS;;mBAAT,KAAA;;QAGEZ,aAAaW,IAAIE,QAAQ,IAAIhB,mBAAmB;QAChD,6DAA6D;QAC7DE,OACEa,KAAKE,YAAY,KAAKC,WACtB;uCAGIV,OAAO,IAAIJ,aACf,IAAIe,IAAIL,IAAIE,QAAQ,GAAGI,KAAK,CAACnB,eAAeoB,KAAK,CAACC,MAAM,IACxD;YAAE,GAAGP,IAAI;YAAEE,cAAc;gBAAEM,OAAO;YAAW;QAAE;IAEnD;AAeF;AAEA;;;;;CAKC,GACD,SAASd,iBACPF,KAA0B;IAE1BL,OAAOK,MAAMiB,IAAI,CAACC,aAAa,KAAKP;IACpCX,MAAMiB,IAAI,CAACC,aAAa,GAAG,CAAC,MAAM,EAAElB,MAAMiB,IAAI,CAACC,aAAa,CAAC,CAAC;IAC9D,OAAOlB;AACT"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { assert } from '@metamask/utils';
|
|
2
|
-
import { HttpLocation } from './http';
|
|
3
|
-
import { LocalLocation } from './local';
|
|
4
|
-
import { NpmLocation } from './npm';
|
|
5
|
-
/**
|
|
6
|
-
* Auto-magically detects which SnapLocation object to create based on the provided {@link location}.
|
|
7
|
-
*
|
|
8
|
-
* @param location - A {@link https://github.com/MetaMask/SIPs/blob/main/SIPS/sip-8.md SIP-8} uri.
|
|
9
|
-
* @param opts - NPM options and feature flags.
|
|
10
|
-
* @returns SnapLocation based on url.
|
|
11
|
-
*/ export function detectSnapLocation(location, opts) {
|
|
12
|
-
const allowHttp = opts?.allowHttp ?? false;
|
|
13
|
-
const allowLocal = opts?.allowLocal ?? false;
|
|
14
|
-
const root = new URL(location);
|
|
15
|
-
switch(root.protocol){
|
|
16
|
-
case 'npm:':
|
|
17
|
-
return new NpmLocation(root, opts);
|
|
18
|
-
case 'local:':
|
|
19
|
-
assert(allowLocal, new TypeError('Fetching local snaps is disabled.'));
|
|
20
|
-
return new LocalLocation(root, opts);
|
|
21
|
-
case 'http:':
|
|
22
|
-
case 'https:':
|
|
23
|
-
assert(allowHttp, new TypeError('Fetching snaps through http/https is disabled.'));
|
|
24
|
-
return new HttpLocation(root, opts);
|
|
25
|
-
default:
|
|
26
|
-
throw new TypeError(`Unrecognized "${root.protocol}" snap location protocol.`);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
//# sourceMappingURL=location.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/snaps/location/location.ts"],"sourcesContent":["import type { SnapManifest, VirtualFile } from '@metamask/snaps-utils';\nimport type { SemVerRange } from '@metamask/utils';\nimport { assert } from '@metamask/utils';\n\nimport { HttpLocation } from './http';\nimport { LocalLocation } from './local';\nimport type { NpmOptions } from './npm';\nimport { NpmLocation } from './npm';\n\ndeclare module '@metamask/snaps-utils' {\n interface DataMap {\n /**\n * Fully qualified, canonical path for the file in {@link https://github.com/MetaMask/SIPs/blob/main/SIPS/sip-8.md SIP-8 } URI format.\n */\n canonicalPath: string;\n }\n}\n\nexport interface SnapLocation {\n /**\n * All files are relative to the manifest, except the manifest itself.\n */\n manifest(): Promise<VirtualFile<SnapManifest>>;\n fetch(path: string): Promise<VirtualFile>;\n\n readonly shouldAlwaysReload?: boolean;\n}\n\nexport type DetectSnapLocationOptions = NpmOptions & {\n /**\n * The function used to fetch data.\n *\n * @default globalThis.fetch\n */\n fetch?: typeof fetch;\n /**\n * @default false\n */\n allowHttp?: boolean;\n /**\n * @default false\n */\n allowLocal?: boolean;\n\n resolveVersion?: (range: SemVerRange) => Promise<SemVerRange>;\n};\n\n/**\n * Auto-magically detects which SnapLocation object to create based on the provided {@link location}.\n *\n * @param location - A {@link https://github.com/MetaMask/SIPs/blob/main/SIPS/sip-8.md SIP-8} uri.\n * @param opts - NPM options and feature flags.\n * @returns SnapLocation based on url.\n */\nexport function detectSnapLocation(\n location: string | URL,\n opts?: DetectSnapLocationOptions,\n): SnapLocation {\n const allowHttp = opts?.allowHttp ?? false;\n const allowLocal = opts?.allowLocal ?? false;\n const root = new URL(location);\n switch (root.protocol) {\n case 'npm:':\n return new NpmLocation(root, opts);\n case 'local:':\n assert(allowLocal, new TypeError('Fetching local snaps is disabled.'));\n return new LocalLocation(root, opts);\n case 'http:':\n case 'https:':\n assert(\n allowHttp,\n new TypeError('Fetching snaps through http/https is disabled.'),\n );\n return new HttpLocation(root, opts);\n default:\n throw new TypeError(\n `Unrecognized \"${root.protocol}\" snap location protocol.`,\n );\n }\n}\n"],"names":["assert","HttpLocation","LocalLocation","NpmLocation","detectSnapLocation","location","opts","allowHttp","allowLocal","root","URL","protocol","TypeError"],"mappings":"AAEA,SAASA,MAAM,QAAQ,kBAAkB;AAEzC,SAASC,YAAY,QAAQ,SAAS;AACtC,SAASC,aAAa,QAAQ,UAAU;AAExC,SAASC,WAAW,QAAQ,QAAQ;AAwCpC;;;;;;CAMC,GACD,OAAO,SAASC,mBACdC,QAAsB,EACtBC,IAAgC;IAEhC,MAAMC,YAAYD,MAAMC,aAAa;IACrC,MAAMC,aAAaF,MAAME,cAAc;IACvC,MAAMC,OAAO,IAAIC,IAAIL;IACrB,OAAQI,KAAKE,QAAQ;QACnB,KAAK;YACH,OAAO,IAAIR,YAAYM,MAAMH;QAC/B,KAAK;YACHN,OAAOQ,YAAY,IAAII,UAAU;YACjC,OAAO,IAAIV,cAAcO,MAAMH;QACjC,KAAK;QACL,KAAK;YACHN,OACEO,WACA,IAAIK,UAAU;YAEhB,OAAO,IAAIX,aAAaQ,MAAMH;QAChC;YACE,MAAM,IAAIM,UACR,CAAC,cAAc,EAAEH,KAAKE,QAAQ,CAAC,yBAAyB,CAAC;IAE/D;AACF"}
|
|
@@ -1,373 +0,0 @@
|
|
|
1
|
-
function _check_private_redeclaration(obj, privateCollection) {
|
|
2
|
-
if (privateCollection.has(obj)) {
|
|
3
|
-
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
7
|
-
if (descriptor.get) {
|
|
8
|
-
return descriptor.get.call(receiver);
|
|
9
|
-
}
|
|
10
|
-
return descriptor.value;
|
|
11
|
-
}
|
|
12
|
-
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
13
|
-
if (descriptor.set) {
|
|
14
|
-
descriptor.set.call(receiver, value);
|
|
15
|
-
} else {
|
|
16
|
-
if (!descriptor.writable) {
|
|
17
|
-
throw new TypeError("attempted to set read only private field");
|
|
18
|
-
}
|
|
19
|
-
descriptor.value = value;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
23
|
-
if (!privateMap.has(receiver)) {
|
|
24
|
-
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
25
|
-
}
|
|
26
|
-
return privateMap.get(receiver);
|
|
27
|
-
}
|
|
28
|
-
function _class_private_field_get(receiver, privateMap) {
|
|
29
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
30
|
-
return _class_apply_descriptor_get(receiver, descriptor);
|
|
31
|
-
}
|
|
32
|
-
function _class_private_field_init(obj, privateMap, value) {
|
|
33
|
-
_check_private_redeclaration(obj, privateMap);
|
|
34
|
-
privateMap.set(obj, value);
|
|
35
|
-
}
|
|
36
|
-
function _class_private_field_set(receiver, privateMap, value) {
|
|
37
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
38
|
-
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
function _class_private_method_get(receiver, privateSet, fn) {
|
|
42
|
-
if (!privateSet.has(receiver)) {
|
|
43
|
-
throw new TypeError("attempted to get private field on non-instance");
|
|
44
|
-
}
|
|
45
|
-
return fn;
|
|
46
|
-
}
|
|
47
|
-
function _class_private_method_init(obj, privateSet) {
|
|
48
|
-
_check_private_redeclaration(obj, privateSet);
|
|
49
|
-
privateSet.add(obj);
|
|
50
|
-
}
|
|
51
|
-
function _define_property(obj, key, value) {
|
|
52
|
-
if (key in obj) {
|
|
53
|
-
Object.defineProperty(obj, key, {
|
|
54
|
-
value: value,
|
|
55
|
-
enumerable: true,
|
|
56
|
-
configurable: true,
|
|
57
|
-
writable: true
|
|
58
|
-
});
|
|
59
|
-
} else {
|
|
60
|
-
obj[key] = value;
|
|
61
|
-
}
|
|
62
|
-
return obj;
|
|
63
|
-
}
|
|
64
|
-
import { createSnapManifest, DEFAULT_REQUESTED_SNAP_VERSION, getTargetVersion, isValidUrl, NpmSnapIdStruct, VirtualFile, normalizeRelative, parseJson } from '@metamask/snaps-utils';
|
|
65
|
-
import { assert, assertIsSemVerVersion, assertStruct, isObject, isValidSemVerVersion } from '@metamask/utils';
|
|
66
|
-
import { createGunzip } from 'browserify-zlib';
|
|
67
|
-
import concat from 'concat-stream';
|
|
68
|
-
import getNpmTarballUrl from 'get-npm-tarball-url';
|
|
69
|
-
import { pipeline } from 'readable-stream';
|
|
70
|
-
import { ReadableWebToNodeStream } from 'readable-web-to-node-stream';
|
|
71
|
-
import { extract as tarExtract } from 'tar-stream';
|
|
72
|
-
export const DEFAULT_NPM_REGISTRY = new URL('https://registry.npmjs.org');
|
|
73
|
-
var _validatedManifest = /*#__PURE__*/ new WeakMap(), _files = /*#__PURE__*/ new WeakMap(), _lazyInit = /*#__PURE__*/ new WeakSet();
|
|
74
|
-
// Base class for NPM implementation, useful for extending with custom NPM fetching logic
|
|
75
|
-
export class BaseNpmLocation {
|
|
76
|
-
async manifest() {
|
|
77
|
-
if (_class_private_field_get(this, _validatedManifest)) {
|
|
78
|
-
return _class_private_field_get(this, _validatedManifest).clone();
|
|
79
|
-
}
|
|
80
|
-
const vfile = await this.fetch('snap.manifest.json');
|
|
81
|
-
const result = parseJson(vfile.toString());
|
|
82
|
-
vfile.result = createSnapManifest(result);
|
|
83
|
-
_class_private_field_set(this, _validatedManifest, vfile);
|
|
84
|
-
return this.manifest();
|
|
85
|
-
}
|
|
86
|
-
async fetch(path) {
|
|
87
|
-
const relativePath = normalizeRelative(path);
|
|
88
|
-
if (!_class_private_field_get(this, _files)) {
|
|
89
|
-
await _class_private_method_get(this, _lazyInit, lazyInit).call(this);
|
|
90
|
-
assert(_class_private_field_get(this, _files) !== undefined);
|
|
91
|
-
}
|
|
92
|
-
const vfile = _class_private_field_get(this, _files).get(relativePath);
|
|
93
|
-
assert(vfile !== undefined, new TypeError(`File "${path}" not found in package.`));
|
|
94
|
-
return vfile.clone();
|
|
95
|
-
}
|
|
96
|
-
get packageName() {
|
|
97
|
-
return this.meta.packageName;
|
|
98
|
-
}
|
|
99
|
-
get version() {
|
|
100
|
-
assert(this.meta.version !== undefined, 'Tried to access version without first fetching NPM package.');
|
|
101
|
-
return this.meta.version;
|
|
102
|
-
}
|
|
103
|
-
get registry() {
|
|
104
|
-
return this.meta.registry;
|
|
105
|
-
}
|
|
106
|
-
get versionRange() {
|
|
107
|
-
return this.meta.requestedRange;
|
|
108
|
-
}
|
|
109
|
-
constructor(url, opts = {}){
|
|
110
|
-
_class_private_method_init(this, _lazyInit);
|
|
111
|
-
_define_property(this, "meta", void 0);
|
|
112
|
-
_class_private_field_init(this, _validatedManifest, {
|
|
113
|
-
writable: true,
|
|
114
|
-
value: void 0
|
|
115
|
-
});
|
|
116
|
-
_class_private_field_init(this, _files, {
|
|
117
|
-
writable: true,
|
|
118
|
-
value: void 0
|
|
119
|
-
});
|
|
120
|
-
const allowCustomRegistries = opts.allowCustomRegistries ?? false;
|
|
121
|
-
const fetchFunction = opts.fetch ?? globalThis.fetch.bind(globalThis);
|
|
122
|
-
const requestedRange = opts.versionRange ?? DEFAULT_REQUESTED_SNAP_VERSION;
|
|
123
|
-
const defaultResolve = async (range)=>range;
|
|
124
|
-
const resolveVersion = opts.resolveVersion ?? defaultResolve;
|
|
125
|
-
assertStruct(url.toString(), NpmSnapIdStruct, 'Invalid Snap Id: ');
|
|
126
|
-
let registry;
|
|
127
|
-
if (url.host === '' && url.port === '' && url.username === '' && url.password === '') {
|
|
128
|
-
registry = DEFAULT_NPM_REGISTRY;
|
|
129
|
-
} else {
|
|
130
|
-
registry = 'https://';
|
|
131
|
-
if (url.username) {
|
|
132
|
-
registry += url.username;
|
|
133
|
-
if (url.password) {
|
|
134
|
-
registry += `:${url.password}`;
|
|
135
|
-
}
|
|
136
|
-
registry += '@';
|
|
137
|
-
}
|
|
138
|
-
registry += url.host;
|
|
139
|
-
registry = new URL(registry);
|
|
140
|
-
assert(allowCustomRegistries, new TypeError(`Custom NPM registries are disabled, tried to use "${registry.toString()}".`));
|
|
141
|
-
}
|
|
142
|
-
assert(registry.pathname === '/' && registry.search === '' && registry.hash === '');
|
|
143
|
-
assert(url.pathname !== '' && url.pathname !== '/', new TypeError('The package name in NPM location is empty.'));
|
|
144
|
-
let packageName = url.pathname;
|
|
145
|
-
if (packageName.startsWith('/')) {
|
|
146
|
-
packageName = packageName.slice(1);
|
|
147
|
-
}
|
|
148
|
-
this.meta = {
|
|
149
|
-
requestedRange,
|
|
150
|
-
registry,
|
|
151
|
-
packageName,
|
|
152
|
-
fetch: fetchFunction,
|
|
153
|
-
resolveVersion
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
async function lazyInit() {
|
|
158
|
-
assert(_class_private_field_get(this, _files) === undefined);
|
|
159
|
-
const resolvedVersion = await this.meta.resolveVersion(this.meta.requestedRange);
|
|
160
|
-
const { tarballURL, targetVersion } = await resolveNpmVersion(this.meta.packageName, resolvedVersion, this.meta.registry, this.meta.fetch);
|
|
161
|
-
if (!isValidUrl(tarballURL) || !tarballURL.toString().endsWith('.tgz')) {
|
|
162
|
-
throw new Error(`Failed to find valid tarball URL in NPM metadata for package "${this.meta.packageName}".`);
|
|
163
|
-
}
|
|
164
|
-
// Override the tarball hostname/protocol with registryUrl hostname/protocol
|
|
165
|
-
const newTarballUrl = new URL(tarballURL);
|
|
166
|
-
newTarballUrl.hostname = this.meta.registry.hostname;
|
|
167
|
-
newTarballUrl.protocol = this.meta.registry.protocol;
|
|
168
|
-
const files = await this.fetchNpmTarball(newTarballUrl);
|
|
169
|
-
_class_private_field_set(this, _files, files);
|
|
170
|
-
this.meta.version = targetVersion;
|
|
171
|
-
}
|
|
172
|
-
// Safety limit for tarballs, 250 MB in bytes
|
|
173
|
-
export const TARBALL_SIZE_SAFETY_LIMIT = 262144000;
|
|
174
|
-
// Main NPM implementation, contains a browser tarball fetching implementation.
|
|
175
|
-
export class NpmLocation extends BaseNpmLocation {
|
|
176
|
-
/**
|
|
177
|
-
* Fetches and unpacks the tarball (`.tgz` file) from the specified URL.
|
|
178
|
-
*
|
|
179
|
-
* @param tarballUrl - The tarball URL to fetch and unpack.
|
|
180
|
-
* @returns A the files for the package tarball.
|
|
181
|
-
* @throws If fetching the tarball fails.
|
|
182
|
-
*/ async fetchNpmTarball(tarballUrl) {
|
|
183
|
-
// Perform a raw fetch because we want the Response object itself.
|
|
184
|
-
const tarballResponse = await this.meta.fetch(tarballUrl.toString());
|
|
185
|
-
if (!tarballResponse.ok || !tarballResponse.body) {
|
|
186
|
-
throw new Error(`Failed to fetch tarball for package "${this.meta.packageName}".`);
|
|
187
|
-
}
|
|
188
|
-
// We assume that NPM is a good actor and provides us with a valid `content-length` header.
|
|
189
|
-
const tarballSizeString = tarballResponse.headers.get('content-length');
|
|
190
|
-
assert(tarballSizeString, 'Snap tarball has invalid content-length');
|
|
191
|
-
const tarballSize = parseInt(tarballSizeString, 10);
|
|
192
|
-
assert(tarballSize <= TARBALL_SIZE_SAFETY_LIMIT, 'Snap tarball exceeds size limit');
|
|
193
|
-
return new Promise((resolve, reject)=>{
|
|
194
|
-
const files = new Map();
|
|
195
|
-
const tarballStream = createTarballStream(getNpmCanonicalBasePath(this.meta.registry, this.meta.packageName), files);
|
|
196
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
197
|
-
const body = tarballResponse.body;
|
|
198
|
-
// The "gz" in "tgz" stands for "gzip". The tarball needs to be decompressed
|
|
199
|
-
// before we can actually grab any files from it.
|
|
200
|
-
// To prevent recursion-based zip bombs, we should not allow recursion here.
|
|
201
|
-
// If native decompression stream is available we use that, otherwise fallback to zlib.
|
|
202
|
-
if ('pipeThrough' in body && 'DecompressionStream' in globalThis) {
|
|
203
|
-
const decompressionStream = new DecompressionStream('gzip');
|
|
204
|
-
const decompressedStream = body.pipeThrough(decompressionStream);
|
|
205
|
-
pipeline(getNodeStream(decompressedStream), tarballStream, (error)=>{
|
|
206
|
-
error ? reject(error) : resolve(files);
|
|
207
|
-
});
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
pipeline(getNodeStream(body), createGunzip(), tarballStream, (error)=>{
|
|
211
|
-
error ? reject(error) : resolve(files);
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Fetches the NPM metadata of the specified package from
|
|
218
|
-
* the public npm registry.
|
|
219
|
-
*
|
|
220
|
-
* @param packageName - The name of the package whose metadata to fetch.
|
|
221
|
-
* @param registryUrl - The URL of the npm registry to fetch the metadata from.
|
|
222
|
-
* @param fetchFunction - The fetch function to use. Defaults to the global
|
|
223
|
-
* {@link fetch}. Useful for Node.js compatibility.
|
|
224
|
-
* @returns The NPM metadata object.
|
|
225
|
-
* @throws If fetching the metadata fails.
|
|
226
|
-
*/ export async function fetchNpmMetadata(packageName, registryUrl, fetchFunction) {
|
|
227
|
-
const packageResponse = await fetchFunction(new URL(packageName, registryUrl).toString(), {
|
|
228
|
-
headers: {
|
|
229
|
-
// Corgi format is slightly smaller: https://github.com/npm/pacote/blob/main/lib/registry.js#L71
|
|
230
|
-
accept: isNPM(registryUrl) ? 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*' : 'application/json'
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
if (!packageResponse.ok) {
|
|
234
|
-
throw new Error(`Failed to fetch NPM registry entry. Status code: ${packageResponse.status}.`);
|
|
235
|
-
}
|
|
236
|
-
const packageMetadata = await packageResponse.json();
|
|
237
|
-
if (!isObject(packageMetadata)) {
|
|
238
|
-
throw new Error(`Failed to fetch package "${packageName}" metadata from npm.`);
|
|
239
|
-
}
|
|
240
|
-
return packageMetadata;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Gets the canonical base path for an NPM snap.
|
|
244
|
-
*
|
|
245
|
-
* @param registryUrl - A registry URL.
|
|
246
|
-
* @param packageName - A package name.
|
|
247
|
-
* @returns The canonical base path.
|
|
248
|
-
*/ export function getNpmCanonicalBasePath(registryUrl, packageName) {
|
|
249
|
-
let canonicalBase = 'npm://';
|
|
250
|
-
if (registryUrl.username !== '') {
|
|
251
|
-
canonicalBase += registryUrl.username;
|
|
252
|
-
if (registryUrl.password !== '') {
|
|
253
|
-
canonicalBase += `:${registryUrl.password}`;
|
|
254
|
-
}
|
|
255
|
-
canonicalBase += '@';
|
|
256
|
-
}
|
|
257
|
-
return `${canonicalBase}${registryUrl.host}/${packageName}/`;
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Determine if a registry URL is NPM.
|
|
261
|
-
*
|
|
262
|
-
* @param registryUrl - A registry url.
|
|
263
|
-
* @returns True if the registry is the NPM registry, otherwise false.
|
|
264
|
-
*/ function isNPM(registryUrl) {
|
|
265
|
-
return registryUrl.toString() === DEFAULT_NPM_REGISTRY.toString();
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Resolves a version range to a version using the NPM registry.
|
|
269
|
-
*
|
|
270
|
-
* Unless the version range is already a version, then the NPM registry is skipped.
|
|
271
|
-
*
|
|
272
|
-
* @param packageName - The name of the package whose metadata to fetch.
|
|
273
|
-
* @param versionRange - The version range of the package.
|
|
274
|
-
* @param registryUrl - The URL of the npm registry to fetch the metadata from.
|
|
275
|
-
* @param fetchFunction - The fetch function to use. Defaults to the global
|
|
276
|
-
* {@link fetch}. Useful for Node.js compatibility.
|
|
277
|
-
* @returns An object containing the resolved version and a URL for its tarball.
|
|
278
|
-
* @throws If fetching the metadata fails.
|
|
279
|
-
*/ async function resolveNpmVersion(packageName, versionRange, registryUrl, fetchFunction) {
|
|
280
|
-
// If the version range is already a static version we don't need to look for the metadata.
|
|
281
|
-
if (isNPM(registryUrl) && isValidSemVerVersion(versionRange)) {
|
|
282
|
-
return {
|
|
283
|
-
tarballURL: getNpmTarballUrl(packageName, versionRange),
|
|
284
|
-
targetVersion: versionRange
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
const packageMetadata = await fetchNpmMetadata(packageName, registryUrl, fetchFunction);
|
|
288
|
-
const versions = Object.keys(packageMetadata?.versions ?? {}).map((version)=>{
|
|
289
|
-
assertIsSemVerVersion(version);
|
|
290
|
-
return version;
|
|
291
|
-
});
|
|
292
|
-
const targetVersion = getTargetVersion(versions, versionRange);
|
|
293
|
-
if (targetVersion === null) {
|
|
294
|
-
throw new Error(`Failed to find a matching version in npm metadata for package "${packageName}" and requested semver range "${versionRange}".`);
|
|
295
|
-
}
|
|
296
|
-
const tarballURL = packageMetadata?.versions?.[targetVersion]?.dist?.tarball;
|
|
297
|
-
return {
|
|
298
|
-
tarballURL,
|
|
299
|
-
targetVersion
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* The paths of files within npm tarballs appear to always be prefixed with
|
|
304
|
-
* "package/".
|
|
305
|
-
*/ const NPM_TARBALL_PATH_PREFIX = /^package\//u;
|
|
306
|
-
/**
|
|
307
|
-
* Converts a {@link ReadableStream} to a Node.js {@link Readable}
|
|
308
|
-
* stream. Returns the stream directly if it is already a Node.js stream.
|
|
309
|
-
* We can't use the native Web {@link ReadableStream} directly because the
|
|
310
|
-
* other stream libraries we use expect Node.js streams.
|
|
311
|
-
*
|
|
312
|
-
* @param stream - The stream to convert.
|
|
313
|
-
* @returns The given stream as a Node.js Readable stream.
|
|
314
|
-
*/ function getNodeStream(stream) {
|
|
315
|
-
if (typeof stream.getReader !== 'function') {
|
|
316
|
-
return stream;
|
|
317
|
-
}
|
|
318
|
-
return new ReadableWebToNodeStream(stream);
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* Creates a `tar-stream` that will get the necessary files from an npm Snap
|
|
322
|
-
* package tarball (`.tgz` file).
|
|
323
|
-
*
|
|
324
|
-
* @param canonicalBase - A base URI as specified in {@link https://github.com/MetaMask/SIPs/blob/main/SIPS/sip-8.md SIP-8}. Starting with 'npm:'. Will be used for canonicalPath vfile argument.
|
|
325
|
-
* @param files - An object to write target file contents to.
|
|
326
|
-
* @returns The {@link Writable} tarball extraction stream.
|
|
327
|
-
*/ function createTarballStream(canonicalBase, files) {
|
|
328
|
-
assert(canonicalBase.endsWith('/'), "Base needs to end with '/' for relative paths to be added as children instead of siblings.");
|
|
329
|
-
assert(canonicalBase.startsWith('npm:'), 'Protocol mismatch, expected "npm:".');
|
|
330
|
-
// `tar-stream` is pretty old-school, so we create it first and then
|
|
331
|
-
// instrument it by adding event listeners.
|
|
332
|
-
const extractStream = tarExtract();
|
|
333
|
-
let totalSize = 0;
|
|
334
|
-
// "entry" is fired for every discreet entity in the tarball. This includes
|
|
335
|
-
// files and folders.
|
|
336
|
-
extractStream.on('entry', (header, entryStream, next)=>{
|
|
337
|
-
const { name: headerName, type: headerType } = header;
|
|
338
|
-
if (headerType === 'file') {
|
|
339
|
-
// The name is a path if the header type is "file".
|
|
340
|
-
const path = headerName.replace(NPM_TARBALL_PATH_PREFIX, '');
|
|
341
|
-
return entryStream.pipe(concat({
|
|
342
|
-
encoding: 'uint8array'
|
|
343
|
-
}, (data)=>{
|
|
344
|
-
try {
|
|
345
|
-
totalSize += data.byteLength;
|
|
346
|
-
// To prevent zip bombs, we set a safety limit for the total size of tarballs.
|
|
347
|
-
assert(totalSize < TARBALL_SIZE_SAFETY_LIMIT, `Snap tarball exceeds limit of ${TARBALL_SIZE_SAFETY_LIMIT} bytes.`);
|
|
348
|
-
const vfile = new VirtualFile({
|
|
349
|
-
value: data,
|
|
350
|
-
path,
|
|
351
|
-
data: {
|
|
352
|
-
canonicalPath: new URL(path, canonicalBase).toString()
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
// We disallow files having identical paths as it may confuse our checksum calculations.
|
|
356
|
-
assert(!files.has(path), 'Malformed tarball, multiple files with the same path.');
|
|
357
|
-
files.set(path, vfile);
|
|
358
|
-
return next();
|
|
359
|
-
} catch (error) {
|
|
360
|
-
return extractStream.destroy(error);
|
|
361
|
-
}
|
|
362
|
-
}));
|
|
363
|
-
}
|
|
364
|
-
// If we get here, the entry is not a file, and we want to ignore. The entry
|
|
365
|
-
// stream must be drained, or the extractStream will stop reading. This is
|
|
366
|
-
// effectively a no-op for the current entry.
|
|
367
|
-
entryStream.on('end', ()=>next());
|
|
368
|
-
return entryStream.resume();
|
|
369
|
-
});
|
|
370
|
-
return extractStream;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
//# sourceMappingURL=npm.js.map
|