Skip to content

Commit 5bd0c74

Browse files
authored
Update mls-validator-service registration flow (#1737)
* use account_identifier.kind() instead of hard-coding Ethereum * test
1 parent e8c52be commit 5bd0c74

File tree

2 files changed

+64
-3
lines changed

2 files changed

+64
-3
lines changed

bindings_ffi/src/mls.rs

+63-2
Original file line numberDiff line numberDiff line change
@@ -3290,7 +3290,7 @@ mod tests {
32903290
};
32913291

32923292
let cred = pk_client
3293-
.authenticate(origin, request, DefaultClientData)
3293+
.authenticate(origin.clone(), request, DefaultClientData)
32943294
.await
32953295
.unwrap();
32963296
let resp = cred.response;
@@ -3326,7 +3326,68 @@ mod tests {
33263326

33273327
// TODO: I'll uncomment this as soon as PR 1733 goes live.
33283328
// Tested locally with this uncommented and it works.
3329-
// alex.apply_signature_request(sig_request).await.unwrap();
3329+
alex.apply_signature_request(sig_request).await.unwrap();
3330+
3331+
let nonce = 0;
3332+
let db_path = tmp_path();
3333+
let db_enc_key = static_enc_key().to_vec();
3334+
let ident = FfiIdentifier {
3335+
identifier: hex::encode(public_key.clone()),
3336+
identifier_kind: FfiIdentifierKind::Passkey,
3337+
};
3338+
let inbox_id = ident.inbox_id(nonce).unwrap();
3339+
let client = create_client(
3340+
connect_to_backend(xmtp_api_grpc::LOCALHOST_ADDRESS.to_string(), false)
3341+
.await
3342+
.unwrap(),
3343+
Some(db_path),
3344+
Some(db_enc_key),
3345+
&inbox_id,
3346+
ident,
3347+
nonce,
3348+
None,
3349+
None,
3350+
)
3351+
.await
3352+
.unwrap();
3353+
3354+
let sig_request = client.signature_request().unwrap().clone();
3355+
let challenge = sig_request.signature_text().await.unwrap();
3356+
let challenge_bytes = challenge.as_bytes().to_vec();
3357+
3358+
let request = CredentialRequestOptions {
3359+
public_key: PublicKeyCredentialRequestOptions {
3360+
challenge: Bytes::from(challenge_bytes),
3361+
timeout: None,
3362+
rp_id: Some(String::from(origin.domain().unwrap())),
3363+
allow_credentials: None,
3364+
user_verification: UserVerificationRequirement::default(),
3365+
hints: None,
3366+
attestation: AttestationConveyancePreference::None,
3367+
attestation_formats: None,
3368+
extensions: None,
3369+
},
3370+
};
3371+
3372+
let cred = pk_client
3373+
.authenticate(origin, request, DefaultClientData)
3374+
.await
3375+
.unwrap();
3376+
let resp = cred.response;
3377+
3378+
let signature = resp.signature.to_vec();
3379+
sig_request
3380+
.add_passkey_signature(FfiPasskeySignature {
3381+
authenticator_data: resp.authenticator_data.to_vec(),
3382+
signature: signature.clone(),
3383+
client_data_json: resp.client_data_json.to_vec(),
3384+
public_key: public_key.clone(),
3385+
})
3386+
.await
3387+
// should be good
3388+
.unwrap();
3389+
3390+
client.register_identity(sig_request).await.unwrap();
33303391
}
33313392

33323393
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]

xmtp_id/src/associations/association_log.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl IdentityAction for CreateInbox {
8787
}
8888

8989
allowed_signature_for_kind(
90-
&MemberKind::Ethereum,
90+
&self.account_identifier.kind(),
9191
&self.initial_identifier_signature.kind,
9292
)?;
9393

0 commit comments

Comments
 (0)