From 38fbd10543b5e3016f593debec8c745033e4469a Mon Sep 17 00:00:00 2001 From: Kelley R Date: Thu, 10 Oct 2024 14:12:33 -0400 Subject: [PATCH 1/2] Improve README, add axios as dependency --- passkeys-backend/.env.example | 2 +- passkeys-backend/README.md | 74 +++++++++++++++++++++++++---------- passkeys-backend/package.json | 4 +- 3 files changed, 57 insertions(+), 23 deletions(-) diff --git a/passkeys-backend/.env.example b/passkeys-backend/.env.example index 5d4139e9..69851946 100644 --- a/passkeys-backend/.env.example +++ b/passkeys-backend/.env.example @@ -1,4 +1,4 @@ -# description: The URL of the comms API for passkeys +# description: The URL of the API for passkeys # format: url # required: true API_URL= diff --git a/passkeys-backend/README.md b/passkeys-backend/README.md index 6d03f52d..d71cbe0f 100644 --- a/passkeys-backend/README.md +++ b/passkeys-backend/README.md @@ -1,4 +1,4 @@ -# passkeys-backend +# Verify Passkeys Verify enables developers to easily add Passkeys into their existing authentication flows, similar to Verify TOTP and Push. The Verify API supports passkey registration, public key storage, and auth flows. On the client-side, developers can optionally embed an open-source library (SDK) that handles interactions with operating systems and customizable UI widgets that maximize conversion. @@ -6,12 +6,10 @@ Verify enables developers to easily add Passkeys into their existing authenticat The best way to use the Function templates is through the Twilio CLI as described below. If you'd like to use the template without the Twilio CLI, [check out our usage docs](../docs/USING_FUNCTIONS.md). -Make sure befores you use the template you have to set up your enviroment variables and -customize the associated files with your client applications origins you can find this -customization [here](#service-customization). - ## Pre-requisites +Verify Passkeys is currently in Pilot. [Request access]() + ### Environment variables This project requires some environment variables to be set. A file named `.env` is used to store the values for those environment variables. To keep your tokens and secrets secure, make sure to not commit the `.env` file in git. When setting up the project with `twilio serverless:init ...` the Twilio CLI will create a `.gitignore` file that excludes `.env` from the version history. @@ -24,11 +22,57 @@ In your `.env` file, set the following values: | Variable | Description | Required | | :------- | :---------- | :------- | -| API_URL | Passkeys API to point at | yes | -| RELYING_PARTY | Customer app or client | yes -| ANDROID_APP_KEYS | The domain of the adroid identity providers hash | yes | -| ACCOUNT_SID | Twilio account where the service belong | yes | -| AUTH_TOKEN | Authentication token for twilio account | yes | +| `API_URL` | Passkeys API to point at | Yes | +| `ACCOUNT_SID` | Find in the [console](https://www.twilio.com/console) | Yes | +| `AUTH_TOKEN` | Find in the [console](https://www.twilio.com/console) | Yes | +| `ANDROID_APP_KEYS` | The domain of the Android identity providers hash | No | + +## Create a new project with the template + +1. Install the [Twilio CLI](https://www.twilio.com/docs/twilio-cli/quickstart#install-twilio-cli) +2. Install the [serverless toolkit](https://www.twilio.com/docs/labs/serverless-toolkit/getting-started) + +```shell +twilio plugins:install @twilio-labs/plugin-serverless +``` + +3. Initiate a new project + +``` +twilio serverless:init passkeys-sample --template=passkeys-backend && cd passkeys-sample +``` + +4. Add your environment variables to `.env`: + +Make sure variables are populated in your `.env` file. See [Environment variables](#environment-variables). + +5. Start the server : + +``` +npm start +``` + +5. Open the web page at https://localhost:3000/index.html and enter your phone number to test + +ℹ️ Check the developer console and terminal for any errors, make sure you've set your environment variables. + +6. [optional] Configure email verification + +[Follow the instructions in the docs](https://www.twilio.com/docs/verify/email) to set up email verification. + +## Deploying + +Deploy your functions and assets with either of the following commands. Note: you must run these commands from inside your project folder. [More details in the docs.](https://www.twilio.com/docs/labs/serverless-toolkit) + +With the [Twilio CLI](https://www.twilio.com/docs/twilio-cli/quickstart): + +``` +twilio serverless:deploy +``` + +## Working with this project + +The following describes customization options and more details for understanding how this application works. ### Service customization @@ -47,7 +91,6 @@ Besides the enviroment variables files, the project also contain two files calle | RELYING_PARTY | Replace it with the value of the relaying party | yes | | FINGERPRINT_CERTIFICATION_HASH | Replace it with the hash fingerprint given by android app in format SHA256 | yes | - ### Function Parameters `/registration/start` expects the following parameters: @@ -81,12 +124,3 @@ Besides the enviroment variables files, the project also contain two files calle | signature | A base64url encoded object given by the `AuthenticatorAttestationResponse` | yes | | userHandle | A base64url encoded object given by the `AuthenticatorAttestationResponse` | yes | -## Deploying - -Deploy your functions and assets with either of the following commands. Note: you must run these commands from inside your project folder. [More details in the docs.](https://www.twilio.com/docs/labs/serverless-toolkit) - -With the [Twilio CLI](https://www.twilio.com/docs/twilio-cli/quickstart): - -``` -twilio serverless:deploy -``` diff --git a/passkeys-backend/package.json b/passkeys-backend/package.json index 66a26eac..856c8293 100644 --- a/passkeys-backend/package.json +++ b/passkeys-backend/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "private": true, "dependencies": { - "@twilio-labs/runtime-helpers": "^0.1.2", - "twilio": "^3.61.0" + "twilio": "^5.3.3", + "axios": "^1.7.7" } } From 009493489cb64a194f61f2f7458030660b7678a4 Mon Sep 17 00:00:00 2001 From: Kelley R Date: Fri, 11 Oct 2024 08:46:00 -0400 Subject: [PATCH 2/2] set default API_URL --- passkeys-backend/.env.example | 2 +- passkeys-backend/README.md | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/passkeys-backend/.env.example b/passkeys-backend/.env.example index 69851946..231380de 100644 --- a/passkeys-backend/.env.example +++ b/passkeys-backend/.env.example @@ -1,7 +1,7 @@ # description: The URL of the API for passkeys # format: url # required: true -API_URL= +API_URL=https://comms.twilio.com/preview # description: The domain of the adroid identity provider # format: list(text) diff --git a/passkeys-backend/README.md b/passkeys-backend/README.md index d71cbe0f..4bff13ee 100644 --- a/passkeys-backend/README.md +++ b/passkeys-backend/README.md @@ -8,8 +8,6 @@ The best way to use the Function templates is through the Twilio CLI as describe ## Pre-requisites -Verify Passkeys is currently in Pilot. [Request access]() - ### Environment variables This project requires some environment variables to be set. A file named `.env` is used to store the values for those environment variables. To keep your tokens and secrets secure, make sure to not commit the `.env` file in git. When setting up the project with `twilio serverless:init ...` the Twilio CLI will create a `.gitignore` file that excludes `.env` from the version history.