UNPKG

@xmtp/proto

Version:

Protobuf client and generated classes for GRPC API

113 lines 3.72 kB
/* eslint-disable */ import Long from "long"; import { Signature } from "./signature.pb"; import _m0 from "protobufjs/minimal"; export const protobufPackage = "xmtp.message_contents"; function createBaseSignedPayload() { return { payload: new Uint8Array(), signature: undefined }; } export const SignedPayload = { encode(message, writer = _m0.Writer.create()) { if (message.payload.length !== 0) { writer.uint32(10).bytes(message.payload); } if (message.signature !== undefined) { Signature.encode(message.signature, writer.uint32(18).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 = createBaseSignedPayload(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.payload = reader.bytes(); break; case 2: message.signature = Signature.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object) { return { payload: isSet(object.payload) ? bytesFromBase64(object.payload) : new Uint8Array(), signature: isSet(object.signature) ? Signature.fromJSON(object.signature) : undefined, }; }, toJSON(message) { const obj = {}; message.payload !== undefined && (obj.payload = base64FromBytes(message.payload !== undefined ? message.payload : new Uint8Array())); message.signature !== undefined && (obj.signature = message.signature ? Signature.toJSON(message.signature) : undefined); return obj; }, fromPartial(object) { var _a; const message = createBaseSignedPayload(); message.payload = (_a = object.payload) !== null && _a !== void 0 ? _a : new Uint8Array(); message.signature = object.signature !== undefined && object.signature !== null ? Signature.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=signed_payload.pb.js.map