feat: complete Ancestor quote bot with production-ready Docker support

This commit is contained in:
unfunny
2026-09-13 14:14:38 -04:00
parent f2016da05a
commit fe7351a7dc
1145 changed files with 30890 additions and 97684 deletions

View File

@@ -1,4 +1,6 @@
import { type IClientWellKnown, type IWellKnownConfig } from "./client.ts";
import { SigningKey } from "oidc-client-ts";
import { IClientWellKnown, IWellKnownConfig, IDelegatedAuthConfig } from "./client";
import { ValidatedIssuerConfig, ValidatedIssuerMetadata } from "./oidc/validate";
export declare enum AutoDiscoveryAction {
SUCCESS = "SUCCESS",
IGNORE = "IGNORE",
@@ -6,7 +8,7 @@ export declare enum AutoDiscoveryAction {
FAIL_PROMPT = "FAIL_PROMPT",
FAIL_ERROR = "FAIL_ERROR"
}
export declare enum AutoDiscoveryError {
declare enum AutoDiscoveryError {
Invalid = "Invalid homeserver discovery response",
GenericFailure = "Failed to get autodiscovery configuration from server",
InvalidHsBaseUrl = "Invalid base_url for m.homeserver",
@@ -15,8 +17,7 @@ export declare enum AutoDiscoveryError {
InvalidIdentityServer = "Identity server URL does not appear to be a valid identity server",
InvalidIs = "Invalid identity server discovery response",
MissingWellknown = "No .well-known JSON file found",
InvalidJson = "Invalid JSON",
UnsupportedHomeserverSpecVersion = "The homeserver does not meet the version requirements"
InvalidJson = "Invalid JSON"
}
interface AutoDiscoveryState {
state: AutoDiscoveryAction;
@@ -24,9 +25,25 @@ interface AutoDiscoveryState {
}
interface WellKnownConfig extends Omit<IWellKnownConfig, "error">, AutoDiscoveryState {
}
/**
* @deprecated in favour of OidcClientConfig
*/
interface DelegatedAuthConfig extends IDelegatedAuthConfig, ValidatedIssuerConfig, AutoDiscoveryState {
}
/**
* @experimental
*/
export interface OidcClientConfig extends IDelegatedAuthConfig, ValidatedIssuerConfig {
metadata: ValidatedIssuerMetadata;
signingKeys?: SigningKey[];
}
export interface ClientConfig extends Omit<IClientWellKnown, "m.homeserver" | "m.identity_server"> {
"m.homeserver": WellKnownConfig;
"m.identity_server": WellKnownConfig;
/**
* @experimental
*/
"m.authentication"?: (OidcClientConfig & AutoDiscoveryState) | AutoDiscoveryState;
}
/**
* Utilities for automatically discovery resources, such as homeservers
@@ -42,8 +59,7 @@ export declare class AutoDiscovery {
static readonly ERROR_INVALID_IS = AutoDiscoveryError.InvalidIs;
static readonly ERROR_MISSING_WELLKNOWN = AutoDiscoveryError.MissingWellknown;
static readonly ERROR_INVALID_JSON = AutoDiscoveryError.InvalidJson;
static readonly ERROR_UNSUPPORTED_HOMESERVER_SPEC_VERSION = AutoDiscoveryError.UnsupportedHomeserverSpecVersion;
static readonly ALL_ERRORS: AutoDiscoveryError[];
static readonly ALL_ERRORS: string[];
/**
* The auto discovery failed. The client is expected to communicate
* the error to the user and refuse logging in.
@@ -79,7 +95,32 @@ export declare class AutoDiscovery {
* configuration, which may include error states. Rejects on unexpected
* failure, not when verification fails.
*/
static fromDiscoveryConfig(wellknown?: IClientWellKnown): Promise<ClientConfig>;
static fromDiscoveryConfig(wellknown: IClientWellKnown): Promise<ClientConfig>;
/**
* Validate delegated auth configuration
* @deprecated use discoverAndValidateAuthenticationConfig
* - m.authentication config is present and valid
* - delegated auth issuer openid-configuration is reachable
* - delegated auth issuer openid-configuration is configured correctly for us
* When successful, DelegatedAuthConfig will be returned with endpoints used for delegated auth
* Any errors are caught, and AutoDiscoveryState returned with error
* @param wellKnown - configuration object as returned
* by the .well-known auto-discovery endpoint
* @returns Config or failure result
*/
static validateDiscoveryAuthenticationConfig(wellKnown: IClientWellKnown): Promise<DelegatedAuthConfig | AutoDiscoveryState>;
/**
* Validate delegated auth configuration
* - m.authentication config is present and valid
* - delegated auth issuer openid-configuration is reachable
* - delegated auth issuer openid-configuration is configured correctly for us
* When successful, validated authentication metadata and optionally signing keys will be returned
* Any errors are caught, and AutoDiscoveryState returned with error
* @param wellKnown - configuration object as returned
* by the .well-known auto-discovery endpoint
* @returns Config or failure result
*/
static discoverAndValidateAuthenticationConfig(wellKnown: IClientWellKnown): Promise<(OidcClientConfig & AutoDiscoveryState) | AutoDiscoveryState>;
/**
* Attempts to automatically discover client configuration information
* prior to logging in. Such information includes the homeserver URL
@@ -113,7 +154,7 @@ export declare class AutoDiscovery {
private static sanitizeWellKnownUrl;
private static fetch;
private static fetchFn?;
static setFetchFn(fetchFn: typeof globalThis.fetch): void;
static setFetchFn(fetchFn: typeof global.fetch): void;
/**
* Fetches a JSON object from a given URL, as expected by all .well-known
* related lookups. If the server gives a 404 then the `action` will be