Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

experimenting with webpack #17872

Closed
wants to merge 4 commits into from
Closed

experimenting with webpack #17872

wants to merge 4 commits into from

Conversation

kumavis
Copy link
Member

@kumavis kumavis commented Feb 22, 2023

exploring a possible path to lavamoat protections for webpack builds:

reasons for webpack:

the pipeline looks something like:
webpack -> endo archive -> bundle

this pipeline also allows us to switch to a different bundler that can output Endo Archives in the future

@brad-decker
Copy link
Contributor

@kumavis I am working on getting webpack able to fully build the application including generating static assets and html files. The WebpackHtmlPlugin does templating as well but uses a different template format so we can cover that use case. My latest commit adds the 'distro' folder which shows the current output. Not that we can import images directly into our javascript and webpack will handle changing them into static assets OR we can use the CopyWepbackPlugin to copy our assets over and continue to reference them the way they are currently (or perhaps both). i'm going to continue on this path until I can get a working build of the extension, including manifest files, using just webpack...then we can add lavamoat support.

@@ -0,0 +1 @@
(()=>{var e,t={90095:(e,t,n)=>{"use strict";var a=n(74286),o=n.n(a),r=n(21396),s=n(88987),i=n.n(s),c=n(93150),l=n.n(c),d=n(83560),m=n.n(d),u=n(14650),p=n(2043),_=n.n(p),g=n(76412);Object.freeze({restrictReturnedAccounts:"restrictReturnedAccounts"});const h=Object.freeze({eth_accounts:"eth_accounts",snap_confirm:"snap_confirm",snap_dialog:"snap_dialog",snap_notify:"snap_notify",snap_manageState:"snap_manageState",snap_getBip32PublicKey:"snap_getBip32PublicKey",snap_getBip32Entropy:"snap_getBip32Entropy",snap_getBip44Entropy:"snap_getBip44Entropy",snap_getEntropy:"snap_getEntropy","wallet_snap_*":"wallet_snap_*"}),f=(Object.freeze({wallet_snap_:"wallet_snap_*"}),Object.freeze({"endowment:network-access":"endowment:network-access","endowment:transaction-insight":"endowment:transaction-insight","endowment:cronjob":"endowment:cronjob","endowment:ethereum-provider":"endowment:ethereum-provider","endowment:rpc":"endowment:rpc","endowment:long-running":"endowment:long-running"}),Object.freeze({eth_accounts:"eth_accounts is disabled. For more information please see https://github.com/MetaMask/snaps-monorepo/issues/990."}),Object.freeze({"endowment:keyring":"This endowment is still in development therefore not available."}),{ADD_ETHEREUM_CHAIN:"wallet_addEthereumChain",ETH_ACCOUNTS:h.eth_accounts,ETH_DECRYPT:"eth_decrypt",ETH_GET_ENCRYPTION_PUBLIC_KEY:"eth_getEncryptionPublicKey",ETH_REQUEST_ACCOUNTS:"eth_requestAccounts",ETH_SIGN:"eth_sign",ETH_SIGN_TYPED_DATA:"eth_signTypedData",ETH_SIGN_TYPED_DATA_V3:"eth_signTypedData_v3",ETH_SIGN_TYPED_DATA_V4:"eth_signTypedData_v4",GET_PROVIDER_STATE:"metamask_getProviderState",LOG_WEB3_SHIM_USAGE:"metamask_logWeb3ShimUsage",PERSONAL_SIGN:"personal_sign",SEND_METADATA:"metamask_sendDomainMetadata",SWITCH_ETHEREUM_CHAIN:"wallet_switchEthereumChain",WALLET_REQUEST_PERMISSIONS:"wallet_requestPermissions",WATCH_ASSET:"wallet_watchAsset",WATCH_ASSET_LEGACY:"metamask_watchAsset",SNAP_DIALOG_ALERT:`${h.snap_dialog}:alert`,SNAP_DIALOG_CONFIRMATION:`${h.snap_dialog}:confirmation`,SNAP_DIALOG_PROMPT:`${h.snap_dialog}:prompt`,ENABLE_DESKTOP:"metamask_enableDesktop"}),w=(g.DialogType.Alert,g.DialogType.Confirmation,g.DialogType.Prompt,"METAMASK_EXTENSION_READY");function E(){const{lastError:e}=l().runtime;if(e)return e.stack&&e.message?e:new Error(e.message)}const M=3===l().runtime.getManifest().manifest_version;function A(){return function(){const{doctype:e}=window.document;if(e)return"html"===e.name;return!0}()&&function(){const e=[/\.xml$/u,/\.pdf$/u],t=window.location.pathname;for(let n=0;n<e.length;n++)if(e[n].test(t))return!1;return!0}()&&function(){const e=document.documentElement.nodeName;if(e)return"html"===e.toLowerCase();return!0}()&&!function(){const e=["uscourts.gov","dropbox.com","webbyawards.com","cdn.shopify.com/s/javascripts/tricorder/xtld-read-only-frame.html","adyen.com","gravityforms.com","harbourair.com","ani.gamer.com.tw","blueskybooking.com","sharefile.com"],t=window.location.href;let n;for(let a=0;a<e.length;a++){const o=e[a].replace(".","\\.");if(n=new RegExp(`(?:https?:\\/\\/)(?:(?!${o}).)*$`,"u"),!n.test(t))return!0}return!1}()}const T=n(23384),S=n(26470),v=T.readFileSync(S.join("/","..","..","dist","chrome","inpage.js"),"utf8")+`//# sourceURL=${l().runtime.getURL("inpage.js")}\n`,y="metamask-contentscript",b="metamask-inpage",k="metamask-phishing-warning-page",L="metamask-phishing-safelist",P="metamask-provider",I="provider",O="publicConfig";let R,N,D,C,x,j,G;const H=new URL(process.env.PHISHING_WARNING_PAGE_URL);let $,U,B,W,K,Y,z,F,V,q,Q,X,J;const Z=[f.GET_PROVIDER_STATE,f.SEND_METADATA];let ee,te;const ne=()=>{l().runtime.sendMessage({name:"WORKER_KEEP_ALIVE_MESSAGE"}).catch((e=>{"Extension context invalidated."===e.message?_().error(`Please refresh the page. MetaMask: ${e}`):_().error(`MetaMask: ${e}`)}))},ae=()=>{clearTimeout(te),te=setTimeout((()=>{clearInterval(ee)}),27e5),clearInterval(ee),ne(),ee=setInterval((()=>{l().runtime.id&&ne()}),1e3)};const oe=()=>{B=l().runtime.connect({name:y}),W=new(m())(B),U=new(i()),U.setMaxListeners(25),o()(U,W,U,(e=>{_e("MetaMask Background Multiplex",e),window.postMessage({target:k,data:{name:L,data:{jsonrpc:"2.0",method:"METAMASK_STREAM_FAILURE"}}},window.location.origin)})),$=U.createStream(L),o()(K,$,K,(e=>console.debug(`MetaMask: Muxed traffic for channel "${L}" failed.`,e))),B.onDisconnect.addListener(re)},re=()=>{const e=E();B.onDisconnect.removeListener(re),K.removeAllListeners(),U.removeAllListeners(),U.destroy(),$.removeAllListeners(),$.destroy(),W=null,e&&(console.warn(`${e} Resetting the phishing streams.`),setTimeout(oe,1e3))},se=e=>{if(e.name===w)return W||oe(),Promise.resolve(`MetaMask: handled "${w}" for phishing streams`)},ie=()=>{!function(){const e=new r.WindowPostMessageStream({name:y,target:k});M&&ae(),Y=new(i()),Y.setMaxListeners(25),o()(Y,e,Y,(e=>_e("MetaMask Inpage Multiplex",e))),K=Y.createStream(L)}(),oe(),l().runtime.onMessage.addListener(se)};let ce=!1;const le=()=>{ce=!0,V=l().runtime.connect({name:y}),Q=new(m())(V),Q.on("data",ge),z=new(i()),z.setMaxListeners(25),z.ignoreStream(O),o()(z,Q,z,(e=>{_e("MetaMask Background Multiplex",e),he()})),F=z.createStream(P),o()(J,F,J,(e=>console.debug(`MetaMask: Muxed traffic for channel "${P}" failed.`,e))),q=z.createStream("phishing"),q.once("data",fe),V.onDisconnect.addListener(ue)},de=()=>{R=new(i()),R.setMaxListeners(25),G=(0,u.obj)(((e,t,n)=>{var a;(null==e?void 0:e.name)===P&&"metamask_accountsChanged"===(null===(a=e.data)||void 0===a?void 0:a.method)&&(e.data.method="wallet_accountsChanged",e.data.result=e.data.params,delete e.data.params),n(null,e)})),o()(R,Q,G,R,(e=>{_e("MetaMask Background Legacy Multiplex",e),he()})),N=R.createStream(P),o()(x,N,x,(e=>console.debug(`MetaMask: Muxed traffic between channels "provider" and "${P}" failed.`,e))),D=R.createStream(O),o()(j,D,j,(e=>console.debug('MetaMask: Muxed traffic for channel "publicConfig" failed.',e)))},me=e=>{if(e.name===w)return Q||(le(),de()),Promise.resolve(`MetaMask: handled ${w}`)},ue=()=>{const e=E();V.onDisconnect.removeListener(ue),J.removeAllListeners(),z.removeAllListeners(),z.destroy(),F.removeAllListeners(),F.destroy(),Q=null,x.removeAllListeners(),j.removeAllListeners(),R.removeAllListeners(),R.destroy(),N.removeAllListeners(),N.destroy(),D.removeAllListeners(),D.destroy(),e&&(console.warn(`${e} Resetting the streams.`),setTimeout(le,1e3))},pe=()=>{(()=>{const e=new r.WindowPostMessageStream({name:y,target:b});M&&e.on("data",(({data:{method:e}})=>{Z.includes(e)||ae()})),X=new(i()),X.setMaxListeners(25),o()(X,e,X,(e=>_e("MetaMask Inpage Multiplex",e))),J=X.createStream(P)})(),(()=>{const e=new r.WindowPostMessageStream({name:"contentscript",target:"inpage"});M&&e.on("data",(({data:{method:e}})=>{Z.includes(e)||ae()})),C=new(i()),C.setMaxListeners(25),o()(C,e,C,(e=>_e("MetaMask Legacy Inpage Multiplex",e))),x=C.createStream(I),j=C.createStream(O)})(),le(),de(),l().runtime.onMessage.addListener(me)};function _e(e,t){console.debug(`MetaMask: Content script lost connection to "${e}".`,t)}function ge(e){ce&&M&&"metamask_chainChanged"===e.data.method&&(ce=!1,window.postMessage({target:b,data:{name:P,data:{jsonrpc:"2.0",method:"METAMASK_EXTENSION_CONNECT_CAN_RETRY"}}},window.location.origin))}function he(){window.postMessage({target:b,data:{name:P,data:{jsonrpc:"2.0",method:"METAMASK_STREAM_FAILURE"}}},window.location.origin)}function fe(e={}){console.debug("MetaMask: Routing to Phishing Warning page.");const{hostname:t,href:n}=window.location,{newIssueUrl:a}=e,o=process.env.PHISHING_WARNING_PAGE_URL,r=new URLSearchParams({hostname:t,href:n,newIssueUrl:a});window.location.href=`${o}#${r}`}window.location.origin===H.origin&&window.location.pathname===H.pathname?ie():A()&&(M||function(e){try{const t=document.head||document.documentElement,n=document.createElement("script");n.setAttribute("async","false"),n.textContent=e,t.insertBefore(n,t.children[0]),t.removeChild(n)}catch(e){console.error("MetaMask: Provider injection failed.",e)}}(v),pe())},79314:()=>{},82414:()=>{},43094:()=>{},46601:()=>{},89214:()=>{},63032:()=>{},84711:()=>{},72783:()=>{},37281:()=>{},27790:()=>{},69386:()=>{},31616:()=>{},29120:()=>{},46586:()=>{},6297:()=>{},71156:()=>{},52361:()=>{},94616:()=>{},6567:()=>{},69862:()=>{},40964:()=>{},50522:()=>{},66882:()=>{}},n={};function a(e){var o=n[e];if(void 0!==o)return o.exports;var r=n[e]={id:e,loaded:!1,exports:{}};return t[e].call(r.exports,r,r.exports,a),r.loaded=!0,r.exports}a.m=t,e=[],a.O=(t,n,o,r)=>{if(!n){var s=1/0;for(d=0;d<e.length;d++){for(var[n,o,r]=e[d],i=!0,c=0;c<n.length;c++)(!1&r||s>=r)&&Object.keys(a.O).every((e=>a.O[e](n[c])))?n.splice(c--,1):(i=!1,r<s&&(s=r));if(i){e.splice(d--,1);var l=o();void 0!==l&&(t=l)}}return t}r=r||0;for(var d=e.length;d>0&&e[d-1][2]>r;d--)e[d]=e[d-1];e[d]=[n,o,r]},a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var n in t)a.o(t,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e={153:0};a.O.j=t=>0===e[t];var t=(t,n)=>{var o,r,[s,i,c]=n,l=0;if(s.some((t=>0!==e[t]))){for(o in i)a.o(i,o)&&(a.m[o]=i[o]);if(c)var d=c(a)}for(t&&t(n);l<s.length;l++)r=s[l],a.o(e,r)&&e[r]&&e[r][0](),e[r]=0;return a.O(d)},n=self.webpackChunkmetamask_crx=self.webpackChunkmetamask_crx||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})();var o=a.O(void 0,[722,633,257],(()=>a(90095)));o=a.O(o)})();

