@fntio/infra-client
Version:
Self-hosted AWS access portal: credential vending, target-account trust, and grant-driven private networking as CDK stacks and constructs.
56 lines (55 loc) • 2.86 kB
TypeScript
/** Synth-time site validation. A site routes by IP alone, so CIDR overlap
* WITHIN a site is silently ambiguous; overlap ACROSS sites is the point. */
import { ConnectorVpcConfig, DevSharesConfig, SiteConfig } from "./project-config";
/** Deployment-ready `network.devShares` (defaults filled). */
export interface ResolvedDevShares {
readonly enabled: boolean;
readonly maxDurationHours: number;
readonly allowGroupTargets: boolean;
readonly maxActiveSharesPerOwner: number;
}
/** A bad cap must fail synth — the API clamps silently, which would hide the typo until a user hit it. */
export declare function resolveDevShares(cfg?: DevSharesConfig): ResolvedDevShares | undefined;
export interface TailnetRangeOwner {
/** Where the ranges come from, for the error message. */
readonly label: string;
readonly cidrs: readonly string[];
}
/** One connector VPC as the deploy sees it — config's single-object form
* normalized to a list per account, entries as written. */
export type ResolvedConnectorVpc = ConnectorVpcConfig;
/** Deployment-ready view of one configured site. */
export interface ResolvedSite {
readonly id: string;
/** Human-facing name (config displayName; falls back to the id). */
readonly displayName: string;
/** `<id>.<subdomain>.<zoneName>` — the login hostname devices enroll to. */
readonly fqdn: string;
readonly controlUrl: string;
/** ALB rule priority: a STABLE hash of the id, never positional —
* renumbering deployed rules fails with PriorityInUse. */
readonly priority: number;
readonly accounts: readonly string[];
readonly connectorAccounts: readonly string[];
readonly splitDns: Record<string, readonly string[]>;
readonly connectorVpcs: Record<string, readonly ResolvedConnectorVpc[]>;
}
/** FNV-1a of the id folded into 100–989 — depends on nothing but the id, so
* a site keeps its priority for life. */
export declare function sitePriority(id: string): number;
/** Throws when ranges from DIFFERENT owners overlap; one owner's may nest
* (same connector — not ambiguous). Callers scope this to ONE site. */
export declare function assertDisjointTailnetRanges(owners: readonly TailnetRangeOwner[]): void;
/** ≤15 chars: the longest derived Lambda name (per-site minter with a
* 20-char site id) must fit AWS's 64-char limit. */
export declare function assertValidResourcePrefix(prefix: string): void;
/** Validate `network.sites` → deployment-ready sites, sorted by id.
* `extraRangesByAccount` injects ranges CDK only knows elsewhere (testbed). */
export declare function resolveSites(network: {
readonly zoneName: string;
readonly subdomain: string;
readonly sites: Record<string, SiteConfig>;
}, extraRangesByAccount?: Record<string, {
label: string;
cidrs: string[];
}>): ResolvedSite[];