Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
68 lines
2.0 KiB
TypeScript
68 lines
2.0 KiB
TypeScript
/**
|
|
* Shared builder for extension UI iframe src URLs.
|
|
* Enforces content hash format and handles RUNNER_PUBLIC_BASE when EXT_UI_HOST_MODE === "rust".
|
|
*
|
|
* Example:
|
|
* const src = buildExtUiSrc("ext-123", "sha256:...64hex...", "/");
|
|
* <iframe src={src} sandbox="allow-scripts"></iframe>
|
|
*/
|
|
export function buildExtUiSrc(
|
|
extensionId: string,
|
|
contentHash: string,
|
|
clientPath: string,
|
|
opts?: { tenantId?: string; publicBaseOverride?: string }
|
|
): string {
|
|
if (!/^sha256:[0-9a-f]{64}$/i.test(contentHash)) {
|
|
throw new Error("Invalid content hash; expected format 'sha256:<hex64>'");
|
|
}
|
|
|
|
const mode = (process.env.EXT_UI_HOST_MODE || 'rust').toLowerCase();
|
|
const overrideBase = normalizePublicBase(opts?.publicBaseOverride);
|
|
const configuredBase = normalizePublicBase(process.env.RUNNER_PUBLIC_BASE);
|
|
const defaultRustBase = mode === 'rust' ? '/runner' : null;
|
|
const publicBase = overrideBase ?? configuredBase ?? defaultRustBase;
|
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
console.log('[ext-ui][buildExtUiSrc]', {
|
|
extensionId,
|
|
mode,
|
|
clientPath,
|
|
tenantId: opts?.tenantId,
|
|
overrideBase,
|
|
runnerBase: process.env.RUNNER_PUBLIC_BASE,
|
|
publicBase,
|
|
});
|
|
}
|
|
|
|
const params = new URLSearchParams({ path: clientPath || '/' });
|
|
if (opts?.tenantId) {
|
|
params.set('tenant', opts.tenantId);
|
|
}
|
|
params.set('extensionId', extensionId);
|
|
const qs = params.toString();
|
|
const suffix = `/ext-ui/${encodeURIComponent(extensionId)}/${encodeURIComponent(contentHash)}/index.html?${qs}`;
|
|
|
|
if (!publicBase) {
|
|
return suffix;
|
|
}
|
|
|
|
return `${publicBase}${suffix}`;
|
|
}
|
|
|
|
function normalizePublicBase(raw: string | undefined): string | null {
|
|
if (!raw) return null;
|
|
const trimmed = raw.trim();
|
|
if (!trimmed) return null;
|
|
|
|
if (/^https?:\/\//i.test(trimmed)) {
|
|
return trimmed.replace(/\/+$/, '');
|
|
}
|
|
|
|
if (trimmed.startsWith('/')) {
|
|
return trimmed.replace(/\/+$/, '');
|
|
}
|
|
|
|
// Treat other values (e.g., custom schemes) as provided but remove trailing slash.
|
|
return trimmed.replace(/\/+$/, '');
|
|
}
|