UNPKG

@google-cloud/containeranalysis

Version:
986 lines (913 loc) 4.92 MB
// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/ (function(global, factory) { /* global define, require, module */ /* AMD */ if (typeof define === 'function' && define.amd) define(["protobufjs/minimal"], factory); /* CommonJS */ else if (typeof require === 'function' && typeof module === 'object' && module && module.exports) module.exports = factory(require("google-gax/build/src/protobuf").protobufMinimal); })(this, function($protobuf) { "use strict"; // Common aliases var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util; // Exported root namespace var $root = $protobuf.roots._google_cloud_containeranalysis_protos || ($protobuf.roots._google_cloud_containeranalysis_protos = {}); $root.grafeas = (function() { /** * Namespace grafeas. * @exports grafeas * @namespace */ var grafeas = {}; grafeas.v1 = (function() { /** * Namespace v1. * @memberof grafeas * @namespace */ var v1 = {}; /** * Severity enum. * @name grafeas.v1.Severity * @enum {number} * @property {number} SEVERITY_UNSPECIFIED=0 SEVERITY_UNSPECIFIED value * @property {number} MINIMAL=1 MINIMAL value * @property {number} LOW=2 LOW value * @property {number} MEDIUM=3 MEDIUM value * @property {number} HIGH=4 HIGH value * @property {number} CRITICAL=5 CRITICAL value */ v1.Severity = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "SEVERITY_UNSPECIFIED"] = 0; values[valuesById[1] = "MINIMAL"] = 1; values[valuesById[2] = "LOW"] = 2; values[valuesById[3] = "MEDIUM"] = 3; values[valuesById[4] = "HIGH"] = 4; values[valuesById[5] = "CRITICAL"] = 5; return values; })(); v1.AttestationNote = (function() { /** * Properties of an AttestationNote. * @memberof grafeas.v1 * @interface IAttestationNote * @property {grafeas.v1.AttestationNote.IHint|null} [hint] AttestationNote hint */ /** * Constructs a new AttestationNote. * @memberof grafeas.v1 * @classdesc Represents an AttestationNote. * @implements IAttestationNote * @constructor * @param {grafeas.v1.IAttestationNote=} [properties] Properties to set */ function AttestationNote(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]]; } /** * AttestationNote hint. * @member {grafeas.v1.AttestationNote.IHint|null|undefined} hint * @memberof grafeas.v1.AttestationNote * @instance */ AttestationNote.prototype.hint = null; /** * Creates a new AttestationNote instance using the specified properties. * @function create * @memberof grafeas.v1.AttestationNote * @static * @param {grafeas.v1.IAttestationNote=} [properties] Properties to set * @returns {grafeas.v1.AttestationNote} AttestationNote instance */ AttestationNote.create = function create(properties) { return new AttestationNote(properties); }; /** * Encodes the specified AttestationNote message. Does not implicitly {@link grafeas.v1.AttestationNote.verify|verify} messages. * @function encode * @memberof grafeas.v1.AttestationNote * @static * @param {grafeas.v1.IAttestationNote} message AttestationNote message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ AttestationNote.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.hint != null && Object.hasOwnProperty.call(message, "hint")) $root.grafeas.v1.AttestationNote.Hint.encode(message.hint, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); return writer; }; /** * Encodes the specified AttestationNote message, length delimited. Does not implicitly {@link grafeas.v1.AttestationNote.verify|verify} messages. * @function encodeDelimited * @memberof grafeas.v1.AttestationNote * @static * @param {grafeas.v1.IAttestationNote} message AttestationNote message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ AttestationNote.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes an AttestationNote message from the specified reader or buffer. * @function decode * @memberof grafeas.v1.AttestationNote * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {grafeas.v1.AttestationNote} AttestationNote * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ AttestationNote.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.grafeas.v1.AttestationNote(); while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) break; switch (tag >>> 3) { case 1: { message.hint = $root.grafeas.v1.AttestationNote.Hint.decode(reader, reader.uint32()); break; } default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes an AttestationNote message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof grafeas.v1.AttestationNote * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {grafeas.v1.AttestationNote} AttestationNote * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ AttestationNote.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies an AttestationNote message. * @function verify * @memberof grafeas.v1.AttestationNote * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ AttestationNote.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.hint != null && message.hasOwnProperty("hint")) { var error = $root.grafeas.v1.AttestationNote.Hint.verify(message.hint); if (error) return "hint." + error; } return null; }; /** * Creates an AttestationNote message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof grafeas.v1.AttestationNote * @static * @param {Object.<string,*>} object Plain object * @returns {grafeas.v1.AttestationNote} AttestationNote */ AttestationNote.fromObject = function fromObject(object) { if (object instanceof $root.grafeas.v1.AttestationNote) return object; var message = new $root.grafeas.v1.AttestationNote(); if (object.hint != null) { if (typeof object.hint !== "object") throw TypeError(".grafeas.v1.AttestationNote.hint: object expected"); message.hint = $root.grafeas.v1.AttestationNote.Hint.fromObject(object.hint); } return message; }; /** * Creates a plain object from an AttestationNote message. Also converts values to other types if specified. * @function toObject * @memberof grafeas.v1.AttestationNote * @static * @param {grafeas.v1.AttestationNote} message AttestationNote * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ AttestationNote.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) object.hint = null; if (message.hint != null && message.hasOwnProperty("hint")) object.hint = $root.grafeas.v1.AttestationNote.Hint.toObject(message.hint, options); return object; }; /** * Converts this AttestationNote to JSON. * @function toJSON * @memberof grafeas.v1.AttestationNote * @instance * @returns {Object.<string,*>} JSON object */ AttestationNote.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** * Gets the default type url for AttestationNote * @function getTypeUrl * @memberof grafeas.v1.AttestationNote * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ AttestationNote.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } return typeUrlPrefix + "/grafeas.v1.AttestationNote"; }; AttestationNote.Hint = (function() { /** * Properties of a Hint. * @memberof grafeas.v1.AttestationNote * @interface IHint * @property {string|null} [humanReadableName] Hint humanReadableName */ /** * Constructs a new Hint. * @memberof grafeas.v1.AttestationNote * @classdesc Represents a Hint. * @implements IHint * @constructor * @param {grafeas.v1.AttestationNote.IHint=} [properties] Properties to set */ function Hint(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]]; } /** * Hint humanReadableName. * @member {string} humanReadableName * @memberof grafeas.v1.AttestationNote.Hint * @instance */ Hint.prototype.humanReadableName = ""; /** * Creates a new Hint instance using the specified properties. * @function create * @memberof grafeas.v1.AttestationNote.Hint * @static * @param {grafeas.v1.AttestationNote.IHint=} [properties] Properties to set * @returns {grafeas.v1.AttestationNote.Hint} Hint instance */ Hint.create = function create(properties) { return new Hint(properties); }; /** * Encodes the specified Hint message. Does not implicitly {@link grafeas.v1.AttestationNote.Hint.verify|verify} messages. * @function encode * @memberof grafeas.v1.AttestationNote.Hint * @static * @param {grafeas.v1.AttestationNote.IHint} message Hint message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Hint.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.humanReadableName != null && Object.hasOwnProperty.call(message, "humanReadableName")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.humanReadableName); return writer; }; /** * Encodes the specified Hint message, length delimited. Does not implicitly {@link grafeas.v1.AttestationNote.Hint.verify|verify} messages. * @function encodeDelimited * @memberof grafeas.v1.AttestationNote.Hint * @static * @param {grafeas.v1.AttestationNote.IHint} message Hint message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Hint.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a Hint message from the specified reader or buffer. * @function decode * @memberof grafeas.v1.AttestationNote.Hint * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {grafeas.v1.AttestationNote.Hint} Hint * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Hint.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.grafeas.v1.AttestationNote.Hint(); while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) break; switch (tag >>> 3) { case 1: { message.humanReadableName = reader.string(); break; } default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a Hint message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof grafeas.v1.AttestationNote.Hint * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {grafeas.v1.AttestationNote.Hint} Hint * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Hint.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a Hint message. * @function verify * @memberof grafeas.v1.AttestationNote.Hint * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ Hint.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.humanReadableName != null && message.hasOwnProperty("humanReadableName")) if (!$util.isString(message.humanReadableName)) return "humanReadableName: string expected"; return null; }; /** * Creates a Hint message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof grafeas.v1.AttestationNote.Hint * @static * @param {Object.<string,*>} object Plain object * @returns {grafeas.v1.AttestationNote.Hint} Hint */ Hint.fromObject = function fromObject(object) { if (object instanceof $root.grafeas.v1.AttestationNote.Hint) return object; var message = new $root.grafeas.v1.AttestationNote.Hint(); if (object.humanReadableName != null) message.humanReadableName = String(object.humanReadableName); return message; }; /** * Creates a plain object from a Hint message. Also converts values to other types if specified. * @function toObject * @memberof grafeas.v1.AttestationNote.Hint * @static * @param {grafeas.v1.AttestationNote.Hint} message Hint * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ Hint.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) object.humanReadableName = ""; if (message.humanReadableName != null && message.hasOwnProperty("humanReadableName")) object.humanReadableName = message.humanReadableName; return object; }; /** * Converts this Hint to JSON. * @function toJSON * @memberof grafeas.v1.AttestationNote.Hint * @instance * @returns {Object.<string,*>} JSON object */ Hint.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** * Gets the default type url for Hint * @function getTypeUrl * @memberof grafeas.v1.AttestationNote.Hint * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ Hint.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } return typeUrlPrefix + "/grafeas.v1.AttestationNote.Hint"; }; return Hint; })(); return AttestationNote; })(); v1.Jwt = (function() { /** * Properties of a Jwt. * @memberof grafeas.v1 * @interface IJwt * @property {string|null} [compactJwt] Jwt compactJwt */ /** * Constructs a new Jwt. * @memberof grafeas.v1 * @classdesc Represents a Jwt. * @implements IJwt * @constructor * @param {grafeas.v1.IJwt=} [properties] Properties to set */ function Jwt(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]]; } /** * Jwt compactJwt. * @member {string} compactJwt * @memberof grafeas.v1.Jwt * @instance */ Jwt.prototype.compactJwt = ""; /** * Creates a new Jwt instance using the specified properties. * @function create * @memberof grafeas.v1.Jwt * @static * @param {grafeas.v1.IJwt=} [properties] Properties to set * @returns {grafeas.v1.Jwt} Jwt instance */ Jwt.create = function create(properties) { return new Jwt(properties); }; /** * Encodes the specified Jwt message. Does not implicitly {@link grafeas.v1.Jwt.verify|verify} messages. * @function encode * @memberof grafeas.v1.Jwt * @static * @param {grafeas.v1.IJwt} message Jwt message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Jwt.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.compactJwt != null && Object.hasOwnProperty.call(message, "compactJwt")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.compactJwt); return writer; }; /** * Encodes the specified Jwt message, length delimited. Does not implicitly {@link grafeas.v1.Jwt.verify|verify} messages. * @function encodeDelimited * @memberof grafeas.v1.Jwt * @static * @param {grafeas.v1.IJwt} message Jwt message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ Jwt.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes a Jwt message from the specified reader or buffer. * @function decode * @memberof grafeas.v1.Jwt * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {grafeas.v1.Jwt} Jwt * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Jwt.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.grafeas.v1.Jwt(); while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) break; switch (tag >>> 3) { case 1: { message.compactJwt = reader.string(); break; } default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes a Jwt message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof grafeas.v1.Jwt * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {grafeas.v1.Jwt} Jwt * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ Jwt.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies a Jwt message. * @function verify * @memberof grafeas.v1.Jwt * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ Jwt.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.compactJwt != null && message.hasOwnProperty("compactJwt")) if (!$util.isString(message.compactJwt)) return "compactJwt: string expected"; return null; }; /** * Creates a Jwt message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof grafeas.v1.Jwt * @static * @param {Object.<string,*>} object Plain object * @returns {grafeas.v1.Jwt} Jwt */ Jwt.fromObject = function fromObject(object) { if (object instanceof $root.grafeas.v1.Jwt) return object; var message = new $root.grafeas.v1.Jwt(); if (object.compactJwt != null) message.compactJwt = String(object.compactJwt); return message; }; /** * Creates a plain object from a Jwt message. Also converts values to other types if specified. * @function toObject * @memberof grafeas.v1.Jwt * @static * @param {grafeas.v1.Jwt} message Jwt * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ Jwt.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) object.compactJwt = ""; if (message.compactJwt != null && message.hasOwnProperty("compactJwt")) object.compactJwt = message.compactJwt; return object; }; /** * Converts this Jwt to JSON. * @function toJSON * @memberof grafeas.v1.Jwt * @instance * @returns {Object.<string,*>} JSON object */ Jwt.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** * Gets the default type url for Jwt * @function getTypeUrl * @memberof grafeas.v1.Jwt * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ Jwt.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } return typeUrlPrefix + "/grafeas.v1.Jwt"; }; return Jwt; })(); v1.AttestationOccurrence = (function() { /** * Properties of an AttestationOccurrence. * @memberof grafeas.v1 * @interface IAttestationOccurrence * @property {Uint8Array|null} [serializedPayload] AttestationOccurrence serializedPayload * @property {Array.<grafeas.v1.ISignature>|null} [signatures] AttestationOccurrence signatures * @property {Array.<grafeas.v1.IJwt>|null} [jwts] AttestationOccurrence jwts */ /** * Constructs a new AttestationOccurrence. * @memberof grafeas.v1 * @classdesc Represents an AttestationOccurrence. * @implements IAttestationOccurrence * @constructor * @param {grafeas.v1.IAttestationOccurrence=} [properties] Properties to set */ function AttestationOccurrence(properties) { this.signatures = []; this.jwts = []; 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]]; } /** * AttestationOccurrence serializedPayload. * @member {Uint8Array} serializedPayload * @memberof grafeas.v1.AttestationOccurrence * @instance */ AttestationOccurrence.prototype.serializedPayload = $util.newBuffer([]); /** * AttestationOccurrence signatures. * @member {Array.<grafeas.v1.ISignature>} signatures * @memberof grafeas.v1.AttestationOccurrence * @instance */ AttestationOccurrence.prototype.signatures = $util.emptyArray; /** * AttestationOccurrence jwts. * @member {Array.<grafeas.v1.IJwt>} jwts * @memberof grafeas.v1.AttestationOccurrence * @instance */ AttestationOccurrence.prototype.jwts = $util.emptyArray; /** * Creates a new AttestationOccurrence instance using the specified properties. * @function create * @memberof grafeas.v1.AttestationOccurrence * @static * @param {grafeas.v1.IAttestationOccurrence=} [properties] Properties to set * @returns {grafeas.v1.AttestationOccurrence} AttestationOccurrence instance */ AttestationOccurrence.create = function create(properties) { return new AttestationOccurrence(properties); }; /** * Encodes the specified AttestationOccurrence message. Does not implicitly {@link grafeas.v1.AttestationOccurrence.verify|verify} messages. * @function encode * @memberof grafeas.v1.AttestationOccurrence * @static * @param {grafeas.v1.IAttestationOccurrence} message AttestationOccurrence message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ AttestationOccurrence.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); if (message.serializedPayload != null && Object.hasOwnProperty.call(message, "serializedPayload")) writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.serializedPayload); if (message.signatures != null && message.signatures.length) for (var i = 0; i < message.signatures.length; ++i) $root.grafeas.v1.Signature.encode(message.signatures[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.jwts != null && message.jwts.length) for (var i = 0; i < message.jwts.length; ++i) $root.grafeas.v1.Jwt.encode(message.jwts[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; /** * Encodes the specified AttestationOccurrence message, length delimited. Does not implicitly {@link grafeas.v1.AttestationOccurrence.verify|verify} messages. * @function encodeDelimited * @memberof grafeas.v1.AttestationOccurrence * @static * @param {grafeas.v1.IAttestationOccurrence} message AttestationOccurrence message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ AttestationOccurrence.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** * Decodes an AttestationOccurrence message from the specified reader or buffer. * @function decode * @memberof grafeas.v1.AttestationOccurrence * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand * @returns {grafeas.v1.AttestationOccurrence} AttestationOccurrence * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ AttestationOccurrence.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.grafeas.v1.AttestationOccurrence(); while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) break; switch (tag >>> 3) { case 1: { message.serializedPayload = reader.bytes(); break; } case 2: { if (!(message.signatures && message.signatures.length)) message.signatures = []; message.signatures.push($root.grafeas.v1.Signature.decode(reader, reader.uint32())); break; } case 3: { if (!(message.jwts && message.jwts.length)) message.jwts = []; message.jwts.push($root.grafeas.v1.Jwt.decode(reader, reader.uint32())); break; } default: reader.skipType(tag & 7); break; } } return message; }; /** * Decodes an AttestationOccurrence message from the specified reader or buffer, length delimited. * @function decodeDelimited * @memberof grafeas.v1.AttestationOccurrence * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @returns {grafeas.v1.AttestationOccurrence} AttestationOccurrence * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ AttestationOccurrence.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** * Verifies an AttestationOccurrence message. * @function verify * @memberof grafeas.v1.AttestationOccurrence * @static * @param {Object.<string,*>} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ AttestationOccurrence.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; if (message.serializedPayload != null && message.hasOwnProperty("serializedPayload")) if (!(message.serializedPayload && typeof message.serializedPayload.length === "number" || $util.isString(message.serializedPayload))) return "serializedPayload: buffer expected"; if (message.signatures != null && message.hasOwnProperty("signatures")) { if (!Array.isArray(message.signatures)) return "signatures: array expected"; for (var i = 0; i < message.signatures.length; ++i) { var error = $root.grafeas.v1.Signature.verify(message.signatures[i]); if (error) return "signatures." + error; } } if (message.jwts != null && message.hasOwnProperty("jwts")) { if (!Array.isArray(message.jwts)) return "jwts: array expected"; for (var i = 0; i < message.jwts.length; ++i) { var error = $root.grafeas.v1.Jwt.verify(message.jwts[i]); if (error) return "jwts." + error; } } return null; }; /** * Creates an AttestationOccurrence message from a plain object. Also converts values to their respective internal types. * @function fromObject * @memberof grafeas.v1.AttestationOccurrence * @static * @param {Object.<string,*>} object Plain object * @returns {grafeas.v1.AttestationOccurrence} AttestationOccurrence */ AttestationOccurrence.fromObject = function fromObject(object) { if (object instanceof $root.grafeas.v1.AttestationOccurrence) return object; var message = new $root.grafeas.v1.AttestationOccurrence(); if (object.serializedPayload != null) if (typeof object.serializedPayload === "string") $util.base64.decode(object.serializedPayload, message.serializedPayload = $util.newBuffer($util.base64.length(object.serializedPayload)), 0); else if (object.serializedPayload.length >= 0) message.serializedPayload = object.serializedPayload; if (object.signatures) { if (!Array.isArray(object.signatures)) throw TypeError(".grafeas.v1.AttestationOccurrence.signatures: array expected"); message.signatures = []; for (var i = 0; i < object.signatures.length; ++i) { if (typeof object.signatures[i] !== "object") throw TypeError(".grafeas.v1.AttestationOccurrence.signatures: object expected"); message.signatures[i] = $root.grafeas.v1.Signature.fromObject(object.signatures[i]); } } if (object.jwts) { if (!Array.isArray(object.jwts)) throw TypeError(".grafeas.v1.AttestationOccurrence.jwts: array expected"); message.jwts = []; for (var i = 0; i < object.jwts.length; ++i) { if (typeof object.jwts[i] !== "object") throw TypeError(".grafeas.v1.AttestationOccurrence.jwts: object expected"); message.jwts[i] = $root.grafeas.v1.Jwt.fromObject(object.jwts[i]); } } return message; }; /** * Creates a plain object from an AttestationOccurrence message. Also converts values to other types if specified. * @function toObject * @memberof grafeas.v1.AttestationOccurrence * @static * @param {grafeas.v1.AttestationOccurrence} message AttestationOccurrence * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.<string,*>} Plain object */ AttestationOccurrence.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.arrays || options.defaults) { object.signatures = []; object.jwts = []; } if (options.defaults) if (options.bytes === String) object.serializedPayload = ""; else { object.serializedPayload = []; if (options.bytes !== Array) object.serializedPayload = $util.newBuffer(object.serializedPayload); } if (message.serializedPayload != null && message.hasOwnProperty("serializedPayload")) object.serializedPayload = options.bytes === String ? $util.base64.encode(message.serializedPayload, 0, message.serializedPayload.length) : options.bytes === Array ? Array.prototype.slice.call(message.serializedPayload) : message.serializedPayload; if (message.signatures && message.signatures.length) { object.signatures = []; for (var j = 0; j < message.signatures.length; ++j) object.signatures[j] = $root.grafeas.v1.Signature.toObject(message.signatures[j], options); } if (message.jwts && message.jwts.length) { object.jwts = []; for (var j = 0; j < message.jwts.length; ++j) object.jwts[j] = $root.grafeas.v1.Jwt.toObject(message.jwts[j], options); } return object; }; /** * Converts this AttestationOccurrence to JSON. * @function toJSON * @memberof grafeas.v1.AttestationOccurrence * @instance * @returns {Object.<string,*>} JSON object */ AttestationOccurrence.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** * Gets the default type url for AttestationOccurrence * @function getTypeUrl * @memberof grafeas.v1.AttestationOccurrence * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url