Check failure

Code scanning / CodeQL

Incomplete regular expression for hostnames

This string, which is used as a regular expression [here](1), has an unescaped '.' before 'shopify.com/s/javascripts/tricorder/xtld-read-only-frame', so it might match more hosts than expected.
@@ -0,0 +1 @@
(()=>{var e,t={90095:(e,t,n)=>{"use strict";var a=n(74286),o=n.n(a),r=n(21396),s=n(88987),i=n.n(s),c=n(93150),l=n.n(c),d=n(83560),m=n.n(d),u=n(14650),p=n(2043),_=n.n(p),g=n(76412);Object.freeze({restrictReturnedAccounts:"restrictReturnedAccounts"});const h=Object.freeze({eth_accounts:"eth_accounts",snap_confirm:"snap_confirm",snap_dialog:"snap_dialog",snap_notify:"snap_notify",snap_manageState:"snap_manageState",snap_getBip32PublicKey:"snap_getBip32PublicKey",snap_getBip32Entropy:"snap_getBip32Entropy",snap_getBip44Entropy:"snap_getBip44Entropy",snap_getEntropy:"snap_getEntropy","wallet_snap_*":"wallet_snap_*"}),f=(Object.freeze({wallet_snap_:"wallet_snap_*"}),Object.freeze({"endowment:network-access":"endowment:network-access","endowment:transaction-insight":"endowment:transaction-insight","endowment:cronjob":"endowment:cronjob","endowment:ethereum-provider":"endowment:ethereum-provider","endowment:rpc":"endowment:rpc","endowment:long-running":"endowment:long-running"}),Object.freeze({eth_accounts:"eth_accounts is disabled. For more information please see https://github.com/MetaMask/snaps-monorepo/issues/990."}),Object.freeze({"endowment:keyring":"This endowment is still in development therefore not available."}),{ADD_ETHEREUM_CHAIN:"wallet_addEthereumChain",ETH_ACCOUNTS:h.eth_accounts,ETH_DECRYPT:"eth_decrypt",ETH_GET_ENCRYPTION_PUBLIC_KEY:"eth_getEncryptionPublicKey",ETH_REQUEST_ACCOUNTS:"eth_requestAccounts",ETH_SIGN:"eth_sign",ETH_SIGN_TYPED_DATA:"eth_signTypedData",ETH_SIGN_TYPED_DATA_V3:"eth_signTypedData_v3",ETH_SIGN_TYPED_DATA_V4:"eth_signTypedData_v4",GET_PROVIDER_STATE:"metamask_getProviderState",LOG_WEB3_SHIM_USAGE:"metamask_logWeb3ShimUsage",PERSONAL_SIGN:"personal_sign",SEND_METADATA:"metamask_sendDomainMetadata",SWITCH_ETHEREUM_CHAIN:"wallet_switchEthereumChain",WALLET_REQUEST_PERMISSIONS:"wallet_requestPermissions",WATCH_ASSET:"wallet_watchAsset",WATCH_ASSET_LEGACY:"metamask_watchAsset",SNAP_DIALOG_ALERT:`${h.snap_dialog}:alert`,SNAP_DIALOG_CONFIRMATION:`${h.snap_dialog}:confirmation`,SNAP_DIALOG_PROMPT:`${h.snap_dialog}:prompt`,ENABLE_DESKTOP:"metamask_enableDesktop"}),w=(g.DialogType.Alert,g.DialogType.Confirmation,g.DialogType.Prompt,"METAMASK_EXTENSION_READY");function E(){const{lastError:e}=l().runtime;if(e)return e.stack&&e.message?e:new Error(e.message)}const M=3===l().runtime.getManifest().manifest_version;function A(){return function(){const{doctype:e}=window.document;if(e)return"html"===e.name;return!0}()&&function(){const e=[/\.xml$/u,/\.pdf$/u],t=window.location.pathname;for(let n=0;n<e.length;n++)if(e[n].test(t))return!1;return!0}()&&function(){const e=document.documentElement.nodeName;if(e)return"html"===e.toLowerCase();return!0}()&&!function(){const e=["uscourts.gov","dropbox.com","webbyawards.com","cdn.shopify.com/s/javascripts/tricorder/xtld-read-only-frame.html","adyen.com","gravityforms.com","harbourair.com","ani.gamer.com.tw","blueskybooking.com","sharefile.com"],t=window.location.href;let n;for(let a=0;a<e.length;a++){const o=e[a].replace(".","\\.");if(n=new RegExp(`(?:https?:\\/\\/)(?:(?!${o}).)*$`,"u"),!n.test(t))return!0}return!1}()}const T=n(23384),S=n(26470),v=T.readFileSync(S.join("/","..","..","dist","chrome","inpage.js"),"utf8")+`//# sourceURL=${l().runtime.getURL("inpage.js")}\n`,y="metamask-contentscript",b="metamask-inpage",k="metamask-phishing-warning-page",L="metamask-phishing-safelist",P="metamask-provider",I="provider",O="publicConfig";let R,N,D,C,x,j,G;const H=new URL(process.env.PHISHING_WARNING_PAGE_URL);let $,U,B,W,K,Y,z,F,V,q,Q,X,J;const Z=[f.GET_PROVIDER_STATE,f.SEND_METADATA];let ee,te;const ne=()=>{l().runtime.sendMessage({name:"WORKER_KEEP_ALIVE_MESSAGE"}).catch((e=>{"Extension context invalidated."===e.message?_().error(`Please refresh the page. MetaMask: ${e}`):_().error(`MetaMask: ${e}`)}))},ae=()=>{clearTimeout(te),te=setTimeout((()=>{clearInterval(ee)}),27e5),clearInterval(ee),ne(),ee=setInterval((()=>{l().runtime.id&&ne()}),1e3)};const oe=()=>{B=l().runtime.connect({name:y}),W=new(m())(B),U=new(i()),U.setMaxListeners(25),o()(U,W,U,(e=>{_e("MetaMask Background Multiplex",e),window.postMessage({target:k,data:{name:L,data:{jsonrpc:"2.0",method:"METAMASK_STREAM_FAILURE"}}},window.location.origin)})),$=U.createStream(L),o()(K,$,K,(e=>console.debug(`MetaMask: Muxed traffic for channel "${L}" failed.`,e))),B.onDisconnect.addListener(re)},re=()=>{const e=E();B.onDisconnect.removeListener(re),K.removeAllListeners(),U.removeAllListeners(),U.destroy(),$.removeAllListeners(),$.destroy(),W=null,e&&(console.warn(`${e} Resetting the phishing streams.`),setTimeout(oe,1e3))},se=e=>{if(e.name===w)return W||oe(),Promise.resolve(`MetaMask: handled "${w}" for phishing streams`)},ie=()=>{!function(){const e=new r.WindowPostMessageStream({name:y,target:k});M&&ae(),Y=new(i()),Y.setMaxListeners(25),o()(Y,e,Y,(e=>_e("MetaMask Inpage Multiplex",e))),K=Y.createStream(L)}(),oe(),l().runtime.onMessage.addListener(se)};let ce=!1;const le=()=>{ce=!0,V=l().runtime.connect({name:y}),Q=new(m())(V),Q.on("data",ge),z=new(i()),z.setMaxListeners(25),z.ignoreStream(O),o()(z,Q,z,(e=>{_e("MetaMask Background Multiplex",e),he()})),F=z.createStream(P),o()(J,F,J,(e=>console.debug(`MetaMask: Muxed traffic for channel "${P}" failed.`,e))),q=z.createStream("phishing"),q.once("data",fe),V.onDisconnect.addListener(ue)},de=()=>{R=new(i()),R.setMaxListeners(25),G=(0,u.obj)(((e,t,n)=>{var a;(null==e?void 0:e.name)===P&&"metamask_accountsChanged"===(null===(a=e.data)||void 0===a?void 0:a.method)&&(e.data.method="wallet_accountsChanged",e.data.result=e.data.params,delete e.data.params),n(null,e)})),o()(R,Q,G,R,(e=>{_e("MetaMask Background Legacy Multiplex",e),he()})),N=R.createStream(P),o()(x,N,x,(e=>console.debug(`MetaMask: Muxed traffic between channels "provider" and "${P}" failed.`,e))),D=R.createStream(O),o()(j,D,j,(e=>console.debug('MetaMask: Muxed traffic for channel "publicConfig" failed.',e)))},me=e=>{if(e.name===w)return Q||(le(),de()),Promise.resolve(`MetaMask: handled ${w}`)},ue=()=>{const e=E();V.onDisconnect.removeListener(ue),J.removeAllListeners(),z.removeAllListeners(),z.destroy(),F.removeAllListeners(),F.destroy(),Q=null,x.removeAllListeners(),j.removeAllListeners(),R.removeAllListeners(),R.destroy(),N.removeAllListeners(),N.destroy(),D.removeAllListeners(),D.destroy(),e&&(console.warn(`${e} Resetting the streams.`),setTimeout(le,1e3))},pe=()=>{(()=>{const e=new r.WindowPostMessageStream({name:y,target:b});M&&e.on("data",(({data:{method:e}})=>{Z.includes(e)||ae()})),X=new(i()),X.setMaxListeners(25),o()(X,e,X,(e=>_e("MetaMask Inpage Multiplex",e))),J=X.createStream(P)})(),(()=>{const e=new r.WindowPostMessageStream({name:"contentscript",target:"inpage"});M&&e.on("data",(({data:{method:e}})=>{Z.includes(e)||ae()})),C=new(i()),C.setMaxListeners(25),o()(C,e,C,(e=>_e("MetaMask Legacy Inpage Multiplex",e))),x=C.createStream(I),j=C.createStream(O)})(),le(),de(),l().runtime.onMessage.addListener(me)};function _e(e,t){console.debug(`MetaMask: Content script lost connection to "${e}".`,t)}function ge(e){ce&&M&&"metamask_chainChanged"===e.data.method&&(ce=!1,window.postMessage({target:b,data:{name:P,data:{jsonrpc:"2.0",method:"METAMASK_EXTENSION_CONNECT_CAN_RETRY"}}},window.location.origin))}function he(){window.postMessage({target:b,data:{name:P,data:{jsonrpc:"2.0",method:"METAMASK_STREAM_FAILURE"}}},window.location.origin)}function fe(e={}){console.debug("MetaMask: Routing to Phishing Warning page.");const{hostname:t,href:n}=window.location,{newIssueUrl:a}=e,o=process.env.PHISHING_WARNING_PAGE_URL,r=new URLSearchParams({hostname:t,href:n,newIssueUrl:a});window.location.href=`${o}#${r}`}window.location.origin===H.origin&&window.location.pathname===H.pathname?ie():A()&&(M||function(e){try{const t=document.head||document.documentElement,n=document.createElement("script");n.setAttribute("async","false"),n.textContent=e,t.insertBefore(n,t.children[0]),t.removeChild(n)}catch(e){console.error("MetaMask: Provider injection failed.",e)}}(v),pe())},79314:()=>{},82414:()=>{},43094:()=>{},46601:()=>{},89214:()=>{},63032:()=>{},84711:()=>{},72783:()=>{},37281:()=>{},27790:()=>{},69386:()=>{},31616:()=>{},29120:()=>{},46586:()=>{},6297:()=>{},71156:()=>{},52361:()=>{},94616:()=>{},6567:()=>{},69862:()=>{},40964:()=>{},50522:()=>{},66882:()=>{}},n={};function a(e){var o=n[e];if(void 0!==o)return o.exports;var r=n[e]={id:e,loaded:!1,exports:{}};return t[e].call(r.exports,r,r.exports,a),r.loaded=!0,r.exports}a.m=t,e=[],a.O=(t,n,o,r)=>{if(!n){var s=1/0;for(d=0;d<e.length;d++){for(var[n,o,r]=e[d],i=!0,c=0;c<n.length;c++)(!1&r||s>=r)&&Object.keys(a.O).every((e=>a.O[e](n[c])))?n.splice(c--,1):(i=!1,r<s&&(s=r));if(i){e.splice(d--,1);var l=o();void 0!==l&&(t=l)}}return t}r=r||0;for(var d=e.length;d>0&&e[d-1][2]>r;d--)e[d]=e[d-1];e[d]=[n,o,r]},a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var n in t)a.o(t,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e={153:0};a.O.j=t=>0===e[t];var t=(t,n)=>{var o,r,[s,i,c]=n,l=0;if(s.some((t=>0!==e[t]))){for(o in i)a.o(i,o)&&(a.m[o]=i[o]);if(c)var d=c(a)}for(t&&t(n);l<s.length;l++)r=s[l],a.o(e,r)&&e[r]&&e[r][0](),e[r]=0;return a.O(d)},n=self.webpackChunkmetamask_crx=self.webpackChunkmetamask_crx||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})();var o=a.O(void 0,[722,633,257],(()=>a(90095)));o=a.O(o)})();

