import { BlockList } from 'node:net'; import { type Optional } from '@silverhand/essentials'; import UrlSet from './UrlSet.js'; /** * Parses a timeout value from an environment variable string. * * The input may be: * - a numeric string (milliseconds), or * - the literal `DISABLE_TIMEOUT` to omit the startup parameter. * * Empty/whitespace or invalid values return `undefined`, which lets Slonik apply * its default timeout of 60000 ms. * * @param value - Raw string value from an environment variable. * @returns A finite numeric timeout, `DISABLE_TIMEOUT`, or `undefined`. * * @example * const timeout = parseTimeoutEnv(process.env.DATABASE_STATEMENT_TIMEOUT); * if (timeout === 'DISABLE_TIMEOUT') { * // omit the startup parameter entirely so server defaults apply * } */ export declare const parseTimeoutEnv: (value?: string) => Optional; export declare const parseNonNegativeIntegerEnv: (value?: string, fallback?: number) => number; export default class GlobalValues { readonly isProduction: boolean; readonly isIntegrationTest: boolean; readonly isUnitTest: boolean; readonly isDevFeaturesEnabled: boolean; readonly httpsCert: string | undefined; readonly httpsKey: string | undefined; readonly isHttpsEnabled: boolean; /** * The UrlSet with no prefix for Logto core service. It serves requests to the OIDC Provider and Management APIs * from all tenants. * * Especially, a glob (`*`) is allowed for the hostname of its property `endpoint` to indicate if the domain-based multi-tenancy (DBMT) * is enabled which affects some critical behaviors of Logto. * * **When DBMT is enabled** * * - For non-admin tenants, tenant endpoint will be generated by replacing the glob in the `urlSet.endpoint`. * - For admin tenant, if `adminUrlSet` has no endpoint available, tenant endpoint will be generated by replacing the glob in the `urlSet.endpoint`. * - Admin Console will NOT be served under admin tenant since the cloud service will do. * - Incoming requests will use glob matching to parse the tenant ID from the request URL. * * ```ts * // ENDPOINT='https://*.domain.com' * getTenantEndpoint('foo') => 'https://foo.domain.com' * ``` * * **When DBMT is disabled** * * - For non-admin tenants, tenant endpoint will always be `urlSet.endpoint`. * - For admin tenant, tenant endpoint will always be `adminUrlSet.endpoint`. * - Admin Console will be served under admin tenant. * - Incoming requests will check whether the URL matches adminUrlSet.endpoint, which indicates the admin tenant ID. If there is no match, the default tenant ID will be used. */ readonly urlSet: UrlSet; /** * The UrlSet with prefix `ADMIN_` for Logto admin tenant. To completely disable it, set `ADMIN_DISABLE_LOCALHOST` to a truthy value and leave `ADMIN_ENDPOINT` unset. * * Should be disabled on the cloud. * * @see urlSet For mutual effects between these two sets. */ readonly adminUrlSet: UrlSet; /** * The UrlSet with prefix `CLOUD_` for Logto cloud service. It affects Admin Console Redirect URIs and some CORS configuration. */ readonly cloudUrlSet: UrlSet; /** @see urlSet For detailed explanation. */ readonly isDomainBasedMultiTenancy: boolean; /** * **NOTE: This is an internal dev-only feature.** * * This value indicates path-based multi-tenancy (PBMT) is enabled by setting env variable `PATH_BASED_MULTI_TENANCY` to a truthy value. * * Note the value will always be `false` if domain-based multi-tenancy is enabled. * * **When PBMT is enabled** * * - For non-admin tenants, tenant endpoint will be generated by appending the tenant ID to `urlSet.endpoint`. * - For admin tenant, if `adminUrlSet` has no endpoint available, tenant endpoint will be generated by appending the tenant ID to `urlSet.endpoint`. * - Admin Console will NOT be served under admin tenant since the cloud service will do. * - Incoming requests will try to match the position of pathname segments of the URLs in `urlSet.deduplicated()` to parse the tenant ID from the request URL. * * ```ts * // ENDPOINT='https://domain.com/foo' * getTenantEndpoint('bar') => 'https://domain.com/foo/bar' * matchTenantId('https://domain.com/foo/bar') => 'bar' * matchTenantId('http://localhost:3001/foo/bar') => 'foo' * ``` * * @see urlSet */ readonly isPathBasedMultiTenancy: boolean; /** Alias for `isDomainBasedMultiTenancy || isPathBasedMultiTenancy`. */ get isMultiTenancy(): boolean; /** If the env explicitly indicates it's in the cloud environment. */ readonly isCloud: boolean; /** * Whether a self-hosted deployment stops sending its usage counts with the license refresh. The * refresh itself still runs, and usage is still evaluated locally. * * Reporting is on unless this is set, and there is no other way to change it. Set it on every * instance of the deployment, since whichever instance claims a refresh sends it. */ readonly isLicenseUsageReportingDisabled: boolean; /** * Whether outbound requests to operator-supplied URLs are protected against SSRF. This covers * oidc-provider's own requests (backchannel logout, client `jwks_uri`, ...) as well as webhook * delivery and enterprise SSO connector discovery. * * Protection is enabled by default and can only be disabled in self-hosted deployments, where * reaching a trusted endpoint on a private network is a legitimate setup. Features that resolve * unregistered remote clients, such as CIMD, must only be enabled while this is true. * * `OIDC_PROVIDER_SSRF_PROTECTION_DISABLED` is the original, narrower name of the opt-out and is * still honored so deployments that already set it keep working. */ readonly isSsrfProtectionEnabled: boolean; /** * @deprecated Renamed to `isSsrfProtectionEnabled` as the protection now covers webhook delivery * and SSO connector discovery/metadata requests as well. */ get isOidcProviderSsrfProtectionEnabled(): boolean; /** * Destinations that stay reachable while the SSRF protection is on, as a comma-separated list of * IP addresses or CIDR ranges (`127.0.0.1,10.0.0.0/8,::1`). * * Prefer this over `SSRF_PROTECTION_DISABLED` when only a known internal host has to be reached: * naming the destinations keeps every other special-use address blocked. Features that accept * unauthenticated target URLs, such as CIMD, are disabled while an allowlist is configured. * Ignored in Cloud. */ readonly ssrfAllowedAddresses: string[]; /** Parsed at startup so malformed entries cannot throw from a socket event listener. */ readonly ssrfAllowedAddressBlockList: Optional; /** Enables protected app local development without Cloud-only behavior. */ readonly isProtectedAppLocalDevEnabled: boolean; /** * Indicates whether this Logto instance supports multiple custom domains. * * **NOTE: Only available to enterprise customers running private instances that need this feature.** * * Controlled by the `MULTIPLE_CUSTOM_DOMAINS_ENABLED` environment variable. When enabled, the instance * can operate with multiple custom domains across both development and production tenants. */ readonly isMultipleCustomDomainsEnabled: boolean; readonly databaseUrl: string; readonly developmentTenantId: string; /** @deprecated Use the built-in user default role configuration (`Roles.isDefault`) instead. */ readonly userDefaultRoleNames: string[]; readonly developmentUserId: string; /** * The public key self-hosted license keys are verified against, as a serialized ES256 public * JWK. It replaces the public key built into Logto, so unit and integration tests — and a * developer running the Logto Cloud license service locally — can install keys they signed * themselves. * * Ignored in production, on the same terms as `DEVELOPMENT_USER_ID`: the consumer decides * whether to honor it, so that the reason it is ignored can be reported where it is read. Anyone * who can set an environment variable on a self-hosted instance can also patch its code, so this * is a guardrail against an accidental or copy-pasted configuration rather than a security * boundary: it keeps "which keys does this instance trust" answerable from the Logto version * alone. */ readonly selfHostedLicensePublicKey: string; readonly trustProxyHeader: boolean; readonly ignoreConnectorVersionCheck: boolean; readonly injectedHeaderMappingJson: string; readonly debugInjectedHeadersJson: string; /** Maximum number of tenants to keep in the tenant pool. */ readonly tenantPoolSize: number; /** Maximum number of clients to keep in a single database pool (i.e. per `Tenant` class). */ readonly databasePoolSize: number; readonly databaseConnectionTimeout: number; /** * PostgreSQL statement timeout in milliseconds. * * - Provide a numeric string (for example, `"5000"`) to send that timeout value. * - Use `"DISABLE_TIMEOUT"` to omit the startup parameter so server defaults apply * (helps with PgBouncer/RDS Proxy). * - If unset or invalid, Slonik uses its default timeout of 60000 ms (1 minute). */ readonly databaseStatementTimeout: Optional; /** * Global switch for enabling/disabling case-sensitive usernames. * * @deprecated Superseded by per-tenant `signInExperience.usernamePolicy.caseSensitive`. * AND-combined as a runtime override: `false` forces case-insensitive for every tenant. * Slated for removal in the next major. */ readonly isCaseSensitiveUsername: boolean; /** * The API key for status endpoint protection. If it's set, requests to the status endpoint may * supply the key in the header for receiving response with additional details. * * @optional */ readonly statusApiKey: string; /** The write-only key for PostHog integration. */ readonly posthogPublicKey: string | undefined; /** The PostHog host URL for SDK to send events to. */ readonly posthogPublicHost: string | undefined; /** * The Redis endpoint (optional). If it's set, the central cache mechanism will be automatically enabled. * * You can set it to a truthy value like `true` or `1` to enable cache with the default Redis URL. */ readonly redisUrl: string; /** * Default grace period for private signing key rotation, in seconds. * Cloud can configure a safe platform-wide default, while OSS/self-host deployments * may opt in through environment configuration. */ readonly privateKeyRotationGracePeriod: number; get dbUrl(): string; get endpoint(): URL; /** * For cloud use only. * Define regional Azure function app endpoint and key to enable the Logto Azure Functions integration. * This is the prerequisite of the calling on `@logto/azure-functions`. */ get azureFunctionAppEndpoint(): string; get azureFunctionAppKey(): string; /** * For cloud use only. * Define regional Untrusted Azure function app endpoint and key to enable the Logto Azure Functions integration for untrusted operations. */ get azureFunctionUntrustedAppEndpoint(): string; get azureFunctionUntrustedAppKey(): string; /** * For cloud use only. * The per-deployment script-runner Worker endpoint. When set, the Cloud script-run path calls * the Worker directly instead of detouring through the cloud service, which is pinned to a * single region while the Worker is reachable from Cloudflare's edge everywhere. */ get scriptRunnerEndpoint(): string; /** * The key encryption key (KEK) for the secret vault. * It is used to encrypt and decrypt secret DEKs (data encryption keys) in the secret vault. */ get secretVaultKek(): string; constructor(); }