import type { WireProfileName } from './topics';
/**
 * Matrix Envelope Types
 *
 * CANONICAL SOURCE: packages/matrix-transport/src/interfaces/MxEnvelopeV1.ts
 *
 * This file maintains federation-specific types that extend/wrap the canonical
 * MxEnvelopeV1 format. The types here are kept in sync with matrix-transport.
 *
 * Migration path:
 * - New code should use matrix-transport MxEnvelopeV1 when possible
 * - Legacy code can continue using CrossRealmEnvelopeLegacy/ReplyEnvelopeLegacy
 * - The envelope_codec.ts provides translation between formats
 */
export interface CrossRealmEnvelopeLegacy {
    toRoot: string;
    toPath: string;
    fromRoot: string;
    replyTo: string;
    correlationId: string;
    idempotencyKey?: string;
    body: unknown;
    timestamp?: string;
    ttlMs?: number;
    traceId?: string;
    /** OPTIONAL extension to support events without switching profile */
    type?: 'request' | 'event';
    /** @deprecated Use toRoot */
    toRealm?: string;
    /** @deprecated Use fromRoot */
    fromRealm?: string;
}
export interface ReplyEnvelopeLegacy {
    toRoot: string;
    toPath: string;
    fromRoot: string;
    correlationId: string;
    body: unknown;
    ok: boolean;
    error?: {
        code: string;
        message: string;
        details?: unknown;
    };
    timestamp?: string;
    traceId?: string;
    /** OPTIONAL explicit discriminator */
    type?: 'reply';
    /** @deprecated Use toRoot */
    toRealm?: string;
    /** @deprecated Use fromRoot */
    fromRealm?: string;
}
export type MxMsgType = 'Cmd' | 'Evt' | 'Result' | 'Sub' | 'Unsub' | 'Nack';
export interface MxAddress {
    root: string;
    path: string;
    /** @deprecated Use root instead */
    realm?: string;
}
export interface MxPrincipal {
    kind: 'anon' | 'jwt' | 'service';
    iss?: string;
    sub?: string;
    aud?: string[];
    scopes?: string[];
}
export interface MxAuth {
    bearer?: string;
    capability?: string;
}
export interface MxEnvelopeV1 {
    ver: 1;
    msgType: MxMsgType;
    msgId: string;
    timestamp: string;
    correlationId?: string;
    to: MxAddress;
    from: MxAddress;
    replyTo?: MxAddress;
    ttl?: number;
    principal?: MxPrincipal;
    auth?: MxAuth;
    traceId?: string;
    spanId?: string;
    parentSpanId?: string;
    body: unknown;
    ok?: boolean;
    error?: {
        code: string;
        message: string;
        details?: unknown;
    };
}
export type TaggedEnvelope = {
    profile: 'mxenv1';
    envelope: MxEnvelopeV1;
} | {
    profile: 'matrix3';
    kind: 'request';
    envelope: CrossRealmEnvelopeLegacy;
} | {
    profile: 'matrix3';
    kind: 'reply';
    envelope: ReplyEnvelopeLegacy;
};
export interface WireContext {
    profile: WireProfileName;
}
//# sourceMappingURL=envelope.d.ts.map