@xmtp/proto
Version:
Protobuf client and generated classes for GRPC API
202 lines (201 loc) • 7.69 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_api/v1/authn.proto
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuthData = exports.Token = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const public_key_pb_1 = require("../../message_contents/public_key.pb");
const signature_pb_1 = require("../../message_contents/signature.pb");
exports.protobufPackage = "xmtp.message_api.v1";
function createBaseToken() {
return { identityKey: undefined, authDataBytes: new Uint8Array(0), authDataSignature: undefined };
}
exports.Token = {
encode(message, writer = minimal_1.default.Writer.create()) {
if (message.identityKey !== undefined) {
public_key_pb_1.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_pb_1.Signature.encode(message.authDataSignature, writer.uint32(26).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 = createBaseToken();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.identityKey = public_key_pb_1.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_pb_1.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) ? public_key_pb_1.PublicKey.fromJSON(object.identityKey) : undefined,
authDataBytes: isSet(object.authDataBytes) ? bytesFromBase64(object.authDataBytes) : new Uint8Array(0),
authDataSignature: isSet(object.authDataSignature) ? signature_pb_1.Signature.fromJSON(object.authDataSignature) : undefined,
};
},
toJSON(message) {
const obj = {};
if (message.identityKey !== undefined) {
obj.identityKey = public_key_pb_1.PublicKey.toJSON(message.identityKey);
}
if (message.authDataBytes.length !== 0) {
obj.authDataBytes = base64FromBytes(message.authDataBytes);
}
if (message.authDataSignature !== undefined) {
obj.authDataSignature = signature_pb_1.Signature.toJSON(message.authDataSignature);
}
return obj;
},
create(base) {
return exports.Token.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseToken();
message.identityKey = (object.identityKey !== undefined && object.identityKey !== null)
? public_key_pb_1.PublicKey.fromPartial(object.identityKey)
: undefined;
message.authDataBytes = object.authDataBytes ?? new Uint8Array(0);
message.authDataSignature = (object.authDataSignature !== undefined && object.authDataSignature !== null)
? signature_pb_1.Signature.fromPartial(object.authDataSignature)
: undefined;
return message;
},
};
function createBaseAuthData() {
return { walletAddr: "", createdNs: long_1.default.UZERO };
}
exports.AuthData = {
encode(message, writer = minimal_1.default.Writer.create()) {
if (message.walletAddr !== "") {
writer.uint32(10).string(message.walletAddr);
}
if (!message.createdNs.equals(long_1.default.UZERO)) {
writer.uint32(16).uint64(message.createdNs);
}
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 = 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_1.default.fromValue(object.createdNs) : long_1.default.UZERO,
};
},
toJSON(message) {
const obj = {};
if (message.walletAddr !== "") {
obj.walletAddr = message.walletAddr;
}
if (!message.createdNs.equals(long_1.default.UZERO)) {
obj.createdNs = (message.createdNs || long_1.default.UZERO).toString();
}
return obj;
},
create(base) {
return exports.AuthData.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseAuthData();
message.walletAddr = object.walletAddr ?? "";
message.createdNs = (object.createdNs !== undefined && object.createdNs !== null)
? long_1.default.fromValue(object.createdNs)
: long_1.default.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 (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;
}