nkn-sdk
Version:
NKN client and wallet SDK
738 lines (688 loc) • 23.3 kB
JavaScript
"use strict";
// source: src/common/pb/payloads.proto
/**
* @fileoverview
* @enhanceable
* @suppress {missingRequire} reports error on implicit type usages.
* @suppress {messageConventions} JS Compiler reports an error if a variable or
* field starts with 'MSG_' and isn't a translatable message.
* @public
*/
// GENERATED CODE -- DO NOT EDIT!
/* eslint-disable */
// @ts-nocheck
var jspb = require('google-protobuf');
var goog = jspb;
var global = typeof globalThis !== 'undefined' && globalThis || typeof window !== 'undefined' && window || typeof global !== 'undefined' && global || typeof self !== 'undefined' && self || function () {
return this;
}.call(null) || Function('return this')();
goog.exportSymbol('proto.payloads.Message', null, global);
goog.exportSymbol('proto.payloads.Payload', null, global);
goog.exportSymbol('proto.payloads.PayloadType', null, global);
goog.exportSymbol('proto.payloads.TextData', null, global);
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.payloads.Message = function (opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.payloads.Message, jspb.Message);
if (goog.DEBUG && !COMPILED) {
/**
* @public
* @override
*/
proto.payloads.Message.displayName = 'proto.payloads.Message';
}
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.payloads.Payload = function (opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.payloads.Payload, jspb.Message);
if (goog.DEBUG && !COMPILED) {
/**
* @public
* @override
*/
proto.payloads.Payload.displayName = 'proto.payloads.Payload';
}
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.payloads.TextData = function (opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.payloads.TextData, jspb.Message);
if (goog.DEBUG && !COMPILED) {
/**
* @public
* @override
*/
proto.payloads.TextData.displayName = 'proto.payloads.TextData';
}
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* Optional fields that are not set will be set to undefined.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* net/proto2/compiler/js/internal/generator.cc#kKeyword.
* @param {boolean=} opt_includeInstance Deprecated. whether to include the
* JSPB instance for transitional soy proto support:
* http://goto/soy-param-migration
* @return {!Object}
*/
proto.payloads.Message.prototype.toObject = function (opt_includeInstance) {
return proto.payloads.Message.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Deprecated. Whether to include
* the JSPB instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.payloads.Message} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.payloads.Message.toObject = function (includeInstance, msg) {
var f,
obj = {
payload: msg.getPayload_asB64(),
encrypted: jspb.Message.getBooleanFieldWithDefault(msg, 2, false),
nonce: msg.getNonce_asB64(),
encryptedKey: msg.getEncryptedKey_asB64()
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}
/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.payloads.Message}
*/
proto.payloads.Message.deserializeBinary = function (bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.payloads.Message();
return proto.payloads.Message.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.payloads.Message} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.payloads.Message}
*/
proto.payloads.Message.deserializeBinaryFromReader = function (msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {!Uint8Array} */reader.readBytes();
msg.setPayload(value);
break;
case 2:
var value = /** @type {boolean} */reader.readBool();
msg.setEncrypted(value);
break;
case 3:
var value = /** @type {!Uint8Array} */reader.readBytes();
msg.setNonce(value);
break;
case 4:
var value = /** @type {!Uint8Array} */reader.readBytes();
msg.setEncryptedKey(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.payloads.Message.prototype.serializeBinary = function () {
var writer = new jspb.BinaryWriter();
proto.payloads.Message.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.payloads.Message} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.payloads.Message.serializeBinaryToWriter = function (message, writer) {
var f = undefined;
f = message.getPayload_asU8();
if (f.length > 0) {
writer.writeBytes(1, f);
}
f = message.getEncrypted();
if (f) {
writer.writeBool(2, f);
}
f = message.getNonce_asU8();
if (f.length > 0) {
writer.writeBytes(3, f);
}
f = message.getEncryptedKey_asU8();
if (f.length > 0) {
writer.writeBytes(4, f);
}
};
/**
* optional bytes payload = 1;
* @return {!(string|Uint8Array)}
*/
proto.payloads.Message.prototype.getPayload = function () {
return /** @type {!(string|Uint8Array)} */jspb.Message.getFieldWithDefault(this, 1, "");
};
/**
* optional bytes payload = 1;
* This is a type-conversion wrapper around `getPayload()`
* @return {string}
*/
proto.payloads.Message.prototype.getPayload_asB64 = function () {
return /** @type {string} */jspb.Message.bytesAsB64(this.getPayload());
};
/**
* optional bytes payload = 1;
* Note that Uint8Array is not supported on all browsers.
* @see http://caniuse.com/Uint8Array
* This is a type-conversion wrapper around `getPayload()`
* @return {!Uint8Array}
*/
proto.payloads.Message.prototype.getPayload_asU8 = function () {
return /** @type {!Uint8Array} */jspb.Message.bytesAsU8(this.getPayload());
};
/**
* @param {!(string|Uint8Array)} value
* @return {!proto.payloads.Message} returns this
*/
proto.payloads.Message.prototype.setPayload = function (value) {
return jspb.Message.setProto3BytesField(this, 1, value);
};
/**
* optional bool encrypted = 2;
* @return {boolean}
*/
proto.payloads.Message.prototype.getEncrypted = function () {
return /** @type {boolean} */jspb.Message.getBooleanFieldWithDefault(this, 2, false);
};
/**
* @param {boolean} value
* @return {!proto.payloads.Message} returns this
*/
proto.payloads.Message.prototype.setEncrypted = function (value) {
return jspb.Message.setProto3BooleanField(this, 2, value);
};
/**
* optional bytes nonce = 3;
* @return {!(string|Uint8Array)}
*/
proto.payloads.Message.prototype.getNonce = function () {
return /** @type {!(string|Uint8Array)} */jspb.Message.getFieldWithDefault(this, 3, "");
};
/**
* optional bytes nonce = 3;
* This is a type-conversion wrapper around `getNonce()`
* @return {string}
*/
proto.payloads.Message.prototype.getNonce_asB64 = function () {
return /** @type {string} */jspb.Message.bytesAsB64(this.getNonce());
};
/**
* optional bytes nonce = 3;
* Note that Uint8Array is not supported on all browsers.
* @see http://caniuse.com/Uint8Array
* This is a type-conversion wrapper around `getNonce()`
* @return {!Uint8Array}
*/
proto.payloads.Message.prototype.getNonce_asU8 = function () {
return /** @type {!Uint8Array} */jspb.Message.bytesAsU8(this.getNonce());
};
/**
* @param {!(string|Uint8Array)} value
* @return {!proto.payloads.Message} returns this
*/
proto.payloads.Message.prototype.setNonce = function (value) {
return jspb.Message.setProto3BytesField(this, 3, value);
};
/**
* optional bytes encrypted_key = 4;
* @return {!(string|Uint8Array)}
*/
proto.payloads.Message.prototype.getEncryptedKey = function () {
return /** @type {!(string|Uint8Array)} */jspb.Message.getFieldWithDefault(this, 4, "");
};
/**
* optional bytes encrypted_key = 4;
* This is a type-conversion wrapper around `getEncryptedKey()`
* @return {string}
*/
proto.payloads.Message.prototype.getEncryptedKey_asB64 = function () {
return /** @type {string} */jspb.Message.bytesAsB64(this.getEncryptedKey());
};
/**
* optional bytes encrypted_key = 4;
* Note that Uint8Array is not supported on all browsers.
* @see http://caniuse.com/Uint8Array
* This is a type-conversion wrapper around `getEncryptedKey()`
* @return {!Uint8Array}
*/
proto.payloads.Message.prototype.getEncryptedKey_asU8 = function () {
return /** @type {!Uint8Array} */jspb.Message.bytesAsU8(this.getEncryptedKey());
};
/**
* @param {!(string|Uint8Array)} value
* @return {!proto.payloads.Message} returns this
*/
proto.payloads.Message.prototype.setEncryptedKey = function (value) {
return jspb.Message.setProto3BytesField(this, 4, value);
};
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* Optional fields that are not set will be set to undefined.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* net/proto2/compiler/js/internal/generator.cc#kKeyword.
* @param {boolean=} opt_includeInstance Deprecated. whether to include the
* JSPB instance for transitional soy proto support:
* http://goto/soy-param-migration
* @return {!Object}
*/
proto.payloads.Payload.prototype.toObject = function (opt_includeInstance) {
return proto.payloads.Payload.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Deprecated. Whether to include
* the JSPB instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.payloads.Payload} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.payloads.Payload.toObject = function (includeInstance, msg) {
var f,
obj = {
type: jspb.Message.getFieldWithDefault(msg, 1, 0),
messageId: msg.getMessageId_asB64(),
data: msg.getData_asB64(),
replyToId: msg.getReplyToId_asB64(),
noReply: jspb.Message.getBooleanFieldWithDefault(msg, 5, false)
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}
/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.payloads.Payload}
*/
proto.payloads.Payload.deserializeBinary = function (bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.payloads.Payload();
return proto.payloads.Payload.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.payloads.Payload} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.payloads.Payload}
*/
proto.payloads.Payload.deserializeBinaryFromReader = function (msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {!proto.payloads.PayloadType} */reader.readEnum();
msg.setType(value);
break;
case 2:
var value = /** @type {!Uint8Array} */reader.readBytes();
msg.setMessageId(value);
break;
case 3:
var value = /** @type {!Uint8Array} */reader.readBytes();
msg.setData(value);
break;
case 4:
var value = /** @type {!Uint8Array} */reader.readBytes();
msg.setReplyToId(value);
break;
case 5:
var value = /** @type {boolean} */reader.readBool();
msg.setNoReply(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.payloads.Payload.prototype.serializeBinary = function () {
var writer = new jspb.BinaryWriter();
proto.payloads.Payload.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.payloads.Payload} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.payloads.Payload.serializeBinaryToWriter = function (message, writer) {
var f = undefined;
f = message.getType();
if (f !== 0.0) {
writer.writeEnum(1, f);
}
f = message.getMessageId_asU8();
if (f.length > 0) {
writer.writeBytes(2, f);
}
f = message.getData_asU8();
if (f.length > 0) {
writer.writeBytes(3, f);
}
f = message.getReplyToId_asU8();
if (f.length > 0) {
writer.writeBytes(4, f);
}
f = message.getNoReply();
if (f) {
writer.writeBool(5, f);
}
};
/**
* optional PayloadType type = 1;
* @return {!proto.payloads.PayloadType}
*/
proto.payloads.Payload.prototype.getType = function () {
return /** @type {!proto.payloads.PayloadType} */jspb.Message.getFieldWithDefault(this, 1, 0);
};
/**
* @param {!proto.payloads.PayloadType} value
* @return {!proto.payloads.Payload} returns this
*/
proto.payloads.Payload.prototype.setType = function (value) {
return jspb.Message.setProto3EnumField(this, 1, value);
};
/**
* optional bytes message_id = 2;
* @return {!(string|Uint8Array)}
*/
proto.payloads.Payload.prototype.getMessageId = function () {
return /** @type {!(string|Uint8Array)} */jspb.Message.getFieldWithDefault(this, 2, "");
};
/**
* optional bytes message_id = 2;
* This is a type-conversion wrapper around `getMessageId()`
* @return {string}
*/
proto.payloads.Payload.prototype.getMessageId_asB64 = function () {
return /** @type {string} */jspb.Message.bytesAsB64(this.getMessageId());
};
/**
* optional bytes message_id = 2;
* Note that Uint8Array is not supported on all browsers.
* @see http://caniuse.com/Uint8Array
* This is a type-conversion wrapper around `getMessageId()`
* @return {!Uint8Array}
*/
proto.payloads.Payload.prototype.getMessageId_asU8 = function () {
return /** @type {!Uint8Array} */jspb.Message.bytesAsU8(this.getMessageId());
};
/**
* @param {!(string|Uint8Array)} value
* @return {!proto.payloads.Payload} returns this
*/
proto.payloads.Payload.prototype.setMessageId = function (value) {
return jspb.Message.setProto3BytesField(this, 2, value);
};
/**
* optional bytes data = 3;
* @return {!(string|Uint8Array)}
*/
proto.payloads.Payload.prototype.getData = function () {
return /** @type {!(string|Uint8Array)} */jspb.Message.getFieldWithDefault(this, 3, "");
};
/**
* optional bytes data = 3;
* This is a type-conversion wrapper around `getData()`
* @return {string}
*/
proto.payloads.Payload.prototype.getData_asB64 = function () {
return /** @type {string} */jspb.Message.bytesAsB64(this.getData());
};
/**
* optional bytes data = 3;
* Note that Uint8Array is not supported on all browsers.
* @see http://caniuse.com/Uint8Array
* This is a type-conversion wrapper around `getData()`
* @return {!Uint8Array}
*/
proto.payloads.Payload.prototype.getData_asU8 = function () {
return /** @type {!Uint8Array} */jspb.Message.bytesAsU8(this.getData());
};
/**
* @param {!(string|Uint8Array)} value
* @return {!proto.payloads.Payload} returns this
*/
proto.payloads.Payload.prototype.setData = function (value) {
return jspb.Message.setProto3BytesField(this, 3, value);
};
/**
* optional bytes reply_to_id = 4;
* @return {!(string|Uint8Array)}
*/
proto.payloads.Payload.prototype.getReplyToId = function () {
return /** @type {!(string|Uint8Array)} */jspb.Message.getFieldWithDefault(this, 4, "");
};
/**
* optional bytes reply_to_id = 4;
* This is a type-conversion wrapper around `getReplyToId()`
* @return {string}
*/
proto.payloads.Payload.prototype.getReplyToId_asB64 = function () {
return /** @type {string} */jspb.Message.bytesAsB64(this.getReplyToId());
};
/**
* optional bytes reply_to_id = 4;
* Note that Uint8Array is not supported on all browsers.
* @see http://caniuse.com/Uint8Array
* This is a type-conversion wrapper around `getReplyToId()`
* @return {!Uint8Array}
*/
proto.payloads.Payload.prototype.getReplyToId_asU8 = function () {
return /** @type {!Uint8Array} */jspb.Message.bytesAsU8(this.getReplyToId());
};
/**
* @param {!(string|Uint8Array)} value
* @return {!proto.payloads.Payload} returns this
*/
proto.payloads.Payload.prototype.setReplyToId = function (value) {
return jspb.Message.setProto3BytesField(this, 4, value);
};
/**
* optional bool no_reply = 5;
* @return {boolean}
*/
proto.payloads.Payload.prototype.getNoReply = function () {
return /** @type {boolean} */jspb.Message.getBooleanFieldWithDefault(this, 5, false);
};
/**
* @param {boolean} value
* @return {!proto.payloads.Payload} returns this
*/
proto.payloads.Payload.prototype.setNoReply = function (value) {
return jspb.Message.setProto3BooleanField(this, 5, value);
};
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* Optional fields that are not set will be set to undefined.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* net/proto2/compiler/js/internal/generator.cc#kKeyword.
* @param {boolean=} opt_includeInstance Deprecated. whether to include the
* JSPB instance for transitional soy proto support:
* http://goto/soy-param-migration
* @return {!Object}
*/
proto.payloads.TextData.prototype.toObject = function (opt_includeInstance) {
return proto.payloads.TextData.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Deprecated. Whether to include
* the JSPB instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.payloads.TextData} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.payloads.TextData.toObject = function (includeInstance, msg) {
var f,
obj = {
text: jspb.Message.getFieldWithDefault(msg, 1, "")
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}
/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.payloads.TextData}
*/
proto.payloads.TextData.deserializeBinary = function (bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.payloads.TextData();
return proto.payloads.TextData.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.payloads.TextData} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.payloads.TextData}
*/
proto.payloads.TextData.deserializeBinaryFromReader = function (msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {string} */reader.readString();
msg.setText(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.payloads.TextData.prototype.serializeBinary = function () {
var writer = new jspb.BinaryWriter();
proto.payloads.TextData.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.payloads.TextData} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.payloads.TextData.serializeBinaryToWriter = function (message, writer) {
var f = undefined;
f = message.getText();
if (f.length > 0) {
writer.writeString(1, f);
}
};
/**
* optional string text = 1;
* @return {string}
*/
proto.payloads.TextData.prototype.getText = function () {
return /** @type {string} */jspb.Message.getFieldWithDefault(this, 1, "");
};
/**
* @param {string} value
* @return {!proto.payloads.TextData} returns this
*/
proto.payloads.TextData.prototype.setText = function (value) {
return jspb.Message.setProto3StringField(this, 1, value);
};
/**
* @enum {number}
*/
proto.payloads.PayloadType = {
BINARY: 0,
TEXT: 1,
ACK: 2,
SESSION: 3
};
goog.object.extend(exports, proto.payloads);