From c37e8ade8d65ff23a69c1875e25d46d1f71835ed Mon Sep 17 00:00:00 2001 From: Kelley R Date: Tue, 6 May 2025 11:22:34 -0400 Subject: [PATCH 1/2] Use E.164 format by default for phone numbers --- passkeys-backend/assets/index.html | 174 +++++++++++------- .../functions/registration/start.js | 1 + 2 files changed, 109 insertions(+), 66 deletions(-) diff --git a/passkeys-backend/assets/index.html b/passkeys-backend/assets/index.html index f447ad71..8c946652 100644 --- a/passkeys-backend/assets/index.html +++ b/passkeys-backend/assets/index.html @@ -1,15 +1,15 @@ - - - + + + Passkeys Demo - - - - + + + + @@ -143,143 +146,182 @@

Sign up or sign in

- +
- + ― or ― - +
diff --git a/passkeys-backend/functions/registration/start.js b/passkeys-backend/functions/registration/start.js index d0bb6834..5b6aadb1 100644 --- a/passkeys-backend/functions/registration/start.js +++ b/passkeys-backend/functions/registration/start.js @@ -69,6 +69,7 @@ exports.handler = async (context, event, callback) => { response.setStatusCode(200); response.setBody(APIResponse.data.next_step); } catch (error) { + console.error('Error in passkeys registration start:', error.message); const statusCode = error.status || 400; response.setStatusCode(statusCode); response.setBody(error.message); From d6f47f13a3205f67f142d3c6e347517d52413341 Mon Sep 17 00:00:00 2001 From: Kelley R Date: Tue, 20 May 2025 15:53:54 -0400 Subject: [PATCH 2/2] Add unit test --- .../tests/registration-start.test.js | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/passkeys-backend/tests/registration-start.test.js b/passkeys-backend/tests/registration-start.test.js index 053c74aa..ecfc9d58 100644 --- a/passkeys-backend/tests/registration-start.test.js +++ b/passkeys-backend/tests/registration-start.test.js @@ -81,6 +81,36 @@ describe('registration/start', () => { handlerFunction(mockContext, { username: 'user001' }, callback); }); + it('works with a phone number as a username', (done) => { + const modifiedBody = structuredClone(mockRequestBody); + modifiedBody.to.user_identifier = '+14151234567'; + modifiedBody.content.user.display_name = '+14151234567'; + + const callback = (_, { _body }) => { + expect(axios.post).toHaveBeenCalledWith( + 'https://api.com/Factors', + modifiedBody, + { auth: { password: 'mockPassword', username: 'mockUsername' } } + ); + done(); + }; + + const mockContextWithoutAndroidKeys = { + API_URL: 'https://api.com', + DOMAIN_NAME: 'example.com', + getTwilioClient: () => ({ + username: 'mockUsername', + password: 'mockPassword', + }), + }; + + handlerFunction( + mockContextWithoutAndroidKeys, + { username: '+14151234567' }, + callback + ); + }); + it('works with empty ANDROID_APP_KEYS', (done) => { const callback = (_, { _body }) => { expect(axios.post).toHaveBeenCalledWith(