diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 21e7b851..377b0ae7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -168,3 +168,6 @@ jobs: - name: run check run: make protos-check + + - name: compile rpc for golang + run: make rpc diff --git a/Makefile b/Makefile index 1e1aab5d..ce48a8bf 100644 --- a/Makefile +++ b/Makefile @@ -193,6 +193,10 @@ list: grep -v Makefile | \ sort +rpc: + @$(call print, "Compiling protos.") + cd ./litrpc; ./gen_protos_docker.sh + protos: @$(call print, "Compiling protos.") cd proto; ./gen_protos_docker.sh diff --git a/app/scripts/build-protos.js b/app/scripts/build-protos.js index b26592dd..29467ae8 100644 --- a/app/scripts/build-protos.js +++ b/app/scripts/build-protos.js @@ -50,11 +50,30 @@ const protoSources = async () => { /** list of proto files and patches to apply */ const filePatches = { - lnd: 'lnrpc: {}', - loop: 'looprpc: {}', - common: 'looprpc: {}', - trader: 'poolrpc: {}', - 'auctioneerrpc/auctioneer': 'poolrpc: {}', + lnd: { + patch: 'lnrpc: {}', + folder: 'proto' + }, + loop: { + patch: 'looprpc: {}', + folder: 'proto' + }, + common: { + patch: 'looprpc: {}', + folder: 'proto' + }, + trader: { + patch: 'poolrpc: {}', + folder: 'proto' + }, + 'auctioneerrpc/auctioneer': { + patch: 'poolrpc: {}', + folder: 'proto' + }, + 'lit-sessions': { + patch: 'litrpc: {}', + folder: 'litrpc' + } }; /** @@ -86,7 +105,7 @@ const download = async () => { */ const sanitize = async () => { const filePaths = Object.keys(filePatches).map(name => - join(appPath, '..', 'proto', `${name}.proto`), + join(appPath, '..', filePatches[name].folder, `${name}.proto`), ); for (path of filePaths) { let content = (await fs.readFile(path)).toString(); @@ -113,14 +132,18 @@ const generate = async () => { '.bin', platform() === 'win32' ? 'protoc-gen-ts.cmd' : 'protoc-gen-ts', ); + const files = Object + .keys(filePatches) + .map(name => `../${filePatches[name].folder}/${name}.proto`); const protocCmd = [ 'protoc', `-I../proto`, + `-I../litrpc`, `--plugin=protoc-gen-ts=${protocGen}`, '--proto_path=../proto', '--js_out=import_style=commonjs,binary:./src/types/generated', '--ts_out=service=grpc-web:./src/types/generated', - ...Object.keys(filePatches).map(file => `../proto/${file}.proto`), + ...files, ].join(' '); console.log(protocCmd); @@ -153,7 +176,7 @@ const patch = async () => { // apply the webpack patch const patch = [ '/* eslint-disable */', - `var proto = { ${filePatches[filename]} };`, + `var proto = { ${filePatches[filename].patch} };`, '', ].join('\n'); content = `${patch}\n${content}`; diff --git a/app/src/types/generated/lit-sessions_pb.d.ts b/app/src/types/generated/lit-sessions_pb.d.ts new file mode 100644 index 00000000..bb2dbd7b --- /dev/null +++ b/app/src/types/generated/lit-sessions_pb.d.ts @@ -0,0 +1,249 @@ +// package: litrpc +// file: lit-sessions.proto + +import * as jspb from "google-protobuf"; + +export class AddSessionRequest extends jspb.Message { + getLabel(): string; + setLabel(value: string): void; + + getSessionType(): SessionTypeMap[keyof SessionTypeMap]; + setSessionType(value: SessionTypeMap[keyof SessionTypeMap]): void; + + getExpiryTimestampSeconds(): string; + setExpiryTimestampSeconds(value: string): void; + + getMailboxServerAddr(): string; + setMailboxServerAddr(value: string): void; + + getDevServer(): boolean; + setDevServer(value: boolean): void; + + clearMacaroonCustomPermissionsList(): void; + getMacaroonCustomPermissionsList(): Array; + setMacaroonCustomPermissionsList(value: Array): void; + addMacaroonCustomPermissions(value?: MacaroonPermission, index?: number): MacaroonPermission; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): AddSessionRequest.AsObject; + static toObject(includeInstance: boolean, msg: AddSessionRequest): AddSessionRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: AddSessionRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): AddSessionRequest; + static deserializeBinaryFromReader(message: AddSessionRequest, reader: jspb.BinaryReader): AddSessionRequest; +} + +export namespace AddSessionRequest { + export type AsObject = { + label: string, + sessionType: SessionTypeMap[keyof SessionTypeMap], + expiryTimestampSeconds: string, + mailboxServerAddr: string, + devServer: boolean, + macaroonCustomPermissionsList: Array, + } +} + +export class MacaroonPermission extends jspb.Message { + getEntity(): string; + setEntity(value: string): void; + + getAction(): string; + setAction(value: string): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): MacaroonPermission.AsObject; + static toObject(includeInstance: boolean, msg: MacaroonPermission): MacaroonPermission.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: MacaroonPermission, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): MacaroonPermission; + static deserializeBinaryFromReader(message: MacaroonPermission, reader: jspb.BinaryReader): MacaroonPermission; +} + +export namespace MacaroonPermission { + export type AsObject = { + entity: string, + action: string, + } +} + +export class AddSessionResponse extends jspb.Message { + hasSession(): boolean; + clearSession(): void; + getSession(): Session | undefined; + setSession(value?: Session): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): AddSessionResponse.AsObject; + static toObject(includeInstance: boolean, msg: AddSessionResponse): AddSessionResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: AddSessionResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): AddSessionResponse; + static deserializeBinaryFromReader(message: AddSessionResponse, reader: jspb.BinaryReader): AddSessionResponse; +} + +export namespace AddSessionResponse { + export type AsObject = { + session?: Session.AsObject, + } +} + +export class Session extends jspb.Message { + getLabel(): string; + setLabel(value: string): void; + + getSessionState(): SessionStateMap[keyof SessionStateMap]; + setSessionState(value: SessionStateMap[keyof SessionStateMap]): void; + + getSessionType(): SessionTypeMap[keyof SessionTypeMap]; + setSessionType(value: SessionTypeMap[keyof SessionTypeMap]): void; + + getExpiryTimestampSeconds(): string; + setExpiryTimestampSeconds(value: string): void; + + getMailboxServerAddr(): string; + setMailboxServerAddr(value: string): void; + + getDevServer(): boolean; + setDevServer(value: boolean): void; + + getPairingSecret(): Uint8Array | string; + getPairingSecret_asU8(): Uint8Array; + getPairingSecret_asB64(): string; + setPairingSecret(value: Uint8Array | string): void; + + getPairingSecretMnemonic(): string; + setPairingSecretMnemonic(value: string): void; + + getLocalPublicKey(): Uint8Array | string; + getLocalPublicKey_asU8(): Uint8Array; + getLocalPublicKey_asB64(): string; + setLocalPublicKey(value: Uint8Array | string): void; + + getRemotePublicKey(): Uint8Array | string; + getRemotePublicKey_asU8(): Uint8Array; + getRemotePublicKey_asB64(): string; + setRemotePublicKey(value: Uint8Array | string): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): Session.AsObject; + static toObject(includeInstance: boolean, msg: Session): Session.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: Session, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): Session; + static deserializeBinaryFromReader(message: Session, reader: jspb.BinaryReader): Session; +} + +export namespace Session { + export type AsObject = { + label: string, + sessionState: SessionStateMap[keyof SessionStateMap], + sessionType: SessionTypeMap[keyof SessionTypeMap], + expiryTimestampSeconds: string, + mailboxServerAddr: string, + devServer: boolean, + pairingSecret: Uint8Array | string, + pairingSecretMnemonic: string, + localPublicKey: Uint8Array | string, + remotePublicKey: Uint8Array | string, + } +} + +export class ListSessionsRequest extends jspb.Message { + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ListSessionsRequest.AsObject; + static toObject(includeInstance: boolean, msg: ListSessionsRequest): ListSessionsRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: ListSessionsRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ListSessionsRequest; + static deserializeBinaryFromReader(message: ListSessionsRequest, reader: jspb.BinaryReader): ListSessionsRequest; +} + +export namespace ListSessionsRequest { + export type AsObject = { + } +} + +export class ListSessionsResponse extends jspb.Message { + clearSessionsList(): void; + getSessionsList(): Array; + setSessionsList(value: Array): void; + addSessions(value?: Session, index?: number): Session; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ListSessionsResponse.AsObject; + static toObject(includeInstance: boolean, msg: ListSessionsResponse): ListSessionsResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: ListSessionsResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ListSessionsResponse; + static deserializeBinaryFromReader(message: ListSessionsResponse, reader: jspb.BinaryReader): ListSessionsResponse; +} + +export namespace ListSessionsResponse { + export type AsObject = { + sessionsList: Array, + } +} + +export class RevokeSessionRequest extends jspb.Message { + getLocalPublicKey(): Uint8Array | string; + getLocalPublicKey_asU8(): Uint8Array; + getLocalPublicKey_asB64(): string; + setLocalPublicKey(value: Uint8Array | string): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): RevokeSessionRequest.AsObject; + static toObject(includeInstance: boolean, msg: RevokeSessionRequest): RevokeSessionRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: RevokeSessionRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): RevokeSessionRequest; + static deserializeBinaryFromReader(message: RevokeSessionRequest, reader: jspb.BinaryReader): RevokeSessionRequest; +} + +export namespace RevokeSessionRequest { + export type AsObject = { + localPublicKey: Uint8Array | string, + } +} + +export class RevokeSessionResponse extends jspb.Message { + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): RevokeSessionResponse.AsObject; + static toObject(includeInstance: boolean, msg: RevokeSessionResponse): RevokeSessionResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: RevokeSessionResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): RevokeSessionResponse; + static deserializeBinaryFromReader(message: RevokeSessionResponse, reader: jspb.BinaryReader): RevokeSessionResponse; +} + +export namespace RevokeSessionResponse { + export type AsObject = { + } +} + +export interface SessionTypeMap { + TYPE_MACAROON_READONLY: 0; + TYPE_MACAROON_ADMIN: 1; + TYPE_MACAROON_CUSTOM: 2; + TYPE_UI_PASSWORD: 3; +} + +export const SessionType: SessionTypeMap; + +export interface SessionStateMap { + STATE_CREATED: 0; + STATE_IN_USE: 1; + STATE_REVOKED: 2; + STATE_EXPIRED: 3; +} + +export const SessionState: SessionStateMap; + diff --git a/app/src/types/generated/lit-sessions_pb.js b/app/src/types/generated/lit-sessions_pb.js new file mode 100644 index 00000000..affa48e5 --- /dev/null +++ b/app/src/types/generated/lit-sessions_pb.js @@ -0,0 +1,1705 @@ +/* eslint-disable */ +var proto = { litrpc: {} }; + +/** + * @fileoverview + * @enhanceable + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = Function('return this')(); + +goog.exportSymbol('proto.litrpc.AddSessionRequest', null, global); +goog.exportSymbol('proto.litrpc.AddSessionResponse', null, global); +goog.exportSymbol('proto.litrpc.ListSessionsRequest', null, global); +goog.exportSymbol('proto.litrpc.ListSessionsResponse', null, global); +goog.exportSymbol('proto.litrpc.MacaroonPermission', null, global); +goog.exportSymbol('proto.litrpc.RevokeSessionRequest', null, global); +goog.exportSymbol('proto.litrpc.RevokeSessionResponse', null, global); +goog.exportSymbol('proto.litrpc.Session', null, global); +goog.exportSymbol('proto.litrpc.SessionState', null, global); +goog.exportSymbol('proto.litrpc.SessionType', 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.AddSessionRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.litrpc.AddSessionRequest.repeatedFields_, null); +}; +goog.inherits(proto.litrpc.AddSessionRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.litrpc.AddSessionRequest.displayName = 'proto.litrpc.AddSessionRequest'; +} +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.litrpc.AddSessionRequest.repeatedFields_ = [6]; + + + +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.AddSessionRequest.prototype.toObject = function(opt_includeInstance) { + return proto.litrpc.AddSessionRequest.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.AddSessionRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.AddSessionRequest.toObject = function(includeInstance, msg) { + var f, obj = { + label: jspb.Message.getFieldWithDefault(msg, 1, ""), + sessionType: jspb.Message.getFieldWithDefault(msg, 2, 0), + expiryTimestampSeconds: jspb.Message.getFieldWithDefault(msg, 3, "0"), + mailboxServerAddr: jspb.Message.getFieldWithDefault(msg, 4, ""), + devServer: jspb.Message.getFieldWithDefault(msg, 5, false), + macaroonCustomPermissionsList: jspb.Message.toObjectList(msg.getMacaroonCustomPermissionsList(), + proto.litrpc.MacaroonPermission.toObject, includeInstance) + }; + + 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.AddSessionRequest} + */ +proto.litrpc.AddSessionRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.litrpc.AddSessionRequest; + return proto.litrpc.AddSessionRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.litrpc.AddSessionRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.litrpc.AddSessionRequest} + */ +proto.litrpc.AddSessionRequest.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.setLabel(value); + break; + case 2: + var value = /** @type {!proto.litrpc.SessionType} */ (reader.readEnum()); + msg.setSessionType(value); + break; + case 3: + var value = /** @type {string} */ (reader.readUint64String()); + msg.setExpiryTimestampSeconds(value); + break; + case 4: + var value = /** @type {string} */ (reader.readString()); + msg.setMailboxServerAddr(value); + break; + case 5: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setDevServer(value); + break; + case 6: + var value = new proto.litrpc.MacaroonPermission; + reader.readMessage(value,proto.litrpc.MacaroonPermission.deserializeBinaryFromReader); + msg.addMacaroonCustomPermissions(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.litrpc.AddSessionRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.litrpc.AddSessionRequest.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.AddSessionRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.AddSessionRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getLabel(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getSessionType(); + if (f !== 0.0) { + writer.writeEnum( + 2, + f + ); + } + f = message.getExpiryTimestampSeconds(); + if (parseInt(f, 10) !== 0) { + writer.writeUint64String( + 3, + f + ); + } + f = message.getMailboxServerAddr(); + if (f.length > 0) { + writer.writeString( + 4, + f + ); + } + f = message.getDevServer(); + if (f) { + writer.writeBool( + 5, + f + ); + } + f = message.getMacaroonCustomPermissionsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 6, + f, + proto.litrpc.MacaroonPermission.serializeBinaryToWriter + ); + } +}; + + +/** + * optional string label = 1; + * @return {string} + */ +proto.litrpc.AddSessionRequest.prototype.getLabel = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** @param {string} value */ +proto.litrpc.AddSessionRequest.prototype.setLabel = function(value) { + jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional SessionType session_type = 2; + * @return {!proto.litrpc.SessionType} + */ +proto.litrpc.AddSessionRequest.prototype.getSessionType = function() { + return /** @type {!proto.litrpc.SessionType} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** @param {!proto.litrpc.SessionType} value */ +proto.litrpc.AddSessionRequest.prototype.setSessionType = function(value) { + jspb.Message.setProto3EnumField(this, 2, value); +}; + + +/** + * optional uint64 expiry_timestamp_seconds = 3; + * @return {string} + */ +proto.litrpc.AddSessionRequest.prototype.getExpiryTimestampSeconds = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "0")); +}; + + +/** @param {string} value */ +proto.litrpc.AddSessionRequest.prototype.setExpiryTimestampSeconds = function(value) { + jspb.Message.setProto3StringIntField(this, 3, value); +}; + + +/** + * optional string mailbox_server_addr = 4; + * @return {string} + */ +proto.litrpc.AddSessionRequest.prototype.getMailboxServerAddr = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** @param {string} value */ +proto.litrpc.AddSessionRequest.prototype.setMailboxServerAddr = function(value) { + jspb.Message.setProto3StringField(this, 4, value); +}; + + +/** + * optional bool dev_server = 5; + * Note that Boolean fields may be set to 0/1 when serialized from a Java server. + * You should avoid comparisons like {@code val === true/false} in those cases. + * @return {boolean} + */ +proto.litrpc.AddSessionRequest.prototype.getDevServer = function() { + return /** @type {boolean} */ (jspb.Message.getFieldWithDefault(this, 5, false)); +}; + + +/** @param {boolean} value */ +proto.litrpc.AddSessionRequest.prototype.setDevServer = function(value) { + jspb.Message.setProto3BooleanField(this, 5, value); +}; + + +/** + * repeated MacaroonPermission macaroon_custom_permissions = 6; + * @return {!Array} + */ +proto.litrpc.AddSessionRequest.prototype.getMacaroonCustomPermissionsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.litrpc.MacaroonPermission, 6)); +}; + + +/** @param {!Array} value */ +proto.litrpc.AddSessionRequest.prototype.setMacaroonCustomPermissionsList = function(value) { + jspb.Message.setRepeatedWrapperField(this, 6, value); +}; + + +/** + * @param {!proto.litrpc.MacaroonPermission=} opt_value + * @param {number=} opt_index + * @return {!proto.litrpc.MacaroonPermission} + */ +proto.litrpc.AddSessionRequest.prototype.addMacaroonCustomPermissions = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 6, opt_value, proto.litrpc.MacaroonPermission, opt_index); +}; + + +proto.litrpc.AddSessionRequest.prototype.clearMacaroonCustomPermissionsList = function() { + this.setMacaroonCustomPermissionsList([]); +}; + + + +/** + * 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.MacaroonPermission = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.litrpc.MacaroonPermission, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.litrpc.MacaroonPermission.displayName = 'proto.litrpc.MacaroonPermission'; +} + + +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.MacaroonPermission.prototype.toObject = function(opt_includeInstance) { + return proto.litrpc.MacaroonPermission.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.MacaroonPermission} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.MacaroonPermission.toObject = function(includeInstance, msg) { + var f, obj = { + entity: jspb.Message.getFieldWithDefault(msg, 1, ""), + action: jspb.Message.getFieldWithDefault(msg, 2, "") + }; + + 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.MacaroonPermission} + */ +proto.litrpc.MacaroonPermission.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.litrpc.MacaroonPermission; + return proto.litrpc.MacaroonPermission.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.litrpc.MacaroonPermission} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.litrpc.MacaroonPermission} + */ +proto.litrpc.MacaroonPermission.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.setEntity(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setAction(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.litrpc.MacaroonPermission.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.litrpc.MacaroonPermission.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.MacaroonPermission} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.MacaroonPermission.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getEntity(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getAction(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } +}; + + +/** + * optional string entity = 1; + * @return {string} + */ +proto.litrpc.MacaroonPermission.prototype.getEntity = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** @param {string} value */ +proto.litrpc.MacaroonPermission.prototype.setEntity = function(value) { + jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string action = 2; + * @return {string} + */ +proto.litrpc.MacaroonPermission.prototype.getAction = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** @param {string} value */ +proto.litrpc.MacaroonPermission.prototype.setAction = function(value) { + jspb.Message.setProto3StringField(this, 2, 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.AddSessionResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.litrpc.AddSessionResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.litrpc.AddSessionResponse.displayName = 'proto.litrpc.AddSessionResponse'; +} + + +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.AddSessionResponse.prototype.toObject = function(opt_includeInstance) { + return proto.litrpc.AddSessionResponse.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.AddSessionResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.AddSessionResponse.toObject = function(includeInstance, msg) { + var f, obj = { + session: (f = msg.getSession()) && proto.litrpc.Session.toObject(includeInstance, f) + }; + + 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.AddSessionResponse} + */ +proto.litrpc.AddSessionResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.litrpc.AddSessionResponse; + return proto.litrpc.AddSessionResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.litrpc.AddSessionResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.litrpc.AddSessionResponse} + */ +proto.litrpc.AddSessionResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.litrpc.Session; + reader.readMessage(value,proto.litrpc.Session.deserializeBinaryFromReader); + msg.setSession(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.litrpc.AddSessionResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.litrpc.AddSessionResponse.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.AddSessionResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.AddSessionResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getSession(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.litrpc.Session.serializeBinaryToWriter + ); + } +}; + + +/** + * optional Session session = 1; + * @return {?proto.litrpc.Session} + */ +proto.litrpc.AddSessionResponse.prototype.getSession = function() { + return /** @type{?proto.litrpc.Session} */ ( + jspb.Message.getWrapperField(this, proto.litrpc.Session, 1)); +}; + + +/** @param {?proto.litrpc.Session|undefined} value */ +proto.litrpc.AddSessionResponse.prototype.setSession = function(value) { + jspb.Message.setWrapperField(this, 1, value); +}; + + +proto.litrpc.AddSessionResponse.prototype.clearSession = function() { + this.setSession(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {!boolean} + */ +proto.litrpc.AddSessionResponse.prototype.hasSession = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * 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.Session = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.litrpc.Session, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.litrpc.Session.displayName = 'proto.litrpc.Session'; +} + + +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.Session.prototype.toObject = function(opt_includeInstance) { + return proto.litrpc.Session.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.Session} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.Session.toObject = function(includeInstance, msg) { + var f, obj = { + label: jspb.Message.getFieldWithDefault(msg, 1, ""), + sessionState: jspb.Message.getFieldWithDefault(msg, 2, 0), + sessionType: jspb.Message.getFieldWithDefault(msg, 3, 0), + expiryTimestampSeconds: jspb.Message.getFieldWithDefault(msg, 4, "0"), + mailboxServerAddr: jspb.Message.getFieldWithDefault(msg, 5, ""), + devServer: jspb.Message.getFieldWithDefault(msg, 6, false), + pairingSecret: msg.getPairingSecret_asB64(), + pairingSecretMnemonic: jspb.Message.getFieldWithDefault(msg, 8, ""), + localPublicKey: msg.getLocalPublicKey_asB64(), + remotePublicKey: msg.getRemotePublicKey_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.litrpc.Session} + */ +proto.litrpc.Session.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.litrpc.Session; + return proto.litrpc.Session.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.litrpc.Session} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.litrpc.Session} + */ +proto.litrpc.Session.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.setLabel(value); + break; + case 2: + var value = /** @type {!proto.litrpc.SessionState} */ (reader.readEnum()); + msg.setSessionState(value); + break; + case 3: + var value = /** @type {!proto.litrpc.SessionType} */ (reader.readEnum()); + msg.setSessionType(value); + break; + case 4: + var value = /** @type {string} */ (reader.readUint64String()); + msg.setExpiryTimestampSeconds(value); + break; + case 5: + var value = /** @type {string} */ (reader.readString()); + msg.setMailboxServerAddr(value); + break; + case 6: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setDevServer(value); + break; + case 7: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setPairingSecret(value); + break; + case 8: + var value = /** @type {string} */ (reader.readString()); + msg.setPairingSecretMnemonic(value); + break; + case 9: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setLocalPublicKey(value); + break; + case 10: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setRemotePublicKey(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.litrpc.Session.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.litrpc.Session.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.Session} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.Session.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getLabel(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getSessionState(); + if (f !== 0.0) { + writer.writeEnum( + 2, + f + ); + } + f = message.getSessionType(); + if (f !== 0.0) { + writer.writeEnum( + 3, + f + ); + } + f = message.getExpiryTimestampSeconds(); + if (parseInt(f, 10) !== 0) { + writer.writeUint64String( + 4, + f + ); + } + f = message.getMailboxServerAddr(); + if (f.length > 0) { + writer.writeString( + 5, + f + ); + } + f = message.getDevServer(); + if (f) { + writer.writeBool( + 6, + f + ); + } + f = message.getPairingSecret_asU8(); + if (f.length > 0) { + writer.writeBytes( + 7, + f + ); + } + f = message.getPairingSecretMnemonic(); + if (f.length > 0) { + writer.writeString( + 8, + f + ); + } + f = message.getLocalPublicKey_asU8(); + if (f.length > 0) { + writer.writeBytes( + 9, + f + ); + } + f = message.getRemotePublicKey_asU8(); + if (f.length > 0) { + writer.writeBytes( + 10, + f + ); + } +}; + + +/** + * optional string label = 1; + * @return {string} + */ +proto.litrpc.Session.prototype.getLabel = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** @param {string} value */ +proto.litrpc.Session.prototype.setLabel = function(value) { + jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional SessionState session_state = 2; + * @return {!proto.litrpc.SessionState} + */ +proto.litrpc.Session.prototype.getSessionState = function() { + return /** @type {!proto.litrpc.SessionState} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** @param {!proto.litrpc.SessionState} value */ +proto.litrpc.Session.prototype.setSessionState = function(value) { + jspb.Message.setProto3EnumField(this, 2, value); +}; + + +/** + * optional SessionType session_type = 3; + * @return {!proto.litrpc.SessionType} + */ +proto.litrpc.Session.prototype.getSessionType = function() { + return /** @type {!proto.litrpc.SessionType} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); +}; + + +/** @param {!proto.litrpc.SessionType} value */ +proto.litrpc.Session.prototype.setSessionType = function(value) { + jspb.Message.setProto3EnumField(this, 3, value); +}; + + +/** + * optional uint64 expiry_timestamp_seconds = 4; + * @return {string} + */ +proto.litrpc.Session.prototype.getExpiryTimestampSeconds = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "0")); +}; + + +/** @param {string} value */ +proto.litrpc.Session.prototype.setExpiryTimestampSeconds = function(value) { + jspb.Message.setProto3StringIntField(this, 4, value); +}; + + +/** + * optional string mailbox_server_addr = 5; + * @return {string} + */ +proto.litrpc.Session.prototype.getMailboxServerAddr = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, "")); +}; + + +/** @param {string} value */ +proto.litrpc.Session.prototype.setMailboxServerAddr = function(value) { + jspb.Message.setProto3StringField(this, 5, value); +}; + + +/** + * optional bool dev_server = 6; + * Note that Boolean fields may be set to 0/1 when serialized from a Java server. + * You should avoid comparisons like {@code val === true/false} in those cases. + * @return {boolean} + */ +proto.litrpc.Session.prototype.getDevServer = function() { + return /** @type {boolean} */ (jspb.Message.getFieldWithDefault(this, 6, false)); +}; + + +/** @param {boolean} value */ +proto.litrpc.Session.prototype.setDevServer = function(value) { + jspb.Message.setProto3BooleanField(this, 6, value); +}; + + +/** + * optional bytes pairing_secret = 7; + * @return {!(string|Uint8Array)} + */ +proto.litrpc.Session.prototype.getPairingSecret = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 7, "")); +}; + + +/** + * optional bytes pairing_secret = 7; + * This is a type-conversion wrapper around `getPairingSecret()` + * @return {string} + */ +proto.litrpc.Session.prototype.getPairingSecret_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getPairingSecret())); +}; + + +/** + * optional bytes pairing_secret = 7; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getPairingSecret()` + * @return {!Uint8Array} + */ +proto.litrpc.Session.prototype.getPairingSecret_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getPairingSecret())); +}; + + +/** @param {!(string|Uint8Array)} value */ +proto.litrpc.Session.prototype.setPairingSecret = function(value) { + jspb.Message.setProto3BytesField(this, 7, value); +}; + + +/** + * optional string pairing_secret_mnemonic = 8; + * @return {string} + */ +proto.litrpc.Session.prototype.getPairingSecretMnemonic = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 8, "")); +}; + + +/** @param {string} value */ +proto.litrpc.Session.prototype.setPairingSecretMnemonic = function(value) { + jspb.Message.setProto3StringField(this, 8, value); +}; + + +/** + * optional bytes local_public_key = 9; + * @return {!(string|Uint8Array)} + */ +proto.litrpc.Session.prototype.getLocalPublicKey = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 9, "")); +}; + + +/** + * optional bytes local_public_key = 9; + * This is a type-conversion wrapper around `getLocalPublicKey()` + * @return {string} + */ +proto.litrpc.Session.prototype.getLocalPublicKey_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getLocalPublicKey())); +}; + + +/** + * optional bytes local_public_key = 9; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getLocalPublicKey()` + * @return {!Uint8Array} + */ +proto.litrpc.Session.prototype.getLocalPublicKey_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getLocalPublicKey())); +}; + + +/** @param {!(string|Uint8Array)} value */ +proto.litrpc.Session.prototype.setLocalPublicKey = function(value) { + jspb.Message.setProto3BytesField(this, 9, value); +}; + + +/** + * optional bytes remote_public_key = 10; + * @return {!(string|Uint8Array)} + */ +proto.litrpc.Session.prototype.getRemotePublicKey = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 10, "")); +}; + + +/** + * optional bytes remote_public_key = 10; + * This is a type-conversion wrapper around `getRemotePublicKey()` + * @return {string} + */ +proto.litrpc.Session.prototype.getRemotePublicKey_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getRemotePublicKey())); +}; + + +/** + * optional bytes remote_public_key = 10; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getRemotePublicKey()` + * @return {!Uint8Array} + */ +proto.litrpc.Session.prototype.getRemotePublicKey_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getRemotePublicKey())); +}; + + +/** @param {!(string|Uint8Array)} value */ +proto.litrpc.Session.prototype.setRemotePublicKey = function(value) { + jspb.Message.setProto3BytesField(this, 10, 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.ListSessionsRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.litrpc.ListSessionsRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.litrpc.ListSessionsRequest.displayName = 'proto.litrpc.ListSessionsRequest'; +} + + +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.ListSessionsRequest.prototype.toObject = function(opt_includeInstance) { + return proto.litrpc.ListSessionsRequest.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.ListSessionsRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.ListSessionsRequest.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + 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.ListSessionsRequest} + */ +proto.litrpc.ListSessionsRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.litrpc.ListSessionsRequest; + return proto.litrpc.ListSessionsRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.litrpc.ListSessionsRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.litrpc.ListSessionsRequest} + */ +proto.litrpc.ListSessionsRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.litrpc.ListSessionsRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.litrpc.ListSessionsRequest.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.ListSessionsRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.ListSessionsRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + +/** + * 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.ListSessionsResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.litrpc.ListSessionsResponse.repeatedFields_, null); +}; +goog.inherits(proto.litrpc.ListSessionsResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.litrpc.ListSessionsResponse.displayName = 'proto.litrpc.ListSessionsResponse'; +} +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.litrpc.ListSessionsResponse.repeatedFields_ = [1]; + + + +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.ListSessionsResponse.prototype.toObject = function(opt_includeInstance) { + return proto.litrpc.ListSessionsResponse.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.ListSessionsResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.ListSessionsResponse.toObject = function(includeInstance, msg) { + var f, obj = { + sessionsList: jspb.Message.toObjectList(msg.getSessionsList(), + proto.litrpc.Session.toObject, includeInstance) + }; + + 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.ListSessionsResponse} + */ +proto.litrpc.ListSessionsResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.litrpc.ListSessionsResponse; + return proto.litrpc.ListSessionsResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.litrpc.ListSessionsResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.litrpc.ListSessionsResponse} + */ +proto.litrpc.ListSessionsResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.litrpc.Session; + reader.readMessage(value,proto.litrpc.Session.deserializeBinaryFromReader); + msg.addSessions(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.litrpc.ListSessionsResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.litrpc.ListSessionsResponse.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.ListSessionsResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.ListSessionsResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getSessionsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 1, + f, + proto.litrpc.Session.serializeBinaryToWriter + ); + } +}; + + +/** + * repeated Session sessions = 1; + * @return {!Array} + */ +proto.litrpc.ListSessionsResponse.prototype.getSessionsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.litrpc.Session, 1)); +}; + + +/** @param {!Array} value */ +proto.litrpc.ListSessionsResponse.prototype.setSessionsList = function(value) { + jspb.Message.setRepeatedWrapperField(this, 1, value); +}; + + +/** + * @param {!proto.litrpc.Session=} opt_value + * @param {number=} opt_index + * @return {!proto.litrpc.Session} + */ +proto.litrpc.ListSessionsResponse.prototype.addSessions = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.litrpc.Session, opt_index); +}; + + +proto.litrpc.ListSessionsResponse.prototype.clearSessionsList = function() { + this.setSessionsList([]); +}; + + + +/** + * 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.RevokeSessionRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.litrpc.RevokeSessionRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.litrpc.RevokeSessionRequest.displayName = 'proto.litrpc.RevokeSessionRequest'; +} + + +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.RevokeSessionRequest.prototype.toObject = function(opt_includeInstance) { + return proto.litrpc.RevokeSessionRequest.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.RevokeSessionRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.RevokeSessionRequest.toObject = function(includeInstance, msg) { + var f, obj = { + localPublicKey: msg.getLocalPublicKey_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.litrpc.RevokeSessionRequest} + */ +proto.litrpc.RevokeSessionRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.litrpc.RevokeSessionRequest; + return proto.litrpc.RevokeSessionRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.litrpc.RevokeSessionRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.litrpc.RevokeSessionRequest} + */ +proto.litrpc.RevokeSessionRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 8: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setLocalPublicKey(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.litrpc.RevokeSessionRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.litrpc.RevokeSessionRequest.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.RevokeSessionRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.RevokeSessionRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getLocalPublicKey_asU8(); + if (f.length > 0) { + writer.writeBytes( + 8, + f + ); + } +}; + + +/** + * optional bytes local_public_key = 8; + * @return {!(string|Uint8Array)} + */ +proto.litrpc.RevokeSessionRequest.prototype.getLocalPublicKey = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 8, "")); +}; + + +/** + * optional bytes local_public_key = 8; + * This is a type-conversion wrapper around `getLocalPublicKey()` + * @return {string} + */ +proto.litrpc.RevokeSessionRequest.prototype.getLocalPublicKey_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getLocalPublicKey())); +}; + + +/** + * optional bytes local_public_key = 8; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getLocalPublicKey()` + * @return {!Uint8Array} + */ +proto.litrpc.RevokeSessionRequest.prototype.getLocalPublicKey_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getLocalPublicKey())); +}; + + +/** @param {!(string|Uint8Array)} value */ +proto.litrpc.RevokeSessionRequest.prototype.setLocalPublicKey = function(value) { + jspb.Message.setProto3BytesField(this, 8, 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.RevokeSessionResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.litrpc.RevokeSessionResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.litrpc.RevokeSessionResponse.displayName = 'proto.litrpc.RevokeSessionResponse'; +} + + +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.RevokeSessionResponse.prototype.toObject = function(opt_includeInstance) { + return proto.litrpc.RevokeSessionResponse.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.RevokeSessionResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.RevokeSessionResponse.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + 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.RevokeSessionResponse} + */ +proto.litrpc.RevokeSessionResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.litrpc.RevokeSessionResponse; + return proto.litrpc.RevokeSessionResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.litrpc.RevokeSessionResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.litrpc.RevokeSessionResponse} + */ +proto.litrpc.RevokeSessionResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.litrpc.RevokeSessionResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.litrpc.RevokeSessionResponse.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.RevokeSessionResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.RevokeSessionResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + +/** + * @enum {number} + */ +proto.litrpc.SessionType = { + TYPE_MACAROON_READONLY: 0, + TYPE_MACAROON_ADMIN: 1, + TYPE_MACAROON_CUSTOM: 2, + TYPE_UI_PASSWORD: 3 +}; + +/** + * @enum {number} + */ +proto.litrpc.SessionState = { + STATE_CREATED: 0, + STATE_IN_USE: 1, + STATE_REVOKED: 2, + STATE_EXPIRED: 3 +}; + +goog.object.extend(exports, proto.litrpc); diff --git a/app/src/types/generated/lit-sessions_pb_service.d.ts b/app/src/types/generated/lit-sessions_pb_service.d.ts new file mode 100644 index 00000000..2f8458cf --- /dev/null +++ b/app/src/types/generated/lit-sessions_pb_service.d.ts @@ -0,0 +1,101 @@ +// package: litrpc +// file: lit-sessions.proto + +import * as lit_sessions_pb from "./lit-sessions_pb"; +import {grpc} from "@improbable-eng/grpc-web"; + +type SessionsAddSession = { + readonly methodName: string; + readonly service: typeof Sessions; + readonly requestStream: false; + readonly responseStream: false; + readonly requestType: typeof lit_sessions_pb.AddSessionRequest; + readonly responseType: typeof lit_sessions_pb.AddSessionResponse; +}; + +type SessionsListSessions = { + readonly methodName: string; + readonly service: typeof Sessions; + readonly requestStream: false; + readonly responseStream: false; + readonly requestType: typeof lit_sessions_pb.ListSessionsRequest; + readonly responseType: typeof lit_sessions_pb.ListSessionsResponse; +}; + +type SessionsRevokeSession = { + readonly methodName: string; + readonly service: typeof Sessions; + readonly requestStream: false; + readonly responseStream: false; + readonly requestType: typeof lit_sessions_pb.RevokeSessionRequest; + readonly responseType: typeof lit_sessions_pb.RevokeSessionResponse; +}; + +export class Sessions { + static readonly serviceName: string; + static readonly AddSession: SessionsAddSession; + static readonly ListSessions: SessionsListSessions; + static readonly RevokeSession: SessionsRevokeSession; +} + +export type ServiceError = { message: string, code: number; metadata: grpc.Metadata } +export type Status = { details: string, code: number; metadata: grpc.Metadata } + +interface UnaryResponse { + cancel(): void; +} +interface ResponseStream { + cancel(): void; + on(type: 'data', handler: (message: T) => void): ResponseStream; + on(type: 'end', handler: (status?: Status) => void): ResponseStream; + on(type: 'status', handler: (status: Status) => void): ResponseStream; +} +interface RequestStream { + write(message: T): RequestStream; + end(): void; + cancel(): void; + on(type: 'end', handler: (status?: Status) => void): RequestStream; + on(type: 'status', handler: (status: Status) => void): RequestStream; +} +interface BidirectionalStream { + write(message: ReqT): BidirectionalStream; + end(): void; + cancel(): void; + on(type: 'data', handler: (message: ResT) => void): BidirectionalStream; + on(type: 'end', handler: (status?: Status) => void): BidirectionalStream; + on(type: 'status', handler: (status: Status) => void): BidirectionalStream; +} + +export class SessionsClient { + readonly serviceHost: string; + + constructor(serviceHost: string, options?: grpc.RpcOptions); + addSession( + requestMessage: lit_sessions_pb.AddSessionRequest, + metadata: grpc.Metadata, + callback: (error: ServiceError|null, responseMessage: lit_sessions_pb.AddSessionResponse|null) => void + ): UnaryResponse; + addSession( + requestMessage: lit_sessions_pb.AddSessionRequest, + callback: (error: ServiceError|null, responseMessage: lit_sessions_pb.AddSessionResponse|null) => void + ): UnaryResponse; + listSessions( + requestMessage: lit_sessions_pb.ListSessionsRequest, + metadata: grpc.Metadata, + callback: (error: ServiceError|null, responseMessage: lit_sessions_pb.ListSessionsResponse|null) => void + ): UnaryResponse; + listSessions( + requestMessage: lit_sessions_pb.ListSessionsRequest, + callback: (error: ServiceError|null, responseMessage: lit_sessions_pb.ListSessionsResponse|null) => void + ): UnaryResponse; + revokeSession( + requestMessage: lit_sessions_pb.RevokeSessionRequest, + metadata: grpc.Metadata, + callback: (error: ServiceError|null, responseMessage: lit_sessions_pb.RevokeSessionResponse|null) => void + ): UnaryResponse; + revokeSession( + requestMessage: lit_sessions_pb.RevokeSessionRequest, + callback: (error: ServiceError|null, responseMessage: lit_sessions_pb.RevokeSessionResponse|null) => void + ): UnaryResponse; +} + diff --git a/app/src/types/generated/lit-sessions_pb_service.js b/app/src/types/generated/lit-sessions_pb_service.js new file mode 100644 index 00000000..62698b6b --- /dev/null +++ b/app/src/types/generated/lit-sessions_pb_service.js @@ -0,0 +1,141 @@ +// package: litrpc +// file: lit-sessions.proto + +var lit_sessions_pb = require("./lit-sessions_pb"); +var grpc = require("@improbable-eng/grpc-web").grpc; + +var Sessions = (function () { + function Sessions() {} + Sessions.serviceName = "litrpc.Sessions"; + return Sessions; +}()); + +Sessions.AddSession = { + methodName: "AddSession", + service: Sessions, + requestStream: false, + responseStream: false, + requestType: lit_sessions_pb.AddSessionRequest, + responseType: lit_sessions_pb.AddSessionResponse +}; + +Sessions.ListSessions = { + methodName: "ListSessions", + service: Sessions, + requestStream: false, + responseStream: false, + requestType: lit_sessions_pb.ListSessionsRequest, + responseType: lit_sessions_pb.ListSessionsResponse +}; + +Sessions.RevokeSession = { + methodName: "RevokeSession", + service: Sessions, + requestStream: false, + responseStream: false, + requestType: lit_sessions_pb.RevokeSessionRequest, + responseType: lit_sessions_pb.RevokeSessionResponse +}; + +exports.Sessions = Sessions; + +function SessionsClient(serviceHost, options) { + this.serviceHost = serviceHost; + this.options = options || {}; +} + +SessionsClient.prototype.addSession = function addSession(requestMessage, metadata, callback) { + if (arguments.length === 2) { + callback = arguments[1]; + } + var client = grpc.unary(Sessions.AddSession, { + 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(); + } + }; +}; + +SessionsClient.prototype.listSessions = function listSessions(requestMessage, metadata, callback) { + if (arguments.length === 2) { + callback = arguments[1]; + } + var client = grpc.unary(Sessions.ListSessions, { + 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(); + } + }; +}; + +SessionsClient.prototype.revokeSession = function revokeSession(requestMessage, metadata, callback) { + if (arguments.length === 2) { + callback = arguments[1]; + } + var client = grpc.unary(Sessions.RevokeSession, { + 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.SessionsClient = SessionsClient; + diff --git a/litrpc/.clang-format b/litrpc/.clang-format new file mode 100644 index 00000000..f1914278 --- /dev/null +++ b/litrpc/.clang-format @@ -0,0 +1,7 @@ +--- +Language: Proto +BasedOnStyle: Google +IndentWidth: 4 +AllowShortFunctionsOnASingleLine: None +SpaceBeforeParens: Always +CompactNamespaces: false diff --git a/litrpc/Dockerfile b/litrpc/Dockerfile new file mode 100644 index 00000000..189764b9 --- /dev/null +++ b/litrpc/Dockerfile @@ -0,0 +1,25 @@ +FROM golang:1.16.3-buster + +RUN apt-get update && apt-get install -y \ + git \ + protobuf-compiler='3.6*' \ + clang-format='1:7.0*' + +# We don't want any default values for these variables to make sure they're +# explicitly provided by parsing the go.mod file. Otherwise we might forget to +# update them here if we bump the versions. +ARG PROTOBUF_VERSION +ARG GRPC_GATEWAY_VERSION + +ENV PROTOC_GEN_GO_GRPC_VERSION="v1.1.0" + +RUN cd /tmp \ + && export GO111MODULE=on \ + && go get google.golang.org/protobuf/cmd/protoc-gen-go@${PROTOBUF_VERSION} \ + && go get google.golang.org/grpc/cmd/protoc-gen-go-grpc@${PROTOC_GEN_GO_GRPC_VERSION} \ + && go get github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@${GRPC_GATEWAY_VERSION} \ + && go get github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@${GRPC_GATEWAY_VERSION} + +WORKDIR /build + +CMD ["/bin/bash", "/build/litrpc/gen_protos.sh"] diff --git a/litrpc/gen_protos.sh b/litrpc/gen_protos.sh new file mode 100755 index 00000000..cc413d8c --- /dev/null +++ b/litrpc/gen_protos.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -e + +# generate compiles the *.pb.go stubs from the *.proto files. +function generate() { + # Generate the gRPC bindings for all proto files. + for file in ./*.proto; do + protoc -I/usr/local/include -I. -I.. \ + --go_out . --go_opt paths=source_relative \ + --go-grpc_out . --go-grpc_opt paths=source_relative \ + "${file}" + done +} + +# format formats the *.proto files with the clang-format utility. +function format() { + find . -name "*.proto" -print0 | xargs -0 clang-format --style=file -i +} + +# Compile and format the litrpc package. +pushd litrpc +format +generate +popd diff --git a/litrpc/gen_protos_docker.sh b/litrpc/gen_protos_docker.sh new file mode 100755 index 00000000..0f755c2f --- /dev/null +++ b/litrpc/gen_protos_docker.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + +# Directory of the script file, independent of where it's called from. +DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)" + +PROTOBUF_VERSION=$(go list -f '{{.Version}}' -m google.golang.org/protobuf) +GRPC_GATEWAY_VERSION=$(go list -f '{{.Version}}' -m github.com/grpc-ecosystem/grpc-gateway/v2) + +echo "Building protobuf compiler docker image..." +docker build -t lit-protobuf-builder \ + --build-arg PROTOBUF_VERSION="$PROTOBUF_VERSION" \ + --build-arg GRPC_GATEWAY_VERSION="$GRPC_GATEWAY_VERSION" \ + . + +echo "Compiling and formatting *.proto files..." +docker run \ + --rm \ + --user $UID:$UID \ + -e UID=$UID \ + -v "$DIR/../:/build" \ + lit-protobuf-builder diff --git a/litrpc/lit-sessions.pb.go b/litrpc/lit-sessions.pb.go new file mode 100644 index 00000000..0e3a3e1a --- /dev/null +++ b/litrpc/lit-sessions.pb.go @@ -0,0 +1,884 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.6.1 +// source: lit-sessions.proto + +package litrpc + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type SessionType int32 + +const ( + SessionType_TYPE_MACAROON_READONLY SessionType = 0 + SessionType_TYPE_MACAROON_ADMIN SessionType = 1 + SessionType_TYPE_MACAROON_CUSTOM SessionType = 2 + SessionType_TYPE_UI_PASSWORD SessionType = 3 +) + +// Enum value maps for SessionType. +var ( + SessionType_name = map[int32]string{ + 0: "TYPE_MACAROON_READONLY", + 1: "TYPE_MACAROON_ADMIN", + 2: "TYPE_MACAROON_CUSTOM", + 3: "TYPE_UI_PASSWORD", + } + SessionType_value = map[string]int32{ + "TYPE_MACAROON_READONLY": 0, + "TYPE_MACAROON_ADMIN": 1, + "TYPE_MACAROON_CUSTOM": 2, + "TYPE_UI_PASSWORD": 3, + } +) + +func (x SessionType) Enum() *SessionType { + p := new(SessionType) + *p = x + return p +} + +func (x SessionType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (SessionType) Descriptor() protoreflect.EnumDescriptor { + return file_lit_sessions_proto_enumTypes[0].Descriptor() +} + +func (SessionType) Type() protoreflect.EnumType { + return &file_lit_sessions_proto_enumTypes[0] +} + +func (x SessionType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use SessionType.Descriptor instead. +func (SessionType) EnumDescriptor() ([]byte, []int) { + return file_lit_sessions_proto_rawDescGZIP(), []int{0} +} + +type SessionState int32 + +const ( + SessionState_STATE_CREATED SessionState = 0 + SessionState_STATE_IN_USE SessionState = 1 + SessionState_STATE_REVOKED SessionState = 2 + SessionState_STATE_EXPIRED SessionState = 3 +) + +// Enum value maps for SessionState. +var ( + SessionState_name = map[int32]string{ + 0: "STATE_CREATED", + 1: "STATE_IN_USE", + 2: "STATE_REVOKED", + 3: "STATE_EXPIRED", + } + SessionState_value = map[string]int32{ + "STATE_CREATED": 0, + "STATE_IN_USE": 1, + "STATE_REVOKED": 2, + "STATE_EXPIRED": 3, + } +) + +func (x SessionState) Enum() *SessionState { + p := new(SessionState) + *p = x + return p +} + +func (x SessionState) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (SessionState) Descriptor() protoreflect.EnumDescriptor { + return file_lit_sessions_proto_enumTypes[1].Descriptor() +} + +func (SessionState) Type() protoreflect.EnumType { + return &file_lit_sessions_proto_enumTypes[1] +} + +func (x SessionState) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use SessionState.Descriptor instead. +func (SessionState) EnumDescriptor() ([]byte, []int) { + return file_lit_sessions_proto_rawDescGZIP(), []int{1} +} + +type AddSessionRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Label string `protobuf:"bytes,1,opt,name=label,proto3" json:"label,omitempty"` + SessionType SessionType `protobuf:"varint,2,opt,name=session_type,json=sessionType,proto3,enum=litrpc.SessionType" json:"session_type,omitempty"` + ExpiryTimestampSeconds uint64 `protobuf:"varint,3,opt,name=expiry_timestamp_seconds,json=expiryTimestampSeconds,proto3" json:"expiry_timestamp_seconds,omitempty"` + MailboxServerAddr string `protobuf:"bytes,4,opt,name=mailbox_server_addr,json=mailboxServerAddr,proto3" json:"mailbox_server_addr,omitempty"` + DevServer bool `protobuf:"varint,5,opt,name=dev_server,json=devServer,proto3" json:"dev_server,omitempty"` + MacaroonCustomPermissions []*MacaroonPermission `protobuf:"bytes,6,rep,name=macaroon_custom_permissions,json=macaroonCustomPermissions,proto3" json:"macaroon_custom_permissions,omitempty"` +} + +func (x *AddSessionRequest) Reset() { + *x = AddSessionRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_lit_sessions_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddSessionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddSessionRequest) ProtoMessage() {} + +func (x *AddSessionRequest) ProtoReflect() protoreflect.Message { + mi := &file_lit_sessions_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddSessionRequest.ProtoReflect.Descriptor instead. +func (*AddSessionRequest) Descriptor() ([]byte, []int) { + return file_lit_sessions_proto_rawDescGZIP(), []int{0} +} + +func (x *AddSessionRequest) GetLabel() string { + if x != nil { + return x.Label + } + return "" +} + +func (x *AddSessionRequest) GetSessionType() SessionType { + if x != nil { + return x.SessionType + } + return SessionType_TYPE_MACAROON_READONLY +} + +func (x *AddSessionRequest) GetExpiryTimestampSeconds() uint64 { + if x != nil { + return x.ExpiryTimestampSeconds + } + return 0 +} + +func (x *AddSessionRequest) GetMailboxServerAddr() string { + if x != nil { + return x.MailboxServerAddr + } + return "" +} + +func (x *AddSessionRequest) GetDevServer() bool { + if x != nil { + return x.DevServer + } + return false +} + +func (x *AddSessionRequest) GetMacaroonCustomPermissions() []*MacaroonPermission { + if x != nil { + return x.MacaroonCustomPermissions + } + return nil +} + +type MacaroonPermission struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The entity a permission grants access to. + Entity string `protobuf:"bytes,1,opt,name=entity,proto3" json:"entity,omitempty"` + // The action that is granted. + Action string `protobuf:"bytes,2,opt,name=action,proto3" json:"action,omitempty"` +} + +func (x *MacaroonPermission) Reset() { + *x = MacaroonPermission{} + if protoimpl.UnsafeEnabled { + mi := &file_lit_sessions_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MacaroonPermission) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MacaroonPermission) ProtoMessage() {} + +func (x *MacaroonPermission) ProtoReflect() protoreflect.Message { + mi := &file_lit_sessions_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MacaroonPermission.ProtoReflect.Descriptor instead. +func (*MacaroonPermission) Descriptor() ([]byte, []int) { + return file_lit_sessions_proto_rawDescGZIP(), []int{1} +} + +func (x *MacaroonPermission) GetEntity() string { + if x != nil { + return x.Entity + } + return "" +} + +func (x *MacaroonPermission) GetAction() string { + if x != nil { + return x.Action + } + return "" +} + +type AddSessionResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Session *Session `protobuf:"bytes,1,opt,name=session,proto3" json:"session,omitempty"` +} + +func (x *AddSessionResponse) Reset() { + *x = AddSessionResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_lit_sessions_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddSessionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddSessionResponse) ProtoMessage() {} + +func (x *AddSessionResponse) ProtoReflect() protoreflect.Message { + mi := &file_lit_sessions_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddSessionResponse.ProtoReflect.Descriptor instead. +func (*AddSessionResponse) Descriptor() ([]byte, []int) { + return file_lit_sessions_proto_rawDescGZIP(), []int{2} +} + +func (x *AddSessionResponse) GetSession() *Session { + if x != nil { + return x.Session + } + return nil +} + +type Session struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Label string `protobuf:"bytes,1,opt,name=label,proto3" json:"label,omitempty"` + SessionState SessionState `protobuf:"varint,2,opt,name=session_state,json=sessionState,proto3,enum=litrpc.SessionState" json:"session_state,omitempty"` + SessionType SessionType `protobuf:"varint,3,opt,name=session_type,json=sessionType,proto3,enum=litrpc.SessionType" json:"session_type,omitempty"` + ExpiryTimestampSeconds uint64 `protobuf:"varint,4,opt,name=expiry_timestamp_seconds,json=expiryTimestampSeconds,proto3" json:"expiry_timestamp_seconds,omitempty"` + MailboxServerAddr string `protobuf:"bytes,5,opt,name=mailbox_server_addr,json=mailboxServerAddr,proto3" json:"mailbox_server_addr,omitempty"` + DevServer bool `protobuf:"varint,6,opt,name=dev_server,json=devServer,proto3" json:"dev_server,omitempty"` + PairingSecret []byte `protobuf:"bytes,7,opt,name=pairing_secret,json=pairingSecret,proto3" json:"pairing_secret,omitempty"` + PairingSecretMnemonic string `protobuf:"bytes,8,opt,name=pairing_secret_mnemonic,json=pairingSecretMnemonic,proto3" json:"pairing_secret_mnemonic,omitempty"` + LocalPublicKey []byte `protobuf:"bytes,9,opt,name=local_public_key,json=localPublicKey,proto3" json:"local_public_key,omitempty"` + RemotePublicKey []byte `protobuf:"bytes,10,opt,name=remote_public_key,json=remotePublicKey,proto3" json:"remote_public_key,omitempty"` +} + +func (x *Session) Reset() { + *x = Session{} + if protoimpl.UnsafeEnabled { + mi := &file_lit_sessions_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Session) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Session) ProtoMessage() {} + +func (x *Session) ProtoReflect() protoreflect.Message { + mi := &file_lit_sessions_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Session.ProtoReflect.Descriptor instead. +func (*Session) Descriptor() ([]byte, []int) { + return file_lit_sessions_proto_rawDescGZIP(), []int{3} +} + +func (x *Session) GetLabel() string { + if x != nil { + return x.Label + } + return "" +} + +func (x *Session) GetSessionState() SessionState { + if x != nil { + return x.SessionState + } + return SessionState_STATE_CREATED +} + +func (x *Session) GetSessionType() SessionType { + if x != nil { + return x.SessionType + } + return SessionType_TYPE_MACAROON_READONLY +} + +func (x *Session) GetExpiryTimestampSeconds() uint64 { + if x != nil { + return x.ExpiryTimestampSeconds + } + return 0 +} + +func (x *Session) GetMailboxServerAddr() string { + if x != nil { + return x.MailboxServerAddr + } + return "" +} + +func (x *Session) GetDevServer() bool { + if x != nil { + return x.DevServer + } + return false +} + +func (x *Session) GetPairingSecret() []byte { + if x != nil { + return x.PairingSecret + } + return nil +} + +func (x *Session) GetPairingSecretMnemonic() string { + if x != nil { + return x.PairingSecretMnemonic + } + return "" +} + +func (x *Session) GetLocalPublicKey() []byte { + if x != nil { + return x.LocalPublicKey + } + return nil +} + +func (x *Session) GetRemotePublicKey() []byte { + if x != nil { + return x.RemotePublicKey + } + return nil +} + +type ListSessionsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ListSessionsRequest) Reset() { + *x = ListSessionsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_lit_sessions_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListSessionsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListSessionsRequest) ProtoMessage() {} + +func (x *ListSessionsRequest) ProtoReflect() protoreflect.Message { + mi := &file_lit_sessions_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListSessionsRequest.ProtoReflect.Descriptor instead. +func (*ListSessionsRequest) Descriptor() ([]byte, []int) { + return file_lit_sessions_proto_rawDescGZIP(), []int{4} +} + +type ListSessionsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Sessions []*Session `protobuf:"bytes,1,rep,name=sessions,proto3" json:"sessions,omitempty"` +} + +func (x *ListSessionsResponse) Reset() { + *x = ListSessionsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_lit_sessions_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListSessionsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListSessionsResponse) ProtoMessage() {} + +func (x *ListSessionsResponse) ProtoReflect() protoreflect.Message { + mi := &file_lit_sessions_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListSessionsResponse.ProtoReflect.Descriptor instead. +func (*ListSessionsResponse) Descriptor() ([]byte, []int) { + return file_lit_sessions_proto_rawDescGZIP(), []int{5} +} + +func (x *ListSessionsResponse) GetSessions() []*Session { + if x != nil { + return x.Sessions + } + return nil +} + +type RevokeSessionRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + LocalPublicKey []byte `protobuf:"bytes,8,opt,name=local_public_key,json=localPublicKey,proto3" json:"local_public_key,omitempty"` +} + +func (x *RevokeSessionRequest) Reset() { + *x = RevokeSessionRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_lit_sessions_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RevokeSessionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RevokeSessionRequest) ProtoMessage() {} + +func (x *RevokeSessionRequest) ProtoReflect() protoreflect.Message { + mi := &file_lit_sessions_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RevokeSessionRequest.ProtoReflect.Descriptor instead. +func (*RevokeSessionRequest) Descriptor() ([]byte, []int) { + return file_lit_sessions_proto_rawDescGZIP(), []int{6} +} + +func (x *RevokeSessionRequest) GetLocalPublicKey() []byte { + if x != nil { + return x.LocalPublicKey + } + return nil +} + +type RevokeSessionResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *RevokeSessionResponse) Reset() { + *x = RevokeSessionResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_lit_sessions_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RevokeSessionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RevokeSessionResponse) ProtoMessage() {} + +func (x *RevokeSessionResponse) ProtoReflect() protoreflect.Message { + mi := &file_lit_sessions_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RevokeSessionResponse.ProtoReflect.Descriptor instead. +func (*RevokeSessionResponse) Descriptor() ([]byte, []int) { + return file_lit_sessions_proto_rawDescGZIP(), []int{7} +} + +var File_lit_sessions_proto protoreflect.FileDescriptor + +var file_lit_sessions_proto_rawDesc = []byte{ + 0x0a, 0x12, 0x6c, 0x69, 0x74, 0x2d, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x22, 0xca, 0x02, 0x0a, + 0x11, 0x41, 0x64, 0x64, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x36, 0x0a, 0x0c, 0x73, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x13, + 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x54, + 0x79, 0x70, 0x65, 0x52, 0x0b, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x3c, 0x0a, 0x18, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x5f, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x04, 0x42, 0x02, 0x30, 0x01, 0x52, 0x16, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x54, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x12, 0x2e, + 0x0a, 0x13, 0x6d, 0x61, 0x69, 0x6c, 0x62, 0x6f, 0x78, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x6d, 0x61, 0x69, + 0x6c, 0x62, 0x6f, 0x78, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x12, 0x1d, + 0x0a, 0x0a, 0x64, 0x65, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x09, 0x64, 0x65, 0x76, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x5a, 0x0a, + 0x1b, 0x6d, 0x61, 0x63, 0x61, 0x72, 0x6f, 0x6f, 0x6e, 0x5f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, + 0x5f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x4d, 0x61, 0x63, 0x61, + 0x72, 0x6f, 0x6f, 0x6e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x19, + 0x6d, 0x61, 0x63, 0x61, 0x72, 0x6f, 0x6f, 0x6e, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x50, 0x65, + 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x44, 0x0a, 0x12, 0x4d, 0x61, 0x63, + 0x61, 0x72, 0x6f, 0x6f, 0x6e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, + 0x16, 0x0a, 0x06, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, + 0x3f, 0x0a, 0x12, 0x41, 0x64, 0x64, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, + 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x22, 0xd4, 0x03, 0x0a, 0x07, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, + 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x61, 0x62, + 0x65, 0x6c, 0x12, 0x39, 0x0a, 0x0d, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74, + 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x6c, 0x69, 0x74, 0x72, + 0x70, 0x63, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, + 0x0c, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x36, 0x0a, + 0x0c, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x13, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0b, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x3c, 0x0a, 0x18, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x5f, + 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x5f, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, + 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x42, 0x02, 0x30, 0x01, 0x52, 0x16, 0x65, 0x78, 0x70, + 0x69, 0x72, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x53, 0x65, 0x63, 0x6f, + 0x6e, 0x64, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x6d, 0x61, 0x69, 0x6c, 0x62, 0x6f, 0x78, 0x5f, 0x73, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x11, 0x6d, 0x61, 0x69, 0x6c, 0x62, 0x6f, 0x78, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, + 0x64, 0x64, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x64, 0x65, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x64, 0x65, 0x76, 0x53, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x61, 0x69, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x65, + 0x63, 0x72, 0x65, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x70, 0x61, 0x69, 0x72, + 0x69, 0x6e, 0x67, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x36, 0x0a, 0x17, 0x70, 0x61, 0x69, + 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x5f, 0x6d, 0x6e, 0x65, 0x6d, + 0x6f, 0x6e, 0x69, 0x63, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x70, 0x61, 0x69, 0x72, + 0x69, 0x6e, 0x67, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4d, 0x6e, 0x65, 0x6d, 0x6f, 0x6e, 0x69, + 0x63, 0x12, 0x28, 0x0a, 0x10, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, + 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x6c, 0x6f, 0x63, + 0x61, 0x6c, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x2a, 0x0a, 0x11, 0x72, + 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, + 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0f, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x75, + 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x22, 0x15, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x53, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x43, + 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2b, 0x0a, 0x08, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, + 0x63, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x73, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x73, 0x22, 0x40, 0x0a, 0x14, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x53, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x28, 0x0a, 0x10, 0x6c, + 0x6f, 0x63, 0x61, 0x6c, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, + 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x50, 0x75, 0x62, 0x6c, + 0x69, 0x63, 0x4b, 0x65, 0x79, 0x22, 0x17, 0x0a, 0x15, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x53, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2a, 0x72, + 0x0a, 0x0b, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, + 0x16, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4d, 0x41, 0x43, 0x41, 0x52, 0x4f, 0x4f, 0x4e, 0x5f, 0x52, + 0x45, 0x41, 0x44, 0x4f, 0x4e, 0x4c, 0x59, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x54, 0x59, 0x50, + 0x45, 0x5f, 0x4d, 0x41, 0x43, 0x41, 0x52, 0x4f, 0x4f, 0x4e, 0x5f, 0x41, 0x44, 0x4d, 0x49, 0x4e, + 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4d, 0x41, 0x43, 0x41, 0x52, + 0x4f, 0x4f, 0x4e, 0x5f, 0x43, 0x55, 0x53, 0x54, 0x4f, 0x4d, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, + 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x49, 0x5f, 0x50, 0x41, 0x53, 0x53, 0x57, 0x4f, 0x52, 0x44, + 0x10, 0x03, 0x2a, 0x59, 0x0a, 0x0c, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x43, 0x52, 0x45, 0x41, + 0x54, 0x45, 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x49, + 0x4e, 0x5f, 0x55, 0x53, 0x45, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x54, 0x41, 0x54, 0x45, + 0x5f, 0x52, 0x45, 0x56, 0x4f, 0x4b, 0x45, 0x44, 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x54, + 0x41, 0x54, 0x45, 0x5f, 0x45, 0x58, 0x50, 0x49, 0x52, 0x45, 0x44, 0x10, 0x03, 0x32, 0xe8, 0x01, + 0x0a, 0x08, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x43, 0x0a, 0x0a, 0x41, 0x64, + 0x64, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x19, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, + 0x63, 0x2e, 0x41, 0x64, 0x64, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x64, 0x64, + 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x49, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, + 0x1b, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x6c, + 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4c, 0x0a, 0x0d, 0x52, 0x65, + 0x76, 0x6f, 0x6b, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x2e, 0x6c, 0x69, + 0x74, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x6c, 0x69, 0x74, 0x72, + 0x70, 0x63, 0x2e, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x6e, 0x69, 0x6e, 0x67, + 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x6e, 0x69, 0x6e, 0x67, 0x2d, 0x74, + 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x2f, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_lit_sessions_proto_rawDescOnce sync.Once + file_lit_sessions_proto_rawDescData = file_lit_sessions_proto_rawDesc +) + +func file_lit_sessions_proto_rawDescGZIP() []byte { + file_lit_sessions_proto_rawDescOnce.Do(func() { + file_lit_sessions_proto_rawDescData = protoimpl.X.CompressGZIP(file_lit_sessions_proto_rawDescData) + }) + return file_lit_sessions_proto_rawDescData +} + +var file_lit_sessions_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_lit_sessions_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_lit_sessions_proto_goTypes = []interface{}{ + (SessionType)(0), // 0: litrpc.SessionType + (SessionState)(0), // 1: litrpc.SessionState + (*AddSessionRequest)(nil), // 2: litrpc.AddSessionRequest + (*MacaroonPermission)(nil), // 3: litrpc.MacaroonPermission + (*AddSessionResponse)(nil), // 4: litrpc.AddSessionResponse + (*Session)(nil), // 5: litrpc.Session + (*ListSessionsRequest)(nil), // 6: litrpc.ListSessionsRequest + (*ListSessionsResponse)(nil), // 7: litrpc.ListSessionsResponse + (*RevokeSessionRequest)(nil), // 8: litrpc.RevokeSessionRequest + (*RevokeSessionResponse)(nil), // 9: litrpc.RevokeSessionResponse +} +var file_lit_sessions_proto_depIdxs = []int32{ + 0, // 0: litrpc.AddSessionRequest.session_type:type_name -> litrpc.SessionType + 3, // 1: litrpc.AddSessionRequest.macaroon_custom_permissions:type_name -> litrpc.MacaroonPermission + 5, // 2: litrpc.AddSessionResponse.session:type_name -> litrpc.Session + 1, // 3: litrpc.Session.session_state:type_name -> litrpc.SessionState + 0, // 4: litrpc.Session.session_type:type_name -> litrpc.SessionType + 5, // 5: litrpc.ListSessionsResponse.sessions:type_name -> litrpc.Session + 2, // 6: litrpc.Sessions.AddSession:input_type -> litrpc.AddSessionRequest + 6, // 7: litrpc.Sessions.ListSessions:input_type -> litrpc.ListSessionsRequest + 8, // 8: litrpc.Sessions.RevokeSession:input_type -> litrpc.RevokeSessionRequest + 4, // 9: litrpc.Sessions.AddSession:output_type -> litrpc.AddSessionResponse + 7, // 10: litrpc.Sessions.ListSessions:output_type -> litrpc.ListSessionsResponse + 9, // 11: litrpc.Sessions.RevokeSession:output_type -> litrpc.RevokeSessionResponse + 9, // [9:12] is the sub-list for method output_type + 6, // [6:9] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name +} + +func init() { file_lit_sessions_proto_init() } +func file_lit_sessions_proto_init() { + if File_lit_sessions_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_lit_sessions_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddSessionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_lit_sessions_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MacaroonPermission); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_lit_sessions_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddSessionResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_lit_sessions_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Session); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_lit_sessions_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListSessionsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_lit_sessions_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListSessionsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_lit_sessions_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RevokeSessionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_lit_sessions_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RevokeSessionResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_lit_sessions_proto_rawDesc, + NumEnums: 2, + NumMessages: 8, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_lit_sessions_proto_goTypes, + DependencyIndexes: file_lit_sessions_proto_depIdxs, + EnumInfos: file_lit_sessions_proto_enumTypes, + MessageInfos: file_lit_sessions_proto_msgTypes, + }.Build() + File_lit_sessions_proto = out.File + file_lit_sessions_proto_rawDesc = nil + file_lit_sessions_proto_goTypes = nil + file_lit_sessions_proto_depIdxs = nil +} diff --git a/litrpc/lit-sessions.proto b/litrpc/lit-sessions.proto new file mode 100644 index 00000000..e1df131e --- /dev/null +++ b/litrpc/lit-sessions.proto @@ -0,0 +1,91 @@ +syntax = "proto3"; + +package litrpc; + +option go_package = "github.com/lightninglabs/lightning-terminal/litrpc"; + +// Sessions is a service that gives access to the core functionalities of the +// daemon's session system. +service Sessions { + rpc AddSession (AddSessionRequest) returns (AddSessionResponse); + + rpc ListSessions (ListSessionsRequest) returns (ListSessionsResponse); + + rpc RevokeSession (RevokeSessionRequest) returns (RevokeSessionResponse); +} + +enum SessionType { + TYPE_MACAROON_READONLY = 0; + TYPE_MACAROON_ADMIN = 1; + TYPE_MACAROON_CUSTOM = 2; + TYPE_UI_PASSWORD = 3; +} + +message AddSessionRequest { + string label = 1; + + SessionType session_type = 2; + + uint64 expiry_timestamp_seconds = 3 [jstype = JS_STRING]; + + string mailbox_server_addr = 4; + + bool dev_server = 5; + + repeated MacaroonPermission macaroon_custom_permissions = 6; +} + +message MacaroonPermission { + // The entity a permission grants access to. + string entity = 1; + + // The action that is granted. + string action = 2; +} + +enum SessionState { + STATE_CREATED = 0; + STATE_IN_USE = 1; + STATE_REVOKED = 2; + STATE_EXPIRED = 3; +} + +message AddSessionResponse { + Session session = 1; +} + +message Session { + string label = 1; + + SessionState session_state = 2; + + SessionType session_type = 3; + + uint64 expiry_timestamp_seconds = 4 [jstype = JS_STRING]; + + string mailbox_server_addr = 5; + + bool dev_server = 6; + + bytes pairing_secret = 7; + + string pairing_secret_mnemonic = 8; + + bytes local_public_key = 9; + + bytes remote_public_key = 10; +} + +message ListSessionsRequest { +} + +message ListSessionsResponse { + repeated Session sessions = 1; +} + +message RevokeSessionRequest { + bytes local_public_key = 8; +} + +message RevokeSessionResponse { +} diff --git a/litrpc/lit-sessions_grpc.pb.go b/litrpc/lit-sessions_grpc.pb.go new file mode 100644 index 00000000..845fcde4 --- /dev/null +++ b/litrpc/lit-sessions_grpc.pb.go @@ -0,0 +1,173 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package litrpc + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// SessionsClient is the client API for Sessions service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type SessionsClient interface { + AddSession(ctx context.Context, in *AddSessionRequest, opts ...grpc.CallOption) (*AddSessionResponse, error) + ListSessions(ctx context.Context, in *ListSessionsRequest, opts ...grpc.CallOption) (*ListSessionsResponse, error) + RevokeSession(ctx context.Context, in *RevokeSessionRequest, opts ...grpc.CallOption) (*RevokeSessionResponse, error) +} + +type sessionsClient struct { + cc grpc.ClientConnInterface +} + +func NewSessionsClient(cc grpc.ClientConnInterface) SessionsClient { + return &sessionsClient{cc} +} + +func (c *sessionsClient) AddSession(ctx context.Context, in *AddSessionRequest, opts ...grpc.CallOption) (*AddSessionResponse, error) { + out := new(AddSessionResponse) + err := c.cc.Invoke(ctx, "/litrpc.Sessions/AddSession", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *sessionsClient) ListSessions(ctx context.Context, in *ListSessionsRequest, opts ...grpc.CallOption) (*ListSessionsResponse, error) { + out := new(ListSessionsResponse) + err := c.cc.Invoke(ctx, "/litrpc.Sessions/ListSessions", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *sessionsClient) RevokeSession(ctx context.Context, in *RevokeSessionRequest, opts ...grpc.CallOption) (*RevokeSessionResponse, error) { + out := new(RevokeSessionResponse) + err := c.cc.Invoke(ctx, "/litrpc.Sessions/RevokeSession", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// SessionsServer is the server API for Sessions service. +// All implementations must embed UnimplementedSessionsServer +// for forward compatibility +type SessionsServer interface { + AddSession(context.Context, *AddSessionRequest) (*AddSessionResponse, error) + ListSessions(context.Context, *ListSessionsRequest) (*ListSessionsResponse, error) + RevokeSession(context.Context, *RevokeSessionRequest) (*RevokeSessionResponse, error) + mustEmbedUnimplementedSessionsServer() +} + +// UnimplementedSessionsServer must be embedded to have forward compatible implementations. +type UnimplementedSessionsServer struct { +} + +func (UnimplementedSessionsServer) AddSession(context.Context, *AddSessionRequest) (*AddSessionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddSession not implemented") +} +func (UnimplementedSessionsServer) ListSessions(context.Context, *ListSessionsRequest) (*ListSessionsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListSessions not implemented") +} +func (UnimplementedSessionsServer) RevokeSession(context.Context, *RevokeSessionRequest) (*RevokeSessionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RevokeSession not implemented") +} +func (UnimplementedSessionsServer) mustEmbedUnimplementedSessionsServer() {} + +// UnsafeSessionsServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to SessionsServer will +// result in compilation errors. +type UnsafeSessionsServer interface { + mustEmbedUnimplementedSessionsServer() +} + +func RegisterSessionsServer(s grpc.ServiceRegistrar, srv SessionsServer) { + s.RegisterService(&Sessions_ServiceDesc, srv) +} + +func _Sessions_AddSession_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AddSessionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SessionsServer).AddSession(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/litrpc.Sessions/AddSession", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SessionsServer).AddSession(ctx, req.(*AddSessionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Sessions_ListSessions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListSessionsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SessionsServer).ListSessions(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/litrpc.Sessions/ListSessions", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SessionsServer).ListSessions(ctx, req.(*ListSessionsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Sessions_RevokeSession_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RevokeSessionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SessionsServer).RevokeSession(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/litrpc.Sessions/RevokeSession", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SessionsServer).RevokeSession(ctx, req.(*RevokeSessionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Sessions_ServiceDesc is the grpc.ServiceDesc for Sessions service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Sessions_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "litrpc.Sessions", + HandlerType: (*SessionsServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "AddSession", + Handler: _Sessions_AddSession_Handler, + }, + { + MethodName: "ListSessions", + Handler: _Sessions_ListSessions_Handler, + }, + { + MethodName: "RevokeSession", + Handler: _Sessions_RevokeSession_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "lit-sessions.proto", +}