import type { GeneralJws } from '../types/jws-types.js';
import type { KeyValues } from '../types/query-types.js';
import type { MessageInterface } from '../types/message-interface.js';
import type { MessageSigner } from '../types/signer.js';
import type { MessageStore } from '../types/message-store.js';
import type { ValidationStateReader } from '../types/validation-state-reader.js';
import type { DataEncodedRecordsWriteMessage, InternalRecordsWriteMessage, RecordsWriteDescriptor, RecordsWriteMessage, RecordsWriteSignaturePayload, RecordsWriteTags } from '../types/records-types.js';
import type { DwnEncryption, EncryptionInput } from '../utils/encryption.js';
import type { GenericMessage, GenericSignaturePayload } from '../types/message-types.js';
export type RecordsWriteOptions = {
    recipient?: string;
    protocol: string;
    protocolPath: string;
    protocolRole?: string;
    schema?: string;
    tags?: RecordsWriteTags;
    recordId?: string;
    /**
     * Must be given if this message is for a non-root protocol record.
     * If not given, it means this write is for a root protocol record.
     */
    parentContextId?: string;
    data?: Uint8Array;
    dataCid?: string;
    dataSize?: number;
    dateCreated?: string;
    messageTimestamp?: string;
    published?: boolean;
    datePublished?: string;
    dataFormat: string;
    /**
     * The signer of the message, which is commonly the author, but can also be a delegate.
     */
    signer?: MessageSigner;
    /**
     * The delegated grant invoked to sign on behalf of the logical author, which is the grantor of the delegated grant.
     */
    delegatedGrant?: DataEncodedRecordsWriteMessage;
    attestationSigners?: MessageSigner[];
    /**
     * Pre-built encryption envelope. Use `encryptionInput` when wrapping a CEK from plaintext/ciphertext inputs.
     */
    encryption?: DwnEncryption;
    encryptionInput?: EncryptionInput;
    permissionGrantId?: string;
    /**
     * When `true`, this record is a squash (snapshot) write that atomically creates a snapshot
     * and deletes all older sibling records at the same protocol path within the same parent context.
     * Only valid at protocol paths with `$squash: true`. Must be an initial write (new record).
     */
    squash?: true;
};
export type { EncryptionInput, KeyEncryptionInput, ProtocolPathKeyEncryptionInput, RoleAudienceKeyEncryptionInput, } from '../utils/encryption.js';
export type CreateFromOptions = {
    recordsWriteMessage: RecordsWriteMessage;
    data?: Uint8Array;
    /**
     * The data format of the new data. If not given, the data format from the existing message will be used.
     */
    dataFormat?: string;
    published?: boolean;
    tags?: RecordsWriteTags;
    messageTimestamp?: string;
    datePublished?: string;
    /**
     * The signer of the message, which is commonly the author, but can also be a delegate.
     */
    signer?: MessageSigner;
    /**
     * The delegated grant to sign on behalf of the logical author, which is the grantor (`grantedBy`) of the delegated grant.
     */
    delegatedGrant?: DataEncodedRecordsWriteMessage;
    attestationSigners?: MessageSigner[];
    encryptionInput?: EncryptionInput;
    protocolRole?: string;
};
/**
 * A class representing a RecordsWrite DWN message.
 * NOTE: Unable to extend `AbstractMessage` directly because the incompatible `_message` type, which is not just a generic `<M>` type.
 */
