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,17 +1,14 @@
/// <reference types="node" />
import * as RustSdkCryptoJs from "@matrix-org/matrix-sdk-crypto-wasm";
import { type ShowQrCodeCallbacks, type ShowSasCallbacks, VerificationPhase, type VerificationRequest, VerificationRequestEvent, type VerificationRequestEventHandlerMap, type Verifier, VerifierEvent, type VerifierEventHandlerMap } from "../crypto-api/verification.ts";
import { TypedEventEmitter } from "../models/typed-event-emitter.ts";
import { type OutgoingRequestProcessor } from "./OutgoingRequestProcessor.ts";
import { type MatrixEvent } from "../models/event.ts";
import type { Logger } from "../logger.ts";
import { ShowQrCodeCallbacks, ShowSasCallbacks, VerificationPhase, VerificationRequest, VerificationRequestEvent, VerificationRequestEventHandlerMap, Verifier, VerifierEvent, VerifierEventHandlerMap } from "../crypto-api/verification";
import { TypedEventEmitter } from "../models/typed-event-emitter";
import { OutgoingRequestProcessor } from "./OutgoingRequestProcessor";
/**
* An incoming, or outgoing, request to verify a user or a device via cross-signing.
*
* @internal
*/
export declare class RustVerificationRequest extends TypedEventEmitter<VerificationRequestEvent, VerificationRequestEventHandlerMap> implements VerificationRequest {
private readonly logger;
private readonly olmMachine;
private readonly inner;
private readonly outgoingRequestProcessor;
private readonly supportedVerificationMethods;
@@ -25,17 +22,11 @@ export declare class RustVerificationRequest extends TypedEventEmitter<Verificat
/**
* Construct a new RustVerificationRequest to wrap the rust-level `VerificationRequest`.
*
* @param logger - A logger instance which will be used to log events.
* @param olmMachine - The `OlmMachine` from the underlying rust crypto sdk.
* @param inner - VerificationRequest from the Rust SDK.
* @param outgoingRequestProcessor - `OutgoingRequestProcessor` to use for making outgoing HTTP requests.
* @param supportedVerificationMethods - Verification methods to use when `accept()` is called.
* @param inner - VerificationRequest from the Rust SDK
* @param outgoingRequestProcessor - `OutgoingRequestProcessor` to use for making outgoing HTTP requests
* @param supportedVerificationMethods - Verification methods to use when `accept()` is called
*/
constructor(logger: Logger, olmMachine: RustSdkCryptoJs.OlmMachine, inner: RustSdkCryptoJs.VerificationRequest, outgoingRequestProcessor: OutgoingRequestProcessor, supportedVerificationMethods: string[]);
/**
* Hook which is called when the underlying rust class notifies us that there has been a change.
*/
private onChange;
constructor(inner: RustSdkCryptoJs.VerificationRequest, outgoingRequestProcessor: OutgoingRequestProcessor, supportedVerificationMethods: string[]);
private setVerifier;
/**
* Unique ID for this verification request.
@@ -60,8 +51,6 @@ export declare class RustVerificationRequest extends TypedEventEmitter<Verificat
get otherUserId(): string;
/** For verifications via to-device messages: the ID of the other device. Otherwise, undefined. */
get otherDeviceId(): string | undefined;
/** Get the other device involved in the verification, if it is known */
private getOtherDevice;
/** True if the other party in this request is one of this user's own devices. */
get isSelfVerification(): boolean;
/** current phase of the request. */
@@ -153,7 +142,7 @@ export declare class RustVerificationRequest extends TypedEventEmitter<Verificat
* @param qrCodeData - the decoded QR code.
* @returns A verifier; call `.verify()` on it to wait for the other side to complete the verification flow.
*/
scanQRCode(uint8Array: Uint8ClampedArray): Promise<Verifier>;
scanQRCode(uint8Array: Uint8Array): Promise<Verifier>;
/**
* The verifier which is doing the actual verification, once the method has been established.
* Only defined when the `phase` is Started.
@@ -162,13 +151,13 @@ export declare class RustVerificationRequest extends TypedEventEmitter<Verificat
/**
* Stub implementation of {@link Crypto.VerificationRequest#getQRCodeBytes}.
*/
getQRCodeBytes(): Uint8ClampedArray | undefined;
getQRCodeBytes(): Buffer | undefined;
/**
* Generate the data for a QR code allowing the other device to verify this one, if it supports it.
*
* Implementation of {@link Crypto.VerificationRequest#generateQRCode}.
*/
generateQRCode(): Promise<Uint8ClampedArray | undefined>;
generateQRCode(): Promise<Buffer | undefined>;
/**
* If this request has been cancelled, the cancellation code (e.g `m.user`) which is responsible for cancelling
* this verification.
@@ -188,16 +177,15 @@ export declare class RustVerificationRequest extends TypedEventEmitter<Verificat
* @internal
*/
declare abstract class BaseRustVerifer<InnerType extends RustSdkCryptoJs.Qr | RustSdkCryptoJs.Sas> extends TypedEventEmitter<VerifierEvent | VerificationRequestEvent, VerifierEventHandlerMap & VerificationRequestEventHandlerMap> {
protected inner: InnerType;
protected readonly inner: InnerType;
protected readonly outgoingRequestProcessor: OutgoingRequestProcessor;
/** A deferred which completes when the verification completes (or rejects when it is cancelled/fails) */
protected readonly completionDeferred: PromiseWithResolvers<void>;
/** A promise which completes when the verification completes (or rejects when it is cancelled/fails) */
protected readonly completionPromise: Promise<void>;
constructor(inner: InnerType, outgoingRequestProcessor: OutgoingRequestProcessor);
/**
* Hook which is called when the underlying rust class notifies us that there has been a change.
*
* Can be overridden by subclasses to see if we can notify the application about an update. The overriding method
* must call `super.onChange()`.
* Can be overridden by subclasses to see if we can notify the application about an update.
*/
protected onChange(): void;
/**
@@ -273,10 +261,6 @@ export declare class RustSASVerifier extends BaseRustVerifer<RustSdkCryptoJs.Sas
* or times out.
*/
verify(): Promise<void>;
/**
* Send the accept or start event, if it hasn't already been sent
*/
private sendAccept;
/** if we can now show the callbacks, do so */
protected onChange(): void;
/**
@@ -290,13 +274,6 @@ export declare class RustSASVerifier extends BaseRustVerifer<RustSdkCryptoJs.Sas
* the SAS matches.
*/
getShowSasCallbacks(): ShowSasCallbacks | null;
/**
* Replace the inner Rust verifier with a different one.
*
* @param inner - the new Rust verifier
* @internal
*/
replaceInner(inner: RustSdkCryptoJs.Sas): void;
}
/**
* Convert a specced verification method identifier into a rust-side `VerificationMethod`.
@@ -308,14 +285,5 @@ export declare class RustSASVerifier extends BaseRustVerifer<RustSdkCryptoJs.Sas
* @internal
*/
export declare function verificationMethodIdentifierToMethod(method: string): RustSdkCryptoJs.VerificationMethod;
/**
* Return true if the event's type matches that of an in-room verification event
*
* @param event - MatrixEvent
* @returns
*
* @internal
*/
export declare function isVerificationEvent(event: MatrixEvent): boolean;
export {};
//# sourceMappingURL=verification.d.ts.map