export declare const CANONICAL_MAX_BYTES = 8192;
export declare const CLOCK_SKEW_MS = 300000;
export declare const SUPPORTED_VERSIONS: readonly [1];
export declare const SUPPORTED_SUITES: readonly ["verus-signmessage-v1"];
export declare const ACTIONS: readonly ["request-access", "review-api-session", "review-submit", "budget-request"];
export type Action = typeof ACTIONS[number];
/** Per-action maximum (expiresAt - issuedAt), in milliseconds. Matches backend verifier table. */
export declare const ACTION_MAX_WINDOW_MS: Record<Action, number>;
export interface EnvelopeV1 {
    version: 1;
    cryptoSuite: 'verus-signmessage-v1';
    action: Action;
    buyer: {
        iaddress: string;
        name?: string;
    };
    seller: {
        iaddress: string;
        name?: string;
    };
    payload: Record<string, unknown>;
    contentHash?: {
        alg: 'sha256';
        digest: string;
    };
    nonce: string;
    issuedAt: string;
    expiresAt: string;
}
export interface SignedEnvelopeV1 {
    envelope: EnvelopeV1;
    signatures: string[];
}
export type CanonicalErrorCode = 'INVALID_BODY' | 'CANONICAL_TOO_LARGE' | 'UNEXPECTED_FIELD' | 'UNSUPPORTED_VERSION' | 'UNSUPPORTED_SUITE' | 'UNKNOWN_ACTION' | 'EXPIRES_BEFORE_ISSUED' | 'EXPIRES_TOO_FAR' | 'EXPIRED' | 'ISSUED_IN_FUTURE' | 'NAME_IADDRESS_MISMATCH' | 'CONTENT_HASH_MISMATCH' | 'NONCE_REPLAY' | 'RPC_UNAVAILABLE' | 'INVALID_SIGNATURE';
export declare class CanonicalError extends Error {
    readonly code: CanonicalErrorCode;
    constructor(code: CanonicalErrorCode, message: string);
}
/**
 * Canonicalize an envelope to RFC 8785 (JCS) bytes.
 * Used for both signing (producer) and verifying (consumer). Both sides MUST agree
 * byte-for-byte; the backend's golden vector in docs/spec/api-session-signing-v2.md
 * is the reference.
 *
 * Throws CANONICAL_TOO_LARGE if output exceeds CANONICAL_MAX_BYTES.
 */
export declare function canonicalBytes(envelope: EnvelopeV1): Buffer;
/**
 * Validate envelope shape and window rules. Throws CanonicalError on any violation.
 * Mirrors steps 3–10 of the backend verifier flow.
 *
 * @param now - override for "now" in ms; defaults to Date.now(). Lets tests inject deterministic time.
 */
export declare function validateEnvelope(envelope: EnvelopeV1, now?: number): void;
/**
 * Build a canonical-v1 envelope and sign it.
 *
 * @param wif - buyer's WIF (primary signing key for the i-address)
 * @param envelope - fully-constructed EnvelopeV1 object
 * @param network - 'verus' or 'verustest'
 * @returns { envelope, signatures: [base64] } — ready to POST as the request body
 *
 * The caller is responsible for building the envelope's payload, nonce, and timestamps.
 * For multisig identities, call signMessage separately for each co-signer and merge
 * signatures array — verifier sums over minimumsignatures.
 */
export declare function signCanonical(wif: string, envelope: EnvelopeV1, network?: 'verus' | 'verustest'): SignedEnvelopeV1;
/** Convenience for the common request-access path — generates nonce + timestamps. */
export declare function buildRequestAccessEnvelope(params: {
    buyerIAddress: string;
    buyerName?: string;
    sellerIAddress: string;
    sellerName?: string;
    ephemeralPubKey: string;
    ttlSeconds?: number;
}): EnvelopeV1;
/**
 * SDK-side format counter per spec §Telemetry.
 * Implementation: structured log line on stderr. Operators can scrape logs into Prometheus
 * via promtail / fluentbit without an in-process Prom client dependency.
 */
declare let _metricEmitter: (e: {
    event: string;
    format: string;
    cryptoSuite: string;
    action: string;
}) => void;
export declare function setMetricEmitter(fn: typeof _metricEmitter): void;
/** Exported for v1 callsites to increment the counter when they still emit v1. */
export declare function recordV1FormatEmission(action: string): void;
/**
 * Verify the signatures on a v2 canonical envelope using the public J41 keys-resolver
 * endpoint (`GET /v1/identity/:idOrName/keys`).
 *
 * Steps:
 *   1. Canonicalize the envelope to bytes (idempotent JCS).
 *   2. Resolve `envelope.buyer.iaddress` via `client.getIdentityKeys()` → primary
 *      R-addresses + minimumSignatures threshold.
 *   3. For each address, find at most one signature from `signatures` that validates
 *      against it via bitcoinjs-message. Count distinct addresses that validated.
 *   4. Pass iff that count is ≥ minimumSignatures.
 *
 * No fallthrough: if the keys endpoint is unreachable, the resolved address list is
 * empty, or fewer signatures validate than the threshold requires, returns false.
 *
 * Structural validation (size, fields, windows) is NOT done here — call
 * validateEnvelope() first. This function assumes the envelope is well-formed.
 *
 * @param envelope - validated canonical envelope
 * @param signatures - base64 signatures over canonicalBytes(envelope)
 * @param client - must expose getIdentityKeys(idOrName) returning { primaryAddresses, minimumSignatures }
 * @param network - 'verus' or 'verustest'
 */
export declare function verifyCanonicalSignatures(envelope: EnvelopeV1, signatures: string[], client: {
    getIdentityKeys(idOrName: string): Promise<{
        primaryAddresses: string[];
        minimumSignatures: number;
    }>;
}, network?: 'verus' | 'verustest'): Promise<boolean>;
export {};
//# sourceMappingURL=canonical.d.ts.map