UNPKG

@fntio/infra-client

Version:

Self-hosted AWS access portal: credential vending, target-account trust, and grant-driven private networking as CDK stacks and constructs.

71 lines (70 loc) • 5.94 kB
/** Headscale rejects digit-first user names and ~half of Cognito subs (random hex) start with one — the prefix * keeps names letter-first. The keyminter (creates users) and ACL reconciler (matches rules) MUST share this mapping. */ export declare const headscaleUserName: (cognitoSub: string) => string; /** A node's name on a site is a DNS label. The device routes, the share form (device + hostname label) and the * keyminter MUST share this rule. */ export declare const NODE_NAME_LABEL = "[a-z0-9]([a-z0-9-]{0,62}[a-z0-9])?"; export declare const NODE_NAME_RE: RegExp; /** The one name a device is listed under: its DNS name, or the hostname it enrolled with when Headscale has * given it none. Device delete removes exactly the node listed under the name — never a lookalike. */ export declare const nodeDisplayName: (node: { name?: string; givenName?: string; }) => string; /** A node answers to its DNS name and to the hostname it enrolled with: Headscale suffixes a duplicate's DNS * name, so a machine that re-enrolls under the same name while its old node lingers is found by either. * Device-bound shares (reconciler) use this so the port follows a re-enrolled machine; device delete does * NOT (nodeDisplayName) — removing the stale duplicate must not take the live node with it. */ export declare const nodeAnswersTo: (node: { name?: string; givenName?: string; }, name: string) => boolean; /** SET-ONCE product prefix for every by-name contract (Lambda/role/secret names, the SG rule marker). Config * `resourcePrefix` may override it only BEFORE the first deploy — renaming later breaks every cross-account by-name invocation and orphans managed SG rules until all stacks in all accounts redeploy in lockstep. */ export declare const DEFAULT_RESOURCE_PREFIX = "infra-client"; /** A connector VPC's `name` (config `connectorVpcs`): letters and digits, letter-first, at most 10 — it * suffixes the connector hostname AND both per-VPC function names, and the longest of those (a 15-char * prefix, the resolver stem, a 20-char site id, the name) must fit Lambda's 64-char limit. */ export declare const CONNECTOR_NAME_RE: RegExp; export declare const assertConnectorName: (name: string, where: string) => void; /** One connector VPC as the hub addresses it: `name` for a named VPC, `region` only outside the hub's region. * NetworkStack writes `CONNECTOR_VPCS` (accountNumber → ConnectorTarget[]) for the reconciler and its relay. */ export interface ConnectorTarget { name?: string; region?: string; } export declare const parseConnectorVpcs: (json: string | undefined) => Map<string, ConnectorTarget[]>; /** `connector-<account>[-<name>]` is a CONTRACT: the ACL reconciler maps a node's routes to grants in the * account it names. The name tells one VPC of an account from another; it coexists with headscale's own * `-<random>` dedupe suffix, which the reconciler's parser tolerates either way. */ export declare const connectorHostname: (account: string, name?: string) => string; /** Well-known SG-manager function name — one per connector VPC (`-<name>` for a named VPC; an account's * one unnamed VPC keeps the bare name), invoked BY NAME across accounts (as the key minters are). The * reconciler builds `arn:aws:lambda:<region>:<account>:function:<this>` from it. */ export declare const sgManagerFnName: (prefix: string, name?: string) => string; /** Well-known key-minter names — invoked BY NAME so stacks deploy in any order. SECURITY SPLIT: the device minter * (per-user keys, takes a siteId) is granted only to the vending API role; each site's connector minter (machine keys, ignores input) may be granted cross-account — site selection rides on WHICH minter an account may invoke, never on an argument, so a connector can neither impersonate a user nor enroll into another site. */ export declare const deviceKeyMinterFnName: (prefix: string) => string; export declare const connectorKeyMinterFnName: (prefix: string, siteId: string) => string; /** Well-known in-VPC DNS resolver — one per connector VPC, named PER SITE (an account may host connector * VPCs in two sites — colliding CIDRs are the whole reason sites exist — and each VPC has its own private-DNS * view, so a per-account name would answer with the wrong VPC's IPs) and, for a named VPC, per VPC. Invoked * BY NAME across accounts like the SG-manager; private-zone names (Cloud Map, RDS) are invisible outside * their VPC. */ export declare const tailnetResolverFnName: (prefix: string, siteId: string, name?: string) => string; /** Fixed reconciler role name: connector accounts pin their SG-manager's invoke trust to this exact ARN. Lambda * resolves the principal at permission-attach time, so recreating this role means redeploying every ConnectorStack. */ export declare const aclReconcilerRoleName: (prefix: string) => string; /** The reconciler's out-of-VPC relay (function AND its invoke-only role share the name) — the hub's way * into connector accounts in OTHER regions. Those accounts pin their SG-manager/resolver trust to the ROLE, * the way hub-region ones pin it to the reconciler role; same recreate caveat. */ export declare const aclReconcilerRelayFnName: (prefix: string) => string; export declare const aclReconcilerRelayRoleName: (prefix: string) => string; /** Site ids: DNS label, letter-first, ≤20 chars — also the per-site resolver name's suffix. */ export declare const SITE_ID_RE: RegExp; /** Fixed reconciler FUNCTION name: the API invokes it by name for the admin "Sync now" button * (same by-name pattern as the key minters, so CredsStack never references NetworkStack). */ export declare const aclReconcilerFnName: (prefix: string) => string; /** Ownership marker on every SG rule the manager writes — it only ever * revokes rules carrying it. */ export declare const managedRuleDesc: (prefix: string) => string;