Urbit Context Resolver (urbit/context.ts)

ScienceClaw · extensions/tlon/src/urbit/context.ts · typescript · MIT
integration, infra, security, auth, tag:urbit

Utility functions to normalize Urbit ship names and hostnames. Use this when building integrations that require secure communication with Urbit nodes.

// Source: https://github.com/beita6969/ScienceClaw | License: MIT | Copyright 2025 Peter Steinberger
// Provided via justclaw.it.com; keep this notice with the code.
import type { SsrFPolicy } from "openclaw/plugin-sdk/tlon";
import { validateUrbitBaseUrl } from "./base-url.js";
import { UrbitUrlError } from "./errors.js";

export type UrbitContext = {
  baseUrl: string;
  hostname: string;
  ship: string;
};

export function resolveShipFromHostname(hostname: string): string {
  const trimmed = hostname.trim().toLowerCase().replace(/\.$/, "");
  if (!trimmed) {
    return "";
  }
  if (trimmed.includes(".")) {
    return trimmed.split(".")[0] ?? trimmed;
  }
  return trimmed;
}

export function normalizeUrbitShip(ship: string | undefined, hostname: string): string {
  const raw = ship?.re

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key