@xmtp/proto
Version:
Protobuf client and generated classes for GRPC API
154 lines (153 loc) • 6.08 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: mls/message_contents/wrapper_encryption.proto
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
export const protobufPackage = "xmtp.mls.message_contents";
/** Encryption algorithms for the Welcome Wrapper */
/** Describes the algorithm used to encrypt the Welcome Wrapper */
export var WelcomeWrapperAlgorithm;
(function (WelcomeWrapperAlgorithm) {
WelcomeWrapperAlgorithm[WelcomeWrapperAlgorithm["WELCOME_WRAPPER_ALGORITHM_UNSPECIFIED"] = 0] = "WELCOME_WRAPPER_ALGORITHM_UNSPECIFIED";
WelcomeWrapperAlgorithm[WelcomeWrapperAlgorithm["WELCOME_WRAPPER_ALGORITHM_CURVE25519"] = 1] = "WELCOME_WRAPPER_ALGORITHM_CURVE25519";
WelcomeWrapperAlgorithm[WelcomeWrapperAlgorithm["WELCOME_WRAPPER_ALGORITHM_XWING_MLKEM_768_DRAFT_6"] = 2] = "WELCOME_WRAPPER_ALGORITHM_XWING_MLKEM_768_DRAFT_6";
/** WELCOME_WRAPPER_ALGORITHM_SYMMETRIC_KEY - Only used for WelcomePointee's */
WelcomeWrapperAlgorithm[WelcomeWrapperAlgorithm["WELCOME_WRAPPER_ALGORITHM_SYMMETRIC_KEY"] = 3] = "WELCOME_WRAPPER_ALGORITHM_SYMMETRIC_KEY";
WelcomeWrapperAlgorithm[WelcomeWrapperAlgorithm["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(WelcomeWrapperAlgorithm || (WelcomeWrapperAlgorithm = {}));
export function welcomeWrapperAlgorithmFromJSON(object) {
switch (object) {
case 0:
case "WELCOME_WRAPPER_ALGORITHM_UNSPECIFIED":
return WelcomeWrapperAlgorithm.WELCOME_WRAPPER_ALGORITHM_UNSPECIFIED;
case 1:
case "WELCOME_WRAPPER_ALGORITHM_CURVE25519":
return WelcomeWrapperAlgorithm.WELCOME_WRAPPER_ALGORITHM_CURVE25519;
case 2:
case "WELCOME_WRAPPER_ALGORITHM_XWING_MLKEM_768_DRAFT_6":
return WelcomeWrapperAlgorithm.WELCOME_WRAPPER_ALGORITHM_XWING_MLKEM_768_DRAFT_6;
case 3:
case "WELCOME_WRAPPER_ALGORITHM_SYMMETRIC_KEY":
return WelcomeWrapperAlgorithm.WELCOME_WRAPPER_ALGORITHM_SYMMETRIC_KEY;
case -1:
case "UNRECOGNIZED":
default:
return WelcomeWrapperAlgorithm.UNRECOGNIZED;
}
}
export function welcomeWrapperAlgorithmToJSON(object) {
switch (object) {
case WelcomeWrapperAlgorithm.WELCOME_WRAPPER_ALGORITHM_UNSPECIFIED:
return "WELCOME_WRAPPER_ALGORITHM_UNSPECIFIED";
case WelcomeWrapperAlgorithm.WELCOME_WRAPPER_ALGORITHM_CURVE25519:
return "WELCOME_WRAPPER_ALGORITHM_CURVE25519";
case WelcomeWrapperAlgorithm.WELCOME_WRAPPER_ALGORITHM_XWING_MLKEM_768_DRAFT_6:
return "WELCOME_WRAPPER_ALGORITHM_XWING_MLKEM_768_DRAFT_6";
case WelcomeWrapperAlgorithm.WELCOME_WRAPPER_ALGORITHM_SYMMETRIC_KEY:
return "WELCOME_WRAPPER_ALGORITHM_SYMMETRIC_KEY";
case WelcomeWrapperAlgorithm.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
function createBaseWelcomeWrapperEncryption() {
return { pubKey: new Uint8Array(0), algorithm: 0 };
}
export const WelcomeWrapperEncryption = {
encode(message, writer = _m0.Writer.create()) {
if (message.pubKey.length !== 0) {
writer.uint32(10).bytes(message.pubKey);
}
if (message.algorithm !== 0) {
writer.uint32(16).int32(message.algorithm);
}
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 = createBaseWelcomeWrapperEncryption();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.pubKey = reader.bytes();
continue;
case 2:
if (tag !== 16) {
break;
}
message.algorithm = reader.int32();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
pubKey: isSet(object.pubKey) ? bytesFromBase64(object.pubKey) : new Uint8Array(0),
algorithm: isSet(object.algorithm) ? welcomeWrapperAlgorithmFromJSON(object.algorithm) : 0,
};
},
toJSON(message) {
const obj = {};
if (message.pubKey.length !== 0) {
obj.pubKey = base64FromBytes(message.pubKey);
}
if (message.algorithm !== 0) {
obj.algorithm = welcomeWrapperAlgorithmToJSON(message.algorithm);
}
return obj;
},
create(base) {
return WelcomeWrapperEncryption.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseWelcomeWrapperEncryption();
message.pubKey = object.pubKey ?? new Uint8Array(0);
message.algorithm = object.algorithm ?? 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;
}