UNPKG

@xmtp/proto

Version:

Protobuf client and generated classes for GRPC API

319 lines (318 loc) 12.7 kB
// Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v1.181.2 // protoc v3.21.12 // source: mls/message_contents/commit_log.proto /* eslint-disable */ import Long from "long"; import _m0 from "protobufjs/minimal"; import { RecoverableEd25519Signature } from "../../identity/associations/signature.pb"; 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(0), commitSequenceId: Long.UZERO, lastEpochAuthenticator: new Uint8Array(0), commitResult: 0, appliedEpochNumber: Long.UZERO, appliedEpochAuthenticator: new Uint8Array(0), }; } export const PlaintextCommitLogEntry = { encode(message, writer = _m0.Writer.create()) { if (message.groupId.length !== 0) { writer.uint32(10).bytes(message.groupId); } if (!message.commitSequenceId.equals(Long.UZERO)) { 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.equals(Long.UZERO)) { 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 : _m0.Reader.create(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: if (tag !== 10) { break; } message.groupId = reader.bytes(); continue; case 2: if (tag !== 16) { break; } message.commitSequenceId = reader.uint64(); continue; case 3: if (tag !== 26) { break; } message.lastEpochAuthenticator = reader.bytes(); continue; case 4: if (tag !== 32) { break; } message.commitResult = reader.int32(); continue; case 5: if (tag !== 40) { break; } message.appliedEpochNumber = reader.uint64(); continue; case 6: if (tag !== 50) { break; } message.appliedEpochAuthenticator = reader.bytes(); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { groupId: isSet(object.groupId) ? bytesFromBase64(object.groupId) : new Uint8Array(0), commitSequenceId: isSet(object.commitSequenceId) ? Long.fromValue(object.commitSequenceId) : Long.UZERO, lastEpochAuthenticator: isSet(object.lastEpochAuthenticator) ? bytesFromBase64(object.lastEpochAuthenticator) : new Uint8Array(0), 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(0), }; }, toJSON(message) { const obj = {}; if (message.groupId.length !== 0) { obj.groupId = base64FromBytes(message.groupId); } if (!message.commitSequenceId.equals(Long.UZERO)) { obj.commitSequenceId = (message.commitSequenceId || Long.UZERO).toString(); } if (message.lastEpochAuthenticator.length !== 0) { obj.lastEpochAuthenticator = base64FromBytes(message.lastEpochAuthenticator); } if (message.commitResult !== 0) { obj.commitResult = commitResultToJSON(message.commitResult); } if (!message.appliedEpochNumber.equals(Long.UZERO)) { obj.appliedEpochNumber = (message.appliedEpochNumber || Long.UZERO).toString(); } if (message.appliedEpochAuthenticator.length !== 0) { obj.appliedEpochAuthenticator = base64FromBytes(message.appliedEpochAuthenticator); } return obj; }, create(base) { return PlaintextCommitLogEntry.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBasePlaintextCommitLogEntry(); message.groupId = object.groupId ?? new Uint8Array(0); message.commitSequenceId = (object.commitSequenceId !== undefined && object.commitSequenceId !== null) ? Long.fromValue(object.commitSequenceId) : Long.UZERO; message.lastEpochAuthenticator = object.lastEpochAuthenticator ?? new Uint8Array(0); message.commitResult = object.commitResult ?? 0; message.appliedEpochNumber = (object.appliedEpochNumber !== undefined && object.appliedEpochNumber !== null) ? Long.fromValue(object.appliedEpochNumber) : Long.UZERO; message.appliedEpochAuthenticator = object.appliedEpochAuthenticator ?? new Uint8Array(0); return message; }, }; function createBaseCommitLogEntry() { return { sequenceId: Long.UZERO, serializedCommitLogEntry: new Uint8Array(0), signature: undefined }; } export const CommitLogEntry = { encode(message, writer = _m0.Writer.create()) { if (!message.sequenceId.equals(Long.UZERO)) { 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 : _m0.Reader.create(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: if (tag !== 8) { break; } message.sequenceId = reader.uint64(); continue; case 2: if (tag !== 18) { break; } message.serializedCommitLogEntry = reader.bytes(); continue; case 3: if (tag !== 26) { break; } message.signature = RecoverableEd25519Signature.decode(reader, reader.uint32()); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { sequenceId: isSet(object.sequenceId) ? Long.fromValue(object.sequenceId) : Long.UZERO, serializedCommitLogEntry: isSet(object.serializedCommitLogEntry) ? bytesFromBase64(object.serializedCommitLogEntry) : new Uint8Array(0), signature: isSet(object.signature) ? RecoverableEd25519Signature.fromJSON(object.signature) : undefined, }; }, toJSON(message) { const obj = {}; if (!message.sequenceId.equals(Long.UZERO)) { obj.sequenceId = (message.sequenceId || Long.UZERO).toString(); } if (message.serializedCommitLogEntry.length !== 0) { obj.serializedCommitLogEntry = base64FromBytes(message.serializedCommitLogEntry); } if (message.signature !== undefined) { obj.signature = RecoverableEd25519Signature.toJSON(message.signature); } return obj; }, create(base) { return CommitLogEntry.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseCommitLogEntry(); message.sequenceId = (object.sequenceId !== undefined && object.sequenceId !== null) ? Long.fromValue(object.sequenceId) : Long.UZERO; message.serializedCommitLogEntry = object.serializedCommitLogEntry ?? new Uint8Array(0); message.signature = (object.signature !== undefined && object.signature !== null) ? RecoverableEd25519Signature.fromPartial(object.signature) : undefined; return message; }, }; 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(globalThis.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; }