diff --git a/services/identity/src/client_service.rs b/services/identity/src/client_service.rs --- a/services/identity/src/client_service.rs +++ b/services/identity/src/client_service.rs @@ -20,9 +20,9 @@ use crate::error::{DeviceListError, Error as DBError}; use crate::grpc_services::protos::unauth::{ find_user_id_request, AddReservedUsernamesRequest, AuthResponse, Empty, - FindUserIdRequest, FindUserIdResponse, GenerateNonceResponse, - OpaqueLoginFinishRequest, OpaqueLoginStartRequest, OpaqueLoginStartResponse, - RegistrationFinishRequest, RegistrationStartRequest, + ExistingDeviceLoginRequest, FindUserIdRequest, FindUserIdResponse, + GenerateNonceResponse, OpaqueLoginFinishRequest, OpaqueLoginStartRequest, + OpaqueLoginStartResponse, RegistrationFinishRequest, RegistrationStartRequest, RegistrationStartResponse, RemoveReservedUsernameRequest, ReservedRegistrationStartRequest, ReservedWalletRegistrationRequest, SecondaryDeviceKeysUploadRequest, VerifyUserAccessTokenRequest, @@ -752,6 +752,13 @@ Ok(Response::new(response)) } + async fn log_in_existing_device( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status> { + Err(tonic::Status::unimplemented("todo")) + } + async fn generate_nonce( &self, _request: tonic::Request, diff --git a/shared/protos/identity_unauth.proto b/shared/protos/identity_unauth.proto --- a/shared/protos/identity_unauth.proto +++ b/shared/protos/identity_unauth.proto @@ -30,6 +30,7 @@ rpc UploadKeysForRegisteredDeviceAndLogIn(SecondaryDeviceKeysUploadRequest) returns (AuthResponse) {} + rpc LogInExistingDevice(ExistingDeviceLoginRequest) returns (AuthResponse) {} /* Service actions */ @@ -217,12 +218,22 @@ message SecondaryDeviceKeysUploadRequest { string user_id = 1; + // Signed nonce message, JSON-stringified string challenge_response = 2; // Information specific to a user's device needed to open a new channel of // communication with this user DeviceKeyUpload device_key_upload = 3; } +// LogInExistingDevice + +message ExistingDeviceLoginRequest { + string user_id = 1; + string device_id = 2; + // Signed nonce message, JSON-stringified + string challenge_response = 3; +} + // GenerateNonce message GenerateNonceResponse{ diff --git a/web/protobufs/identity-unauth-structs.cjs b/web/protobufs/identity-unauth-structs.cjs --- a/web/protobufs/identity-unauth-structs.cjs +++ b/web/protobufs/identity-unauth-structs.cjs @@ -27,6 +27,7 @@ goog.exportSymbol('proto.identity.unauth.DeviceKeyUpload', null, global); goog.exportSymbol('proto.identity.unauth.DeviceType', null, global); goog.exportSymbol('proto.identity.unauth.Empty', null, global); +goog.exportSymbol('proto.identity.unauth.ExistingDeviceLoginRequest', null, global); goog.exportSymbol('proto.identity.unauth.FarcasterUser', null, global); goog.exportSymbol('proto.identity.unauth.FindUserIDRequest', null, global); goog.exportSymbol('proto.identity.unauth.FindUserIDRequest.IdentifierCase', null, global); @@ -364,6 +365,27 @@ */ proto.identity.unauth.SecondaryDeviceKeysUploadRequest.displayName = 'proto.identity.unauth.SecondaryDeviceKeysUploadRequest'; } +/** + * 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.identity.unauth.ExistingDeviceLoginRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.identity.unauth.ExistingDeviceLoginRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.identity.unauth.ExistingDeviceLoginRequest.displayName = 'proto.identity.unauth.ExistingDeviceLoginRequest'; +} /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -3932,6 +3954,196 @@ +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.identity.unauth.ExistingDeviceLoginRequest.prototype.toObject = function(opt_includeInstance) { + return proto.identity.unauth.ExistingDeviceLoginRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.identity.unauth.ExistingDeviceLoginRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.identity.unauth.ExistingDeviceLoginRequest.toObject = function(includeInstance, msg) { + var f, obj = { + userId: jspb.Message.getFieldWithDefault(msg, 1, ""), + deviceId: jspb.Message.getFieldWithDefault(msg, 2, ""), + challengeResponse: jspb.Message.getFieldWithDefault(msg, 3, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.identity.unauth.ExistingDeviceLoginRequest} + */ +proto.identity.unauth.ExistingDeviceLoginRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.identity.unauth.ExistingDeviceLoginRequest; + return proto.identity.unauth.ExistingDeviceLoginRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.identity.unauth.ExistingDeviceLoginRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.identity.unauth.ExistingDeviceLoginRequest} + */ +proto.identity.unauth.ExistingDeviceLoginRequest.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.setUserId(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setDeviceId(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setChallengeResponse(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.identity.unauth.ExistingDeviceLoginRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.identity.unauth.ExistingDeviceLoginRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.identity.unauth.ExistingDeviceLoginRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.identity.unauth.ExistingDeviceLoginRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getUserId(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getDeviceId(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getChallengeResponse(); + if (f.length > 0) { + writer.writeString( + 3, + f + ); + } +}; + + +/** + * optional string user_id = 1; + * @return {string} + */ +proto.identity.unauth.ExistingDeviceLoginRequest.prototype.getUserId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.identity.unauth.ExistingDeviceLoginRequest} returns this + */ +proto.identity.unauth.ExistingDeviceLoginRequest.prototype.setUserId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string device_id = 2; + * @return {string} + */ +proto.identity.unauth.ExistingDeviceLoginRequest.prototype.getDeviceId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.identity.unauth.ExistingDeviceLoginRequest} returns this + */ +proto.identity.unauth.ExistingDeviceLoginRequest.prototype.setDeviceId = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional string challenge_response = 3; + * @return {string} + */ +proto.identity.unauth.ExistingDeviceLoginRequest.prototype.getChallengeResponse = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.identity.unauth.ExistingDeviceLoginRequest} returns this + */ +proto.identity.unauth.ExistingDeviceLoginRequest.prototype.setChallengeResponse = function(value) { + return jspb.Message.setProto3StringField(this, 3, value); +}; + + + + + if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. diff --git a/web/protobufs/identity-unauth-structs.cjs.flow b/web/protobufs/identity-unauth-structs.cjs.flow --- a/web/protobufs/identity-unauth-structs.cjs.flow +++ b/web/protobufs/identity-unauth-structs.cjs.flow @@ -411,6 +411,30 @@ deviceKeyUpload?: DeviceKeyUploadObject, } +declare export class ExistingDeviceLoginRequest extends Message { + getUserId(): string; + setUserId(value: string): ExistingDeviceLoginRequest; + + getDeviceId(): string; + setDeviceId(value: string): ExistingDeviceLoginRequest; + + getChallengeResponse(): string; + setChallengeResponse(value: string): ExistingDeviceLoginRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ExistingDeviceLoginRequestObject; + static toObject(includeInstance: boolean, msg: ExistingDeviceLoginRequest): ExistingDeviceLoginRequestObject; + static serializeBinaryToWriter(message: ExistingDeviceLoginRequest, writer: BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ExistingDeviceLoginRequest; + static deserializeBinaryFromReader(message: ExistingDeviceLoginRequest, reader: BinaryReader): ExistingDeviceLoginRequest; +} + +export type ExistingDeviceLoginRequestObject = { + userId: string, + deviceId: string, + challengeResponse: string, +} + declare export class GenerateNonceResponse extends Message { getNonce(): string; setNonce(value: string): GenerateNonceResponse; diff --git a/web/protobufs/identity-unauth.cjs b/web/protobufs/identity-unauth.cjs --- a/web/protobufs/identity-unauth.cjs +++ b/web/protobufs/identity-unauth.cjs @@ -625,6 +625,67 @@ }; +/** + * @const + * @type {!grpc.web.MethodDescriptor< + * !proto.identity.unauth.ExistingDeviceLoginRequest, + * !proto.identity.unauth.AuthResponse>} + */ +const methodDescriptor_IdentityClientService_LogInExistingDevice = new grpc.web.MethodDescriptor( + '/identity.unauth.IdentityClientService/LogInExistingDevice', + grpc.web.MethodType.UNARY, + proto.identity.unauth.ExistingDeviceLoginRequest, + proto.identity.unauth.AuthResponse, + /** + * @param {!proto.identity.unauth.ExistingDeviceLoginRequest} request + * @return {!Uint8Array} + */ + function(request) { + return request.serializeBinary(); + }, + proto.identity.unauth.AuthResponse.deserializeBinary +); + + +/** + * @param {!proto.identity.unauth.ExistingDeviceLoginRequest} request The + * request proto + * @param {?Object} metadata User defined + * call metadata + * @param {function(?grpc.web.RpcError, ?proto.identity.unauth.AuthResponse)} + * callback The callback function(error, response) + * @return {!grpc.web.ClientReadableStream|undefined} + * The XHR Node Readable Stream + */ +proto.identity.unauth.IdentityClientServiceClient.prototype.logInExistingDevice = + function(request, metadata, callback) { + return this.client_.rpcCall(this.hostname_ + + '/identity.unauth.IdentityClientService/LogInExistingDevice', + request, + metadata || {}, + methodDescriptor_IdentityClientService_LogInExistingDevice, + callback); +}; + + +/** + * @param {!proto.identity.unauth.ExistingDeviceLoginRequest} request The + * request proto + * @param {?Object=} metadata User defined + * call metadata + * @return {!Promise} + * Promise that resolves to the response + */ +proto.identity.unauth.IdentityClientServicePromiseClient.prototype.logInExistingDevice = + function(request, metadata) { + return this.client_.unaryCall(this.hostname_ + + '/identity.unauth.IdentityClientService/LogInExistingDevice', + request, + metadata || {}, + methodDescriptor_IdentityClientService_LogInExistingDevice); +}; + + /** * @const * @type {!grpc.web.MethodDescriptor< diff --git a/web/protobufs/identity-unauth.cjs.flow b/web/protobufs/identity-unauth.cjs.flow --- a/web/protobufs/identity-unauth.cjs.flow +++ b/web/protobufs/identity-unauth.cjs.flow @@ -72,6 +72,13 @@ response: identityStructs.AuthResponse) => void ): grpcWeb.ClientReadableStream; + logInExistingDevice( + request: identityStructs.ExistingDeviceLoginRequest, + metadata: grpcWeb.Metadata | void, + callback: (err: grpcWeb.RpcError, + response: identityStructs.AuthResponse) => void + ): grpcWeb.ClientReadableStream; + verifyUserAccessToken( request: identityStructs.VerifyUserAccessTokenRequest, metadata: grpcWeb.Metadata | void, @@ -172,6 +179,11 @@ metadata?: grpcWeb.Metadata ): Promise; + logInExistingDevice( + request: identityStructs.ExistingDeviceLoginRequest, + metadata?: grpcWeb.Metadata + ): Promise; + verifyUserAccessToken( request: identityStructs.VerifyUserAccessTokenRequest, metadata?: grpcWeb.Metadata