UNPKG

@xmtp/proto

Version:

Protobuf client and generated classes for GRPC API

315 lines 12.6 kB
/* eslint-disable */ import Long from "long"; import { RecoverableEd25519Signature } from "../../identity/associations/signature.pb"; import _m0 from "protobufjs/minimal"; export const protobufPackage = "xmtp.mls.message_contents"; /** * Defines entries on the commit log, used for fork detection and recovery * XIP: https://community.xmtp.org/t/xip-68-draft-automated-fork-recovery/951 */ export var CommitResult; (function (CommitResult) { CommitResult[CommitResult["COMMIT_RESULT_UNSPECIFIED"] = 0] = "COMMIT_RESULT_UNSPECIFIED"; CommitResult[CommitResult["COMMIT_RESULT_APPLIED"] = 1] = "COMMIT_RESULT_APPLIED"; CommitResult[CommitResult["COMMIT_RESULT_WRONG_EPOCH"] = 2] = "COMMIT_RESULT_WRONG_EPOCH"; CommitResult[CommitResult["COMMIT_RESULT_UNDECRYPTABLE"] = 3] = "COMMIT_RESULT_UNDECRYPTABLE"; CommitResult[CommitResult["COMMIT_RESULT_INVALID"] = 4] = "COMMIT_RESULT_INVALID"; CommitResult[CommitResult["UNRECOGNIZED"] = -1] = "UNRECOGNIZED"; })(CommitResult || (CommitResult = {})); export function commitResultFromJSON(object) { switch (object) { case 0: case "COMMIT_RESULT_UNSPECIFIED": return CommitResult.COMMIT_RESULT_UNSPECIFIED; case 1: case "COMMIT_RESULT_APPLIED": return CommitResult.COMMIT_RESULT_APPLIED; case 2: case "COMMIT_RESULT_WRONG_EPOCH": return CommitResult.COMMIT_RESULT_WRONG_EPOCH; case 3: case "COMMIT_RESULT_UNDECRYPTABLE": return CommitResult.COMMIT_RESULT_UNDECRYPTABLE; case 4: case "COMMIT_RESULT_INVALID": return CommitResult.COMMIT_RESULT_INVALID; case -1: case "UNRECOGNIZED": default: return CommitResult.UNRECOGNIZED; } } export function commitResultToJSON(object) { switch (object) { case CommitResult.COMMIT_RESULT_UNSPECIFIED: return "COMMIT_RESULT_UNSPECIFIED"; case CommitResult.COMMIT_RESULT_APPLIED: return "COMMIT_RESULT_APPLIED"; case CommitResult.COMMIT_RESULT_WRONG_EPOCH: return "COMMIT_RESULT_WRONG_EPOCH"; case CommitResult.COMMIT_RESULT_UNDECRYPTABLE: return "COMMIT_RESULT_UNDECRYPTABLE"; case CommitResult.COMMIT_RESULT_INVALID: return "COMMIT_RESULT_INVALID"; case CommitResult.UNRECOGNIZED: default: return "UNRECOGNIZED"; } } function createBasePlaintextCommitLogEntry() { return { groupId: new Uint8Array(), commitSequenceId: Long.UZERO, lastEpochAuthenticator: new Uint8Array(), commitResult: 0, appliedEpochNumber: Long.UZERO, appliedEpochAuthenticator: new Uint8Array(), }; } export const PlaintextCommitLogEntry = { encode(message, writer = _m0.Writer.create()) { if (message.groupId.length !== 0) { writer.uint32(10).bytes(message.groupId); } if (!message.commitSequenceId.isZero()) { writer.uint32(16).uint64(message.commitSequenceId); } if (message.lastEpochAuthenticator.length !== 0) { writer.uint32(26).bytes(message.lastEpochAuthenticator); } if (message.commitResult !== 0) { writer.uint32(32).int32(message.commitResult); } if (!message.appliedEpochNumber.isZero()) { writer.uint32(40).uint64(message.appliedEpochNumber); } if (message.appliedEpochAuthenticator.length !== 0) { writer.uint32(50).bytes(message.appliedEpochAuthenticator); } return writer; }, decode(input, length) { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBasePlaintextCommitLogEntry(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.groupId = reader.bytes(); break; case 2: message.commitSequenceId = reader.uint64(); break; case 3: message.lastEpochAuthenticator = reader.bytes(); break; case 4: message.commitResult = reader.int32(); break; case 5: message.appliedEpochNumber = reader.uint64(); break; case 6: message.appliedEpochAuthenticator = reader.bytes(); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object) { return { groupId: isSet(object.groupId) ? bytesFromBase64(object.groupId) : new Uint8Array(), commitSequenceId: isSet(object.commitSequenceId) ? Long.fromValue(object.commitSequenceId) : Long.UZERO, lastEpochAuthenticator: isSet(object.lastEpochAuthenticator) ? bytesFromBase64(object.lastEpochAuthenticator) : new Uint8Array(), commitResult: isSet(object.commitResult) ? commitResultFromJSON(object.commitResult) : 0, appliedEpochNumber: isSet(object.appliedEpochNumber) ? Long.fromValue(object.appliedEpochNumber) : Long.UZERO, appliedEpochAuthenticator: isSet(object.appliedEpochAuthenticator) ? bytesFromBase64(object.appliedEpochAuthenticator) : new Uint8Array(), }; }, toJSON(message) { const obj = {}; message.groupId !== undefined && (obj.groupId = base64FromBytes(message.groupId !== undefined ? message.groupId : new Uint8Array())); message.commitSequenceId !== undefined && (obj.commitSequenceId = (message.commitSequenceId || Long.UZERO).toString()); message.lastEpochAuthenticator !== undefined && (obj.lastEpochAuthenticator = base64FromBytes(message.lastEpochAuthenticator !== undefined ? message.lastEpochAuthenticator : new Uint8Array())); message.commitResult !== undefined && (obj.commitResult = commitResultToJSON(message.commitResult)); message.appliedEpochNumber !== undefined && (obj.appliedEpochNumber = (message.appliedEpochNumber || Long.UZERO).toString()); message.appliedEpochAuthenticator !== undefined && (obj.appliedEpochAuthenticator = base64FromBytes(message.appliedEpochAuthenticator !== undefined ? message.appliedEpochAuthenticator : new Uint8Array())); return obj; }, fromPartial(object) { var _a, _b, _c, _d; const message = createBasePlaintextCommitLogEntry(); message.groupId = (_a = object.groupId) !== null && _a !== void 0 ? _a : new Uint8Array(); message.commitSequenceId = object.commitSequenceId !== undefined && object.commitSequenceId !== null ? Long.fromValue(object.commitSequenceId) : Long.UZERO; message.lastEpochAuthenticator = (_b = object.lastEpochAuthenticator) !== null && _b !== void 0 ? _b : new Uint8Array(); message.commitResult = (_c = object.commitResult) !== null && _c !== void 0 ? _c : 0; message.appliedEpochNumber = object.appliedEpochNumber !== undefined && object.appliedEpochNumber !== null ? Long.fromValue(object.appliedEpochNumber) : Long.UZERO; message.appliedEpochAuthenticator = (_d = object.appliedEpochAuthenticator) !== null && _d !== void 0 ? _d : new Uint8Array(); return message; }, }; function createBaseCommitLogEntry() { return { sequenceId: Long.UZERO, serializedCommitLogEntry: new Uint8Array(), signature: undefined, }; } export const CommitLogEntry = { encode(message, writer = _m0.Writer.create()) { if (!message.sequenceId.isZero()) { writer.uint32(8).uint64(message.sequenceId); } if (message.serializedCommitLogEntry.length !== 0) { writer.uint32(18).bytes(message.serializedCommitLogEntry); } if (message.signature !== undefined) { RecoverableEd25519Signature.encode(message.signature, writer.uint32(26).fork()).ldelim(); } return writer; }, decode(input, length) { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseCommitLogEntry(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.sequenceId = reader.uint64(); break; case 2: message.serializedCommitLogEntry = reader.bytes(); break; case 3: message.signature = RecoverableEd25519Signature.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object) { return { sequenceId: isSet(object.sequenceId) ? Long.fromValue(object.sequenceId) : Long.UZERO, serializedCommitLogEntry: isSet(object.serializedCommitLogEntry) ? bytesFromBase64(object.serializedCommitLogEntry) : new Uint8Array(), signature: isSet(object.signature) ? RecoverableEd25519Signature.fromJSON(object.signature) : undefined, }; }, toJSON(message) { const obj = {}; message.sequenceId !== undefined && (obj.sequenceId = (message.sequenceId || Long.UZERO).toString()); message.serializedCommitLogEntry !== undefined && (obj.serializedCommitLogEntry = base64FromBytes(message.serializedCommitLogEntry !== undefined ? message.serializedCommitLogEntry : new Uint8Array())); message.signature !== undefined && (obj.signature = message.signature ? RecoverableEd25519Signature.toJSON(message.signature) : undefined); return obj; }, fromPartial(object) { var _a; const message = createBaseCommitLogEntry(); message.sequenceId = object.sequenceId !== undefined && object.sequenceId !== null ? Long.fromValue(object.sequenceId) : Long.UZERO; message.serializedCommitLogEntry = (_a = object.serializedCommitLogEntry) !== null && _a !== void 0 ? _a : new Uint8Array(); message.signature = object.signature !== undefined && object.signature !== null ? RecoverableEd25519Signature.fromPartial(object.signature) : undefined; return message; }, }; var globalThis = (() => { if (typeof globalThis !== "undefined") return globalThis; if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; throw "Unable to locate global object"; })(); function bytesFromBase64(b64) { if (globalThis.Buffer) { return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); for (let i = 0; i < bin.length; ++i) { arr[i] = bin.charCodeAt(i); } return arr; } } function base64FromBytes(arr) { if (globalThis.Buffer) { return globalThis.Buffer.from(arr).toString("base64"); } else { const bin = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); return globalThis.btoa(bin.join("")); } } if (_m0.util.Long !== Long) { _m0.util.Long = Long; _m0.configure(); } function isSet(value) { return value !== null && value !== undefined; } //# sourceMappingURL=commit_log.pb.js.map