From 763388532659c25a52d95191b4e0aa4b2a2e86c1 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Wed, 14 Jun 2023 21:22:29 +0200 Subject: [PATCH] app+proto: run make protos --- app/src/types/generated/proxy_pb.d.ts | 40 +++ app/src/types/generated/proxy_pb.js | 286 ++++++++++++++++++ app/src/types/generated/proxy_pb_service.d.ts | 19 ++ app/src/types/generated/proxy_pb_service.js | 40 +++ proto/proxy.proto | 20 ++ 5 files changed, 405 insertions(+) diff --git a/app/src/types/generated/proxy_pb.d.ts b/app/src/types/generated/proxy_pb.d.ts index be730dc96..4399a2954 100644 --- a/app/src/types/generated/proxy_pb.d.ts +++ b/app/src/types/generated/proxy_pb.d.ts @@ -3,6 +3,46 @@ import * as jspb from "google-protobuf"; +export class BakeSuperMacaroonRequest extends jspb.Message { + getRootKeyIdSuffix(): number; + setRootKeyIdSuffix(value: number): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): BakeSuperMacaroonRequest.AsObject; + static toObject(includeInstance: boolean, msg: BakeSuperMacaroonRequest): BakeSuperMacaroonRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: BakeSuperMacaroonRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): BakeSuperMacaroonRequest; + static deserializeBinaryFromReader(message: BakeSuperMacaroonRequest, reader: jspb.BinaryReader): BakeSuperMacaroonRequest; +} + +export namespace BakeSuperMacaroonRequest { + export type AsObject = { + rootKeyIdSuffix: number, + } +} + +export class BakeSuperMacaroonResponse extends jspb.Message { + getMacaroon(): string; + setMacaroon(value: string): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): BakeSuperMacaroonResponse.AsObject; + static toObject(includeInstance: boolean, msg: BakeSuperMacaroonResponse): BakeSuperMacaroonResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: BakeSuperMacaroonResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): BakeSuperMacaroonResponse; + static deserializeBinaryFromReader(message: BakeSuperMacaroonResponse, reader: jspb.BinaryReader): BakeSuperMacaroonResponse; +} + +export namespace BakeSuperMacaroonResponse { + export type AsObject = { + macaroon: string, + } +} + export class StopDaemonRequest extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): StopDaemonRequest.AsObject; diff --git a/app/src/types/generated/proxy_pb.js b/app/src/types/generated/proxy_pb.js index 1aa1c6d25..3aa964de7 100644 --- a/app/src/types/generated/proxy_pb.js +++ b/app/src/types/generated/proxy_pb.js @@ -14,11 +14,297 @@ var jspb = require('google-protobuf'); var goog = jspb; var global = Function('return this')(); +goog.exportSymbol('proto.litrpc.BakeSuperMacaroonRequest', null, global); +goog.exportSymbol('proto.litrpc.BakeSuperMacaroonResponse', null, global); goog.exportSymbol('proto.litrpc.GetInfoRequest', null, global); goog.exportSymbol('proto.litrpc.GetInfoResponse', null, global); goog.exportSymbol('proto.litrpc.StopDaemonRequest', null, global); goog.exportSymbol('proto.litrpc.StopDaemonResponse', 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.litrpc.BakeSuperMacaroonRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.litrpc.BakeSuperMacaroonRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.litrpc.BakeSuperMacaroonRequest.displayName = 'proto.litrpc.BakeSuperMacaroonRequest'; +} + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.litrpc.BakeSuperMacaroonRequest.prototype.toObject = function(opt_includeInstance) { + return proto.litrpc.BakeSuperMacaroonRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.litrpc.BakeSuperMacaroonRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.BakeSuperMacaroonRequest.toObject = function(includeInstance, msg) { + var f, obj = { + rootKeyIdSuffix: jspb.Message.getFieldWithDefault(msg, 1, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.litrpc.BakeSuperMacaroonRequest} + */ +proto.litrpc.BakeSuperMacaroonRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.litrpc.BakeSuperMacaroonRequest; + return proto.litrpc.BakeSuperMacaroonRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.litrpc.BakeSuperMacaroonRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.litrpc.BakeSuperMacaroonRequest} + */ +proto.litrpc.BakeSuperMacaroonRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readUint32()); + msg.setRootKeyIdSuffix(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.litrpc.BakeSuperMacaroonRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.litrpc.BakeSuperMacaroonRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.litrpc.BakeSuperMacaroonRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.BakeSuperMacaroonRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getRootKeyIdSuffix(); + if (f !== 0) { + writer.writeUint32( + 1, + f + ); + } +}; + + +/** + * optional uint32 root_key_id_suffix = 1; + * @return {number} + */ +proto.litrpc.BakeSuperMacaroonRequest.prototype.getRootKeyIdSuffix = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** @param {number} value */ +proto.litrpc.BakeSuperMacaroonRequest.prototype.setRootKeyIdSuffix = function(value) { + jspb.Message.setProto3IntField(this, 1, value); +}; + + + +/** + * 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.litrpc.BakeSuperMacaroonResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.litrpc.BakeSuperMacaroonResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.litrpc.BakeSuperMacaroonResponse.displayName = 'proto.litrpc.BakeSuperMacaroonResponse'; +} + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.litrpc.BakeSuperMacaroonResponse.prototype.toObject = function(opt_includeInstance) { + return proto.litrpc.BakeSuperMacaroonResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.litrpc.BakeSuperMacaroonResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.BakeSuperMacaroonResponse.toObject = function(includeInstance, msg) { + var f, obj = { + macaroon: 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.litrpc.BakeSuperMacaroonResponse} + */ +proto.litrpc.BakeSuperMacaroonResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.litrpc.BakeSuperMacaroonResponse; + return proto.litrpc.BakeSuperMacaroonResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.litrpc.BakeSuperMacaroonResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.litrpc.BakeSuperMacaroonResponse} + */ +proto.litrpc.BakeSuperMacaroonResponse.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.setMacaroon(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.litrpc.BakeSuperMacaroonResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.litrpc.BakeSuperMacaroonResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.litrpc.BakeSuperMacaroonResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.BakeSuperMacaroonResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getMacaroon(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string macaroon = 1; + * @return {string} + */ +proto.litrpc.BakeSuperMacaroonResponse.prototype.getMacaroon = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** @param {string} value */ +proto.litrpc.BakeSuperMacaroonResponse.prototype.setMacaroon = function(value) { + jspb.Message.setProto3StringField(this, 1, value); +}; + + + /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a diff --git a/app/src/types/generated/proxy_pb_service.d.ts b/app/src/types/generated/proxy_pb_service.d.ts index e99a4bc85..f9787859c 100644 --- a/app/src/types/generated/proxy_pb_service.d.ts +++ b/app/src/types/generated/proxy_pb_service.d.ts @@ -22,10 +22,20 @@ type ProxyStopDaemon = { readonly responseType: typeof proxy_pb.StopDaemonResponse; }; +type ProxyBakeSuperMacaroon = { + readonly methodName: string; + readonly service: typeof Proxy; + readonly requestStream: false; + readonly responseStream: false; + readonly requestType: typeof proxy_pb.BakeSuperMacaroonRequest; + readonly responseType: typeof proxy_pb.BakeSuperMacaroonResponse; +}; + export class Proxy { static readonly serviceName: string; static readonly GetInfo: ProxyGetInfo; static readonly StopDaemon: ProxyStopDaemon; + static readonly BakeSuperMacaroon: ProxyBakeSuperMacaroon; } export type ServiceError = { message: string, code: number; metadata: grpc.Metadata } @@ -78,5 +88,14 @@ export class ProxyClient { requestMessage: proxy_pb.StopDaemonRequest, callback: (error: ServiceError|null, responseMessage: proxy_pb.StopDaemonResponse|null) => void ): UnaryResponse; + bakeSuperMacaroon( + requestMessage: proxy_pb.BakeSuperMacaroonRequest, + metadata: grpc.Metadata, + callback: (error: ServiceError|null, responseMessage: proxy_pb.BakeSuperMacaroonResponse|null) => void + ): UnaryResponse; + bakeSuperMacaroon( + requestMessage: proxy_pb.BakeSuperMacaroonRequest, + callback: (error: ServiceError|null, responseMessage: proxy_pb.BakeSuperMacaroonResponse|null) => void + ): UnaryResponse; } diff --git a/app/src/types/generated/proxy_pb_service.js b/app/src/types/generated/proxy_pb_service.js index f0dea8e5a..00d6168d8 100644 --- a/app/src/types/generated/proxy_pb_service.js +++ b/app/src/types/generated/proxy_pb_service.js @@ -28,6 +28,15 @@ Proxy.StopDaemon = { responseType: proxy_pb.StopDaemonResponse }; +Proxy.BakeSuperMacaroon = { + methodName: "BakeSuperMacaroon", + service: Proxy, + requestStream: false, + responseStream: false, + requestType: proxy_pb.BakeSuperMacaroonRequest, + responseType: proxy_pb.BakeSuperMacaroonResponse +}; + exports.Proxy = Proxy; function ProxyClient(serviceHost, options) { @@ -97,5 +106,36 @@ ProxyClient.prototype.stopDaemon = function stopDaemon(requestMessage, metadata, }; }; +ProxyClient.prototype.bakeSuperMacaroon = function bakeSuperMacaroon(requestMessage, metadata, callback) { + if (arguments.length === 2) { + callback = arguments[1]; + } + var client = grpc.unary(Proxy.BakeSuperMacaroon, { + request: requestMessage, + host: this.serviceHost, + metadata: metadata, + transport: this.options.transport, + debug: this.options.debug, + onEnd: function (response) { + if (callback) { + if (response.status !== grpc.Code.OK) { + var err = new Error(response.statusMessage); + err.code = response.status; + err.metadata = response.trailers; + callback(err, null); + } else { + callback(null, response.message); + } + } + } + }); + return { + cancel: function () { + callback = null; + client.close(); + } + }; +}; + exports.ProxyClient = ProxyClient; diff --git a/proto/proxy.proto b/proto/proxy.proto index a764b825d..503989a6f 100644 --- a/proto/proxy.proto +++ b/proto/proxy.proto @@ -15,6 +15,26 @@ service Proxy { triggering a graceful shutdown of the daemon. */ rpc StopDaemon (StopDaemonRequest) returns (StopDaemonResponse); + + /* litcli: `bakesupermacaroon` + BakeSuperMacaroon bakes a new macaroon that includes permissions for + all the active daemons that LiT is connected to. + */ + rpc BakeSuperMacaroon (BakeSuperMacaroonRequest) + returns (BakeSuperMacaroonResponse); +} + +message BakeSuperMacaroonRequest { + /* + The root key ID suffix is the 4-byte suffix of the root key ID that will + be used to create the macaroon. + */ + uint32 root_key_id_suffix = 1; +} + +message BakeSuperMacaroonResponse { + // The hex encoded macaroon. + string macaroon = 1; } message StopDaemonRequest {