@@ -3290,7 +3290,7 @@ mod tests {
3290
3290
} ;
3291
3291
3292
3292
let cred = pk_client
3293
- . authenticate ( origin, request, DefaultClientData )
3293
+ . authenticate ( origin. clone ( ) , request, DefaultClientData )
3294
3294
. await
3295
3295
. unwrap ( ) ;
3296
3296
let resp = cred. response ;
@@ -3326,7 +3326,68 @@ mod tests {
3326
3326
3327
3327
// TODO: I'll uncomment this as soon as PR 1733 goes live.
3328
3328
// 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 ( ) ;
3330
3391
}
3331
3392
3332
3393
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 1 ) ]
0 commit comments