Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32564088
D10797.1767365441.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
13 KB
Referenced Files
None
Subscribers
None
D10797.1767365441.diff
View Options
diff --git a/services/identity/src/grpc_services/authenticated.rs b/services/identity/src/grpc_services/authenticated.rs
--- a/services/identity/src/grpc_services/authenticated.rs
+++ b/services/identity/src/grpc_services/authenticated.rs
@@ -26,8 +26,9 @@
InboundKeyInfo, InboundKeysForUserRequest, InboundKeysForUserResponse,
KeyserverKeysResponse, OutboundKeyInfo, OutboundKeysForUserRequest,
OutboundKeysForUserResponse, RefreshUserPrekeysRequest,
- UpdateUserPasswordFinishRequest, UpdateUserPasswordStartRequest,
- UpdateUserPasswordStartResponse, UploadOneTimeKeysRequest,
+ UpdateDeviceListRequest, UpdateUserPasswordFinishRequest,
+ UpdateUserPasswordStartRequest, UpdateUserPasswordStartResponse,
+ UploadOneTimeKeysRequest,
};
use super::protos::unauth::Empty;
@@ -412,10 +413,17 @@
device_list_updates: stringified_updates,
}))
}
+
+ async fn update_device_list_for_user(
+ &self,
+ _request: tonic::Request<UpdateDeviceListRequest>,
+ ) -> Result<Response<Empty>, tonic::Status> {
+ Err(tonic::Status::unimplemented("not implemented"))
+ }
}
// raw device list that can be serialized to JSON (and then signed in the future)
-#[derive(serde::Serialize)]
+#[derive(serde::Serialize, serde::Deserialize)]
struct RawDeviceList {
devices: Vec<String>,
timestamp: i64,
@@ -430,7 +438,7 @@
}
}
-#[derive(serde::Serialize)]
+#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct SignedDeviceList {
/// JSON-stringified [`RawDeviceList`]
@@ -451,6 +459,16 @@
}
}
+impl TryFrom<UpdateDeviceListRequest> for SignedDeviceList {
+ type Error = tonic::Status;
+ fn try_from(request: UpdateDeviceListRequest) -> Result<Self, Self::Error> {
+ serde_json::from_str(&request.new_device_list).map_err(|err| {
+ error!("Failed to deserialize device list update: {}", err);
+ tonic::Status::failed_precondition("unexpected error")
+ })
+ }
+}
+
#[cfg(test)]
mod tests {
use super::*;
diff --git a/shared/protos/identity_auth.proto b/shared/protos/identity_auth.proto
--- a/shared/protos/identity_auth.proto
+++ b/shared/protos/identity_auth.proto
@@ -57,6 +57,9 @@
// Returns device list history
rpc GetDeviceListForUser(GetDeviceListRequest) returns
(GetDeviceListResponse) {}
+
+ rpc UpdateDeviceListForUser(UpdateDeviceListRequest) returns
+ (identity.unauth.Empty) {}
}
// Helper types
@@ -197,3 +200,16 @@
// }
repeated string device_list_updates = 1;
}
+
+// UpdateDeviceListForUser
+
+message UpdateDeviceListRequest {
+ // A stringified JSON object of the following format:
+ // {
+ // "rawDeviceList": JSON.stringify({
+ // "devices": [<device_id: string>, ...]
+ // "timestamp": <UTC timestamp in milliseconds: int>,
+ // })
+ // }
+ string new_device_list = 1;
+}
diff --git a/web/protobufs/identity-auth-client.cjs b/web/protobufs/identity-auth-client.cjs
--- a/web/protobufs/identity-auth-client.cjs
+++ b/web/protobufs/identity-auth-client.cjs
@@ -749,5 +749,66 @@
};
+/**
+ * @const
+ * @type {!grpc.web.MethodDescriptor<
+ * !proto.identity.auth.UpdateDeviceListRequest,
+ * !proto.identity.unauth.Empty>}
+ */
+const methodDescriptor_IdentityClientService_UpdateDeviceListForUser = new grpc.web.MethodDescriptor(
+ '/identity.auth.IdentityClientService/UpdateDeviceListForUser',
+ grpc.web.MethodType.UNARY,
+ proto.identity.auth.UpdateDeviceListRequest,
+ identity_unauth_pb.Empty,
+ /**
+ * @param {!proto.identity.auth.UpdateDeviceListRequest} request
+ * @return {!Uint8Array}
+ */
+ function(request) {
+ return request.serializeBinary();
+ },
+ identity_unauth_pb.Empty.deserializeBinary
+);
+
+
+/**
+ * @param {!proto.identity.auth.UpdateDeviceListRequest} request The
+ * request proto
+ * @param {?Object<string, string>} metadata User defined
+ * call metadata
+ * @param {function(?grpc.web.RpcError, ?proto.identity.unauth.Empty)}
+ * callback The callback function(error, response)
+ * @return {!grpc.web.ClientReadableStream<!proto.identity.unauth.Empty>|undefined}
+ * The XHR Node Readable Stream
+ */
+proto.identity.auth.IdentityClientServiceClient.prototype.updateDeviceListForUser =
+ function(request, metadata, callback) {
+ return this.client_.rpcCall(this.hostname_ +
+ '/identity.auth.IdentityClientService/UpdateDeviceListForUser',
+ request,
+ metadata || {},
+ methodDescriptor_IdentityClientService_UpdateDeviceListForUser,
+ callback);
+};
+
+
+/**
+ * @param {!proto.identity.auth.UpdateDeviceListRequest} request The
+ * request proto
+ * @param {?Object<string, string>=} metadata User defined
+ * call metadata
+ * @return {!Promise<!proto.identity.unauth.Empty>}
+ * Promise that resolves to the response
+ */
+proto.identity.auth.IdentityClientServicePromiseClient.prototype.updateDeviceListForUser =
+ function(request, metadata) {
+ return this.client_.unaryCall(this.hostname_ +
+ '/identity.auth.IdentityClientService/UpdateDeviceListForUser',
+ request,
+ metadata || {},
+ methodDescriptor_IdentityClientService_UpdateDeviceListForUser);
+};
+
+
module.exports = proto.identity.auth;
diff --git a/web/protobufs/identity-auth-client.cjs.flow b/web/protobufs/identity-auth-client.cjs.flow
--- a/web/protobufs/identity-auth-client.cjs.flow
+++ b/web/protobufs/identity-auth-client.cjs.flow
@@ -87,6 +87,13 @@
callback: (err: grpcWeb.RpcError,
response: identityAuthStructs.GetDeviceListResponse) => void
): grpcWeb.ClientReadableStream<identityAuthStructs.GetDeviceListResponse>;
+
+ updateDeviceListForUser(
+ request: identityAuthStructs.UpdateDeviceListRequest,
+ metadata: grpcWeb.Metadata | void,
+ callback: (err: grpcWeb.RpcError,
+ response: identityStructs.Empty) => void
+ ): grpcWeb.ClientReadableStream<identityStructs.Empty>;
}
declare export class IdentityClientServicePromiseClient {
@@ -148,4 +155,9 @@
request: identityAuthStructs.GetDeviceListRequest,
metadata?: grpcWeb.Metadata
): Promise<identityAuthStructs.GetDeviceListResponse>;
+
+ updateDeviceListForUser(
+ request: identityAuthStructs.UpdateDeviceListRequest,
+ metadata?: grpcWeb.Metadata
+ ): Promise<identityStructs.Empty>;
}
diff --git a/web/protobufs/identity-auth-structs.cjs b/web/protobufs/identity-auth-structs.cjs
--- a/web/protobufs/identity-auth-structs.cjs
+++ b/web/protobufs/identity-auth-structs.cjs
@@ -40,6 +40,7 @@
goog.exportSymbol('proto.identity.auth.OutboundKeysForUserRequest', null, global);
goog.exportSymbol('proto.identity.auth.OutboundKeysForUserResponse', null, global);
goog.exportSymbol('proto.identity.auth.RefreshUserPrekeysRequest', null, global);
+goog.exportSymbol('proto.identity.auth.UpdateDeviceListRequest', null, global);
goog.exportSymbol('proto.identity.auth.UpdateUserPasswordFinishRequest', null, global);
goog.exportSymbol('proto.identity.auth.UpdateUserPasswordStartRequest', null, global);
goog.exportSymbol('proto.identity.auth.UpdateUserPasswordStartResponse', null, global);
@@ -422,6 +423,27 @@
*/
proto.identity.auth.GetDeviceListResponse.displayName = 'proto.identity.auth.GetDeviceListResponse';
}
+/**
+ * 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.auth.UpdateDeviceListRequest = function(opt_data) {
+ jspb.Message.initialize(this, opt_data, 0, -1, null, null);
+};
+goog.inherits(proto.identity.auth.UpdateDeviceListRequest, jspb.Message);
+if (goog.DEBUG && !COMPILED) {
+ /**
+ * @public
+ * @override
+ */
+ proto.identity.auth.UpdateDeviceListRequest.displayName = 'proto.identity.auth.UpdateDeviceListRequest';
+}
@@ -3853,4 +3875,134 @@
};
+
+
+
+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_<name>, 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.auth.UpdateDeviceListRequest.prototype.toObject = function(opt_includeInstance) {
+ return proto.identity.auth.UpdateDeviceListRequest.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.auth.UpdateDeviceListRequest} msg The msg instance to transform.
+ * @return {!Object}
+ * @suppress {unusedLocalVariables} f is only used for nested messages
+ */
+proto.identity.auth.UpdateDeviceListRequest.toObject = function(includeInstance, msg) {
+ var f, obj = {
+ newDeviceList: jspb.Message.getFieldWithDefault(msg, 1, "")
+ };
+
+ if (includeInstance) {
+ obj.$jspbMessageInstance = msg;
+ }
+ return obj;
+};
+}
+
+
+/**
+ * Deserializes binary data (in protobuf wire format).
+ * @param {jspb.ByteSource} bytes The bytes to deserialize.
+ * @return {!proto.identity.auth.UpdateDeviceListRequest}
+ */
+proto.identity.auth.UpdateDeviceListRequest.deserializeBinary = function(bytes) {
+ var reader = new jspb.BinaryReader(bytes);
+ var msg = new proto.identity.auth.UpdateDeviceListRequest;
+ return proto.identity.auth.UpdateDeviceListRequest.deserializeBinaryFromReader(msg, reader);
+};
+
+
+/**
+ * Deserializes binary data (in protobuf wire format) from the
+ * given reader into the given message object.
+ * @param {!proto.identity.auth.UpdateDeviceListRequest} msg The message object to deserialize into.
+ * @param {!jspb.BinaryReader} reader The BinaryReader to use.
+ * @return {!proto.identity.auth.UpdateDeviceListRequest}
+ */
+proto.identity.auth.UpdateDeviceListRequest.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.setNewDeviceList(value);
+ break;
+ default:
+ reader.skipField();
+ break;
+ }
+ }
+ return msg;
+};
+
+
+/**
+ * Serializes the message to binary data (in protobuf wire format).
+ * @return {!Uint8Array}
+ */
+proto.identity.auth.UpdateDeviceListRequest.prototype.serializeBinary = function() {
+ var writer = new jspb.BinaryWriter();
+ proto.identity.auth.UpdateDeviceListRequest.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.auth.UpdateDeviceListRequest} message
+ * @param {!jspb.BinaryWriter} writer
+ * @suppress {unusedLocalVariables} f is only used for nested messages
+ */
+proto.identity.auth.UpdateDeviceListRequest.serializeBinaryToWriter = function(message, writer) {
+ var f = undefined;
+ f = message.getNewDeviceList();
+ if (f.length > 0) {
+ writer.writeString(
+ 1,
+ f
+ );
+ }
+};
+
+
+/**
+ * optional string new_device_list = 1;
+ * @return {string}
+ */
+proto.identity.auth.UpdateDeviceListRequest.prototype.getNewDeviceList = function() {
+ return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
+};
+
+
+/**
+ * @param {string} value
+ * @return {!proto.identity.auth.UpdateDeviceListRequest} returns this
+ */
+proto.identity.auth.UpdateDeviceListRequest.prototype.setNewDeviceList = function(value) {
+ return jspb.Message.setProto3StringField(this, 1, value);
+};
+
+
goog.object.extend(exports, proto.identity.auth);
diff --git a/web/protobufs/identity-auth-structs.cjs.flow b/web/protobufs/identity-auth-structs.cjs.flow
--- a/web/protobufs/identity-auth-structs.cjs.flow
+++ b/web/protobufs/identity-auth-structs.cjs.flow
@@ -418,3 +418,20 @@
export type GetDeviceListResponseObject = {
deviceListUpdatesList: Array<string>,
}
+
+declare export class UpdateDeviceListRequest extends Message {
+ getNewDeviceList(): string;
+ setNewDeviceList(value: string): UpdateDeviceListRequest;
+
+ serializeBinary(): Uint8Array;
+ toObject(includeInstance?: boolean): UpdateDeviceListRequestObject;
+ static toObject(includeInstance: boolean, msg: UpdateDeviceListRequest): UpdateDeviceListRequestObject;
+ static serializeBinaryToWriter(message: UpdateDeviceListRequest, writer: BinaryWriter): void;
+ static deserializeBinary(bytes: Uint8Array): UpdateDeviceListRequest;
+ static deserializeBinaryFromReader(message: UpdateDeviceListRequest, reader: BinaryReader): UpdateDeviceListRequest;
+}
+
+export type UpdateDeviceListRequestObject = {
+ newDeviceList: string,
+}
+
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 2, 2:50 PM (1 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5879918
Default Alt Text
D10797.1767365441.diff (13 KB)
Attached To
Mode
D10797: [identity] Scaffold RPC for device list updates
Attached
Detach File
Event Timeline
Log In to Comment