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 MatrixEvent } from "../models/event.ts";
import { type TypedEventEmitter } from "../models/typed-event-emitter.ts";
/// <reference types="node" />
import { MatrixEvent } from "../models/event";
import { TypedEventEmitter } from "../models/typed-event-emitter";
/**
* An incoming, or outgoing, request to verify a user or a device via cross-signing.
*/
@@ -83,18 +84,31 @@ export interface VerificationRequest extends TypedEventEmitter<VerificationReque
reason?: string;
code?: string;
}): Promise<void>;
/**
* Create a {@link Verifier} to do this verification via a particular method.
*
* If a verifier has already been created for this request, returns that verifier.
*
* This does *not* send the `m.key.verification.start` event - to do so, call {@link Crypto.Verifier#verify} on the
* returned verifier.
*
* If no previous events have been sent, pass in `targetDevice` to set who to direct this request to.
*
* @param method - the name of the verification method to use.
* @param targetDevice - details of where to send the request to.
*
* @returns The verifier which will do the actual verification.
*
* @deprecated Use {@link VerificationRequest#startVerification} instead.
*/
beginKeyVerification(method: string, targetDevice?: {
userId?: string;
deviceId?: string;
}): Verifier;
/**
* Send an `m.key.verification.start` event to start verification via a particular method.
*
* This is used for SAS (emoji) verification: `method` should be set to `m.sas.v1`. It does not start
* QR-code verification, and passing a QR-code method (such as `m.reciprocate.v1`, `m.qr_code.scan.v1`,
* or `m.qr_code.show.v1`) will be rejected with an "Unsupported verification method" error.
*
* For QR-code verification, use {@link VerificationRequest#generateQRCode} to display a QR code to the
* other device, or {@link VerificationRequest#scanQRCode} to consume a QR code scanned from it. This is
* only possible once the `phase` is {@link VerificationPhase.Ready}; when it is, a client can typically
* offer the user any of three options: show a QR code, scan the other party's QR code, or fall back to
* emoji (SAS) verification via this method.
* This is normally used when starting a verification via emojis (ie, `method` is set to `m.sas.v1`).
*
* @param method - the name of the verification method to use.
*
@@ -104,37 +118,35 @@ export interface VerificationRequest extends TypedEventEmitter<VerificationReque
/**
* Start a QR code verification by providing a scanned QR code for this verification flow.
*
* Call this once the user has scanned the QR code displayed by the other device (for example, the bytes
* produced by that device's {@link VerificationRequest#generateQRCode}). Validates the QR code, and if it
* is ok, sends an `m.key.verification.start` event with `method` set to `m.reciprocate.v1`, to tell the
* other side the scan was successful.
* Validates the QR code, and if it is ok, sends an `m.key.verification.start` event with `method` set to
* `m.reciprocate.v1`, to tell the other side the scan was successful.
*
* See also {@link VerificationRequest#startVerification} which can be used to start other verification methods.
*
* @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(qrCodeData: Uint8ClampedArray): Promise<Verifier>;
scanQRCode(qrCodeData: Uint8Array): Promise<Verifier>;
/**
* The verifier which is doing the actual verification, once the method has been established.
* Only defined when the `phase` is Started.
*/
get verifier(): Verifier | undefined;
/**
* Get the data for a QR code allowing the other device to verify this one, if it supports it.
*
* Only set after a .ready if the other party can scan a QR code, otherwise undefined.
*
* @deprecated Not supported in Rust Crypto. Use {@link VerificationRequest#generateQRCode} instead.
*/
getQRCodeBytes(): Buffer | undefined;
/**
* Generate the data for a QR code allowing the other device to verify this one, if it supports it.
*
* Returns the QR code data only when all of the following hold; otherwise it returns `undefined`:
* - `phase` is {@link VerificationPhase.Ready};
* - the other party advertises support for scanning a QR code (ie, `otherPartySupportsMethod("m.qr_code.scan.v1")`
* is true); and
* - this device has its cross-signing keys available locally. A frequent cause of an unexpected `undefined`
* is that cross-signing has not been set up or the keys have not yet been fetched, so the QR code cannot be
* constructed even though the phase and method checks pass.
*
* On success, display the returned bytes as a QR code for the other device to scan; if the other side scans it
* and confirms, there is nothing further to do on this side.
* Only returns data once `phase` is {@link VerificationPhase.Ready} and the other party can scan a QR code;
* otherwise returns `undefined`.
*/
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.
@@ -172,23 +184,11 @@ export declare enum VerificationPhase {
Requested = 2,
/** An `m.key.verification.ready` event has been sent or received, indicating the verification request is accepted. */
Ready = 3,
/**
* The verification is in flight.
*
* This means that an `m.key.verification.start` event has been sent or received, choosing a verification method;
* however the verification has not yet completed or been cancelled.
*/
/** An `m.key.verification.start` event has been sent or received, choosing a verification method */
Started = 4,
/**
* An `m.key.verification.cancel` event has been sent or received at any time before the `done` event, cancelling
* the verification request
*/
/** An `m.key.verification.cancel` event has been sent or received at any time before the `done` event, cancelling the verification request */
Cancelled = 5,
/**
* The verification request is complete.
*
* Normally this means that `m.key.verification.done` events have been sent and received.
*/
/** An `m.key.verification.done` event has been **sent**, completing the verification request. */
Done = 6
}
/**
@@ -223,7 +223,7 @@ export interface Verifier extends TypedEventEmitter<VerifierEvent, VerifierEvent
* Cancel a verification.
*
* We will send an `m.key.verification.cancel` if the verification is still in flight. The verification promise
* will reject, and a {@link crypto-api.VerifierEvent.Cancel | VerifierEvent.Cancel} will be emitted.
* will reject, and a {@link Crypto.VerifierEvent#Cancel} will be emitted.
*
* @param e - the reason for the cancellation.
*/