* feat: restructure tunnel handling around provider-based service model" -m "Introduce tunnel service/registry/provider architecture and move Cloudflare handling behind provider adapter." -m "Add canonical tunnel modes (quick, managed-remote, managed-local) with legacy named/try-cf-tunnel compatibility mapping." -m "Add managed-local config-path support, normalized API response fields, tunnel-focused tests, and shell aliases for tunnel test workflows. * feat(tunnels): harden managed startup and decouple runtime APIs Improve managed Cloudflare startup reliability with explicit config validation, YAML diagnostics, and readiness detection based on process output instead of fixed delay assumptions. Refactor server tunnel lifecycle around provider-aware runtime state and API responses while keeping legacy Cloudflare token endpoint compatibility, and add coverage for unsupported mode validation plus managed-local startup cases. * feat: remove named tunnel mode and standardize managed modes Replace named tunnel terminology with managed-remote and managed-local across API, server state, and UI settings without legacy aliases. Add provider capability discovery endpoint and descriptor-based mode validation, including explicit mode_unsupported errors for removed mode values. * feat(tunnels): finalize provider-aware tunnel UX and managed-local safety Restructure tunnel settings with provider selection, mode chips, persisted managed-local config path, and clearer session badges while preserving existing tunnel flows. Add legacy named-data migration, provider discovery CLI, and user-friendly managed-local config validation/error messaging with updated API/CLI/server tests. * Add provider icon to tunnel settings * Add control+C to stop tunnel * feat(cli): add tunnel lifecycle profiles and preserve preset naming Replace legacy tunnel flags with explicit tunnel lifecycle commands, daemon-by-default startup, and file-backed log tailing so tunnel operations are predictable and provider-agnostic. Add managed-remote profile storage/migration for start-by-name workflows and propagate preset summaries to settings so user-defined profile names are preserved instead of falling back to Default. * feat: improve tunnel CLI safety and startup UX Add interactive TTL support and per-start TTL overrides for tunnel start Strengthen port safety and instance validation with clearer startup and error guidance Refine tunnel doctor and CLI output formatting for clearer, less noisy diagnostics * feat: add TTL support, safety gates, and polished tunnel CLI output * fix: harden tunnel doctor checks and CLI port handling * fix: improve tunnel CLI diagnostics and profile output * fix: streamline tunnel profile UX and doctor diagnostics * fix: clarify tunnel replacement behavior across CLI and UI * Upd docs * docs: add mandatory clack CLI skill guidance. cleanup * fix: standardize tunnel CLI mode parity and prompt UX * fix: align CLI quiet and JSON output behavior * feat/web-serve: in-progress animation * fix: tunnel doctor managed remote validation * Fix: security tightening * fix: instance restart ux * fix: tighten tunnel doctor input handling and CLI port/prompt validation * chore: remove tunnel test suites per owner request --------- Signed-off-by: Iuliia Ivashko <yulia.ivashko@gmail.com>
52 lines
1.5 KiB
JavaScript
52 lines
1.5 KiB
JavaScript
const REQUIRED_PROVIDER_METHODS = ['start', 'stop', 'checkAvailability', 'resolvePublicUrl'];
|
|
|
|
export function createTunnelProviderRegistry(initialProviders = []) {
|
|
const providers = new Map();
|
|
let sealed = false;
|
|
|
|
const register = (provider) => {
|
|
if (sealed) {
|
|
throw new Error('Tunnel provider registry is sealed; no further registrations allowed');
|
|
}
|
|
if (!provider || typeof provider.id !== 'string' || provider.id.trim().length === 0) {
|
|
throw new Error('Tunnel provider must define a non-empty id');
|
|
}
|
|
for (const method of REQUIRED_PROVIDER_METHODS) {
|
|
if (typeof provider[method] !== 'function') {
|
|
throw new Error(`Tunnel provider '${provider.id}' must implement ${method}()`);
|
|
}
|
|
}
|
|
const key = provider.id.trim().toLowerCase();
|
|
if (providers.has(key)) {
|
|
throw new Error(`Tunnel provider '${key}' is already registered`);
|
|
}
|
|
providers.set(key, provider);
|
|
return provider;
|
|
};
|
|
|
|
const get = (providerId) => {
|
|
if (typeof providerId !== 'string' || providerId.trim().length === 0) {
|
|
return null;
|
|
}
|
|
return providers.get(providerId.trim().toLowerCase()) ?? null;
|
|
};
|
|
|
|
const list = () => Array.from(providers.values());
|
|
|
|
const listCapabilities = () => list().map((provider) => ({ ...provider.capabilities }));
|
|
|
|
for (const provider of initialProviders) {
|
|
register(provider);
|
|
}
|
|
|
|
const seal = () => { sealed = true; };
|
|
|
|
return {
|
|
register,
|
|
get,
|
|
list,
|
|
listCapabilities,
|
|
seal,
|
|
};
|
|
}
|