UNPKG

@xmtp/proto

Version:

Protobuf client and generated classes for GRPC API

196 lines (195 loc) 6.96 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_api/v1/authn.proto /* eslint-disable */ import Long from "long"; import _m0 from "protobufjs/minimal"; import { PublicKey } from "../../message_contents/public_key.pb"; import { Signature } from "../../message_contents/signature.pb"; export const protobufPackage = "xmtp.message_api.v1"; function createBaseToken() { return { identityKey: undefined, authDataBytes: new Uint8Array(0), authDataSignature: undefined }; } export const Token = { encode(message, writer = _m0.Writer.create()) { if (message.identityKey !== undefined) { PublicKey.encode(message.identityKey, writer.uint32(10).fork()).ldelim(); } if (message.authDataBytes.length !== 0) { writer.uint32(18).bytes(message.authDataBytes); } if (message.authDataSignature !== undefined) { Signature.encode(message.authDataSignature, writer.uint32(26).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 = createBaseToken(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.identityKey = PublicKey.decode(reader, reader.uint32()); continue; case 2: if (tag !== 18) { break; } message.authDataBytes = reader.bytes(); continue; case 3: if (tag !== 26) { break; } message.authDataSignature = Signature.decode(reader, reader.uint32()); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { identityKey: isSet(object.identityKey) ? PublicKey.fromJSON(object.identityKey) : undefined, authDataBytes: isSet(object.authDataBytes) ? bytesFromBase64(object.authDataBytes) : new Uint8Array(0), authDataSignature: isSet(object.authDataSignature) ? Signature.fromJSON(object.authDataSignature) : undefined, }; }, toJSON(message) { const obj = {}; if (message.identityKey !== undefined) { obj.identityKey = PublicKey.toJSON(message.identityKey); } if (message.authDataBytes.length !== 0) { obj.authDataBytes = base64FromBytes(message.authDataBytes); } if (message.authDataSignature !== undefined) { obj.authDataSignature = Signature.toJSON(message.authDataSignature); } return obj; }, create(base) { return Token.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseToken(); message.identityKey = (object.identityKey !== undefined && object.identityKey !== null) ? PublicKey.fromPartial(object.identityKey) : undefined; message.authDataBytes = object.authDataBytes ?? new Uint8Array(0); message.authDataSignature = (object.authDataSignature !== undefined && object.authDataSignature !== null) ? Signature.fromPartial(object.authDataSignature) : undefined; return message; }, }; function createBaseAuthData() { return { walletAddr: "", createdNs: Long.UZERO }; } export const AuthData = { encode(message, writer = _m0.Writer.create()) { if (message.walletAddr !== "") { writer.uint32(10).string(message.walletAddr); } if (!message.createdNs.equals(Long.UZERO)) { writer.uint32(16).uint64(message.createdNs); } 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 = createBaseAuthData(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.walletAddr = reader.string(); continue; case 2: if (tag !== 16) { break; } message.createdNs = reader.uint64(); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { walletAddr: isSet(object.walletAddr) ? globalThis.String(object.walletAddr) : "", createdNs: isSet(object.createdNs) ? Long.fromValue(object.createdNs) : Long.UZERO, }; }, toJSON(message) { const obj = {}; if (message.walletAddr !== "") { obj.walletAddr = message.walletAddr; } if (!message.createdNs.equals(Long.UZERO)) { obj.createdNs = (message.createdNs || Long.UZERO).toString(); } return obj; }, create(base) { return AuthData.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseAuthData(); message.walletAddr = object.walletAddr ?? ""; message.createdNs = (object.createdNs !== undefined && object.createdNs !== null) ? Long.fromValue(object.createdNs) : Long.UZERO; 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; }