import { i18n } from './i18n' import { sdk } from './sdk' import { CERTRELAY_PORT, EXPLORER_PORT, spacedRpcPort, SUBSPACES_PROVER_PORT, SUBSPACES_REGISTRY_PORT, SUBSPACES_UI_PORT, uiPort, } from './utils' export const setInterfaces = sdk.setupInterfaces(async ({ effects }) => { const uiMulti = sdk.MultiHost.of(effects, 'ui-multi') const uiMultiOrigin = await uiMulti.bindPort(uiPort, { protocol: 'http', }) const ui = sdk.createInterface(effects, { name: i18n('Space-CLI Web UI'), id: 'ui', description: i18n( 'Browser terminal that exposes space-cli inside the Spaces container.', ), type: 'ui', masked: false, schemeOverride: null, username: null, path: '', query: {}, }) const uiReceipt = await uiMultiOrigin.export([ui]) const explorerMulti = sdk.MultiHost.of(effects, 'explorer-multi') const explorerMultiOrigin = await explorerMulti.bindPort(EXPLORER_PORT, { protocol: 'http', }) const explorer = sdk.createInterface(effects, { name: i18n('Explorer Web UI'), id: 'explorer', description: i18n( 'SvelteKit explorer for the Spaces protocol. Reads from the embedded PostgreSQL populated by the indexer. Only useful while the embedded explorer is enabled.', ), type: 'ui', masked: false, schemeOverride: null, username: null, path: '', query: {}, }) const explorerReceipt = await explorerMultiOrigin.export([explorer]) const subspacesMulti = sdk.MultiHost.of(effects, 'subspaces-multi') const subspacesMultiOrigin = await subspacesMulti.bindPort(SUBSPACES_UI_PORT, { protocol: 'http', }) const subspaces = sdk.createInterface(effects, { name: i18n('Subspaces Web UI'), id: 'subspaces', description: i18n( 'Off-chain Bitcoin handles via the Spaces protocol (spacesops/subs). Talks to the local spaced over loopback RPC. Only useful while Subspaces is enabled.', ), type: 'ui', masked: false, schemeOverride: null, username: null, path: '', query: {}, }) // The subs daemon ("subsd — HTTP REST API server for subs operations") serves // its REST API on the same port. Expose it as a distinct `api` interface, // separate from the prover (8888) and registry (8081) interfaces. const subsApi = sdk.createInterface(effects, { name: i18n('Subs API'), id: 'subs-api', description: i18n( 'REST API of the subs daemon (subsd) for Subspaces operations. Distinct from the Subspaces Prover and Subspaces Registry. Only useful while Subspaces is enabled.', ), type: 'api', masked: false, schemeOverride: null, username: null, path: '', query: {}, }) const subspacesReceipt = await subspacesMultiOrigin.export([ subspaces, subsApi, ]) const proverMulti = sdk.MultiHost.of(effects, 'subspaces-prover-multi') const proverMultiOrigin = await proverMulti.bindPort(SUBSPACES_PROVER_PORT, { protocol: 'http', }) const prover = sdk.createInterface(effects, { name: i18n('Subspaces Prover'), id: 'subspaces-prover', description: i18n( 'RISC Zero prover server for Subspaces (no GPU). Generates the cryptographic proofs the Subspaces UI requests. Only useful while Subspaces is enabled.', ), type: 'api', masked: false, schemeOverride: null, username: null, path: '', query: {}, }) const proverReceipt = await proverMultiOrigin.export([prover]) const registryMulti = sdk.MultiHost.of(effects, 'subspaces-registry-multi') const registryMultiOrigin = await registryMulti.bindPort( SUBSPACES_REGISTRY_PORT, { protocol: 'http' }, ) const registry = sdk.createInterface(effects, { name: i18n('Subspaces Registry'), id: 'subspaces-registry', description: i18n( 'Registry server for publishing and resolving Subspaces handles. Only useful while Subspaces is enabled.', ), type: 'api', masked: false, schemeOverride: null, username: null, path: '', query: {}, }) const registryReceipt = await registryMultiOrigin.export([registry]) const certrelayMulti = sdk.MultiHost.of(effects, 'certrelay-multi') const certrelayMultiOrigin = await certrelayMulti.bindPort(CERTRELAY_PORT, { protocol: 'http', }) const certrelay = sdk.createInterface(effects, { name: i18n('Certrelay'), id: 'certrelay', description: i18n( 'Certrelay serves cryptographic proofs binding Bitcoin-anchored handles to owner keys. SETUP NOTE: run the "Configure Certrelay" action and set CERTRELAY_SELF_URL to the publicly visible URL StartOS exposes for this interface (your clearnet domain or .onion address) — peers and clients reach this relay at that URL.', ), type: 'api', masked: false, schemeOverride: null, username: null, path: '', query: {}, }) const certrelayReceipt = await certrelayMultiOrigin.export([certrelay]) const spacedMulti = sdk.MultiHost.of(effects, 'spaced-api-multi') const spacedMultiOrigin = await spacedMulti.bindPort(spacedRpcPort, { protocol: 'http', }) const spacedApi = sdk.createInterface(effects, { name: i18n('Spaces API'), id: 'spaces-api', description: i18n( 'JSON-RPC API served by the spaced daemon. Authenticated with the spaced RPC credentials (SPACED_RPC_USER / SPACED_RPC_PASSWORD from store.spacedAuth). spaced binds 0.0.0.0 so external processes can reach this endpoint.', ), type: 'api', masked: false, schemeOverride: null, username: null, path: '', query: {}, }) const spacedApiReceipt = await spacedMultiOrigin.export([spacedApi]) return [ uiReceipt, explorerReceipt, subspacesReceipt, proverReceipt, registryReceipt, certrelayReceipt, spacedApiReceipt, ] })