import { ISequencedDocumentMessage , ISequencedDocumentSystemMessage } from "@fluidframework/protocol-definitions" ; import { str } from "crc-32" ; export const defaultHash = "00000000" ; const clientIdProperty = "clientId" ; const sequenceNumberProperty = "sequenceNumber" ; const minimumSequenceNumberProperty = "minimumSequenceNumber" ; const clientSequenceNumberProperty = "clientSequenceNumber" ; const referenceSequenceNumberProperty = "referenceSequenceNumber" ; const typeProperty = "type" ; const timestampProperty = "timestamp" ; const dataProperty = "data" ; const fields = [ clientIdProperty , sequenceNumberProperty , minimumSequenceNumberProperty , clientSequenceNumberProperty , referenceSequenceNumberProperty , typeProperty , timestampProperty , dataProperty , ] ; export function getNextHash ( message , lastHash ) { const messageWithData = message as ISequencedDocumentSystemMessage ; const serializedMessage = JSON . stringify ( messageWithData , fields ) ; const hash = str ( serializedMessage , parseInt ( lastHash , 16 ) ) ; return hash . toString ( 16 ) ; }