publicRemote

tcmts.cli.sync.publicRemote · #nuzou2oq · term · runs on the server

uses tcmts.cli.sync.HttpRemote, which uses node:zlib

A codebase someone else names (an announcement's source, a registry visitor's codebase), as a registry asks it: an http(s) URL alone (no remote's name, no directory), at a public address (publicUrl; https or http, any address on a local network), asked with no credentials.

import { publicUrl } from "#codebase/tcmts/atproto";
import { HttpRemote } from "#codebase/tcmts/cli/sync";
import { UsageError } from "#codebase/tcmts/cli/ui";

export async function publicRemote(spec: string, what: string): Promise<HttpRemote> {
  if (!/^https?:\/\//i.test(spec))
    throw new UsageError(`${what} must be an http(s) address: ${spec}`);
  // (http is allowed, as tcm serve may be: what arrives is checked by hash)
  const u = await publicUrl(spec.replace(/^http:/i, "https:"), what);
  if (u.search || u.hash) throw new UsageError(`${what} must be a server's address: ${spec}`);
  return new HttpRemote(spec);
}

uses

used by