neroxbailx
Version:
baileys whatsapp-api
1,446 lines • 109 kB
JavaScript
/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
"use strict";
var $protobuf = require("protobufjs/minimal");
// Common aliases
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
// Exported root namespace
var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});
$root.ServerSync = (function() {
/**
* Namespace ServerSync.
* @exports ServerSync
* @namespace
*/
var ServerSync = {};
ServerSync.SyncdPatch = (function() {
/**
* Properties of a SyncdPatch.
* @memberof ServerSync
* @interface ISyncdPatch
* @property {ServerSync.ISyncdVersion|null} [version] SyncdPatch version
* @property {Array.<ServerSync.ISyncdMutation>|null} [mutations] SyncdPatch mutations
* @property {ServerSync.IExternalBlobReference|null} [externalMutations] SyncdPatch externalMutations
* @property {Uint8Array|null} [snapshotMac] SyncdPatch snapshotMac
* @property {Uint8Array|null} [patchMac] SyncdPatch patchMac
* @property {ServerSync.IKeyId|null} [keyId] SyncdPatch keyId
* @property {ServerSync.IExitCode|null} [exitCode] SyncdPatch exitCode
* @property {number|null} [deviceIndex] SyncdPatch deviceIndex
* @property {Uint8Array|null} [clientDebugData] SyncdPatch clientDebugData
*/
/**
* Constructs a new SyncdPatch.
* @memberof ServerSync
* @classdesc Represents a SyncdPatch.
* @implements ISyncdPatch
* @constructor
* @param {ServerSync.ISyncdPatch=} [properties] Properties to set
*/
function SyncdPatch(properties) {
this.mutations = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* SyncdPatch version.
* @member {ServerSync.ISyncdVersion|null|undefined} version
* @memberof ServerSync.SyncdPatch
* @instance
*/
SyncdPatch.prototype.version = null;
/**
* SyncdPatch mutations.
* @member {Array.<ServerSync.ISyncdMutation>} mutations
* @memberof ServerSync.SyncdPatch
* @instance
*/
SyncdPatch.prototype.mutations = $util.emptyArray;
/**
* SyncdPatch externalMutations.
* @member {ServerSync.IExternalBlobReference|null|undefined} externalMutations
* @memberof ServerSync.SyncdPatch
* @instance
*/
SyncdPatch.prototype.externalMutations = null;
/**
* SyncdPatch snapshotMac.
* @member {Uint8Array|null|undefined} snapshotMac
* @memberof ServerSync.SyncdPatch
* @instance
*/
SyncdPatch.prototype.snapshotMac = null;
/**
* SyncdPatch patchMac.
* @member {Uint8Array|null|undefined} patchMac
* @memberof ServerSync.SyncdPatch
* @instance
*/
SyncdPatch.prototype.patchMac = null;
/**
* SyncdPatch keyId.
* @member {ServerSync.IKeyId|null|undefined} keyId
* @memberof ServerSync.SyncdPatch
* @instance
*/
SyncdPatch.prototype.keyId = null;
/**
* SyncdPatch exitCode.
* @member {ServerSync.IExitCode|null|undefined} exitCode
* @memberof ServerSync.SyncdPatch
* @instance
*/
SyncdPatch.prototype.exitCode = null;
/**
* SyncdPatch deviceIndex.
* @member {number|null|undefined} deviceIndex
* @memberof ServerSync.SyncdPatch
* @instance
*/
SyncdPatch.prototype.deviceIndex = null;
/**
* SyncdPatch clientDebugData.
* @member {Uint8Array|null|undefined} clientDebugData
* @memberof ServerSync.SyncdPatch
* @instance
*/
SyncdPatch.prototype.clientDebugData = null;
// OneOf field names bound to virtual getters and setters
var $oneOfFields;
/**
* SyncdPatch _version.
* @member {"version"|undefined} _version
* @memberof ServerSync.SyncdPatch
* @instance
*/
Object.defineProperty(SyncdPatch.prototype, "_version", {
get: $util.oneOfGetter($oneOfFields = ["version"]),
set: $util.oneOfSetter($oneOfFields)
});
/**
* SyncdPatch _externalMutations.
* @member {"externalMutations"|undefined} _externalMutations
* @memberof ServerSync.SyncdPatch
* @instance
*/
Object.defineProperty(SyncdPatch.prototype, "_externalMutations", {
get: $util.oneOfGetter($oneOfFields = ["externalMutations"]),
set: $util.oneOfSetter($oneOfFields)
});
/**
* SyncdPatch _snapshotMac.
* @member {"snapshotMac"|undefined} _snapshotMac
* @memberof ServerSync.SyncdPatch
* @instance
*/
Object.defineProperty(SyncdPatch.prototype, "_snapshotMac", {
get: $util.oneOfGetter($oneOfFields = ["snapshotMac"]),
set: $util.oneOfSetter($oneOfFields)
});
/**
* SyncdPatch _patchMac.
* @member {"patchMac"|undefined} _patchMac
* @memberof ServerSync.SyncdPatch
* @instance
*/
Object.defineProperty(SyncdPatch.prototype, "_patchMac", {
get: $util.oneOfGetter($oneOfFields = ["patchMac"]),
set: $util.oneOfSetter($oneOfFields)
});
/**
* SyncdPatch _keyId.
* @member {"keyId"|undefined} _keyId
* @memberof ServerSync.SyncdPatch
* @instance
*/
Object.defineProperty(SyncdPatch.prototype, "_keyId", {
get: $util.oneOfGetter($oneOfFields = ["keyId"]),
set: $util.oneOfSetter($oneOfFields)
});
/**
* SyncdPatch _exitCode.
* @member {"exitCode"|undefined} _exitCode
* @memberof ServerSync.SyncdPatch
* @instance
*/
Object.defineProperty(SyncdPatch.prototype, "_exitCode", {
get: $util.oneOfGetter($oneOfFields = ["exitCode"]),
set: $util.oneOfSetter($oneOfFields)
});
/**
* SyncdPatch _deviceIndex.
* @member {"deviceIndex"|undefined} _deviceIndex
* @memberof ServerSync.SyncdPatch
* @instance
*/
Object.defineProperty(SyncdPatch.prototype, "_deviceIndex", {
get: $util.oneOfGetter($oneOfFields = ["deviceIndex"]),
set: $util.oneOfSetter($oneOfFields)
});
/**
* SyncdPatch _clientDebugData.
* @member {"clientDebugData"|undefined} _clientDebugData
* @memberof ServerSync.SyncdPatch
* @instance
*/
Object.defineProperty(SyncdPatch.prototype, "_clientDebugData", {
get: $util.oneOfGetter($oneOfFields = ["clientDebugData"]),
set: $util.oneOfSetter($oneOfFields)
});
/**
* Creates a new SyncdPatch instance using the specified properties.
* @function create
* @memberof ServerSync.SyncdPatch
* @static
* @param {ServerSync.ISyncdPatch=} [properties] Properties to set
* @returns {ServerSync.SyncdPatch} SyncdPatch instance
*/
SyncdPatch.create = function create(properties) {
return new SyncdPatch(properties);
};
/**
* Encodes the specified SyncdPatch message. Does not implicitly {@link ServerSync.SyncdPatch.verify|verify} messages.
* @function encode
* @memberof ServerSync.SyncdPatch
* @static
* @param {ServerSync.ISyncdPatch} message SyncdPatch message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
SyncdPatch.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.version != null && Object.hasOwnProperty.call(message, "version"))
$root.ServerSync.SyncdVersion.encode(message.version, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
if (message.mutations != null && message.mutations.length)
for (var i = 0; i < message.mutations.length; ++i)
$root.ServerSync.SyncdMutation.encode(message.mutations[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
if (message.externalMutations != null && Object.hasOwnProperty.call(message, "externalMutations"))
$root.ServerSync.ExternalBlobReference.encode(message.externalMutations, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
if (message.snapshotMac != null && Object.hasOwnProperty.call(message, "snapshotMac"))
writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.snapshotMac);
if (message.patchMac != null && Object.hasOwnProperty.call(message, "patchMac"))
writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.patchMac);
if (message.keyId != null && Object.hasOwnProperty.call(message, "keyId"))
$root.ServerSync.KeyId.encode(message.keyId, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim();
if (message.exitCode != null && Object.hasOwnProperty.call(message, "exitCode"))
$root.ServerSync.ExitCode.encode(message.exitCode, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim();
if (message.deviceIndex != null && Object.hasOwnProperty.call(message, "deviceIndex"))
writer.uint32(/* id 8, wireType 0 =*/64).uint32(message.deviceIndex);
if (message.clientDebugData != null && Object.hasOwnProperty.call(message, "clientDebugData"))
writer.uint32(/* id 9, wireType 2 =*/74).bytes(message.clientDebugData);
return writer;
};
/**
* Encodes the specified SyncdPatch message, length delimited. Does not implicitly {@link ServerSync.SyncdPatch.verify|verify} messages.
* @function encodeDelimited
* @memberof ServerSync.SyncdPatch
* @static
* @param {ServerSync.ISyncdPatch} message SyncdPatch message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
SyncdPatch.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a SyncdPatch message from the specified reader or buffer.
* @function decode
* @memberof ServerSync.SyncdPatch
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {ServerSync.SyncdPatch} SyncdPatch
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
SyncdPatch.decode = function decode(reader, length, error) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.ServerSync.SyncdPatch();
while (reader.pos < end) {
var tag = reader.uint32();
if (tag === error)
break;
switch (tag >>> 3) {
case 1: {
message.version = $root.ServerSync.SyncdVersion.decode(reader, reader.uint32());
break;
}
case 2: {
if (!(message.mutations && message.mutations.length))
message.mutations = [];
message.mutations.push($root.ServerSync.SyncdMutation.decode(reader, reader.uint32()));
break;
}
case 3: {
message.externalMutations = $root.ServerSync.ExternalBlobReference.decode(reader, reader.uint32());
break;
}
case 4: {
message.snapshotMac = reader.bytes();
break;
}
case 5: {
message.patchMac = reader.bytes();
break;
}
case 6: {
message.keyId = $root.ServerSync.KeyId.decode(reader, reader.uint32());
break;
}
case 7: {
message.exitCode = $root.ServerSync.ExitCode.decode(reader, reader.uint32());
break;
}
case 8: {
message.deviceIndex = reader.uint32();
break;
}
case 9: {
message.clientDebugData = reader.bytes();
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a SyncdPatch message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof ServerSync.SyncdPatch
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {ServerSync.SyncdPatch} SyncdPatch
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
SyncdPatch.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a SyncdPatch message.
* @function verify
* @memberof ServerSync.SyncdPatch
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
SyncdPatch.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
var properties = {};
if (message.version != null && message.hasOwnProperty("version")) {
properties._version = 1;
{
var error = $root.ServerSync.SyncdVersion.verify(message.version);
if (error)
return "version." + error;
}
}
if (message.mutations != null && message.hasOwnProperty("mutations")) {
if (!Array.isArray(message.mutations))
return "mutations: array expected";
for (var i = 0; i < message.mutations.length; ++i) {
var error = $root.ServerSync.SyncdMutation.verify(message.mutations[i]);
if (error)
return "mutations." + error;
}
}
if (message.externalMutations != null && message.hasOwnProperty("externalMutations")) {
properties._externalMutations = 1;
{
var error = $root.ServerSync.ExternalBlobReference.verify(message.externalMutations);
if (error)
return "externalMutations." + error;
}
}
if (message.snapshotMac != null && message.hasOwnProperty("snapshotMac")) {
properties._snapshotMac = 1;
if (!(message.snapshotMac && typeof message.snapshotMac.length === "number" || $util.isString(message.snapshotMac)))
return "snapshotMac: buffer expected";
}
if (message.patchMac != null && message.hasOwnProperty("patchMac")) {
properties._patchMac = 1;
if (!(message.patchMac && typeof message.patchMac.length === "number" || $util.isString(message.patchMac)))
return "patchMac: buffer expected";
}
if (message.keyId != null && message.hasOwnProperty("keyId")) {
properties._keyId = 1;
{
var error = $root.ServerSync.KeyId.verify(message.keyId);
if (error)
return "keyId." + error;
}
}
if (message.exitCode != null && message.hasOwnProperty("exitCode")) {
properties._exitCode = 1;
{
var error = $root.ServerSync.ExitCode.verify(message.exitCode);
if (error)
return "exitCode." + error;
}
}
if (message.deviceIndex != null && message.hasOwnProperty("deviceIndex")) {
properties._deviceIndex = 1;
if (!$util.isInteger(message.deviceIndex))
return "deviceIndex: integer expected";
}
if (message.clientDebugData != null && message.hasOwnProperty("clientDebugData")) {
properties._clientDebugData = 1;
if (!(message.clientDebugData && typeof message.clientDebugData.length === "number" || $util.isString(message.clientDebugData)))
return "clientDebugData: buffer expected";
}
return null;
};
/**
* Creates a SyncdPatch message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof ServerSync.SyncdPatch
* @static
* @param {Object.<string,*>} object Plain object
* @returns {ServerSync.SyncdPatch} SyncdPatch
*/
SyncdPatch.fromObject = function fromObject(object) {
if (object instanceof $root.ServerSync.SyncdPatch)
return object;
var message = new $root.ServerSync.SyncdPatch();
if (object.version != null) {
if (typeof object.version !== "object")
throw TypeError(".ServerSync.SyncdPatch.version: object expected");
message.version = $root.ServerSync.SyncdVersion.fromObject(object.version);
}
if (object.mutations) {
if (!Array.isArray(object.mutations))
throw TypeError(".ServerSync.SyncdPatch.mutations: array expected");
message.mutations = [];
for (var i = 0; i < object.mutations.length; ++i) {
if (typeof object.mutations[i] !== "object")
throw TypeError(".ServerSync.SyncdPatch.mutations: object expected");
message.mutations[i] = $root.ServerSync.SyncdMutation.fromObject(object.mutations[i]);
}
}
if (object.externalMutations != null) {
if (typeof object.externalMutations !== "object")
throw TypeError(".ServerSync.SyncdPatch.externalMutations: object expected");
message.externalMutations = $root.ServerSync.ExternalBlobReference.fromObject(object.externalMutations);
}
if (object.snapshotMac != null)
if (typeof object.snapshotMac === "string")
$util.base64.decode(object.snapshotMac, message.snapshotMac = $util.newBuffer($util.base64.length(object.snapshotMac)), 0);
else if (object.snapshotMac.length >= 0)
message.snapshotMac = object.snapshotMac;
if (object.patchMac != null)
if (typeof object.patchMac === "string")
$util.base64.decode(object.patchMac, message.patchMac = $util.newBuffer($util.base64.length(object.patchMac)), 0);
else if (object.patchMac.length >= 0)
message.patchMac = object.patchMac;
if (object.keyId != null) {
if (typeof object.keyId !== "object")
throw TypeError(".ServerSync.SyncdPatch.keyId: object expected");
message.keyId = $root.ServerSync.KeyId.fromObject(object.keyId);
}
if (object.exitCode != null) {
if (typeof object.exitCode !== "object")
throw TypeError(".ServerSync.SyncdPatch.exitCode: object expected");
message.exitCode = $root.ServerSync.ExitCode.fromObject(object.exitCode);
}
if (object.deviceIndex != null)
message.deviceIndex = object.deviceIndex >>> 0;
if (object.clientDebugData != null)
if (typeof object.clientDebugData === "string")
$util.base64.decode(object.clientDebugData, message.clientDebugData = $util.newBuffer($util.base64.length(object.clientDebugData)), 0);
else if (object.clientDebugData.length >= 0)
message.clientDebugData = object.clientDebugData;
return message;
};
/**
* Creates a plain object from a SyncdPatch message. Also converts values to other types if specified.
* @function toObject
* @memberof ServerSync.SyncdPatch
* @static
* @param {ServerSync.SyncdPatch} message SyncdPatch
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
SyncdPatch.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (options.arrays || options.defaults)
object.mutations = [];
if (message.version != null && message.hasOwnProperty("version")) {
object.version = $root.ServerSync.SyncdVersion.toObject(message.version, options);
if (options.oneofs)
object._version = "version";
}
if (message.mutations && message.mutations.length) {
object.mutations = [];
for (var j = 0; j < message.mutations.length; ++j)
object.mutations[j] = $root.ServerSync.SyncdMutation.toObject(message.mutations[j], options);
}
if (message.externalMutations != null && message.hasOwnProperty("externalMutations")) {
object.externalMutations = $root.ServerSync.ExternalBlobReference.toObject(message.externalMutations, options);
if (options.oneofs)
object._externalMutations = "externalMutations";
}
if (message.snapshotMac != null && message.hasOwnProperty("snapshotMac")) {
object.snapshotMac = options.bytes === String ? $util.base64.encode(message.snapshotMac, 0, message.snapshotMac.length) : options.bytes === Array ? Array.prototype.slice.call(message.snapshotMac) : message.snapshotMac;
if (options.oneofs)
object._snapshotMac = "snapshotMac";
}
if (message.patchMac != null && message.hasOwnProperty("patchMac")) {
object.patchMac = options.bytes === String ? $util.base64.encode(message.patchMac, 0, message.patchMac.length) : options.bytes === Array ? Array.prototype.slice.call(message.patchMac) : message.patchMac;
if (options.oneofs)
object._patchMac = "patchMac";
}
if (message.keyId != null && message.hasOwnProperty("keyId")) {
object.keyId = $root.ServerSync.KeyId.toObject(message.keyId, options);
if (options.oneofs)
object._keyId = "keyId";
}
if (message.exitCode != null && message.hasOwnProperty("exitCode")) {
object.exitCode = $root.ServerSync.ExitCode.toObject(message.exitCode, options);
if (options.oneofs)
object._exitCode = "exitCode";
}
if (message.deviceIndex != null && message.hasOwnProperty("deviceIndex")) {
object.deviceIndex = message.deviceIndex;
if (options.oneofs)
object._deviceIndex = "deviceIndex";
}
if (message.clientDebugData != null && message.hasOwnProperty("clientDebugData")) {
object.clientDebugData = options.bytes === String ? $util.base64.encode(message.clientDebugData, 0, message.clientDebugData.length) : options.bytes === Array ? Array.prototype.slice.call(message.clientDebugData) : message.clientDebugData;
if (options.oneofs)
object._clientDebugData = "clientDebugData";
}
return object;
};
/**
* Converts this SyncdPatch to JSON.
* @function toJSON
* @memberof ServerSync.SyncdPatch
* @instance
* @returns {Object.<string,*>} JSON object
*/
SyncdPatch.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
/**
* Gets the default type url for SyncdPatch
* @function getTypeUrl
* @memberof ServerSync.SyncdPatch
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
SyncdPatch.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/ServerSync.SyncdPatch";
};
return SyncdPatch;
})();
ServerSync.SyncdMutation = (function() {
/**
* Properties of a SyncdMutation.
* @memberof ServerSync
* @interface ISyncdMutation
* @property {ServerSync.SyncdMutation.SyncdOperation|null} [operation] SyncdMutation operation
* @property {ServerSync.ISyncdRecord|null} [record] SyncdMutation record
*/
/**
* Constructs a new SyncdMutation.
* @memberof ServerSync
* @classdesc Represents a SyncdMutation.
* @implements ISyncdMutation
* @constructor
* @param {ServerSync.ISyncdMutation=} [properties] Properties to set
*/
function SyncdMutation(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* SyncdMutation operation.
* @member {ServerSync.SyncdMutation.SyncdOperation|null|undefined} operation
* @memberof ServerSync.SyncdMutation
* @instance
*/
SyncdMutation.prototype.operation = null;
/**
* SyncdMutation record.
* @member {ServerSync.ISyncdRecord|null|undefined} record
* @memberof ServerSync.SyncdMutation
* @instance
*/
SyncdMutation.prototype.record = null;
// OneOf field names bound to virtual getters and setters
var $oneOfFields;
/**
* SyncdMutation _operation.
* @member {"operation"|undefined} _operation
* @memberof ServerSync.SyncdMutation
* @instance
*/
Object.defineProperty(SyncdMutation.prototype, "_operation", {
get: $util.oneOfGetter($oneOfFields = ["operation"]),
set: $util.oneOfSetter($oneOfFields)
});
/**
* SyncdMutation _record.
* @member {"record"|undefined} _record
* @memberof ServerSync.SyncdMutation
* @instance
*/
Object.defineProperty(SyncdMutation.prototype, "_record", {
get: $util.oneOfGetter($oneOfFields = ["record"]),
set: $util.oneOfSetter($oneOfFields)
});
/**
* Creates a new SyncdMutation instance using the specified properties.
* @function create
* @memberof ServerSync.SyncdMutation
* @static
* @param {ServerSync.ISyncdMutation=} [properties] Properties to set
* @returns {ServerSync.SyncdMutation} SyncdMutation instance
*/
SyncdMutation.create = function create(properties) {
return new SyncdMutation(properties);
};
/**
* Encodes the specified SyncdMutation message. Does not implicitly {@link ServerSync.SyncdMutation.verify|verify} messages.
* @function encode
* @memberof ServerSync.SyncdMutation
* @static
* @param {ServerSync.ISyncdMutation} message SyncdMutation message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
SyncdMutation.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.operation != null && Object.hasOwnProperty.call(message, "operation"))
writer.uint32(/* id 1, wireType 0 =*/8).int32(message.operation);
if (message.record != null && Object.hasOwnProperty.call(message, "record"))
$root.ServerSync.SyncdRecord.encode(message.record, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
return writer;
};
/**
* Encodes the specified SyncdMutation message, length delimited. Does not implicitly {@link ServerSync.SyncdMutation.verify|verify} messages.
* @function encodeDelimited
* @memberof ServerSync.SyncdMutation
* @static
* @param {ServerSync.ISyncdMutation} message SyncdMutation message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
SyncdMutation.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a SyncdMutation message from the specified reader or buffer.
* @function decode
* @memberof ServerSync.SyncdMutation
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {ServerSync.SyncdMutation} SyncdMutation
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
SyncdMutation.decode = function decode(reader, length, error) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.ServerSync.SyncdMutation();
while (reader.pos < end) {
var tag = reader.uint32();
if (tag === error)
break;
switch (tag >>> 3) {
case 1: {
message.operation = reader.int32();
break;
}
case 2: {
message.record = $root.ServerSync.SyncdRecord.decode(reader, reader.uint32());
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a SyncdMutation message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof ServerSync.SyncdMutation
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {ServerSync.SyncdMutation} SyncdMutation
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
SyncdMutation.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a SyncdMutation message.
* @function verify
* @memberof ServerSync.SyncdMutation
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
SyncdMutation.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
var properties = {};
if (message.operation != null && message.hasOwnProperty("operation")) {
properties._operation = 1;
switch (message.operation) {
default:
return "operation: enum value expected";
case 0:
case 1:
break;
}
}
if (message.record != null && message.hasOwnProperty("record")) {
properties._record = 1;
{
var error = $root.ServerSync.SyncdRecord.verify(message.record);
if (error)
return "record." + error;
}
}
return null;
};
/**
* Creates a SyncdMutation message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof ServerSync.SyncdMutation
* @static
* @param {Object.<string,*>} object Plain object
* @returns {ServerSync.SyncdMutation} SyncdMutation
*/
SyncdMutation.fromObject = function fromObject(object) {
if (object instanceof $root.ServerSync.SyncdMutation)
return object;
var message = new $root.ServerSync.SyncdMutation();
switch (object.operation) {
default:
if (typeof object.operation === "number") {
message.operation = object.operation;
break;
}
break;
case "SET":
case 0:
message.operation = 0;
break;
case "REMOVE":
case 1:
message.operation = 1;
break;
}
if (object.record != null) {
if (typeof object.record !== "object")
throw TypeError(".ServerSync.SyncdMutation.record: object expected");
message.record = $root.ServerSync.SyncdRecord.fromObject(object.record);
}
return message;
};
/**
* Creates a plain object from a SyncdMutation message. Also converts values to other types if specified.
* @function toObject
* @memberof ServerSync.SyncdMutation
* @static
* @param {ServerSync.SyncdMutation} message SyncdMutation
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
SyncdMutation.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (message.operation != null && message.hasOwnProperty("operation")) {
object.operation = options.enums === String ? $root.ServerSync.SyncdMutation.SyncdOperation[message.operation] === undefined ? message.operation : $root.ServerSync.SyncdMutation.SyncdOperation[message.operation] : message.operation;
if (options.oneofs)
object._operation = "operation";
}
if (message.record != null && message.hasOwnProperty("record")) {
object.record = $root.ServerSync.SyncdRecord.toObject(message.record, options);
if (options.oneofs)
object._record = "record";
}
return object;
};
/**
* Converts this SyncdMutation to JSON.
* @function toJSON
* @memberof ServerSync.SyncdMutation
* @instance
* @returns {Object.<string,*>} JSON object
*/
SyncdMutation.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
/**
* Gets the default type url for SyncdMutation
* @function getTypeUrl
* @memberof ServerSync.SyncdMutation
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
SyncdMutation.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/ServerSync.SyncdMutation";
};
/**
* SyncdOperation enum.
* @name ServerSync.SyncdMutation.SyncdOperation
* @enum {number}
* @property {number} SET=0 SET value
* @property {number} REMOVE=1 REMOVE value
*/
SyncdMutation.SyncdOperation = (function() {
var valuesById = {}, values = Object.create(valuesById);
values[valuesById[0] = "SET"] = 0;
values[valuesById[1] = "REMOVE"] = 1;
return values;
})();
return SyncdMutation;
})();
ServerSync.SyncdMutations = (function() {
/**
* Properties of a SyncdMutations.
* @memberof ServerSync
* @interface ISyncdMutations
* @property {Array.<ServerSync.ISyncdMutation>|null} [mutations] SyncdMutations mutations
*/
/**
* Constructs a new SyncdMutations.
* @memberof ServerSync
* @classdesc Represents a SyncdMutations.
* @implements ISyncdMutations
* @constructor
* @param {ServerSync.ISyncdMutations=} [properties] Properties to set
*/
function SyncdMutations(properties) {
this.mutations = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* SyncdMutations mutations.
* @member {Array.<ServerSync.ISyncdMutation>} mutations
* @memberof ServerSync.SyncdMutations
* @instance
*/
SyncdMutations.prototype.mutations = $util.emptyArray;
/**
* Creates a new SyncdMutations instance using the specified properties.
* @function create
* @memberof ServerSync.SyncdMutations
* @static
* @param {ServerSync.ISyncdMutations=} [properties] Properties to set
* @returns {ServerSync.SyncdMutations} SyncdMutations instance
*/
SyncdMutations.create = function create(properties) {
return new SyncdMutations(properties);
};
/**
* Encodes the specified SyncdMutations message. Does not implicitly {@link ServerSync.SyncdMutations.verify|verify} messages.
* @function encode
* @memberof ServerSync.SyncdMutations
* @static
* @param {ServerSync.ISyncdMutations} message SyncdMutations message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
SyncdMutations.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.mutations != null && message.mutations.length)
for (var i = 0; i < message.mutations.length; ++i)
$root.ServerSync.SyncdMutation.encode(message.mutations[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
return writer;
};
/**
* Encodes the specified SyncdMutations message, length delimited. Does not implicitly {@link ServerSync.SyncdMutations.verify|verify} messages.
* @function encodeDelimited
* @memberof ServerSync.SyncdMutations
* @static
* @param {ServerSync.ISyncdMutations} message SyncdMutations message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
SyncdMutations.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a SyncdMutations message from the specified reader or buffer.
* @function decode
* @memberof ServerSync.SyncdMutations
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {ServerSync.SyncdMutations} SyncdMutations
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
SyncdMutations.decode = function decode(reader, length, error) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.ServerSync.SyncdMutations();
while (reader.pos < end) {
var tag = reader.uint32();
if (tag === error)
break;
switch (tag >>> 3) {
case 1: {
if (!(message.mutations && message.mutations.length))
message.mutations = [];
message.mutations.push($root.ServerSync.SyncdMutation.decode(reader, reader.uint32()));
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a SyncdMutations message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof ServerSync.SyncdMutations
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {ServerSync.SyncdMutations} SyncdMutations
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
SyncdMutations.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a SyncdMutations message.
* @function verify
* @memberof ServerSync.SyncdMutations
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
SyncdMutations.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.mutations != null && message.hasOwnProperty("mutations")) {
if (!Array.isArray(message.mutations))
return "mutations: array expected";
for (var i = 0; i < message.mutations.length; ++i) {
var error = $root.ServerSync.SyncdMutation.verify(message.mutations[i]);
if (error)
return "mutations." + error;
}
}
return null;
};
/**
* Creates a SyncdMutations message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof ServerSync.SyncdMutations
* @static
* @param {Object.<string,*>} object Plain object
* @returns {ServerSync.SyncdMutations} SyncdMutations
*/
SyncdMutations.fromObject = function fromObject(object) {
if (object instanceof $root.ServerSync.SyncdMutations)
return object;
var message = new $root.ServerSync.SyncdMutations();
if (object.mutations) {
if (!Array.isArray(object.mutations))
throw TypeError(".ServerSync.SyncdMutations.mutations: array expected");
message.mutations = [];
for (var i = 0; i < object.mutations.length; ++i) {
if (typeof object.mutations[i] !== "object")
throw TypeError(".ServerSync.SyncdMutations.mutations: object expected");
message.mutations[i] = $root.ServerSync.SyncdMutation.fromObject(object.mutations[i]);
}
}
return message;
};
/**
* Creates a plain object from a SyncdMutations message. Also converts values to other types if specified.
* @function toObject
* @memberof ServerSync.SyncdMutations
* @static
* @param {ServerSync.SyncdMutations} message SyncdMutations
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
SyncdMutations.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (options.arrays || options.defaults)
object.mutations = [];
if (message.mutations && message.mutations.length) {
object.mutations = [];
for (var j = 0; j < message.mutations.length; ++j)
object.mutations[j] = $root.ServerSync.SyncdMutation.toObject(message.mutations[j], options);
}
return object;
};
/**
* Converts this SyncdMutations to JSON.
* @function toJSON
* @memberof ServerSync.SyncdMutations
* @instance
* @returns {Object.<string,*>} JSON object
*/
SyncdMutations.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
/**
* Gets the default type url for SyncdMutations
* @function getTypeUrl
* @memberof ServerSync.SyncdMutations
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
SyncdMutations.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/ServerSync.SyncdMutations";
};
return SyncdMutations;
})();
ServerSync.SyncdSnapshot = (function() {
/**
* Properties of a SyncdSnapshot.
* @memberof ServerSync
* @interface ISyncdSnapshot
* @property {ServerSync.ISyncdVersion|null} [version] SyncdSnapshot version
* @property {Array.<ServerSync.ISyncdRecord>|null} [records] SyncdSnapshot records
* @property {Uint8Array|null} [mac] SyncdSnapshot mac
* @property {ServerSync.IKeyId|null} [keyId] SyncdSnapshot keyId
*/
/**
* Constructs a new SyncdSnapshot.
* @memberof ServerSync
* @classdesc Represents a SyncdSnapshot.
* @implements ISyncdSnapshot
* @constructor
* @param {ServerSync.ISyncdSnapshot=} [properties] Properties to set
*/
function SyncdSnapshot(properties) {
this.records = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* SyncdSnapshot version.
* @member {ServerSync.ISyncdVersion|null|undefined} version
* @memberof ServerSync.SyncdSnapshot
* @instance
*/
SyncdSnapshot.prototype.version = null;
/**
* SyncdSnapshot records.
* @member {Array.<ServerSync.ISyncdRecord>} records
* @memberof ServerSync.SyncdSnapshot
* @instance
*/
SyncdSnapshot.prototype.records = $util.emptyArray;
/**
* SyncdSnapshot mac.
* @member {Uint8Array|null|undefined} mac
* @memberof ServerSync.SyncdSnapshot
* @instance
*/
SyncdSnapshot.prototype.mac = null;
/**
* SyncdSnapshot keyId.
* @member {ServerSync.IKeyId|null|undefined} keyId
* @memberof ServerSync.SyncdSnapshot
* @instance
*/
SyncdSnapshot.prototype.keyId = null;
// OneOf field names bound to virtual getters and setters
var $oneOfFields;
/**
* SyncdSnapshot _version.
* @member {"version"|undefined} _version
* @memberof ServerSync.SyncdSnapshot
* @instance
*/
Object.defineProperty(SyncdSnapshot.prototype, "_version", {
get: $util.oneOfGetter($oneOfFields = ["version"]),
set: $util.oneOfSetter($oneOfFields)
});
/**
* SyncdSnapshot _mac.
* @member {"mac"|undefined} _mac
* @memberof ServerSync.SyncdSnapshot
* @instance
*/
Object.defineProperty(SyncdSnapshot.prototype, "_mac", {
get: $util.oneOfGetter($oneOfFields = ["mac"]),
set: $util.oneOfSetter($oneOfFields)
});
/**
* SyncdSnapshot _keyId.
* @member {"keyId"|undefined} _keyId
* @memberof ServerSync.SyncdSnapshot
* @instance
*/
Object.defineProperty(SyncdSnapshot.prototype, "_keyId", {
get: $util.oneOfGetter($oneOfFields = ["keyId"]),
set: $util.oneOfSetter($oneOfFields)
});
/**
* Creates a new SyncdSnapshot instance using the specified properties.
* @function create
* @memberof ServerSync.SyncdSnapshot
* @static
* @param {ServerSync.ISyncdSnapshot=} [properties] Properties to set
* @returns {ServerSync.SyncdSnapshot} SyncdSnapshot instance
*/
SyncdSnapshot.create = function create(properties) {
return new SyncdSnapshot(properties);
};
/**
* Encodes the specified SyncdSnapshot message. Does not implicitly {@link ServerSync.SyncdSnapshot.verify|verify} messages.
* @function encode
* @memberof ServerSync.SyncdSnapshot
* @static
* @param {ServerSync.ISyncdSnapshot} message SyncdSnapshot message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
SyncdSnapshot.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.version != null && Object.hasOwnProperty.call(message, "version"))
$root.ServerSync.SyncdVersion.encode(message.version, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
if (message.records != null && message.records.length)
for (var i = 0; i < message.records.length; ++i)
$root.ServerSync.SyncdRecord.encode(message.records[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
if (message.mac != null && Object.hasOwnProperty.call(message, "mac"))
writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.mac);
if (message.keyId != null && Object.hasOwnProperty.call(message, "keyId"))
$root.ServerSync.KeyId.encode(message.keyId, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
return writer;
};
/**
* Encodes the specified SyncdSnapshot message, length delimited. Does not implicitly {@link ServerSync.SyncdSnapshot.verify|verify} messages.
* @function encodeDelimited
* @memberof ServerSync.SyncdSnapshot
* @static
* @param {ServerSync.ISyncdSnapshot} message SyncdSnapshot message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
SyncdSnapshot.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a SyncdSnapshot message from the specified reader or buffer.
* @function decode
* @memberof ServerSync.SyncdSnapshot
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {ServerSync.SyncdSnapshot} SyncdSnapshot
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
SyncdSnapshot.decode = function decode(reader, length, error) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.ServerSync.SyncdSnapshot();
while (reader.pos < end) {
var tag = reader.uint32();
if (tag === error)
break;
switch (tag >>> 3) {
case 1: {
message.version = $root.ServerSync.SyncdVersion.decode(reader, reader.uint32());
break;
}
case 2: {
if (!(message.records && message.records.length))
message.records = [];
message.records.push($root.ServerSync.SyncdRecord.decode(reader, reader.uint32()));
break;
}
case 3: {
message.mac = reader.bytes();
break;
}
case 4: {
message.keyId = $root.ServerSync.KeyId.decode(reader, reader.uint32());
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a SyncdSnapshot message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof ServerSync.SyncdSnapshot
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {ServerSync.SyncdSnapshot} SyncdSnapshot
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
SyncdSnapshot.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a SyncdSnapshot message.
* @function verify
* @memberof ServerSync.SyncdSnapshot
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
SyncdSnapshot.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
var properties = {};
if (message.version != null && message.hasOwnProperty("version")) {
properties._version = 1;
{
var error = $root.ServerSync.SyncdVersion.verify(message.version);
if (error)
return "version." + error;
}
}
if (message.records != null && message.hasOwnProperty("records")) {
if (!Array.isArray(message.records))
return "records: array expected";
for (var i = 0; i < message.records.length; ++i) {
var error = $root.ServerSync.SyncdRecord.verify(message.records[i]);
if (error)
return "records." + error;
}
}
if (message.mac != null && message.hasOwnProperty("mac")) {
properties._mac = 1;
if (!(message.mac && typeof message.mac.length === "number" || $util.isString(message.mac)))
return "mac: buffer expected";
}
if (message.keyId != null && message.hasOwnProperty("keyId")) {
properties._keyId = 1;
{
var error = $root.ServerSync.KeyId.verify(message.keyId);
if (error)
return "keyId." + error;
}
}
return null;
};
/**
* Creates a SyncdSnapshot message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof ServerSync.SyncdSnapshot
* @static
* @param {Object.<string,*>} object Plain object
* @returns {ServerSync.SyncdSnapshot} SyncdSnapshot
*/
SyncdSnapshot.fromObject = function fromObject(object) {
if (object instanceof $root.ServerSync.SyncdSnapshot)
return object;
var message = new $root.ServerSync.SyncdSnapshot();
if (object.version != null) {
if (typeof object.version !== "object")
throw TypeError(".ServerSync.SyncdSnapshot.version: object expected");
message.version = $root.ServerSync.SyncdVersion.fromObject(object.version);
}
if (object.records) {
if (!Array.isArray(object.records))
throw TypeError(".ServerSync.SyncdSnapshot.records: array expected");
message.records = [];
for (var i = 0; i < object.records.length; ++i) {
if (typeof object.records[i] !== "object")
throw TypeError(".ServerSync.SyncdSnapshot.records: object expected");
message.records[i] = $root.ServerSync.SyncdRecord.fromObject(object.records[i]);
}
}
if (object.mac != null)
if (typeof object.mac === "string")
$util.base64.decode(object.mac, message.mac = $util.newBuffer($util.base64.length(object.mac)), 0);
else if (object.mac.length >= 0)
message.mac = object.mac;
if (object.keyId != null) {
if (typeof object.keyId !== "object")
throw TypeError(".ServerSync.SyncdSnapshot.keyId: object expected");
message.keyId = $root.ServerSync.KeyId.fromObject(object.keyId);
}
return message;
};
/**
* Creates a plain object from a SyncdSnapshot message. Also converts values to other types if specified.
* @function toObject
* @memberof ServerSync.SyncdSnapshot
* @static
* @param {ServerSync.SyncdSnapshot} message SyncdSnapshot
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
SyncdSnapshot.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (options.arrays || options.defaults)
object.records = [];
if (message.version != null && message.hasOwnProperty("version")) {
object.version = $root.ServerSync.SyncdVersion.toObject(message.version, options);
if (options.oneofs)
object._version = "version";
}
if (message.records && message.records.length) {
object.records = [];
for (var j = 0; j < message.records.length; ++j)
object.records[j] = $root.ServerSync.SyncdRecord.toObject(message.records[j], options);
}
if (message.mac != null && message.hasOwnProperty("mac")) {
object.mac = options.bytes === String ? $util.base64.encode(message.mac, 0, message.mac.length) : options.bytes === Array ? Array.prototype.slice.call(message.mac) : message.mac;
if (options.oneofs)
object._mac = "mac";
}
if (message.keyId != null && message.hasOwnProperty("keyId")) {
object.keyId = $root.ServerSync.KeyId.toObject(message.keyId, options);
if (options.oneofs)
object._keyId = "keyId";
}
return object;
};
/**
* Converts this SyncdSnapshot to JSON.
* @function toJSON
* @memberof ServerSync.SyncdSnapshot
* @instance
* @returns {Object.<string,*>} JSON object
*/
SyncdSnapshot.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
/**
* Gets the default type url for SyncdSnapshot
* @function getTypeUrl
* @memberof ServerSync.SyncdSnapshot
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
SyncdSnapshot.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/ServerSync.SyncdSnapshot";
};
return SyncdSnapshot;
})();
ServerSync.ExternalBlobReference = (function() {
/**
* Properties of an ExternalBlobReference.
* @memberof ServerSync
* @interface IExternalBlobReference
* @property {Uint8Array|null} [mediaKey] ExternalBlobReference mediaKey
* @property {string|null} [directPath] ExternalBlobReference directPath
* @property {string|null} [handle] ExternalBlobReference handle
* @property {number|Long|null} [fileSizeBytes] ExternalBlobReference fileSizeBytes
* @property {Uint8Array|null} [fileSha256] ExternalBlobReference fileSha256
* @property {Uint8Array|null} [fileEncSha256] ExternalBlobReference fileEncSha256
*/
/**
* Constructs a new ExternalBlobReference.
* @memberof ServerSync
* @classdesc Represents an ExternalBlobReference.
* @implements IExternalBlobReference
* @constructor
* @param {ServerSync.IExternalBlobReference=} [properties] Properties to set
*/
function ExternalBlobReference(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* ExternalBlobReference mediaKey.
* @member {Uint8Array|null|undefined} mediaKey
* @memberof ServerSync.ExternalBlobReference
* @instance
*/
ExternalBlobReference.prototype.mediaKey = null;
/**
* ExternalBlobReference directPath.
* @member {string|null|undefined} directPath
* @memberof ServerSync.ExternalBlobReference
* @instance
*/
ExternalBlobReference.prototype.directPath = null;
/**
* ExternalBlobReference handle.
* @member {string|null|undefined} handle
* @memberof ServerSync.ExternalBlobReference
* @instance
*/
ExternalBlobReference.prototype.handle = null;
/**
* ExternalBlobReference fileSizeBytes.
* @member {number|Long|null|undefined} fileSizeBytes
* @memberof ServerSync.ExternalBlobReference
* @instance
*/
ExternalBlobReference.prototype.fileSizeBytes = null;
/**
* ExternalBlobReference fileSha256.
* @member {Uint8Array|null|undefined} fileSha256
* @memberof ServerSync.ExternalBlobReference
* @instance
*/
ExternalBlobReference.prototype.fileSha256 = null;
/**
* ExternalBlobReference fileEncSha256.
* @member {Uint8Array|null|undefined} fileEncSha256
* @memberof ServerSync.ExternalBlobReference
* @instance
*/
ExternalBlobReference.prototype.fileEncSha256 = null;
// OneOf field names bound to virtu