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,5 +1,6 @@
import { type MatrixClient } from "./client.ts";
import { type UserIdentifier } from "./@types/auth.ts";
import { MatrixClient } from "./client";
import { UIAResponse } from "./@types/uia";
import { UserIdentifier } from "./@types/auth";
export interface UIAFlow {
stages: Array<AuthType | string>;
}
@@ -50,12 +51,7 @@ export declare enum AuthType {
SsoUnstable = "org.matrix.login.sso",
Dummy = "m.login.dummy",
RegistrationToken = "m.login.registration_token",
UnstableRegistrationToken = "org.matrix.msc3231.login.registration_token",
/**
* m.oauth stage introduced by MSC4312:
* https://spec.matrix.org/v1.17/client-server-api/#oauth-authentication
*/
OAuth = "m.oauth"
UnstableRegistrationToken = "org.matrix.msc3231.login.registration_token"
}
/**
* https://spec.matrix.org/v1.7/client-server-api/#password-based
@@ -86,6 +82,10 @@ interface ThreepidCreds {
type EmailIdentityDict = {
type: AuthType.Email;
threepid_creds: ThreepidCreds;
/**
* @deprecated in favour of `threepid_creds` - kept for backwards compatibility
*/
threepidCreds?: ThreepidCreds;
session: string;
};
/**
@@ -97,6 +97,11 @@ export type AuthDict = PasswordDict | RecaptchaDict | EmailIdentityDict | {
type: Exclude<string, AuthType>;
[key: string]: any;
} | {};
/**
* Backwards compatible export
* @deprecated in favour of AuthDict
*/
export type IAuthDict = AuthDict;
export declare class NoAuthFlowFoundError extends Error {
readonly required_stages: string[];
readonly flows: UIAFlow[];
@@ -112,7 +117,7 @@ export declare class NoAuthFlowFoundError extends Error {
*
* The generic parameter `T` is the type of the response of the endpoint, once it is eventually successful.
*/
export type UIAuthCallback<T> = (makeRequest: (authData: AuthDict | null) => Promise<T>) => Promise<T>;
export type UIAuthCallback<T> = (makeRequest: (authData: IAuthDict | null) => Promise<UIAResponse<T>>) => Promise<T>;
interface IOpts<T> {
/**
* A matrix client to use for the auth process
@@ -152,7 +157,7 @@ interface IOpts<T> {
* The busyChanged callback should be used instead of the background flag.
* Should return a promise which resolves to the successful response or rejects with a MatrixError.
*/
doRequest(this: void, auth: AuthDict | null, background: boolean): Promise<T>;
doRequest(auth: AuthDict | null, background: boolean): Promise<T>;
/**
* Called when the status of the UI auth changes,
* ie. when the state of an auth stage changes of when the auth flow moves to a new stage.
@@ -166,14 +171,14 @@ interface IOpts<T> {
* m.login.email.identity:
* * emailSid: string, the sid of the active email auth session
*/
stateUpdated(this: void, nextStage: AuthType | string, status: IStageStatus): void;
stateUpdated(nextStage: AuthType | string, status: IStageStatus): void;
/**
* A function that takes the email address (string), clientSecret (string), attempt number (int) and
* sessionId (string) and calls the relevant requestToken function and returns the promise returned by that
* function.
* If the resulting promise rejects, the rejection will propagate through to the attemptAuth promise.
*/
requestEmailToken(this: void, email: string, secret: string, attempt: number, session: string): Promise<{
requestEmailToken(email: string, secret: string, attempt: number, session: string): Promise<{
sid: string;
}>;
/**
@@ -181,8 +186,8 @@ interface IOpts<T> {
* After this has been called with true the UI should indicate that a request is in progress
* until it is called again with false.
*/
busyChanged?(this: void, busy: boolean): void;
startAuthStage?(this: void, nextStage: string): Promise<void>;
busyChanged?(busy: boolean): void;
startAuthStage?(nextStage: string): Promise<void>;
}
/**
* Abstracts the logic used to drive the interactive auth process.
@@ -264,7 +269,7 @@ export declare class InteractiveAuth<T> {
* in the attemptAuth promise being rejected. This can be set to true
* for requests that just poll to see if auth has been completed elsewhere.
*/
submitAuthDict(authData: AuthDict, background?: boolean): Promise<void>;
submitAuthDict(authData: IAuthDict, background?: boolean): Promise<void>;
/**
* Gets the sid for the email validation session
* Specific to m.login.email.identity