UNPKG

@xmtp/proto

Version:

Protobuf client and generated classes for GRPC API

154 lines 6.32 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.WelcomeWrapperEncryption = exports.welcomeWrapperAlgorithmToJSON = exports.welcomeWrapperAlgorithmFromJSON = exports.WelcomeWrapperAlgorithm = exports.protobufPackage = void 0; /* eslint-disable */ const long_1 = __importDefault(require("long")); const minimal_1 = __importDefault(require("protobufjs/minimal")); exports.protobufPackage = "xmtp.mls.message_contents"; /** Encryption algorithms for the Welcome Wrapper */ /** Describes the algorithm used to encrypt the Welcome Wrapper */ 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"; WelcomeWrapperAlgorithm[WelcomeWrapperAlgorithm["UNRECOGNIZED"] = -1] = "UNRECOGNIZED"; })(WelcomeWrapperAlgorithm = exports.WelcomeWrapperAlgorithm || (exports.WelcomeWrapperAlgorithm = {})); 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 -1: case "UNRECOGNIZED": default: return WelcomeWrapperAlgorithm.UNRECOGNIZED; } } exports.welcomeWrapperAlgorithmFromJSON = welcomeWrapperAlgorithmFromJSON; 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.UNRECOGNIZED: default: return "UNRECOGNIZED"; } } exports.welcomeWrapperAlgorithmToJSON = welcomeWrapperAlgorithmToJSON; function createBaseWelcomeWrapperEncryption() { return { pubKey: new Uint8Array(), algorithm: 0 }; } exports.WelcomeWrapperEncryption = { encode(message, writer = minimal_1.default.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 minimal_1.default.Reader ? input : new minimal_1.default.Reader(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: message.pubKey = reader.bytes(); break; case 2: message.algorithm = reader.int32(); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object) { return { pubKey: isSet(object.pubKey) ? bytesFromBase64(object.pubKey) : new Uint8Array(), algorithm: isSet(object.algorithm) ? welcomeWrapperAlgorithmFromJSON(object.algorithm) : 0, }; }, toJSON(message) { const obj = {}; message.pubKey !== undefined && (obj.pubKey = base64FromBytes(message.pubKey !== undefined ? message.pubKey : new Uint8Array())); message.algorithm !== undefined && (obj.algorithm = welcomeWrapperAlgorithmToJSON(message.algorithm)); return obj; }, fromPartial(object) { var _a, _b; const message = createBaseWelcomeWrapperEncryption(); message.pubKey = (_a = object.pubKey) !== null && _a !== void 0 ? _a : new Uint8Array(); message.algorithm = (_b = object.algorithm) !== null && _b !== void 0 ? _b : 0; 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 (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; } //# sourceMappingURL=wrapper_encryption.pb.js.map