/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { UnexpectedDataError } from "../MatterError.js";
import { Bytes } from "../util/Bytes.js";
export declare class DerError extends UnexpectedDataError {
}
export declare enum DerType {
    Boolean = 1,
    Integer = 2,
    BitString = 3,
    OctetString = 4,
    Null = 5,
    ObjectIdentifier = 6,
    UTF8String = 12,
    Sequence = 16,
    Set = 17,
    PrintableString = 19,
    T16String = 20,
    IA5String = 22,
    UtcDate = 23,
    GeneralizedTime = 24
}
export interface ObjectId {
    _tag: DerType.ObjectIdentifier;
    _bytes: Bytes;
}
export declare const ObjectId: (objectId: string | bigint) => ObjectId;
export interface DerObject {
    readonly _tag?: undefined;
    readonly _objectId: ObjectId;
    readonly [field: string]: unknown;
}
export declare const DerObject: (objectId: string | bigint, content?: Record<string, unknown>) => DerObject;
export interface DerTagged {
    _tag: number;
    _bytes: Bytes;
}
export interface DerBitString extends DerTagged {
    _tag: DerType.BitString;
    _bytes: Bytes;
    _padding: number;
}
export declare const DerBitString: (data: Bytes, padding?: number) => DerBitString;
export declare const ContextTagged: (tagId: number, value?: any) => DerTagged;
export declare const ContextTaggedBytes: (tagId: number, value: Bytes) => DerTagged;
export type DatatypeOverride = {
    _tag?: undefined;
    _type: DerType.Integer;
    _raw: Bytes;
} | {
    _tag?: undefined;
    _type: DerType.BitString;
    _raw: number;
} | {
    _tag?: undefined;
    _type: DerType.PrintableString | DerType.IA5String;
    _raw: string;
};
export declare const DatatypeOverride: <T extends DatatypeOverride["_type"]>(type: T, value: (DatatypeOverride & {
    _type: T;
})["_raw"]) => DatatypeOverride;
export interface RawBytes {
    _bytes: Bytes;
}
export declare const RawBytes: (bytes: Bytes) => RawBytes;
/**
 * Optimized path for encoding raw bytes that represent an unsigned integer.
 *
 * This allows to avoid e.g. round tripping a 256-bit number through a bigint when encoding.
 */
export declare const DerRawUint: (number: Bytes) => DerTagged;
export type DerNode = {
    _tag: number;
    _bytes: Bytes;
    _elements?: DerNode[];
    _padding?: number;
};
/**
 * Arrays define a DER set.
 */
export type DerSetDefinition = Array<DerNodeDefinition>;
/**
 * Objects without special fields define an "object".
 *
 * Under this somewhat strange construct, the field name is effectively just documentation.  The object order and
 * ObjectID of the referenced nodes define the actual serialized format.
 */
export type DerSequenceDefinition = {
    _tag?: undefined;
    _type?: undefined;
    _bytes?: undefined;
    _objectId?: ObjectId;
    [field: string]: DerNodeDefinition;
};
/**
 * Input to {@link DerCodec.encode}.
 *
 * This is a lenient mapping of native JS types we accept on encoding.  We map each of these to a {@link DerNode} and
 * then encode.
 */
export type DerNodeDefinition = string | number | bigint | Date | boolean | Bytes | undefined | DerNode | DerSetDefinition | DerSequenceDefinition | DerObject | RawBytes | DatatypeOverride;
export declare class DerCodec {
    #private;
    static encode(value: DerNodeDefinition): Bytes;
    static decode(data: Bytes): DerNode;
    /**
     * Extract a large integer value to a byte array with a specific number of bytes.
     */
    static decodeBigUint(value: DerNode | undefined, byteLength: number): AllowSharedBufferSource;
}
//# sourceMappingURL=DerCodec.d.ts.map