@xmtp/proto
Version:
Protobuf client and generated classes for GRPC API
354 lines (353 loc) • 13.2 kB
JavaScript
;
// 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
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SignedEciesCiphertext_Ecies = exports.SignedEciesCiphertext = exports.Ciphertext_Aes256gcmHkdfsha256 = exports.Ciphertext = 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 createBaseCiphertext() {
return { aes256GcmHkdfSha256: undefined };
}
exports.Ciphertext = {
encode(message, writer = minimal_1.default.Writer.create()) {
if (message.aes256GcmHkdfSha256 !== undefined) {
exports.Ciphertext_Aes256gcmHkdfsha256.encode(message.aes256GcmHkdfSha256, writer.uint32(10).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 = createBaseCiphertext();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.aes256GcmHkdfSha256 = exports.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)
? exports.Ciphertext_Aes256gcmHkdfsha256.fromJSON(object.aes256GcmHkdfSha256)
: undefined,
};
},
toJSON(message) {
const obj = {};
if (message.aes256GcmHkdfSha256 !== undefined) {
obj.aes256GcmHkdfSha256 = exports.Ciphertext_Aes256gcmHkdfsha256.toJSON(message.aes256GcmHkdfSha256);
}
return obj;
},
create(base) {
return exports.Ciphertext.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseCiphertext();
message.aes256GcmHkdfSha256 = (object.aes256GcmHkdfSha256 !== undefined && object.aes256GcmHkdfSha256 !== null)
? exports.Ciphertext_Aes256gcmHkdfsha256.fromPartial(object.aes256GcmHkdfSha256)
: undefined;
return message;
},
};
function createBaseCiphertext_Aes256gcmHkdfsha256() {
return { hkdfSalt: new Uint8Array(0), gcmNonce: new Uint8Array(0), payload: new Uint8Array(0) };
}
exports.Ciphertext_Aes256gcmHkdfsha256 = {
encode(message, writer = minimal_1.default.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 minimal_1.default.Reader ? input : minimal_1.default.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 exports.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 };
}
exports.SignedEciesCiphertext = {
encode(message, writer = minimal_1.default.Writer.create()) {
if (message.eciesBytes.length !== 0) {
writer.uint32(10).bytes(message.eciesBytes);
}
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 = 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_pb_1.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_pb_1.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_pb_1.Signature.toJSON(message.signature);
}
return obj;
},
create(base) {
return exports.SignedEciesCiphertext.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseSignedEciesCiphertext();
message.eciesBytes = object.eciesBytes ?? new Uint8Array(0);
message.signature = (object.signature !== undefined && object.signature !== null)
? signature_pb_1.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),
};
}
exports.SignedEciesCiphertext_Ecies = {
encode(message, writer = minimal_1.default.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 minimal_1.default.Reader ? input : minimal_1.default.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 exports.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 (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;
}