ADR-38: Communication between Desktop unity and Kernel

More details about this document
Latest published version:
https://adr.decentraland.org/adr/ADR-38
Authors:
kuruk-mm
Feedback:
GitHub decentraland/adr (pull requests, new issue, open issues)
Edit this documentation:
GitHub View commits View commits on githistory.xyz

Context and Problem Statement

The desktop client will be executed outside of an internet navigator like Chrome or Firefox, and the explorer-website will not be used.

Currently, to log in into the world, you must enter through explorer-website (or derived), and the authentication happens with exchanges of messages between kernel and website.

On Desktop, website will not be used, and those exchanges will be with kernel and renderer. So explorer-desktop must implement a way to communicate those to be able to log in.

The problem is how to execute kernel without a navigator and communicate it with the renderer.

Considered options

Decision outcome

Launching kernel with Chromium headless is the most compatible with what currently explorer has. But executing kernel in NodeJS is inevitable because it will execute kernel unit tests and other cases. Taking advantage of this approach is the best option not to rewrite code and isolate it as much as possible.

Removing explorer-website from the Desktop Client Project is required. So the communication with kernel and renderer to authenticate will be implemented without other options.

Solution

To implement what it's described above the team decided the following flows:

Initialization of components

LKernelNodeJSDesktop rendererLKernelNodeJSDesktop rendereropen processSpawn NodeJS processLoad kernelInitialize WS ConnectionWS Connection detailsWS Connection

Guest login flow

RKernelRKernelStartAuthentication_Native {provider=null,isGuest=true}Load or create guest sessionAuthenticated

Wallet connect flow (NOT GUEST)

Syntax error in textmermaid version 11.6.0

Some pseudo code of how explorer-website and explorer-desktop will start:

// shell=explorer-website (browser)

import Renderer from "..."
import Kernel from "..."

const kernel = new Kernel({
  renderer: new Renderer()
})

await kernel.authenticate(provider, (isGuest = true))
// kernel emits a message to start the renderer
// shell=explorer-desktop (NodeJS)

import Renderer from "..."
import Kernel from "..."

const renderer = new WebSocket_Remote_Renderer("ws://localhost:8000")

const kernel = new Kernel({
  renderer
})

renderer.onAuthenticateMessage((message) => {
  await kernel.authenticate(message.provider, message.isGuest)
})

Participants

License

Copyright and related rights waived via CC0-1.0. DRAFT Living