Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3401476
D11515.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
D11515.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
@@ -1,7 +1,10 @@
// @flow
import type { SignedIdentityKeysBlob } from 'lib/types/crypto-types.js';
-import type { InboundKeyInfoResponse } from 'lib/types/identity-service-types.js';
+import type {
+ InboundKeyInfoResponse,
+ FarcasterUser,
+} from 'lib/types/identity-service-types.js';
import type { IdentityInfo } from '../../src/user/identity.js';
@@ -55,6 +58,9 @@
userId: string,
deviceId: string,
) => Promise<InboundKeyInfoResponse>,
+ +getFarcasterUsers: (
+ farcasterIds: $ReadOnlyArray<string>,
+ ) => Promise<$ReadOnlyArray<FarcasterUser>>,
};
export type { RustNativeBindingAPI };
diff --git a/keyserver/addons/rust-node-addon/src/identity_client/get_farcaster_users.rs b/keyserver/addons/rust-node-addon/src/identity_client/get_farcaster_users.rs
new file mode 100644
--- /dev/null
+++ b/keyserver/addons/rust-node-addon/src/identity_client/get_farcaster_users.rs
@@ -0,0 +1,43 @@
+use super::*;
+use grpc_clients::identity::protos::unauth::GetFarcasterUsersRequest;
+use tracing::debug;
+
+#[napi]
+#[instrument(skip_all)]
+pub async fn get_farcaster_users(
+ farcaster_ids: Vec<String>,
+) -> Result<Vec<FarcasterUser>> {
+ let mut identity_client = get_identity_client().await?;
+
+ let request = GetFarcasterUsersRequest { farcaster_ids };
+
+ debug!("Getting Farcaster users from Identity service");
+ let response = identity_client
+ .get_farcaster_users(request)
+ .await
+ .map_err(handle_grpc_error)?;
+
+ let mapped_response: Vec<FarcasterUser> = response
+ .into_inner()
+ .farcaster_users
+ .into_iter()
+ .map(|farcaster_user| FarcasterUser {
+ user_id: farcaster_user.user_id,
+ username: farcaster_user.username,
+ farcaster_id: farcaster_user.farcaster_id,
+ })
+ .collect();
+
+ Ok(mapped_response)
+}
+
+// This struct should not be altered without also updating FarcasterUser in
+// lib/types/identity-service-types.js
+#[napi(object)]
+pub struct FarcasterUser {
+ #[napi(js_name = "userID")]
+ pub user_id: String,
+ pub username: String,
+ #[napi(js_name = "farcasterID")]
+ pub farcaster_id: String,
+}
diff --git a/keyserver/addons/rust-node-addon/src/identity_client/mod.rs b/keyserver/addons/rust-node-addon/src/identity_client/mod.rs
--- a/keyserver/addons/rust-node-addon/src/identity_client/mod.rs
+++ b/keyserver/addons/rust-node-addon/src/identity_client/mod.rs
@@ -1,5 +1,6 @@
pub mod add_reserved_usernames;
pub mod config;
+pub mod get_farcaster_users;
pub mod get_inbound_keys_for_user;
pub mod login;
pub mod prekey;
diff --git a/lib/types/identity-service-types.js b/lib/types/identity-service-types.js
--- a/lib/types/identity-service-types.js
+++ b/lib/types/identity-service-types.js
@@ -24,8 +24,8 @@
+accessToken: string,
};
-// This type should not be altered without also updating
-// OutboundKeyInfoResponse in native/native_rust_library/src/lib.rs
+// This type should not be altered without also updating OutboundKeyInfoResponse
+// in native/native_rust_library/src/identity/x3dh.rs
export type OutboundKeyInfoResponse = {
+payload: string,
+payloadSignature: string,
@@ -38,8 +38,8 @@
+oneTimeNotifPrekey: ?string,
};
-// This type should not be altered without also updating
-// InboundKeyInfoResponse in native/native_rust_library/src/lib.rs
+// This type should not be altered without also updating InboundKeyInfoResponse
+// in native/native_rust_library/src/identity/x3dh.rs
export type InboundKeyInfoResponse = {
+payload: string,
+payloadSignature: string,
@@ -93,6 +93,8 @@
+walletAddress?: ?string,
};
+// This type should not be altered without also updating FarcasterUser in
+// keyserver/addons/rust-node-addon/src/identity_client/get_farcaster_users.rs
export type FarcasterUser = {
+userID: string,
+username: string,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 3, 12:24 PM (21 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2611655
Default Alt Text
D11515.diff (3 KB)
Attached To
Mode
D11515: [keyserver] expose getFarcasterUsers client method to JS on keyserver
Attached
Detach File
Event Timeline
Log In to Comment