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 @@ -24,6 +24,7 @@ RegistrationFinishResponse, RegistrationStartRequest, RegistrationStartResponse, RemoveReservedUsernameRequest, ReservedRegistrationStartRequest, ReservedWalletLoginRequest, + SecondaryDeviceLoginRequest, SecondaryDeviceLoginResponse, VerifyUserAccessTokenRequest, VerifyUserAccessTokenResponse, WalletLoginRequest, WalletLoginResponse, }; @@ -578,6 +579,13 @@ Ok(Response::new(response)) } + async fn log_in_secondary_device( + &self, + request: tonic::Request, + ) -> Result, tonic::Status> { + Err(tonic::Status::unimplemented("unimplemented")) + } + async fn generate_nonce( &self, _request: tonic::Request, diff --git a/services/identity/src/grpc_utils.rs b/services/identity/src/grpc_utils.rs --- a/services/identity/src/grpc_utils.rs +++ b/services/identity/src/grpc_utils.rs @@ -10,7 +10,7 @@ unauth::{ DeviceKeyUpload, OpaqueLoginStartRequest, RegistrationStartRequest, ReservedRegistrationStartRequest, ReservedWalletLoginRequest, - WalletLoginRequest, + SecondaryDeviceLoginRequest, WalletLoginRequest, }, }, }; @@ -93,6 +93,12 @@ } } +impl DeviceKeyUploadData for SecondaryDeviceLoginRequest { + fn device_key_upload(&self) -> Option<&DeviceKeyUpload> { + self.device_key_upload.as_ref() + } +} + pub trait DeviceKeyUploadActions { fn payload(&self) -> Result; fn payload_signature(&self) -> Result; 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 @@ -26,6 +26,9 @@ rpc LogInReservedWalletUser(ReservedWalletLoginRequest) returns (WalletLoginResponse) {} + rpc LogInSecondaryDevice(SecondaryDeviceLoginRequest) returns + (SecondaryDeviceLoginResponse) {} + // Sign-In with Ethereum actions // Called by clients to get a nonce for a Sign-In with Ethereum message @@ -208,6 +211,21 @@ string access_token = 2; } +// LogInSecondaryDevice + +message SecondaryDeviceLoginRequest { + string user_id = 1; + // Information specific to a user's device needed to open a new channel of + // communication with this user + DeviceKeyUpload device_key_upload = 2; +} + +message SecondaryDeviceLoginResponse { + string user_id = 1; + // Mint and return a new access token upon successful login + string access_token = 2; +} + // 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 @@ -40,6 +40,8 @@ goog.exportSymbol('proto.identity.unauth.RemoveReservedUsernameRequest', null, global); goog.exportSymbol('proto.identity.unauth.ReservedRegistrationStartRequest', null, global); goog.exportSymbol('proto.identity.unauth.ReservedWalletLoginRequest', null, global); +goog.exportSymbol('proto.identity.unauth.SecondaryDeviceLoginRequest', null, global); +goog.exportSymbol('proto.identity.unauth.SecondaryDeviceLoginResponse', null, global); goog.exportSymbol('proto.identity.unauth.VerifyUserAccessTokenRequest', null, global); goog.exportSymbol('proto.identity.unauth.VerifyUserAccessTokenResponse', null, global); goog.exportSymbol('proto.identity.unauth.WalletLoginRequest', null, global); @@ -380,6 +382,48 @@ */ proto.identity.unauth.WalletLoginResponse.displayName = 'proto.identity.unauth.WalletLoginResponse'; } +/** + * 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.SecondaryDeviceLoginRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.identity.unauth.SecondaryDeviceLoginRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.identity.unauth.SecondaryDeviceLoginRequest.displayName = 'proto.identity.unauth.SecondaryDeviceLoginRequest'; +} +/** + * 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.SecondaryDeviceLoginResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.identity.unauth.SecondaryDeviceLoginResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.identity.unauth.SecondaryDeviceLoginResponse.displayName = 'proto.identity.unauth.SecondaryDeviceLoginResponse'; +} /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -3808,6 +3852,347 @@ +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.SecondaryDeviceLoginRequest.prototype.toObject = function(opt_includeInstance) { + return proto.identity.unauth.SecondaryDeviceLoginRequest.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.SecondaryDeviceLoginRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.identity.unauth.SecondaryDeviceLoginRequest.toObject = function(includeInstance, msg) { + var f, obj = { + userId: jspb.Message.getFieldWithDefault(msg, 1, ""), + deviceKeyUpload: (f = msg.getDeviceKeyUpload()) && proto.identity.unauth.DeviceKeyUpload.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.identity.unauth.SecondaryDeviceLoginRequest} + */ +proto.identity.unauth.SecondaryDeviceLoginRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.identity.unauth.SecondaryDeviceLoginRequest; + return proto.identity.unauth.SecondaryDeviceLoginRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.identity.unauth.SecondaryDeviceLoginRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.identity.unauth.SecondaryDeviceLoginRequest} + */ +proto.identity.unauth.SecondaryDeviceLoginRequest.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 = new proto.identity.unauth.DeviceKeyUpload; + reader.readMessage(value,proto.identity.unauth.DeviceKeyUpload.deserializeBinaryFromReader); + msg.setDeviceKeyUpload(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.identity.unauth.SecondaryDeviceLoginRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.identity.unauth.SecondaryDeviceLoginRequest.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.SecondaryDeviceLoginRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.identity.unauth.SecondaryDeviceLoginRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getUserId(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getDeviceKeyUpload(); + if (f != null) { + writer.writeMessage( + 2, + f, + proto.identity.unauth.DeviceKeyUpload.serializeBinaryToWriter + ); + } +}; + + +/** + * optional string user_id = 1; + * @return {string} + */ +proto.identity.unauth.SecondaryDeviceLoginRequest.prototype.getUserId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.identity.unauth.SecondaryDeviceLoginRequest} returns this + */ +proto.identity.unauth.SecondaryDeviceLoginRequest.prototype.setUserId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional DeviceKeyUpload device_key_upload = 2; + * @return {?proto.identity.unauth.DeviceKeyUpload} + */ +proto.identity.unauth.SecondaryDeviceLoginRequest.prototype.getDeviceKeyUpload = function() { + return /** @type{?proto.identity.unauth.DeviceKeyUpload} */ ( + jspb.Message.getWrapperField(this, proto.identity.unauth.DeviceKeyUpload, 2)); +}; + + +/** + * @param {?proto.identity.unauth.DeviceKeyUpload|undefined} value + * @return {!proto.identity.unauth.SecondaryDeviceLoginRequest} returns this +*/ +proto.identity.unauth.SecondaryDeviceLoginRequest.prototype.setDeviceKeyUpload = function(value) { + return jspb.Message.setWrapperField(this, 2, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.identity.unauth.SecondaryDeviceLoginRequest} returns this + */ +proto.identity.unauth.SecondaryDeviceLoginRequest.prototype.clearDeviceKeyUpload = function() { + return this.setDeviceKeyUpload(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.identity.unauth.SecondaryDeviceLoginRequest.prototype.hasDeviceKeyUpload = function() { + return jspb.Message.getField(this, 2) != null; +}; + + + + + +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.SecondaryDeviceLoginResponse.prototype.toObject = function(opt_includeInstance) { + return proto.identity.unauth.SecondaryDeviceLoginResponse.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.SecondaryDeviceLoginResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.identity.unauth.SecondaryDeviceLoginResponse.toObject = function(includeInstance, msg) { + var f, obj = { + userId: jspb.Message.getFieldWithDefault(msg, 1, ""), + accessToken: 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.identity.unauth.SecondaryDeviceLoginResponse} + */ +proto.identity.unauth.SecondaryDeviceLoginResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.identity.unauth.SecondaryDeviceLoginResponse; + return proto.identity.unauth.SecondaryDeviceLoginResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.identity.unauth.SecondaryDeviceLoginResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.identity.unauth.SecondaryDeviceLoginResponse} + */ +proto.identity.unauth.SecondaryDeviceLoginResponse.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.setAccessToken(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.identity.unauth.SecondaryDeviceLoginResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.identity.unauth.SecondaryDeviceLoginResponse.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.SecondaryDeviceLoginResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.identity.unauth.SecondaryDeviceLoginResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getUserId(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getAccessToken(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } +}; + + +/** + * optional string user_id = 1; + * @return {string} + */ +proto.identity.unauth.SecondaryDeviceLoginResponse.prototype.getUserId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.identity.unauth.SecondaryDeviceLoginResponse} returns this + */ +proto.identity.unauth.SecondaryDeviceLoginResponse.prototype.setUserId = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string access_token = 2; + * @return {string} + */ +proto.identity.unauth.SecondaryDeviceLoginResponse.prototype.getAccessToken = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.identity.unauth.SecondaryDeviceLoginResponse} returns this + */ +proto.identity.unauth.SecondaryDeviceLoginResponse.prototype.setAccessToken = function(value) { + return jspb.Message.setProto3StringField(this, 2, 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 @@ -408,6 +408,48 @@ accessToken: string, }; +declare export class SecondaryDeviceLoginRequest extends Message { + getUserId(): string; + setUserId(value: string): SecondaryDeviceLoginRequest; + + getDeviceKeyUpload(): DeviceKeyUpload | void; + setDeviceKeyUpload(value?: DeviceKeyUpload): SecondaryDeviceLoginRequest; + hasDeviceKeyUpload(): boolean; + clearDeviceKeyUpload(): SecondaryDeviceLoginRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): SecondaryDeviceLoginRequestObject; + static toObject(includeInstance: boolean, msg: SecondaryDeviceLoginRequest): SecondaryDeviceLoginRequestObject; + static serializeBinaryToWriter(message: SecondaryDeviceLoginRequest, writer: BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): SecondaryDeviceLoginRequest; + static deserializeBinaryFromReader(message: SecondaryDeviceLoginRequest, reader: BinaryReader): SecondaryDeviceLoginRequest; +} + +export type SecondaryDeviceLoginRequestObject = { + userId: string, + deviceKeyUpload?: DeviceKeyUploadObject, +} + +declare export class SecondaryDeviceLoginResponse extends Message { + getUserId(): string; + setUserId(value: string): SecondaryDeviceLoginResponse; + + getAccessToken(): string; + setAccessToken(value: string): SecondaryDeviceLoginResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): SecondaryDeviceLoginResponseObject; + static toObject(includeInstance: boolean, msg: SecondaryDeviceLoginResponse): SecondaryDeviceLoginResponseObject; + static serializeBinaryToWriter(message: SecondaryDeviceLoginResponse, writer: BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): SecondaryDeviceLoginResponse; + static deserializeBinaryFromReader(message: SecondaryDeviceLoginResponse, reader: BinaryReader): SecondaryDeviceLoginResponse; +} + +export type SecondaryDeviceLoginResponseObject = { + userId: string, + accessToken: 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 @@ -503,6 +503,67 @@ }; +/** + * @const + * @type {!grpc.web.MethodDescriptor< + * !proto.identity.unauth.SecondaryDeviceLoginRequest, + * !proto.identity.unauth.SecondaryDeviceLoginResponse>} + */ +const methodDescriptor_IdentityClientService_LogInSecondaryDevice = new grpc.web.MethodDescriptor( + '/identity.unauth.IdentityClientService/LogInSecondaryDevice', + grpc.web.MethodType.UNARY, + proto.identity.unauth.SecondaryDeviceLoginRequest, + proto.identity.unauth.SecondaryDeviceLoginResponse, + /** + * @param {!proto.identity.unauth.SecondaryDeviceLoginRequest} request + * @return {!Uint8Array} + */ + function(request) { + return request.serializeBinary(); + }, + proto.identity.unauth.SecondaryDeviceLoginResponse.deserializeBinary +); + + +/** + * @param {!proto.identity.unauth.SecondaryDeviceLoginRequest} request The + * request proto + * @param {?Object} metadata User defined + * call metadata + * @param {function(?grpc.web.RpcError, ?proto.identity.unauth.SecondaryDeviceLoginResponse)} + * callback The callback function(error, response) + * @return {!grpc.web.ClientReadableStream|undefined} + * The XHR Node Readable Stream + */ +proto.identity.unauth.IdentityClientServiceClient.prototype.logInSecondaryDevice = + function(request, metadata, callback) { + return this.client_.rpcCall(this.hostname_ + + '/identity.unauth.IdentityClientService/LogInSecondaryDevice', + request, + metadata || {}, + methodDescriptor_IdentityClientService_LogInSecondaryDevice, + callback); +}; + + +/** + * @param {!proto.identity.unauth.SecondaryDeviceLoginRequest} request The + * request proto + * @param {?Object=} metadata User defined + * call metadata + * @return {!Promise} + * Promise that resolves to the response + */ +proto.identity.unauth.IdentityClientServicePromiseClient.prototype.logInSecondaryDevice = + function(request, metadata) { + return this.client_.unaryCall(this.hostname_ + + '/identity.unauth.IdentityClientService/LogInSecondaryDevice', + request, + metadata || {}, + methodDescriptor_IdentityClientService_LogInSecondaryDevice); +}; + + /** * @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 @@ -58,6 +58,13 @@ response: identityStructs.WalletLoginResponse) => void ): grpcWeb.ClientReadableStream; + logInSecondaryDevice( + request: identityStructs.SecondaryDeviceLoginRequest, + metadata: grpcWeb.Metadata | void, + callback: (err: grpcWeb.RpcError, + response: identityStructs.SecondaryDeviceLoginResponse) => void + ): grpcWeb.ClientReadableStream; + generateNonce( request: identityStructs.Empty, metadata: grpcWeb.Metadata | void, @@ -135,6 +142,11 @@ metadata?: grpcWeb.Metadata ): Promise; + logInSecondaryDevice( + request: identityStructs.SecondaryDeviceLoginRequest, + metadata?: grpcWeb.Metadata + ): Promise; + generateNonce( request: identityStructs.Empty, metadata?: grpcWeb.Metadata