///
import DidPublicKeyModel from '../latest/models/DidPublicKeyModel';
import DocumentModel from './models/DocumentModel';
/**
* Sidetree operation types.
*/
export declare enum OperationType {
Create = "create",
Update = "update",
Delete = "delete",
Recover = "recover"
}
/**
* A class that represents a Sidetree operation.
* The primary purphose of this class is to provide an abstraction to the underlying JSON data structure.
*
* NOTE: Design choices of:
* 1. No subclassing of specific operations. The intention here is to keep the hierarchy flat, as most properties are common.
* 2. Factory method to hide constructor in case subclassing becomes useful in the future. Most often a good practice anyway.
*/
export default class Operation {
/** The original request buffer sent by the requester. */
readonly operationBuffer: Buffer;
/** The encoded protected header. */
readonly encodedProtectedHeader: string;
/** The encoded operation payload. */
readonly encodedPayload: string;
/**
* The unique suffix of the DID of the DID document to be created/updated.
* If this is a create operation waiting to be anchored, a DID unique suffix will be generated based on the current blockchain time.
*/
readonly didUniqueSuffix: string;
/** Hash of the operation based on the encoded payload string. */
readonly operationHash: string;
/** The type of operation. */
readonly type: OperationType;
/** The hash of the previous operation - undefined for DID create operation */
readonly previousOperationHash?: string;
/** ID of the key used to sign this operation. */
readonly signingKeyId: string;
/** Signature of this operation. */
readonly signature: string;
/** DID document given in the operation, only applicable to create and recovery operations, undefined otherwise. */
readonly didDocument?: DocumentModel;
/** Patches to the DID Document, only applicable to update operations, undefined otherwise. */
readonly patches?: any[];
/**
* Constructs an Operation if the operation buffer passes schema validation, throws error otherwise.
* NOTE: Would love to mark this constructor private to prevent direct calls, but need it to be public for `AnchoredOperation` to inherit from.
*/
constructor(operationBuffer: Buffer);
/**
* Creates an Operation that has not been anchored on the blockchain.
* @throws Error if given operation buffer fails any validation.
*/
static create(operationBuffer: Buffer): Operation;
/**
* Verifies the operation is signed correctly.
* @param publicKey The public key used for verification.
* @returns true if signature is successfully verified, false otherwise.
*/
verifySignature(publicKey: DidPublicKeyModel): Promise;
/**
* Computes the cryptographic multihash of the given string.
*/
private static computeHash;
/**
* Applies the given patches in order to the given DID Document.
* NOTE: Assumes no schema validation is needed.
*/
static applyPatchesToDidDocument(didDocument: DocumentModel, patches: any[]): void;
/**
* Applies the given patch to the given DID Document.
*/
private static applyPatchToDidDocument;
/**
* Parses and validates the given operation object object.
* NOTE: Operation validation does not include signature verification.
* @returns [decoded protected header JSON object, decoded payload JSON object] if given operation JWS is valid, Error is thrown otherwise.
*/
private static parseAndValidateOperation;
/**
* Validates the schema given update operation payload.
* @throws Error if given operation payload fails validation.
*/
static validateUpdatePayload(payload: any): void;
private static validateUpdatePatches;
private static validateUpdatePatch;
private static validateAddPublicKeysPatch;
private static validateRemovePublicKeysPatch;
/**
* Validates update patch for either adding or removing service endpoints.
*/
private static validateServiceEndpointsPatch;
}