UNPKG

@xmtp/proto

Version:

Protobuf client and generated classes for GRPC API

348 lines (347 loc) 12.4 kB
// 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/ciphertext.proto /* eslint-disable */ import Long from "long"; import _m0 from "protobufjs/minimal"; import { Signature } from "./signature.pb"; export const protobufPackage = "xmtp.message_contents"; function createBaseCiphertext() { return { aes256GcmHkdfSha256: undefined }; } export const Ciphertext = { encode(message, writer = _m0.Writer.create()) { if (message.aes256GcmHkdfSha256 !== undefined) { Ciphertext_Aes256gcmHkdfsha256.encode(message.aes256GcmHkdfSha256, writer.uint32(10).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 = createBaseCiphertext(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.aes256GcmHkdfSha256 = Ciphertext_Aes256gcmHkdfsha256.decode(reader, reader.uint32()); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { aes256GcmHkdfSha256: isSet(object.aes256GcmHkdfSha256) ? Ciphertext_Aes256gcmHkdfsha256.fromJSON(object.aes256GcmHkdfSha256) : undefined, }; }, toJSON(message) { const obj = {}; if (message.aes256GcmHkdfSha256 !== undefined) { obj.aes256GcmHkdfSha256 = Ciphertext_Aes256gcmHkdfsha256.toJSON(message.aes256GcmHkdfSha256); } return obj; }, create(base) { return Ciphertext.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseCiphertext(); message.aes256GcmHkdfSha256 = (object.aes256GcmHkdfSha256 !== undefined && object.aes256GcmHkdfSha256 !== null) ? Ciphertext_Aes256gcmHkdfsha256.fromPartial(object.aes256GcmHkdfSha256) : undefined; return message; }, }; function createBaseCiphertext_Aes256gcmHkdfsha256() { return { hkdfSalt: new Uint8Array(0), gcmNonce: new Uint8Array(0), payload: new Uint8Array(0) }; } export const Ciphertext_Aes256gcmHkdfsha256 = { encode(message, writer = _m0.Writer.create()) { if (message.hkdfSalt.length !== 0) { writer.uint32(10).bytes(message.hkdfSalt); } if (message.gcmNonce.length !== 0) { writer.uint32(18).bytes(message.gcmNonce); } if (message.payload.length !== 0) { writer.uint32(26).bytes(message.payload); } 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 = createBaseCiphertext_Aes256gcmHkdfsha256(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.hkdfSalt = reader.bytes(); continue; case 2: if (tag !== 18) { break; } message.gcmNonce = reader.bytes(); continue; case 3: if (tag !== 26) { break; } message.payload = reader.bytes(); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { hkdfSalt: isSet(object.hkdfSalt) ? bytesFromBase64(object.hkdfSalt) : new Uint8Array(0), gcmNonce: isSet(object.gcmNonce) ? bytesFromBase64(object.gcmNonce) : new Uint8Array(0), payload: isSet(object.payload) ? bytesFromBase64(object.payload) : new Uint8Array(0), }; }, toJSON(message) { const obj = {}; if (message.hkdfSalt.length !== 0) { obj.hkdfSalt = base64FromBytes(message.hkdfSalt); } if (message.gcmNonce.length !== 0) { obj.gcmNonce = base64FromBytes(message.gcmNonce); } if (message.payload.length !== 0) { obj.payload = base64FromBytes(message.payload); } return obj; }, create(base) { return Ciphertext_Aes256gcmHkdfsha256.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseCiphertext_Aes256gcmHkdfsha256(); message.hkdfSalt = object.hkdfSalt ?? new Uint8Array(0); message.gcmNonce = object.gcmNonce ?? new Uint8Array(0); message.payload = object.payload ?? new Uint8Array(0); return message; }, }; function createBaseSignedEciesCiphertext() { return { eciesBytes: new Uint8Array(0), signature: undefined }; } export const SignedEciesCiphertext = { encode(message, writer = _m0.Writer.create()) { if (message.eciesBytes.length !== 0) { writer.uint32(10).bytes(message.eciesBytes); } 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 : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSignedEciesCiphertext(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.eciesBytes = reader.bytes(); continue; case 2: if (tag !== 18) { break; } message.signature = Signature.decode(reader, reader.uint32()); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { eciesBytes: isSet(object.eciesBytes) ? bytesFromBase64(object.eciesBytes) : new Uint8Array(0), signature: isSet(object.signature) ? Signature.fromJSON(object.signature) : undefined, }; }, toJSON(message) { const obj = {}; if (message.eciesBytes.length !== 0) { obj.eciesBytes = base64FromBytes(message.eciesBytes); } if (message.signature !== undefined) { obj.signature = Signature.toJSON(message.signature); } return obj; }, create(base) { return SignedEciesCiphertext.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseSignedEciesCiphertext(); message.eciesBytes = object.eciesBytes ?? new Uint8Array(0); message.signature = (object.signature !== undefined && object.signature !== null) ? Signature.fromPartial(object.signature) : undefined; return message; }, }; function createBaseSignedEciesCiphertext_Ecies() { return { ephemeralPublicKey: new Uint8Array(0), iv: new Uint8Array(0), mac: new Uint8Array(0), ciphertext: new Uint8Array(0), }; } export const SignedEciesCiphertext_Ecies = { encode(message, writer = _m0.Writer.create()) { if (message.ephemeralPublicKey.length !== 0) { writer.uint32(10).bytes(message.ephemeralPublicKey); } if (message.iv.length !== 0) { writer.uint32(18).bytes(message.iv); } if (message.mac.length !== 0) { writer.uint32(26).bytes(message.mac); } if (message.ciphertext.length !== 0) { writer.uint32(34).bytes(message.ciphertext); } 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 = createBaseSignedEciesCiphertext_Ecies(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.ephemeralPublicKey = reader.bytes(); continue; case 2: if (tag !== 18) { break; } message.iv = reader.bytes(); continue; case 3: if (tag !== 26) { break; } message.mac = reader.bytes(); continue; case 4: if (tag !== 34) { break; } message.ciphertext = reader.bytes(); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { ephemeralPublicKey: isSet(object.ephemeralPublicKey) ? bytesFromBase64(object.ephemeralPublicKey) : new Uint8Array(0), iv: isSet(object.iv) ? bytesFromBase64(object.iv) : new Uint8Array(0), mac: isSet(object.mac) ? bytesFromBase64(object.mac) : new Uint8Array(0), ciphertext: isSet(object.ciphertext) ? bytesFromBase64(object.ciphertext) : new Uint8Array(0), }; }, toJSON(message) { const obj = {}; if (message.ephemeralPublicKey.length !== 0) { obj.ephemeralPublicKey = base64FromBytes(message.ephemeralPublicKey); } if (message.iv.length !== 0) { obj.iv = base64FromBytes(message.iv); } if (message.mac.length !== 0) { obj.mac = base64FromBytes(message.mac); } if (message.ciphertext.length !== 0) { obj.ciphertext = base64FromBytes(message.ciphertext); } return obj; }, create(base) { return SignedEciesCiphertext_Ecies.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseSignedEciesCiphertext_Ecies(); message.ephemeralPublicKey = object.ephemeralPublicKey ?? new Uint8Array(0); message.iv = object.iv ?? new Uint8Array(0); message.mac = object.mac ?? new Uint8Array(0); message.ciphertext = object.ciphertext ?? new Uint8Array(0); 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; }