export declare class RecordsWrite implements MessageInterface<RecordsWriteMessage> {
    private readonly parentContextId;
    private readonly _message;
    /**
     * Valid JSON message representing this RecordsWrite.
     * @throws `DwnErrorCode.RecordsWriteMissingSigner` if the message is not signed yet.
     */
    get message(): RecordsWriteMessage;
    private _author;
    get author(): string | undefined;
    private _signaturePayload;
    get signaturePayload(): RecordsWriteSignaturePayload | undefined;
    private _owner;
    /**
     * The owner DID of the message if owner signature is present in the message; `undefined` otherwise.
     * This is the logical owner of the message, not to be confused with the actual signer of the owner signature,
     * this is because the signer of the owner signature may not be the actual DWN owner, but a delegate authorized by the owner.
     */
    get owner(): string | undefined;
    private _ownerSignaturePayload;
    /**
     * Decoded owner signature payload.
     */
    get ownerSignaturePayload(): GenericSignaturePayload | undefined;
    /**
     * If this message is signed by an author-delegate.
     */
    get isSignedByAuthorDelegate(): boolean;
    /**
     * If this message is signed by an owner-delegate.
     */
    get isSignedByOwnerDelegate(): boolean;
    /**
     * Gets the signer of this message.
     * This is not to be confused with the logical author of the message.
     */
    get signer(): string | undefined;
    /**
     * Gets the signer of owner signature; `undefined` if owner signature is not present in the message.
     * This is not to be confused with the logical owner {@link #owner} of the message,
     * this is because the signer of the owner signature may not be the actual DWN owner, but a delegate authorized by the owner.
     * In the case that the owner signature is signed by the actual DWN owner, this value will be the same as {@link #owner}.
     */
    get ownerSignatureSigner(): string | undefined;
    readonly attesters: string[];
    private constructor();
    /**
     * Parses a RecordsWrite message and returns a {RecordsWrite} instance.
     */
    static parse(recordsWriteMessage: RecordsWriteMessage): Promise<RecordsWrite>;
    /**
     * Creates a RecordsWrite message.
     * @param options.recordId If `undefined`, will be auto-filled as the initial message as convenience for developer.
     * @param options.data Data used to compute the `dataCid`, must be the encrypted data bytes if `options.encryptionInput` is given.
     *                     Must specify `options.dataCid` if `undefined`.
     * @param options.dataCid CID of the data that is already stored in the DWN. Must specify `options.data` if `undefined`.
     * @param options.dataSize Size of data in number of bytes. Must be defined if `options.dataCid` is defined; must be `undefined` otherwise.
     * @param options.dateCreated If `undefined`, it will be auto-filled with current time.
     * @param options.messageTimestamp If `undefined`, it will be auto-filled with current time.
     * @param options.parentContextId Must be given if this message is for a non-root protocol record.
     *                                If not given, it means this write is for a root protocol record.
     */
    static create(options: RecordsWriteOptions): Promise<RecordsWrite>;
    private static validateCreateOptions;
    private static getRecordIdFromContextId;
    /**
     * Convenience method that creates a message by:
     * 1. Copying over immutable properties from the given source message
     * 2. Copying over mutable properties that are not overwritten from the given source message
     * 3. Replace the mutable properties that are given new value
     * @param options.recordsWriteMessage Message that the new RecordsWrite will be based from.
     * @param options.messageTimestamp The new date the record is modified. If not given, current time will be used .
     * @param options.data The new data or the record. If not given, data from given message will be used.
     * @param options.published The new published state. If not given, then will be set to `true` if {options.messageTimestamp} is given;
     * else the state from given message will be used.
     * @param options.publishedDate The new date the record is modified. If not given, then:
     * - will not be set if the record will be unpublished as the result of this RecordsWrite; else
     * - will be set to the same published date as the given message if it wss already published; else
     * - will be set to current time (because this is a toggle from unpublished to published)
     */
    static createFrom(options: CreateFromOptions): Promise<RecordsWrite>;
    /**
     * Validates the expected `dataCid` and `dataSize` in the descriptor against the actual data.
     *
     * @throws {DwnError} with `DwnErrorCode.RecordsWriteDataCidMismatch`
     *                    if the actual data CID does not match `dataCid` in the descriptor.
     * @throws {DwnError} with `DwnErrorCode.RecordsWriteDataSizeMismatch`
     *                    if the actual byte size does not match `dataSize` in the descriptor.
     */
    static validateDataIntegrity(expectedDataCid: string, expectedDataSize: number, actualDataCid: string, actualDataSize: number): void;
    /**
     * Called by `JSON.stringify(...)` automatically.
     */
    toJSON(): RecordsWriteMessage;
    /**
     * Encrypts the symmetric encryption key using the public keys given and attaches the resulting `encryption` property.
     */
    encryptSymmetricEncryptionKey(encryptionInput: EncryptionInput): Promise<void>;
    /**
     * Signs the RecordsWrite, the signer is commonly the author, but can also be a delegate.
     */
    sign(options: {
        signer: MessageSigner;
        delegatedGrant?: DataEncodedRecordsWriteMessage;
        permissionGrantId?: string;
        protocolRole?: string;
    }): Promise<void>;
    /**
     * Signs the `RecordsWrite` as the DWN owner.
     * This is used when the DWN owner wants to retain a copy of a message that the owner did not author.
     * NOTE: requires the `RecordsWrite` to already have the author's signature.
     */
    signAsOwner(signer: MessageSigner): Promise<void>;
    /**
     * Signs the `RecordsWrite` as the DWN owner-delegate.
     * This is used when a DWN owner-delegate wants to retain a copy of a message that the owner did not author.
     * NOTE: requires the `RecordsWrite` to already have the author's signature.
     */
    signAsOwnerDelegate(signer: MessageSigner, delegatedGrant: DataEncodedRecordsWriteMessage): Promise<void>;
    /**
     * Validates the integrity of the RecordsWrite message assuming the message passed basic schema validation.
     * There is opportunity to integrate better with `validateSchema(...)`
     */
    private validateIntegrity;
    /**
     * Computes the deterministic Entry ID of this message.
     */
    getEntryId(): Promise<string>;
    /**
     * Computes the deterministic Entry ID of this message.
     */
    static getEntryId(author: string | undefined, descriptor: RecordsWriteDescriptor): Promise<string>;
    /**
     * Checks if the given message is the initial entry of a record.
     */
    isInitialWrite(): Promise<boolean>;
    constructIndexes(isLatestBaseState: boolean): Promise<KeyValues>;
    /**
     * Authorizes the author-delegate who signed this message.
     * @param validationStateReader Used to check if the grant has been revoked.
     */
    authorizeAuthorDelegate(validationStateReader: ValidationStateReader): Promise<void>;
    /**
     * Authorizes the owner-delegate who signed this message.
     * @param validationStateReader Used to check if the grant has been revoked.
     */
    authorizeOwnerDelegate(validationStateReader: ValidationStateReader): Promise<void>;
    /**
     * Checks if the given message is the initial entry of a record.
     */
    static isInitialWrite(message: GenericMessage): Promise<boolean>;
    /** Delegate to `createAttestation` in `records-write-signing.ts`. */
    static createAttestation(descriptorCid: string, signers?: MessageSigner[]): Promise<GeneralJws | undefined>;
    /** Delegate to `createSignerSignature` in `records-write-signing.ts`. */
    static createSignerSignature(input: {
        recordId: string;
        contextId: string;
        descriptorCid: string;
        attestation: GeneralJws | undefined;
        encryption: DwnEncryption | undefined;
        signer: MessageSigner;
        delegatedGrantId?: string;
        permissionGrantId?: string;
        protocolRole?: string;
    }): Promise<GeneralJws>;
    /** Delegate to `getInitialWrite` in `records-write-query.ts`. */
    static getInitialWrite(messages: GenericMessage[]): Promise<RecordsWriteMessage>;
    /** Delegate to `verifyEqualityOfImmutableProperties` in `records-write-query.ts`. */
    static verifyEqualityOfImmutableProperties(existingWriteMessage: RecordsWriteMessage, newMessage: RecordsWriteMessage): boolean;
    /** Delegate to `getAttesters` in `records-write-query.ts`. */
    static getAttesters(message: InternalRecordsWriteMessage): string[];
    /** Delegate to `fetchNewestRecordsWrite` in `records-write-query.ts`. */
    static fetchNewestRecordsWrite(messageStore: MessageStore, tenant: string, recordId: string): Promise<RecordsWriteMessage>;
    /** Delegate to `fetchInitialRecordsWrite` in `records-write-query.ts`. */
    static fetchInitialRecordsWrite(messageStore: MessageStore, tenant: string, recordId: string): Promise<RecordsWrite | undefined>;
    /** Delegate to `fetchInitialRecordsWriteMessage` in `records-write-query.ts`. */
    static fetchInitialRecordsWriteMessage(messageStore: MessageStore, tenant: string, recordId: string): Promise<RecordsWriteMessage | undefined>;
}
//# sourceMappingURL=records-write.d.ts.map