Documentation
¶
Overview ¶
Package nativeapps prepares a private native graphical stack without changing system packages. Callers own user consent, authorization, and application launch.
Index ¶
- Constants
- Variables
- func PrepareInputClient(source, destination string) error
- func SelfTest(parent context.Context, root string) (result error)
- func SystemClientInputPython(ctx context.Context, xpra string, environment []string) (string, error)
- func WriteApplicationLauncher(directory string) (string, error)
- func WriteBundle(ctx context.Context, pkg Package, cacheRoot string, output io.Writer, ...) error
- func WriteBundleWithOptions(ctx context.Context, pkg Package, cacheRoot string, output io.Writer, ...) error
- func WriteTransferBundle(ctx context.Context, pkg Package, plan TransferPlan, cacheRoot string, ...) error
- func WriteTransferBundleWithOptions(ctx context.Context, pkg Package, plan TransferPlan, cacheRoot string, ...) error
- func XpraApplicationLifetimeArgs() []string
- func XpraNoAudioArgs() []string
- type ApplicationLaunchPlan
- type ApplicationPackage
- type ApplicationPlanDescription
- type ApplicationPlanOptions
- type Artifact
- type BackendCapability
- type BundleOptions
- type BundleProgress
- type ClientAssets
- type ClientInput
- type ClientInputCapability
- type Installation
- type LaunchUnavailable
- type Manager
- func (m *Manager) Cancel(owner, id string) (Status, error)
- func (m *Manager) Close()
- func (m *Manager) CompleteUpload(owner, id string) (Status, error)
- func (m *Manager) Directory() (string, error)
- func (m *Manager) DirectoryFor(digest string) (string, error)
- func (m *Manager) InstallationForProcess(process ProcessIdentity) (*Installation, error)
- func (m *Manager) Package() Package
- func (m *Manager) Plan(ctx context.Context) (TransferPlan, error)
- func (m *Manager) Snapshot(owner string) Status
- func (m *Manager) Start(owner, requestID, source string, uploadSize int64) (Status, error)
- func (m *Manager) Watch() (<-chan struct{}, func())
- func (m *Manager) WriteChunk(owner, id string, offset int64, data []byte) (Status, error)
- type Package
- type ProcessIdentity
- type Status
- type Tools
- type TransferPlan
Examples ¶
Constants ¶
const ClientInputTextLimit = 16000
ClientInputTextLimit bounds one atomic text commit in UTF-8 bytes. Applications must report rejected commits; truncation and automatic retry are forbidden.
const ClientInputVersion = 1
ClientInputVersion is the confirmed-text protocol advertised on Xpra's authenticated connection. Consumers must reject sessions without this version.
Variables ¶
var ErrBusy = errors.New("native preparation is already running")
var ErrForbidden = errors.New("native preparation belongs to another caller")
var ErrInvalid = errors.New("invalid native preparation request")
var ErrUnsupported = errors.New("native graphical components are unavailable for this platform")
Functions ¶
func PrepareInputClient ¶ added in v0.5.0
PrepareInputClient prepares an Xpra HTML5 v20/v21 distribution with exactly one external keyboard owner and one external pointer owner. It retains the graphics, clipboard and pointer transport. The destination must not exist. Neither a failed preparation nor an unsupported source is usable as a client. Consumers serve this directory through the same authenticated Xpra endpoint.
func SelfTest ¶
SelfTest creates only its own virtual display and transient GTK fixture. A successful check proves actual window discovery, rendered pixels, and input; importing a module or starting a process alone is not readiness evidence.
func SystemClientInputPython ¶ added in v0.5.0
func SystemClientInputPython(ctx context.Context, xpra string, environment []string) (string, error)
SystemClientInputPython resolves the interpreter selected by an installed Xpra script, then probes that exact interpreter. It never substitutes the host's unrelated desktop Python or installs missing system dependencies.
func WriteApplicationLauncher ¶ added in v0.3.0
WriteApplicationLauncher installs the Linux GIO launcher in a consumer-owned private directory. Invoke it with the tools' Python, an absolute .desktop file and an absolute receipt path. The atomic receipt reports running, exited or failed. A running receipt confirms process launch, not window/pixel readiness. Spawn failures include phase and a stable error_code. Final receipts include the actual direct-launcher exit_code (negative for a signal), per-launcher statuses and termination_requested. These are process observations; the graphical backend determines whether launch or established execution ended. The supervisor retains a nonzero launcher result after reaping descendants. The launcher restores the host application environment and reaps descendants; closing a window or losing a viewer never terminates the application. A verified Snap plan additionally requires FLOE_NATIVE_HOST_BUS to identify the real user bus, separate from DBUS_SESSION_BUS_ADDRESS. Only the supervisor receives that handoff; it is removed from the final application's environment. The supervisor exposes only its admitted direct launcher's scope operation.
func WriteBundle ¶
func WriteBundle(ctx context.Context, pkg Package, cacheRoot string, output io.Writer, progress func(int64)) error
WriteBundle acquires the exact catalog archives for an offline host. It neither extracts nor executes them; the destination host verifies every original byte. Callers must publish the output only after this function returns successfully.
func WriteBundleWithOptions ¶ added in v0.9.0
func WriteBundleWithOptions(ctx context.Context, pkg Package, cacheRoot string, output io.Writer, options BundleOptions) error
WriteBundleWithOptions keeps the cache lease through the final ZIP read and applies optional maintenance afterwards, including on cancellation or failure.
func WriteTransferBundle ¶ added in v0.4.0
func WriteTransferBundle(ctx context.Context, pkg Package, plan TransferPlan, cacheRoot string, output io.Writer, progress func(int64)) error
WriteTransferBundle accepts only a subset of the supplied trusted recipe. Consumer adapters must resolve pkg from their compiled catalog, not a client. An empty plan needs no bundle: use Manager.Start with source "cache" instead.
func WriteTransferBundleWithOptions ¶ added in v0.9.0
func WriteTransferBundleWithOptions(ctx context.Context, pkg Package, plan TransferPlan, cacheRoot string, output io.Writer, options BundleOptions) error
WriteTransferBundleWithOptions validates receiver identities before any cache access, then uses the same leased acquisition path as a complete bundle.
func XpraApplicationLifetimeArgs ¶ added in v0.3.0
func XpraApplicationLifetimeArgs() []string
XpraApplicationLifetimeArgs binds an Xpra server to a monitored application child, independently of its viewers and windows. Use a --start-child command that remains alive until the application and its descendants have exited. Consumers still own application authorization, persistence and session policy.
func XpraNoAudioArgs ¶ added in v0.2.1
func XpraNoAudioArgs() []string
XpraNoAudioArgs disables audio support for a silent Xpra 6.x graphics session. Muting the speaker and microphone with "off" still initializes audio codecs; a missing audio backend can then delay every server inventory request. Session ownership, transport, and all other feature choices remain with the host.
Types ¶
type ApplicationLaunchPlan ¶ added in v0.11.0
type ApplicationLaunchPlan struct {
// contains filtered or unexported fields
}
ApplicationLaunchPlan is an immutable, short-lived snapshot. It is not an authorization token, a persistent application record, or a backend fallback. Package updates require a fresh plan before executing the application.
func PlanApplication ¶ added in v0.11.0
func PlanApplication(ctx context.Context, options ApplicationPlanOptions) (ApplicationLaunchPlan, error)
PlanApplication observes the desktop entry and installed package metadata without starting an application. Unknown protocol metadata selects the combined Wayland/Xwayland backend; its absence is explicit, never an Xpra retry.
func (ApplicationLaunchPlan) Description ¶ added in v0.11.0
func (p ApplicationLaunchPlan) Description() ApplicationPlanDescription
func (ApplicationLaunchPlan) Revalidate ¶ added in v0.11.0
func (p ApplicationLaunchPlan) Revalidate(ctx context.Context, options ApplicationPlanOptions) error
Revalidate rereads the same desktop entry, executable and package revision. The supervisor must also revalidate at its execution boundary. Calling this method alone cannot authorize a later unchecked launch.
func (ApplicationLaunchPlan) Write ¶ added in v0.11.0
func (p ApplicationLaunchPlan) Write(directory string) (string, error)
Write places this plan in the new application's private directory. Invoke the installed application launcher as --plan PATH RECEIPT. It revalidates before GIO creates a child; graphical resources must already match Backend.Component. Do not overwrite a running instance's plan or change its backend identity.
type ApplicationPackage ¶ added in v0.11.0
type ApplicationPackage struct {
Kind string `json:"kind"`
ID string `json:"id"`
Revision string `json:"revision"`
Version string `json:"version,omitempty"`
Confinement string `json:"confinement,omitempty"`
Application string `json:"application,omitempty"`
SecurityTag string `json:"security_tag,omitempty"`
Ref string `json:"ref,omitempty"`
Deployment string `json:"deployment,omitempty"`
Format int `json:"format,omitempty"`
}
type ApplicationPlanDescription ¶ added in v0.11.0
type ApplicationPlanDescription struct {
Version int `json:"version"`
SHA256 string `json:"sha256"`
Backend BackendCapability `json:"backend"`
Package ApplicationPackage `json:"package"`
Services []string `json:"services"`
Desktop string `json:"desktop"`
DesktopSHA256 string `json:"desktop_sha256"`
}
ApplicationPlanDescription describes identity and required resources without granting readiness or input permission. Each call returns independent values.
type ApplicationPlanOptions ¶ added in v0.11.0
type ApplicationPlanOptions struct {
Python string
Environment []string
DesktopFile string
Backends []BackendCapability
}
ApplicationPlanOptions contains the already authorized host desktop entry. Python must provide GIO. Environment is the original host environment, or a Tools.Environment result whose saved overrides the planner restores.
type BackendCapability ¶ added in v0.11.0
type BackendCapability struct {
ID string `json:"id"`
Component string `json:"component"`
Protocols []string `json:"protocols"`
Services []string `json:"services,omitempty"`
}
BackendCapability describes one prepared backend. The trusted host obtains these values from its installed backend, never from a browser request. A capability describes available resources, not application readiness.
type BundleOptions ¶ added in v0.9.0
type BundleOptions struct {
CachePolicy artifactcache.Policy
OnProgress func(BundleProgress) error
OnMaintenance func(artifactcache.Maintenance, error)
// Client is a trusted network policy/test hook, never a renderer input.
Client *http.Client
}
type BundleProgress ¶ added in v0.9.0
type BundleProgress struct {
Phase string `json:"phase"`
ComponentBytes int64 `json:"component_bytes"`
CachedBytes *int64 `json:"cached_bytes,omitempty"`
DownloadBytes *int64 `json:"download_bytes,omitempty"`
DownloadedBytes int64 `json:"downloaded_bytes"`
}
BundleProgress distinguishes verified cache bytes from actual network bytes. Totals remain absent until every requested archive has been checked.
type ClientAssets ¶ added in v0.6.0
type ClientAssets struct {
// contains filtered or unexported fields
}
ClientAssets is an immutable snapshot of public resources from a directory produced by PrepareInputClient. It excludes HTML, configuration and session files. Hosts own authorization, route placement and snapshot lifetime.
func OpenClientAssets ¶ added in v0.6.0
func OpenClientAssets(directory string) (*ClientAssets, error)
OpenClientAssets snapshots and precompresses a prepared Xpra HTML5 v20/v21 client. Worker URLs follow the script's resource directory, independently of the session document URL. The source and installed vendor files are unchanged. The digest covers the exact prepared resource names and bytes, including the input adapter and worker transformation, rather than only the native recipe.
func (*ClientAssets) Digest ¶ added in v0.6.0
func (a *ClientAssets) Digest() string
Digest is the content version to include in the host's resource route.
func (*ClientAssets) RewriteHTML ¶ added in v0.6.0
func (a *ClientAssets) RewriteHTML(document []byte, basePath string) ([]byte, error)
RewriteHTML relocates only references to resources in this snapshot. basePath must be an absolute same-origin directory path containing the content version. It leaves WebSocket addresses, session settings and inline startup code alone. The resulting session document must remain authenticated and uncached.
func (*ClientAssets) ServeHTTP ¶ added in v0.6.0
func (a *ClientAssets) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP serves a resource path (for example /js/Client.js). The host must first select this snapshot by its exact digest and strip the versioned prefix. Authorization belongs before this handler. Cached scripts never authorize a connection: hosts must continue authenticating session documents and traffic.
type ClientInput ¶ added in v0.5.0
type ClientInput struct {
Launcher, GTKModules, QtPlugins string
// GTKPath is a private module root. Only GTK4 scans its 4.0.0 ABI directory;
// GTK3 uses GTKModules and must never load the GTK4 shared object.
GTKPath string
}
ClientInput is prepared support for one private X11 application session. Launch Launcher with the probed Xpra Python interpreter, normal Xpra arguments and XpraArgs. Start a private session bus first and pass its address explicitly to the application's start environment. These paths contain first-party adapters, never a copied host toolkit or a second input method engine.
func PrepareClientInput ¶ added in v0.5.0
func PrepareClientInput(directory, architecture string) (ClientInput, error)
PrepareClientInput installs the complete input contract into a new absolute private directory. The architecture is the application host's Go architecture.
func (ClientInput) XpraArgs ¶ added in v0.5.0
func (input ClientInput) XpraArgs(baseEnvironment []string) []string
XpraArgs selects client-owned composition in the private application environment. No host desktop input configuration is inherited or modified.
type ClientInputCapability ¶ added in v0.5.0
type ClientInputCapability struct {
Version int `json:"version"`
XpraVersion string `json:"xpra_version"`
}
func ProbeClientInput ¶ added in v0.5.0
func ProbeClientInput(ctx context.Context, python string, environment []string) (ClientInputCapability, error)
ProbeClientInput checks the interpreter and original XIM library before any application is launched. It does not acquire components or require a display. A successful probe does not assert that a particular application has a focused editable input context; that boundary is checked for every submitted commit.
type Installation ¶ added in v0.4.0
type Installation struct {
ID string `json:"id"`
Digest string `json:"digest"`
Architecture string `json:"architecture"`
Contract string `json:"contract"`
Ready bool `json:"ready"`
}
Installation identifies an installed recipe independently of the SDK release. Ready is a lightweight check of its private marker and required tool layout.
type LaunchUnavailable ¶ added in v0.11.0
type LaunchUnavailable struct {
}
LaunchUnavailable is safe for production diagnostics. It contains no child output, input text, environment values, or desktop file contents.
func (*LaunchUnavailable) Error ¶ added in v0.11.0
func (e *LaunchUnavailable) Error() string
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func New ¶
New requires a private state root. Creating a manager never downloads or starts native processes. The optional validator is useful for host-owned qualification; production callers use the built-in graphical self-check by passing nil.
Example ¶
This example compiles in source checks but performs no network operations in tests. A service should retain its manager for the service's entire lifetime.
package main
import (
"context"
"fmt"
"log"
"os"
"path/filepath"
"time"
nativeapps "github.com/floegence/floe-native-apps"
)
func main() {
prepare := func(ctx context.Context, stateRoot, owner, requestID string) (nativeapps.Tools, error) {
pkg, err := nativeapps.NativePackage()
if err != nil {
return nativeapps.Tools{}, err
}
manager, err := nativeapps.New(stateRoot, pkg, nil)
if err != nil {
return nativeapps.Tools{}, err
}
defer manager.Close()
changes, stop := manager.Watch()
defer stop()
if _, err := manager.Start(owner, requestID, "download", 0); err != nil {
return nativeapps.Tools{}, err
}
for {
status := manager.Snapshot(owner)
if status.State == "ready" {
root, err := manager.Directory()
if err != nil {
return nativeapps.Tools{}, err
}
return nativeapps.ResolveTools(root)
}
if !status.Active() {
return nativeapps.Tools{}, fmt.Errorf("preparation %s: %s", status.State, status.ErrorCode)
}
select {
case <-ctx.Done():
return nativeapps.Tools{}, ctx.Err()
case <-changes:
}
}
}
cache, err := os.UserCacheDir()
if err != nil {
log.Fatal(err)
}
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Minute)
defer cancel()
// A real product supplies an authenticated owner and a stable request ID.
tools, err := prepare(ctx, filepath.Join(cache, "floe-native-apps"), "local-user", "prepare-1")
if err != nil {
log.Fatal(err)
}
fmt.Println(tools.Xpra)
}
Output:
func (*Manager) DirectoryFor ¶ added in v0.4.0
DirectoryFor resolves an exact supported installation for a surviving process. It never changes the current installation or prepares another version.
func (*Manager) InstallationForProcess ¶ added in v0.4.0
func (m *Manager) InstallationForProcess(process ProcessIdentity) (*Installation, error)
InstallationForProcess identifies a legacy backend's private loader using kernel evidence. Nil means a system installation outside this manager's root. The caller still owns application authorization and backend identity checks.
func (*Manager) Plan ¶ added in v0.4.0
func (m *Manager) Plan(ctx context.Context) (TransferPlan, error)
Plan verifies archives only on explicit preparation/inspection, never on the normal application-open or status path. It performs no network requests.
type Package ¶
type Package struct {
ID string `json:"id"`
Architecture string `json:"architecture"`
SizeBytes int64 `json:"size_bytes"`
InstalledBytes int64 `json:"installed_bytes"`
Artifacts []Artifact `json:"artifacts"`
}
func ForPlatform ¶
func NativePackage ¶
type ProcessIdentity ¶ added in v0.3.0
type ProcessIdentity struct {
PID int `json:"pid"`
Boot string `json:"boot"`
Started string `json:"started"`
}
ProcessIdentity is an observation of one Linux process generation. Persisting it allows a host to distinguish a surviving native backend from a reused PID after restart. It grants no authorization and must never be used alone to select an application or issue a signal.
func ObserveProcess ¶ added in v0.3.0
func ObserveProcess(pid int) (ProcessIdentity, error)
ObserveProcess reads the kernel's boot and start identity for a live process.
func (ProcessIdentity) Alive ¶ added in v0.3.0
func (p ProcessIdentity) Alive() bool
type Status ¶
type Status struct {
State string `json:"state"`
OperationID string `json:"operation_id,omitempty"`
ReceivedBytes int64 `json:"received_bytes"`
ExpectedBytes int64 `json:"expected_bytes"`
ErrorCode string `json:"error_code,omitempty"`
CanCancel bool `json:"can_cancel"`
Installed *Installation `json:"installed,omitempty"`
UpdateAvailable bool `json:"update_available"`
InstallationErrorCode string `json:"installation_error_code,omitempty"`
}
type Tools ¶
type Tools struct{ Root, Xpra, Python, Xvfb, Xauth, DBus, HTML string }
func ResolveTools ¶
func (Tools) Environment ¶
Environment scopes support-tool overrides. The GIO launcher must restore this small saved map on its AppLaunchContext before starting the user's program. Display and D-Bus addresses are deliberately not restored: those belong to the caller's private graphical session.
type TransferPlan ¶ added in v0.4.0
type TransferPlan struct {
PackageDigest string `json:"package_digest"`
Architecture string `json:"architecture"`
MissingArtifacts []string `json:"missing_artifacts"`
MissingBytes int64 `json:"missing_bytes"`
}
TransferPlan contains only identities from the receiver's trusted catalog. It is a cache observation, not an authorization or a reservation of cache files.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package artifactcache acquires pinned publisher archives into a private, content-addressed cache.
|
Package artifactcache acquires pinned publisher archives into a private, content-addressed cache. |
|
cmd
|
|
|
floe-native-apps
command
floe-native-apps is an explicit qualification and offline acquisition tool.
|
floe-native-apps is an explicit qualification and offline acquisition tool. |