Check failure

Code scanning / CodeQL

Incomplete regular expression for hostnames

This string, which is used as a regular expression [here](1), has an unescaped '.' before 'gamer.com', so it might match more hosts than expected.
@brad-decker
Copy link
Contributor

distro folder removed cause I added static asset copying to the config. I also added what I think to be a drop in replacement for the code fencing transform, using a webpack plugin, but its configured naively right now. I need to get manifest copying/transpiling in place and start seeing what shakes loose when I attempt to add it to chrome. 😅

@@ -1,80 +1,80 @@
@use "sass:map";

$fa-font-path: 'fonts/fontawesome';
$fa-font-path: '~@fortawesome/fontawesome-free/webfonts';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the idea here - is there some loader or plugin which will make this work? (reverting just this part seems to make it pass)

legobeat added a commit to legobeat/metamask-extension that referenced this pull request Mar 7, 2023
I am not sure what the intention and direction is here. Getting the
following error without reverting:

```
$ yarn build dist
Running task "dist"...
Starting 'dist'...
Starting 'clean'...
Finished 'clean'
Starting 'styles:prod'...
LavaMoat: ignoring write attempt to read-access global "process"
LavaMoat: ignoring write attempt to read-access global "__dirname"
LavaMoat: ignoring write attempt to read-access global "__filename"
LavaMoat: ignoring write attempt to read-access global "Buffer"
[Error: Missing error message
  at new PluginError (/app/node_modules/plugin-error/index.js:64:11)
  at errorM (/app/node_modules/gulp-dart-sass/index.js:123:15)
  at callback (/app/node_modules/gulp-dart-sass/index.js:132:16)
  at eval (/app/node_modules/sass/sass.dart.js:22:46)
  at Function.call$2 (/app/node_modules/sass/sass.dart.js:93648:16)
  at _render_closure1.call$2 (/app/node_modules/sass/sass.dart.js:82008:12)
  at _RootZone.runBinary$3$3 (/app/node_modules/sass/sass.dart.js:27548:18)
  at _FutureListener.handleError$1 (/app/node_modules/sass/sass.dart.js:26097:19)
  at _Future__propagateToListeners_handleError.call$0 (/app/node_modules/sass/sass.dart.js:26395:49)
  at Object._Future__propagateToListeners (/app/node_modules/sass/sass.dart.js:4548:77)] {
  dartException: <ref *1> {
    '$cachedTrace': _StackTrace {
      _exception: [Circular *1],
      _trace: 'Error: Missing error message\n' +
        '  at new PluginError (/app/node_modules/plugin-error/index.js:64:11)\n' +
        '  at errorM (/app/node_modules/gulp-dart-sass/index.js:123:15)\n' +
        '  at callback (/app/node_modules/gulp-dart-sass/index.js:132:16)\n' +
        '  at eval (/app/node_modules/sass/sass.dart.js:22:46)\n' +
        '  at Function.call$2 (/app/node_modules/sass/sass.dart.js:93648:16)\n' +
        '  at _render_closure1.call$2 (/app/node_modules/sass/sass.dart.js:82008:12)\n' +
        '  at _RootZone.runBinary$3$3 (/app/node_modules/sass/sass.dart.js:27548:18)\n' +
        '  at _FutureListener.handleError$1 (/app/node_modules/sass/sass.dart.js:26097:19)\n' +
        '  at _Future__propagateToListeners_handleError.call$0 (/app/node_modules/sass/sass.dart.js:26395:49)\n' +
        '  at Object._Future__propagateToListeners (/app/node_modules/sass/sass.dart.js:4548:77)'
    }
  }
}
```

