Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3389703
D12155.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D12155.diff
View Options
diff --git a/keyserver/addons/rust-node-addon/rust-binding-types.js b/keyserver/addons/rust-node-addon/rust-binding-types.js
--- a/keyserver/addons/rust-node-addon/rust-binding-types.js
+++ b/keyserver/addons/rust-node-addon/rust-binding-types.js
@@ -62,6 +62,18 @@
farcasterIds: $ReadOnlyArray<string>,
) => Promise<$ReadOnlyArray<FarcasterUser>>,
+generateNonce: () => Promise<string>,
+ +uploadSecondaryDeviceKeysAndLogIn: (
+ userId: string,
+ nonce: string,
+ nonceSignature: string,
+ signedIdentityKeysBlob: SignedIdentityKeysBlob,
+ contentPrekey: string,
+ contentPrekeySignature: string,
+ notifPrekey: string,
+ notifPrekeySignature: string,
+ contentOneTimeKeys: $ReadOnlyArray<string>,
+ notifOneTimeKeys: $ReadOnlyArray<string>,
+ ) => Promise<IdentityInfo>,
};
export type { RustNativeBindingAPI };
diff --git a/keyserver/addons/rust-node-addon/src/identity_client/login.rs b/keyserver/addons/rust-node-addon/src/identity_client/login.rs
--- a/keyserver/addons/rust-node-addon/src/identity_client/login.rs
+++ b/keyserver/addons/rust-node-addon/src/identity_client/login.rs
@@ -1,8 +1,9 @@
use super::*;
use comm_opaque2::client::Login;
-use grpc_clients::identity::protos::unauthenticated::{
- OpaqueLoginFinishRequest, OpaqueLoginStartRequest,
+use grpc_clients::identity::protos::{
+ unauth::SecondaryDeviceKeysUploadRequest,
+ unauthenticated::{OpaqueLoginFinishRequest, OpaqueLoginStartRequest},
};
use tracing::debug;
@@ -85,3 +86,63 @@
Ok(user_info)
}
+
+#[napi]
+#[instrument(skip_all)]
+#[allow(clippy::too_many_arguments)]
+pub async fn upload_secondary_device_keys_and_log_in(
+ user_id: String,
+ nonce: String,
+ nonce_signature: String,
+ signed_identity_keys_blob: SignedIdentityKeysBlob,
+ content_prekey: String,
+ content_prekey_signature: String,
+ notif_prekey: String,
+ notif_prekey_signature: String,
+ content_one_time_keys: Vec<String>,
+ notif_one_time_keys: Vec<String>,
+) -> Result<UserLoginInfo> {
+ let device_key_upload = DeviceKeyUpload {
+ device_key_info: Some(IdentityKeyInfo {
+ payload: signed_identity_keys_blob.payload,
+ payload_signature: signed_identity_keys_blob.signature,
+ }),
+ content_upload: Some(Prekey {
+ prekey: content_prekey,
+ prekey_signature: content_prekey_signature,
+ }),
+ notif_upload: Some(Prekey {
+ prekey: notif_prekey,
+ prekey_signature: notif_prekey_signature,
+ }),
+ one_time_content_prekeys: content_one_time_keys,
+ one_time_notif_prekeys: notif_one_time_keys,
+ device_type: DeviceType::Keyserver.into(),
+ };
+
+ let mut identity_client = get_identity_client().await?;
+
+ let request = SecondaryDeviceKeysUploadRequest {
+ user_id,
+ nonce,
+ nonce_signature,
+ device_key_upload: Some(device_key_upload),
+ };
+
+ let response = identity_client
+ .upload_keys_for_registered_device_and_log_in(request)
+ .await
+ .map_err(|_| {
+ Error::from_reason(
+ "Failed to upload keys for registered device and log in",
+ )
+ })?
+ .into_inner();
+
+ let user_info = UserLoginInfo {
+ user_id: response.user_id,
+ access_token: response.access_token,
+ };
+
+ Ok(user_info)
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 30, 8:23 PM (16 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2602259
Default Alt Text
D12155.diff (3 KB)
Attached To
Mode
D12155: [keyserver] uploadSecondaryDeviceKeysAndLogIn client method
Attached
Detach File
Event Timeline
Log In to Comment