django-passkeys icon indicating copy to clipboard operation
django-passkeys copied to clipboard

Update helpers.js to fix Software Keys

Open resba opened this issue 11 months ago • 7 comments

Cast Uint8Array objects to base64url encoding when preparing the payload so fido2 knows how to process it.

In newer versions of the credential creation function, some software passkeys will return Uint8Array objects where hardware tokens would pass base64 objects for elements like response.clientDataJSON and response.attestationObject.

This would result in those elements being casted as objects which would then fail out when running AuthenticationResponse.from_dict(response) in any of the views trying to process it due to a type where we pass it dict instead of the expected bytes.

resba avatar Jan 22 '25 18:01 resba

Thanks for your contribution.

What type of keys can this be tested against?

mkalioby avatar Jan 22 '25 19:01 mkalioby

Thanks for your contribution.

What type of keys can this be tested against?

I tested against key generation from Bitwarden and iOS Face ID authenticators using an OSX machine. I would test with Chrome latest.

resba avatar Jan 22 '25 19:01 resba

Does this mean the current library shouldn't work with Apple Passkeys on Mac OSX?

mkalioby avatar Jan 22 '25 20:01 mkalioby

Does this mean the current library shouldn't work with Apple Passkeys on Mac OSX?

AFAIK, when using the library (latest pypi) it attempts to save the passkey then Errors out with a bytes-to-dict TypeError

resba avatar Jan 23 '25 00:01 resba

Thanks, I'll take the patch for a spin and will let you know.

mkalioby avatar Jan 23 '25 05:01 mkalioby

Hello @resba,

I tested the current version of the libray (without Patch) on Mac OS X (Sequoia) with Safari (Version 18.2 (20620.1.16.11.8) and it worked as expected, Also, I tried Chrome and it worked fine, Can you please give me more specific version or can you deploy the version anywhere so we can check it together.

mkalioby avatar Jan 24 '25 10:01 mkalioby

Hi @mkalioby

I have the same issue (with bitwarden and samsung pass) but only on Firefox : Uint8Array are not base64 encoded leading to authentication failure.

I applied this patch to fix my issue.

As ArrayBuffer and Uint8Array are 2 types of binary array in javascript, I think it is safe to always base64 both of those types.

Cheers

nitmir avatar Aug 10 '25 08:08 nitmir