Technical implementation of window.ethereum?

I am trying to understand the implementation of the Ethereum provider API provided by MetaMask. I understand that MetaMask injects an object into the global window, and all requests made using that “window.ethereum” object are passed through MetaMask’s extension and processed according to what that specific request. I am confused as to how that’s exactly implemented. A more specific question: When I enter the command “window.ethereum.enable()”, how is that communicated to the extension?

Willing to send over 0.015 ETH or equivalent BTC if anyone could explain the technical implementation of the this provider API. Thank you!