@fntio/infra-client
Version:
Self-hosted AWS access portal: credential vending, target-account trust, and grant-driven private networking as CDK stacks and constructs.
107 lines (106 loc) • 6.3 kB
TypeScript
import type { ResolvedDevShares } from "./network-validation";
import type { ResolvedPersonalAccessTokens } from "./personal-access-tokens";
import type { ResolvedAccountDimensions } from "./dimensions-validation";
import * as cdk from "aws-cdk-lib";
import { Construct } from "constructs";
import * as acm from "aws-cdk-lib/aws-certificatemanager";
import * as apigw from "aws-cdk-lib/aws-apigateway";
import * as cognito from "aws-cdk-lib/aws-cognito";
import * as s3 from "aws-cdk-lib/aws-s3";
import { type ResolvedFederation } from "./federation";
/** Angular SPA from a private bucket behind CloudFront, the vending API
* fronted same-origin under /api/* (no CORS), plus the SPA's Cognito client. */
/** What the sidebar brand row shows (mirrors the frontend Branding type). */
export type BrandShow = "logo" | "project" | "company" | "logo-and-project" | "logo-and-company";
/** Per-project branding injected into the generated config.json (white-label:
* one frontend build, re-branded per deployment). */
export interface WebBranding {
/** Sidebar title + browser-tab title (default "Access Portal"). */
readonly projectName?: string;
/** The client's company name, for the 'company' brandShow modes. */
readonly companyName?: string;
/** Which of logo / project name / company name the brand row shows.
* Omitted → 'logo-and-project' when logoUrl is set, else 'project'. */
readonly brandShow?: BrandShow;
/** URL of a square logo image; omitted = letter mark from projectName. */
readonly logoUrl?: string;
/** A local image file to use as the logo instead of `logoUrl` (.svg, .png, .jpg, .webp or .gif,
* up to about 47 KB). Read at synth and embedded in the web app's config, so nothing has to be
* hosted publicly. A relative path resolves from the directory `cdk` runs in. */
readonly logoFile?: string;
readonly primaryColor?: string;
/** Hover shade; darkened primary if omitted. */
readonly primaryHoverColor?: string;
readonly accentColor?: string;
}
/** Custom domains for the app + its sign-in pages. */
export interface WebDomains {
readonly hostedZoneId: string;
readonly zoneName: string;
/** The app's public URL (CloudFront alias). */
readonly domainName: string;
/** Managed Login sign-in domain — must be a child of `domainName`. */
readonly authDomainName: string;
}
/** By-name contract: the API Lambda derives the same name to write
* /branding.json without a cross-stack ref (CredsStack deploys first). */
export declare function webBucketName(resourcePrefix: string, account: string): string;
export interface WebStackProps extends cdk.StackProps {
/** SET-ONCE product prefix — names the site bucket; see webBucketName(). */
readonly resourcePrefix: string;
/** The CredsStack REST API, mounted under /api/* on the distribution. */
readonly api: apigw.LambdaRestApi;
/** The SPA's app client + domain are created HERE — their callback URLs
* need the CloudFront domain (avoids a circular stack ref). */
readonly userPool: cognito.IUserPool;
/** This project's branding, baked into config.json at deploy time. */
readonly branding?: WebBranding;
/** Baked into config.json so the frontend only offers MFA screens when the
* pool actually challenges TOTP. Omit = MFA UI hidden. */
readonly mfa?: "optional" | "required";
/** Baked into config.json so the frontend only offers passkey management
* when the pool accepts WebAuthn. Omit/false = passkey UI hidden. */
readonly passkey?: boolean;
/** Whether private-network (VPN) sites exist on this deployment, baked
* into config.json so the SPA hides its Network pages when they don't. */
readonly network?: boolean;
/** `loginMethods.federation`, validated: one Cognito OIDC provider each, offered on the
* SPA client; the login buttons + claim labels ride config.json. */
readonly federation?: ResolvedFederation;
/** Enabled `network.devShares`, baked into config.json (the UI's limits); absent = hidden. */
readonly devShares?: ResolvedDevShares;
/** Enabled `personalAccessTokens`, baked into config.json (the token page's lifetime cap); absent = hidden. */
readonly personalAccessTokens?: ResolvedPersonalAccessTokens;
/** Enabled `accountDimensions`, baked into config.json (labels + stage silhouettes); absent = no filters. */
readonly accountDimensions?: ResolvedAccountDimensions;
/** Custom domains; omit to stay on the raw CloudFront URL + default
* Cognito domain. */
readonly web?: WebDomains;
/** Cert covering both `web` domains. Must come from WebCertStack
* (us-east-1) — CloudFront and Cognito reject certs from any other region. */
readonly certificate?: acm.ICertificate;
/** CloudFront-scope WAFv2 web ACL ARN — from WebCertStack, since WAF only
* accepts CloudFront ACLs in us-east-1. Omit = no WAF. */
readonly webAclArn?: string;
/** A prebuilt web bundle to serve instead of the frontend build shipped
* with this package — the seam for deploying your own frontend build. */
readonly webAssetPath?: string;
/** Customer plugins, on: the /plugin-assets/* behavior over DataStack's assets bucket (by name — a
* bucket reference would try to write its policy from here and cycle the stacks) and the discovery
* settings in config.json. Absent = feature off. */
readonly plugins?: WebStackPlugins;
/** DataStack's log bucket: S3 server-access logs of the site bucket and the distribution's standard logs. */
readonly accessLogsBucket?: s3.IBucket;
}
export interface WebStackPlugins {
readonly discoveryRefreshSeconds: number;
readonly assetsBucketName: string;
}
/** The session cap: refresh-token validity of the web clients AND config.json's `sessionHours`, which the
* SPA uses to show when a sign-in ends — one constant so the two can't disagree (issue #29). */
export declare const SESSION_HOURS = 12;
export declare class WebStack extends cdk.Stack {
/** The generated config.json body — what the SPA self-configures from. */
readonly appConfig: Record<string, unknown>;
constructor(scope: Construct, id: string, props: WebStackProps);
}