Definitions#

All code blocks below are TypeScript declarations copied from the server. They document validation, not JSON to send or code to paste into a chat. Clients can use any HTTP library without importing these declarations. check.object rejects unknown fields. Custom functions and refinements specify additional checks.

Imported definitions#

BackendAccount#

export type BackendAccount = {
    userId: string;
    accessToken: string;
    native: JsonObject;
};

Related definitions:

BackendConfiguration#

export type BackendConfiguration = {
    type: string;
    parameters: JsonObject;
};

Related definitions:

BackendDescription#

export type BackendDescription = {
    type: string;
    label: string;
    chatUrl: string;
    signupUrl: string;
    signupInstructions: string[];
    configuration: BackendConfiguration;
};

Related definitions:

AccessField#

export type AccessField = {
    key: string;
    label: string;
    minimum: number;
    maximum: number;
    defaultValue: number;
};

RoomAccessIntent#

export type RoomAccessIntent = {
    accessMode: 'none' | 'read' | 'reply' | 'custom';
    nativeAccess: JsonObject | null;
    muted: boolean;
};

Related definitions:

RoomFacts#

export type RoomFacts = {
    roomId: string;
    name: string;
    topic: string;
    alias: string | null;
    backendUserId: string;
    canInvite: boolean;
    accessModes: ('read' | 'reply' | 'custom')[];
    authorityRevision: string;
    accessFields: AccessField[];
    permissions: {
        action: string;
        label: string;
        allowed: boolean;
    }[];
};

Related definitions:

RoomMembership#

export type RoomMembership = {
    backendUserId: string;
    displayName: string;
    membership: 'join' | 'invite' | 'leave' | 'ban';
    nativeAccess: JsonObject | null;
};

Related definitions:

RoomInvitation#

export type RoomInvitation = {
    roomId: string;
    eventId: string;
    senderBackendUserId: string;
    direct: boolean;
};

RoomAdmission#

export type RoomAdmission = {
    kind: 'managed';
} | {
    kind: 'invitation';
    eventId: string;
    senderBackendUserId: string;
};

BackendEvent#

export type BackendEvent = {
    eventId: string;
    roomId: string;
    senderBackendUserId: string;
    type: string;
    messageType: string | null;
    body: string | null;
    mentions: string[];
    edited: boolean;
    control: boolean;
};

MessagingAuthority#

export type MessagingAuthority = {
    describe(publicOrigin: string): BackendDescription;
    authenticate(username: string, password: string): Promise<Result<string>>;
    agentAccount(userId: string, accessToken: string): BackendAccount;
    agentUserId(agentId: string): string;
    serviceUserId(): string;
    localLabel(userId: string): string;
    registrationUserId(input: {
        username: string;
        password: string;
        native: JsonObject;
    }): Result<string>;
    identify(token: string): Promise<Result<string>>;
    exists(backendUserId: string): Promise<Result<boolean>>;
    provision(backendUserId: string, password: string, native?: JsonObject): Promise<Result<BackendAccount>>;
    deactivate(backendUserId: string): Promise<Result<void>>;
    discard(backendUserId: string): Promise<Result<void>>;
    profileName(backendUserId: string): Promise<Result<string | null>>;
    setDisplayName(backendUserId: string, displayName: string): Promise<Result<void>>;
    joined(backendUserId: string): Promise<Result<string[]>>;
    ownerConversation(ownerBackendUserId: string, agentBackendUserId: string, roomId: string | null, previousName: string | null): Promise<Result<string>>;
    verifyOwnerConversation(ownerBackendUserId: string, agentBackendUserId: string, roomId: string): Promise<Result<void>>;
    markDirect(backendUserId: string, counterpartBackendUserId: string, roomId: string): Promise<Result<void>>;
    room(backendUserId: string, roomId: string, subjectUserId?: string): Promise<Result<RoomFacts>>;
    membership(backendUserId: string, targetBackendUserId: string, roomId: string): Promise<Result<RoomMembership>>;
    invitation(backendUserId: string, roomId: string): Promise<Result<RoomInvitation | null>>;
    authorizeRoomAccess(authorizerBackendUserId: string, targetBackendUserId: string, roomId: string, intent: RoomAccessIntent): Promise<Result<RoomFacts>>;
    setRoomAccess(authorizerBackendUserId: string, targetBackendUserId: string, roomId: string, intent: RoomAccessIntent, admission: RoomAdmission | null): Promise<Result<RoomMembership>>;
    leave(backendUserId: string, roomId: string): Promise<Result<void>>;
    event(backendUserId: string, roomId: string, eventId: string): Promise<Result<BackendEvent>>;
    sendNotice(backendUserId: string, roomId: string, transactionId: string, body: string, senderBackendUserId: string): Promise<Result<string>>;
    close(): void;
};

Related definitions: