UNPKG

@xmtp/proto

Version:

Protobuf client and generated classes for GRPC API

352 lines (351 loc) 15.2 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: mls/message_contents/welcome_pointer.proto var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.WelcomePointeeEncryptionAeadTypesExtension = exports.WelcomePointer_WelcomeV1Pointer = exports.WelcomePointer = exports.WelcomePointerWrapperAlgorithm = exports.WelcomePointeeEncryptionAeadType = exports.protobufPackage = void 0; exports.welcomePointeeEncryptionAeadTypeFromJSON = welcomePointeeEncryptionAeadTypeFromJSON; exports.welcomePointeeEncryptionAeadTypeToJSON = welcomePointeeEncryptionAeadTypeToJSON; exports.welcomePointerWrapperAlgorithmFromJSON = welcomePointerWrapperAlgorithmFromJSON; exports.welcomePointerWrapperAlgorithmToJSON = welcomePointerWrapperAlgorithmToJSON; /* eslint-disable */ const long_1 = __importDefault(require("long")); const minimal_1 = __importDefault(require("protobufjs/minimal")); exports.protobufPackage = "xmtp.mls.message_contents"; /** WelcomePointer is used to point to the welcome message for several installations at once to save overhead */ var WelcomePointeeEncryptionAeadType; (function (WelcomePointeeEncryptionAeadType) { WelcomePointeeEncryptionAeadType[WelcomePointeeEncryptionAeadType["WELCOME_POINTEE_ENCRYPTION_AEAD_TYPE_UNSPECIFIED"] = 0] = "WELCOME_POINTEE_ENCRYPTION_AEAD_TYPE_UNSPECIFIED"; /** WELCOME_POINTEE_ENCRYPTION_AEAD_TYPE_CHACHA20_POLY1305 - Use same encoding as openmls::AeadType */ WelcomePointeeEncryptionAeadType[WelcomePointeeEncryptionAeadType["WELCOME_POINTEE_ENCRYPTION_AEAD_TYPE_CHACHA20_POLY1305"] = 3] = "WELCOME_POINTEE_ENCRYPTION_AEAD_TYPE_CHACHA20_POLY1305"; WelcomePointeeEncryptionAeadType[WelcomePointeeEncryptionAeadType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED"; })(WelcomePointeeEncryptionAeadType || (exports.WelcomePointeeEncryptionAeadType = WelcomePointeeEncryptionAeadType = {})); function welcomePointeeEncryptionAeadTypeFromJSON(object) { switch (object) { case 0: case "WELCOME_POINTEE_ENCRYPTION_AEAD_TYPE_UNSPECIFIED": return WelcomePointeeEncryptionAeadType.WELCOME_POINTEE_ENCRYPTION_AEAD_TYPE_UNSPECIFIED; case 3: case "WELCOME_POINTEE_ENCRYPTION_AEAD_TYPE_CHACHA20_POLY1305": return WelcomePointeeEncryptionAeadType.WELCOME_POINTEE_ENCRYPTION_AEAD_TYPE_CHACHA20_POLY1305; case -1: case "UNRECOGNIZED": default: return WelcomePointeeEncryptionAeadType.UNRECOGNIZED; } } function welcomePointeeEncryptionAeadTypeToJSON(object) { switch (object) { case WelcomePointeeEncryptionAeadType.WELCOME_POINTEE_ENCRYPTION_AEAD_TYPE_UNSPECIFIED: return "WELCOME_POINTEE_ENCRYPTION_AEAD_TYPE_UNSPECIFIED"; case WelcomePointeeEncryptionAeadType.WELCOME_POINTEE_ENCRYPTION_AEAD_TYPE_CHACHA20_POLY1305: return "WELCOME_POINTEE_ENCRYPTION_AEAD_TYPE_CHACHA20_POLY1305"; case WelcomePointeeEncryptionAeadType.UNRECOGNIZED: default: return "UNRECOGNIZED"; } } /** MUST match the WelcomeWrapperAlgorithm enum values without 25519 so that the i32 transformations are compatible */ var WelcomePointerWrapperAlgorithm; (function (WelcomePointerWrapperAlgorithm) { WelcomePointerWrapperAlgorithm[WelcomePointerWrapperAlgorithm["WELCOME_POINTER_WRAPPER_ALGORITHM_UNSPECIFIED"] = 0] = "WELCOME_POINTER_WRAPPER_ALGORITHM_UNSPECIFIED"; WelcomePointerWrapperAlgorithm[WelcomePointerWrapperAlgorithm["WELCOME_POINTER_WRAPPER_ALGORITHM_XWING_MLKEM_768_DRAFT_6"] = 2] = "WELCOME_POINTER_WRAPPER_ALGORITHM_XWING_MLKEM_768_DRAFT_6"; WelcomePointerWrapperAlgorithm[WelcomePointerWrapperAlgorithm["UNRECOGNIZED"] = -1] = "UNRECOGNIZED"; })(WelcomePointerWrapperAlgorithm || (exports.WelcomePointerWrapperAlgorithm = WelcomePointerWrapperAlgorithm = {})); function welcomePointerWrapperAlgorithmFromJSON(object) { switch (object) { case 0: case "WELCOME_POINTER_WRAPPER_ALGORITHM_UNSPECIFIED": return WelcomePointerWrapperAlgorithm.WELCOME_POINTER_WRAPPER_ALGORITHM_UNSPECIFIED; case 2: case "WELCOME_POINTER_WRAPPER_ALGORITHM_XWING_MLKEM_768_DRAFT_6": return WelcomePointerWrapperAlgorithm.WELCOME_POINTER_WRAPPER_ALGORITHM_XWING_MLKEM_768_DRAFT_6; case -1: case "UNRECOGNIZED": default: return WelcomePointerWrapperAlgorithm.UNRECOGNIZED; } } function welcomePointerWrapperAlgorithmToJSON(object) { switch (object) { case WelcomePointerWrapperAlgorithm.WELCOME_POINTER_WRAPPER_ALGORITHM_UNSPECIFIED: return "WELCOME_POINTER_WRAPPER_ALGORITHM_UNSPECIFIED"; case WelcomePointerWrapperAlgorithm.WELCOME_POINTER_WRAPPER_ALGORITHM_XWING_MLKEM_768_DRAFT_6: return "WELCOME_POINTER_WRAPPER_ALGORITHM_XWING_MLKEM_768_DRAFT_6"; case WelcomePointerWrapperAlgorithm.UNRECOGNIZED: default: return "UNRECOGNIZED"; } } function createBaseWelcomePointer() { return { welcomeV1Pointer: undefined }; } exports.WelcomePointer = { encode(message, writer = minimal_1.default.Writer.create()) { if (message.welcomeV1Pointer !== undefined) { exports.WelcomePointer_WelcomeV1Pointer.encode(message.welcomeV1Pointer, 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 = createBaseWelcomePointer(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.welcomeV1Pointer = exports.WelcomePointer_WelcomeV1Pointer.decode(reader, reader.uint32()); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { welcomeV1Pointer: isSet(object.welcomeV1Pointer) ? exports.WelcomePointer_WelcomeV1Pointer.fromJSON(object.welcomeV1Pointer) : undefined, }; }, toJSON(message) { const obj = {}; if (message.welcomeV1Pointer !== undefined) { obj.welcomeV1Pointer = exports.WelcomePointer_WelcomeV1Pointer.toJSON(message.welcomeV1Pointer); } return obj; }, create(base) { return exports.WelcomePointer.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseWelcomePointer(); message.welcomeV1Pointer = (object.welcomeV1Pointer !== undefined && object.welcomeV1Pointer !== null) ? exports.WelcomePointer_WelcomeV1Pointer.fromPartial(object.welcomeV1Pointer) : undefined; return message; }, }; function createBaseWelcomePointer_WelcomeV1Pointer() { return { destination: new Uint8Array(0), aeadType: 0, encryptionKey: new Uint8Array(0), dataNonce: new Uint8Array(0), welcomeMetadataNonce: new Uint8Array(0), }; } exports.WelcomePointer_WelcomeV1Pointer = { encode(message, writer = minimal_1.default.Writer.create()) { if (message.destination.length !== 0) { writer.uint32(10).bytes(message.destination); } if (message.aeadType !== 0) { writer.uint32(16).int32(message.aeadType); } if (message.encryptionKey.length !== 0) { writer.uint32(26).bytes(message.encryptionKey); } if (message.dataNonce.length !== 0) { writer.uint32(34).bytes(message.dataNonce); } if (message.welcomeMetadataNonce.length !== 0) { writer.uint32(42).bytes(message.welcomeMetadataNonce); } 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 = createBaseWelcomePointer_WelcomeV1Pointer(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.destination = reader.bytes(); continue; case 2: if (tag !== 16) { break; } message.aeadType = reader.int32(); continue; case 3: if (tag !== 26) { break; } message.encryptionKey = reader.bytes(); continue; case 4: if (tag !== 34) { break; } message.dataNonce = reader.bytes(); continue; case 5: if (tag !== 42) { break; } message.welcomeMetadataNonce = reader.bytes(); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { destination: isSet(object.destination) ? bytesFromBase64(object.destination) : new Uint8Array(0), aeadType: isSet(object.aeadType) ? welcomePointeeEncryptionAeadTypeFromJSON(object.aeadType) : 0, encryptionKey: isSet(object.encryptionKey) ? bytesFromBase64(object.encryptionKey) : new Uint8Array(0), dataNonce: isSet(object.dataNonce) ? bytesFromBase64(object.dataNonce) : new Uint8Array(0), welcomeMetadataNonce: isSet(object.welcomeMetadataNonce) ? bytesFromBase64(object.welcomeMetadataNonce) : new Uint8Array(0), }; }, toJSON(message) { const obj = {}; if (message.destination.length !== 0) { obj.destination = base64FromBytes(message.destination); } if (message.aeadType !== 0) { obj.aeadType = welcomePointeeEncryptionAeadTypeToJSON(message.aeadType); } if (message.encryptionKey.length !== 0) { obj.encryptionKey = base64FromBytes(message.encryptionKey); } if (message.dataNonce.length !== 0) { obj.dataNonce = base64FromBytes(message.dataNonce); } if (message.welcomeMetadataNonce.length !== 0) { obj.welcomeMetadataNonce = base64FromBytes(message.welcomeMetadataNonce); } return obj; }, create(base) { return exports.WelcomePointer_WelcomeV1Pointer.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseWelcomePointer_WelcomeV1Pointer(); message.destination = object.destination ?? new Uint8Array(0); message.aeadType = object.aeadType ?? 0; message.encryptionKey = object.encryptionKey ?? new Uint8Array(0); message.dataNonce = object.dataNonce ?? new Uint8Array(0); message.welcomeMetadataNonce = object.welcomeMetadataNonce ?? new Uint8Array(0); return message; }, }; function createBaseWelcomePointeeEncryptionAeadTypesExtension() { return { supportedAeadTypes: [] }; } exports.WelcomePointeeEncryptionAeadTypesExtension = { encode(message, writer = minimal_1.default.Writer.create()) { writer.uint32(10).fork(); for (const v of message.supportedAeadTypes) { writer.int32(v); } writer.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 = createBaseWelcomePointeeEncryptionAeadTypesExtension(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag === 8) { message.supportedAeadTypes.push(reader.int32()); continue; } if (tag === 10) { const end2 = reader.uint32() + reader.pos; while (reader.pos < end2) { message.supportedAeadTypes.push(reader.int32()); } continue; } break; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { supportedAeadTypes: globalThis.Array.isArray(object?.supportedAeadTypes) ? object.supportedAeadTypes.map((e) => welcomePointeeEncryptionAeadTypeFromJSON(e)) : [], }; }, toJSON(message) { const obj = {}; if (message.supportedAeadTypes?.length) { obj.supportedAeadTypes = message.supportedAeadTypes.map((e) => welcomePointeeEncryptionAeadTypeToJSON(e)); } return obj; }, create(base) { return exports.WelcomePointeeEncryptionAeadTypesExtension.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseWelcomePointeeEncryptionAeadTypesExtension(); message.supportedAeadTypes = object.supportedAeadTypes?.map((e) => e) || []; 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; }