diff --git a/sites/cheerpx/src/content/docs/11-guides/Networking.md b/sites/cheerpx/src/content/docs/11-guides/Networking.md index caed7217..fc5dc25f 100644 --- a/sites/cheerpx/src/content/docs/11-guides/Networking.md +++ b/sites/cheerpx/src/content/docs/11-guides/Networking.md @@ -62,8 +62,8 @@ const cx = await CheerpX.Linux.create({ What is happening here? -- `controlUrl` is a string URL of the Tailscale control plane which verifies the user's identity. You only need to pass this option if you are [self-hosting Tailscale](/docs/guides/Networking#self-hosting-headscale). -- `authKey` is string with an auth key to register new users/devices that are pre-authenticated. You can create an auth key [here](https://login.tailscale.com/admin/settings/keys). +- [`controlUrl`](/docs/reference/CheerpX-Linux-create#controlurl) is a string URL of the Tailscale control plane which verifies the user's identity. You only need to pass this option if you are [self-hosting Tailscale](/docs/guides/Networking#self-hosting-headscale). +- [`authKey`](/docs/reference/CheerpX-Linux-create#authkey) is string with an auth key to register new users/devices that are pre-authenticated. You can create an auth key [here](https://login.tailscale.com/admin/settings/keys). - [`stateUpdateCb`](/docs/reference/CheerpX-Linux-create#stateupdatecb) is a callback function that receives the current state of the network. It is required for monitoring changes in the network status. - [`netmapUpdateCb`](/docs/reference/CheerpX-Linux-create#netmapupdatecb) is a callback function that receives updates about the network map. This callback is also necessary for receiving network mapping information. diff --git a/sites/cheerpx/src/content/docs/12-reference/00-CheerpX-Linux-create.md b/sites/cheerpx/src/content/docs/12-reference/00-CheerpX-Linux-create.md index 3e7d5a94..f763a98c 100644 --- a/sites/cheerpx/src/content/docs/12-reference/00-CheerpX-Linux-create.md +++ b/sites/cheerpx/src/content/docs/12-reference/00-CheerpX-Linux-create.md @@ -80,6 +80,59 @@ This option configures network settings, which allows CheerpX to communicate ove [Promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise +### `authKey` + +```ts +authKey?: string; +``` + +The `authKey` is an optional string used for authentication. It is usually taken from the URL, allowing the CheerpX Linux environment to be set up automatically without the user needing to enter it manually. + +**Example of usage:** + +```js +let authKey = undefined; +if (browser) { + let params = new URLSearchParams("?" + window.location.hash.substr(1)); + authKey = params.get("authKey") || undefined; +} +const networkInterface = { authKey }; +``` + +**Explanation** + +1. The `authKey` is taken from the URL, allowing the application to automatically use the authentication key provided by the browser. + +2. The `authKey` is added to the `networkInterface` object, ensuring the application can access the authentication data whenever needed in the CheerpX environment. + +### `controlUrl` + +```ts +controlUrl?: string; +``` + +The `controlUrl` is an optional string parameter representing a URL used to manage or monitor the connection. It is typically fetched from the URL parameters and can be utilized for dashboard or configuration purposes. + +**Example of usage:** + +```js +let controlUrl = undefined; +if (browser) { + let params = new URLSearchParams("?" + window.location.hash.substr(1)); + controlUrl = params.get("controlUrl") || undefined; +} +const dashboardUrl = controlUrl + ? null + : "https://login.tailscale.com/admin/machines"; +const networkInterface = { controlUrl }; +``` + +**Explanation** + +1. The `controlUrl` is taken from the URL and added to the `networkInterface` object, making it easy to connect to the appropriate control dashboard. + +2. If `controlUrl` isn’t provided, the app automatically uses a default URL (`dashboardUrl`) for monitoring or setup. + ### `loginUrlCb` ```ts