MetaMask#17872 (review)
@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

legobeat added a commit to legobeat/metamask-extension that referenced this pull request Apr 4, 2023
I am not sure what the intention and direction is here. Getting the
following error without reverting:

```
$ yarn build dist
Running task "dist"...
Starting 'dist'...
Starting 'clean'...
Finished 'clean'
Starting 'styles:prod'...
LavaMoat: ignoring write attempt to read-access global "process"
LavaMoat: ignoring write attempt to read-access global "__dirname"
LavaMoat: ignoring write attempt to read-access global "__filename"
LavaMoat: ignoring write attempt to read-access global "Buffer"
[Error: Missing error message
  at new PluginError (/app/node_modules/plugin-error/index.js:64:11)
  at errorM (/app/node_modules/gulp-dart-sass/index.js:123:15)
  at callback (/app/node_modules/gulp-dart-sass/index.js:132:16)
  at eval (/app/node_modules/sass/sass.dart.js:22:46)
  at Function.call$2 (/app/node_modules/sass/sass.dart.js:93648:16)
  at _render_closure1.call$2 (/app/node_modules/sass/sass.dart.js:82008:12)
  at _RootZone.runBinary$3$3 (/app/node_modules/sass/sass.dart.js:27548:18)
  at _FutureListener.handleError$1 (/app/node_modules/sass/sass.dart.js:26097:19)
  at _Future__propagateToListeners_handleError.call$0 (/app/node_modules/sass/sass.dart.js:26395:49)
  at Object._Future__propagateToListeners (/app/node_modules/sass/sass.dart.js:4548:77)] {
  dartException: <ref *1> {
    '$cachedTrace': _StackTrace {
      _exception: [Circular *1],
      _trace: 'Error: Missing error message\n' +
        '  at new PluginError (/app/node_modules/plugin-error/index.js:64:11)\n' +
        '  at errorM (/app/node_modules/gulp-dart-sass/index.js:123:15)\n' +
        '  at callback (/app/node_modules/gulp-dart-sass/index.js:132:16)\n' +
        '  at eval (/app/node_modules/sass/sass.dart.js:22:46)\n' +
        '  at Function.call$2 (/app/node_modules/sass/sass.dart.js:93648:16)\n' +
        '  at _render_closure1.call$2 (/app/node_modules/sass/sass.dart.js:82008:12)\n' +
        '  at _RootZone.runBinary$3$3 (/app/node_modules/sass/sass.dart.js:27548:18)\n' +
        '  at _FutureListener.handleError$1 (/app/node_modules/sass/sass.dart.js:26097:19)\n' +
        '  at _Future__propagateToListeners_handleError.call$0 (/app/node_modules/sass/sass.dart.js:26395:49)\n' +
        '  at Object._Future__propagateToListeners (/app/node_modules/sass/sass.dart.js:4548:77)'
    }
  }
}
```

