SealSkin

webclient

The web client of an application image, exported once per image and served by this node.

A session's page is the Selkies web client. Served by the container, it is code of the image running on whatever origin the browser reached it on, and on the web app's origin that code could act as the signed-in user. So the node takes the client out of the image instead, once per image digest, with a throwaway instance of the image that gives up web_client_path as a tar stream (BaseProvider.export_web_client), and serves it at /<session id>/ itself; the container answers its api/ alone. The export runs after every pull and, failing that, at the first launch of the image on this node.

Bundles live under <node_state_path>/web/<digest>/, one subdirectory per dashboard as the image keeps them; dashboard_dir picks the one a session's DASHBOARD names. prune removes the bundles of images no installed application runs any more.

attributelogger
= logging.getLogger(__name__)
attributeDEFAULT_DASHBOARD
= 'selkies-dashboard'
attributeMAX_BUNDLE_BYTES
= 256 * 1024 * 1024
attributeEXPORT_TIMEOUT
= 300
funcbundles_root() -> str

Return the directory the exported clients are kept under.

Returns

str
funcbundle_dir(digest) -> str

Return the directory of an image's exported client, by its digest.

paramdigeststr

Returns

str
funcdashboard_dir(bundle, env) -> str | None

Return the directory of the dashboard a session serves, inside a bundle.

parambundlestr

The image's bundle directory.

paramenvdict[str, Any] | None

The session's environment, whose DASHBOARD names the dashboard.

Returns

str | None

The directory holding index.html: the named dashboard, the default

func_unpack(data, target, top) -> None

Unpack an export into target, refusing anything that would land outside it.

paramdatabytes

The tar stream, gzipped or not.

paramtargetstr

The directory to fill.

paramtopstr

The name of the exported directory: entries under it, as a copy of the directory itself has them, lose that first component.

Returns

None
func_export(image, digest) -> str

Export an image's client into its bundle directory and return the directory.

paramimagestr
paramdigeststr

Returns

str
func_digest(image) -> str | None

Return the digest of the image sessions of image run now, pulling or pinning it when none is known.

paramimagestr

Returns

str | None
funcensure(image) -> str

Return the bundle directory of an image's client, exporting it when this node has none.

paramimagestr

The image reference an application runs.

Returns

str

The bundle directory.

funcexport_quietly(image) -> None

Export an image's client after a pull, logging a failure rather than raising it.

paramimagestr

Returns

None
funcprune(keep) -> None

Remove the bundles of every digest not in keep.

paramkeepset[str]

The digests of the images installed applications run, and of the sessions running.

Returns

None
funcdigests_in_use() -> set[str]

Return the digests of the installed applications' images and the running sessions' bundles.

Returns

set[str]
funcroot_for_session(app_image, env, required) -> str | None

Return the directory a new session's client is served from.

paramapp_imagestr

The image the session runs.

paramenvdict[str, Any]

The session's environment, for its DASHBOARD.

paramrequiredbool

Whether the session cannot be served without it: a web sign-in's session on the web app's origin.

Returns

str | None

The dashboard directory, or None when the client could not be