Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32215729
D14882.1765162475.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D14882.1765162475.diff
View Options
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
@@ -187,7 +187,7 @@
deviceList: SignedDeviceList,
siweSocialProof?: SignedMessage,
backupSecret: string,
- ) => Promise<IdentityAuthResult>;
+ ) => Promise<RestoreUserResult>;
// on native, publishing prekeys to Identity is called directly from C++,
// there is no need to expose it to JS
+publishWebPrekeys?: (prekeys: SignedPrekeys) => Promise<void>;
@@ -230,12 +230,23 @@
+username: string,
+preRequestUserState?: ?CurrentUserInfo,
};
+const identityAuthResultValidatorObject = {
+ userID: tUserID,
+ accessToken: t.String,
+ username: t.String,
+ preRequestUserState: t.maybe(currentUserInfoValidator),
+};
export const identityAuthResultValidator: TInterface<IdentityAuthResult> =
- tShape<IdentityAuthResult>({
- userID: tUserID,
- accessToken: t.String,
- username: t.String,
- preRequestUserState: t.maybe(currentUserInfoValidator),
+ tShape<IdentityAuthResult>(identityAuthResultValidatorObject);
+
+export type RestoreUserResult = {
+ ...IdentityAuthResult,
+ +backupID: string,
+};
+export const restoreUserResultValidator: TInterface<RestoreUserResult> =
+ tShape<RestoreUserResult>({
+ ...identityAuthResultValidatorObject,
+ backupID: t.String,
});
export type IdentityNewDeviceKeyUpload = {
diff --git a/native/account/restore.js b/native/account/restore.js
--- a/native/account/restore.js
+++ b/native/account/restore.js
@@ -153,8 +153,9 @@
);
//8. Return the result
+ const { backupID: _, ...authResult } = result;
return {
- ...result,
+ ...authResult,
preRequestUserState,
deviceLists: { [userID]: initialDeviceList },
usersPlatformDetails: {
diff --git a/native/identity-service/identity-service-context-provider.react.js b/native/identity-service/identity-service-context-provider.react.js
--- a/native/identity-service/identity-service-context-provider.react.js
+++ b/native/identity-service/identity-service-context-provider.react.js
@@ -19,6 +19,7 @@
deviceOlmOutboundKeysValidator,
farcasterUsersValidator,
identityAuthResultValidator,
+ restoreUserResultValidator,
type IdentityServiceClient,
ONE_TIME_KEYS_NUMBER,
type SignedDeviceList,
@@ -627,10 +628,15 @@
backupSecret,
);
- return await processAuthResult(
+ const { backupID } = assertWithValidator(
+ JSON.parse(restoreResult),
+ restoreUserResultValidator,
+ );
+ const authResult = await processAuthResult(
restoreResult,
primaryIdentityPublicKeys.ed25519,
);
+ return { backupID, ...authResult };
},
uploadKeysForRegisteredDeviceAndLogIn: async (
userID: string,
diff --git a/native/native_rust_library/src/identity.rs b/native/native_rust_library/src/identity.rs
--- a/native/native_rust_library/src/identity.rs
+++ b/native/native_rust_library/src/identity.rs
@@ -169,6 +169,15 @@
username: String,
}
+#[derive(Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct RestoreUserResult {
+ #[serde(flatten)]
+ auth_result: IdentityAuthResult,
+ #[serde(rename = "backupID")]
+ backup_id: String,
+}
+
impl From<AuthResponse> for IdentityAuthResult {
fn from(value: AuthResponse) -> Self {
let AuthResponse {
diff --git a/native/native_rust_library/src/identity/login.rs b/native/native_rust_library/src/identity/login.rs
--- a/native/native_rust_library/src/identity/login.rs
+++ b/native/native_rust_library/src/identity/login.rs
@@ -11,7 +11,7 @@
use super::{
IdentityAuthResult, LogInPasswordUserInfo, LogInWalletUserInfo,
- RestoreUserInfo, PLATFORM_METADATA,
+ RestoreUserInfo, RestoreUserResult, PLATFORM_METADATA,
};
use crate::backup::create_ephemeral_user_keys_compaction;
use crate::utils::jsi_callbacks::handle_string_result_as_callback;
@@ -294,13 +294,14 @@
Some(user_info.siwe_backup_msg)
};
+ let backup_id = user_info.backup_id;
let restore_request = RestoreUserRequest {
user_id: user_info.user_id,
siwe_message: user_info.siwe_social_proof_message,
siwe_signature: user_info.siwe_social_proof_signature,
device_list: user_info.device_list,
device_key_upload: Some(user_info.device_keys.into()),
- new_backup_id: user_info.backup_id,
+ new_backup_id: backup_id.clone(),
encrypted_user_keys: user_keys,
siwe_backup_msg,
};
@@ -315,7 +316,11 @@
.into_inner();
let auth_result = IdentityAuthResult::from(auth_response);
- Ok(serde_json::to_string(&auth_result)?)
+ let result = RestoreUserResult {
+ auth_result,
+ backup_id,
+ };
+ Ok(serde_json::to_string(&result)?)
}
async fn upload_secondary_device_keys_and_log_in_helper(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 8, 2:54 AM (17 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5846850
Default Alt Text
D14882.1765162475.diff (4 KB)
Attached To
Mode
D14882: [native] Return backupID from restoreUser() Identity call
Attached
Detach File
Event Timeline
Log In to Comment