MetaMask#17872 (review)
@@ -9,7 +9,7 @@ import NetworkDisplay from '../network-display';

///: BEGIN:ONLY_INCLUDE_IN(beta)
import BetaHeader from '../beta-header';
///: END:ONLY_INCLUDE_IN(beta)
///: END:ONLY_INCLUDE_IN
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why were these changes made?

Copy link
Contributor

@legobeat legobeat Apr 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The webpack-remove-code-blocks approach of this branch doesn't actually work properly.

This should do this right thing: legobeat@8443806#diff-ec2cabc8139e814d33682814c1ba15a1056d946ab70f740c9d42ada07af42050R116

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was attempting to remove the custom code fencing transform alltogether, but as legobeat pointed out its probable that my changes were not fully effective.

@kumavis
Copy link
Member Author

kumavis commented May 1, 2023

These were the build outputs I got. I think both are minified and equivalent.
Fairly large reduction in size!
15M -> 11M (-25%)
I assume mostly from tree shaking.
One larger reason for moving to webpack is easy lazy loading, but I haven't tried adding that to the mix

➜ du -cb distro/**/*.js
2770380	distro/218.js
3974393	distro/373.js
224922	distro/44.js
208263	distro/497.js
16052	distro/623.js
2386444	distro/711.js
299304	distro/background.js
7832	distro/contentscript.js
84	distro/disable-console.js
166	distro/init-globals.js
1342770	distro/ui.js
292	distro/vendor/trezor/content-script.js
738	distro/vendor/trezor/usb-permissions.js
11231640	total
➜ du -cb dist/chrome/**/*.js
588380	dist/chrome/background-0.js
785411	dist/chrome/background-1.js
975002	dist/chrome/background-2.js
398567	dist/chrome/background-3.js
120052	dist/chrome/background-4.js
42	dist/chrome/chromereload.js
817154	dist/chrome/common-0.js
794499	dist/chrome/common-1.js
1024074	dist/chrome/common-2.js
409649	dist/chrome/common-3.js
536324	dist/chrome/common-4.js
155424	dist/chrome/common-5.js
492	dist/chrome/content-script-0.js
465597	dist/chrome/contentscript.js
2311	dist/chrome/disable-console.js
9017	dist/chrome/globalthis.js
513	dist/chrome/init-globals.js
221137	dist/chrome/inpage.js
40073	dist/chrome/lockdown-install.js
4069	dist/chrome/lockdown-more.js
751	dist/chrome/lockdown-run.js
85443	dist/chrome/policy-load.js
6504	dist/chrome/runtime-cjs.js
403316	dist/chrome/runtime-lavamoat.js
208236	dist/chrome/sentry-install.js
16782	dist/chrome/snow.js
705296	dist/chrome/ui-0.js
819727	dist/chrome/ui-10.js
34484	dist/chrome/ui-11.js
940269	dist/chrome/ui-1.js
666198	dist/chrome/ui-2.js
525753	dist/chrome/ui-3.js
1115515	dist/chrome/ui-4.js
481567	dist/chrome/ui-5.js
412797	dist/chrome/ui-6.js
418410	dist/chrome/ui-7.js
510777	dist/chrome/ui-8.js
326942	dist/chrome/ui-9.js
254	dist/chrome/use-snow.js
496	dist/chrome/vendor/trezor/content-script.js
1526	dist/chrome/vendor/trezor/usb-permissions.js
15028830	total

@github-actions
Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity in the last 60 days. It will be closed in 14 days. Thank you for your contributions.

@github-actions github-actions bot added the stale issues and PRs marked as stale label Jul 20, 2023
@mcmire
Copy link
Contributor

mcmire commented Jul 24, 2023

I am excited that this is being worked on! Adding a comment to prevent this from being closed automatically.

@github-actions github-actions bot removed the stale issues and PRs marked as stale label Jul 24, 2023
@github-actions
Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity in the last 60 days. It will be closed in 14 days. Thank you for your contributions.

@github-actions github-actions bot added the stale issues and PRs marked as stale label Sep 22, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2023

This PR was closed because there has been no follow up activity in the last 14 days. Thank you for your contributions.

@github-actions github-actions bot closed this Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale issues and PRs marked as stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants