UNPKG

@xmtp/proto

Version:

Protobuf client and generated classes for GRPC API

117 lines (116 loc) 4.13 kB
"use strict"; // Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v1.181.2 // protoc v3.21.12 // source: message_contents/signed_payload.proto var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.SignedPayload = exports.protobufPackage = void 0; /* eslint-disable */ const long_1 = __importDefault(require("long")); const minimal_1 = __importDefault(require("protobufjs/minimal")); const signature_pb_1 = require("./signature.pb"); exports.protobufPackage = "xmtp.message_contents"; function createBaseSignedPayload() { return { payload: new Uint8Array(0), signature: undefined }; } exports.SignedPayload = { encode(message, writer = minimal_1.default.Writer.create()) { if (message.payload.length !== 0) { writer.uint32(10).bytes(message.payload); } if (message.signature !== undefined) { signature_pb_1.Signature.encode(message.signature, writer.uint32(18).fork()).ldelim(); } return writer; }, decode(input, length) { const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSignedPayload(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.payload = reader.bytes(); continue; case 2: if (tag !== 18) { break; } message.signature = signature_pb_1.Signature.decode(reader, reader.uint32()); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { payload: isSet(object.payload) ? bytesFromBase64(object.payload) : new Uint8Array(0), signature: isSet(object.signature) ? signature_pb_1.Signature.fromJSON(object.signature) : undefined, }; }, toJSON(message) { const obj = {}; if (message.payload.length !== 0) { obj.payload = base64FromBytes(message.payload); } if (message.signature !== undefined) { obj.signature = signature_pb_1.Signature.toJSON(message.signature); } return obj; }, create(base) { return exports.SignedPayload.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseSignedPayload(); message.payload = object.payload ?? new Uint8Array(0); message.signature = (object.signature !== undefined && object.signature !== null) ? signature_pb_1.Signature.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 (minimal_1.default.util.Long !== long_1.default) { minimal_1.default.util.Long = long_1.default; minimal_1.default.configure(); } function isSet(value) { return value !== null && value !== undefined; }