π Configure WebAuthn for Biometric Authentication π οΈ
π Description
Configure the WebAuthn library to enable biometric authentication (e.g., fingerprint or Face ID) for the Stellar wallet service. This setup will provide secure user authentication by leveraging WebAuthnβs public key cryptography, preparing the service for registering and verifying user credentials in subsequent issues. The configuration will establish the server as a Relying Party (RP) for WebAuthn.
π― Objective
Set up WebAuthn in services/stellar-wallet/src/auth/webauthn.js to initialize the server as a Relying Party and provide functions for generating registration and verification options.
π Structure
- Directory:
services/stellar-wallet
- Files:
src/auth/webauthn.js
package.json (updated)
- Expected structure:
services/stellar-wallet
βββ src
β βββ index.js
β βββ stellar
β β βββ client.js
β β βββ keys.js
β β βββ fund.js
β βββ db
β β βββ kyc.js
β βββ routes
β β βββ kyc.js
β β βββ kyc-verify.js
β β βββ kyc-status.js
β βββ kyc
β β βββ validate.js
β βββ soroban
β β βββ client.js
β β βββ kyc-contract.rs
β β βββ deploy.js
β βββ auth
β βββ webauthn.js
βββ config
β βββ db.sqlite
βββ tests
β βββ stellar
β β βββ client.test.js
β β βββ keys.test.js
β β βββ fund.test.js
β βββ db
β β βββ kyc.test.js
β βββ routes
β β βββ kyc.test.js
β β βββ kyc-verify.test.js
β β βββ kyc-status.test.js
β βββ kyc
β β βββ validate.test.js
β βββ soroban
β βββ client.test.js
β βββ deploy.test.js
βββ package.json
βββ .env.example
βββ .eslintrc.json
βββ .eslintignore
βββ .prettierrc.json
βββ .prettierignore
βββ .gitignore
β
Requirements
- Create a branch named
feat/webauthn-config for this task.
- Install the WebAuthn server library using
npm install @simplewebauthn/server.
- Update
package.json to include @simplewebauthn/server as a dependency.
- Create
src/auth/webauthn.js with functions:
configureWebAuthn: Initializes the WebAuthn server as a Relying Party with configuration (e.g., RP name, ID, and origin from .env).
generateRegistrationOptions: Generates WebAuthn registration options for a user.
generateAuthenticationOptions: Generates WebAuthn authentication options for a user.
- Add environment variables to
.env.example for WebAuthn configuration (e.g., RP_NAME, RP_ID, ORIGIN).
- Set
RP_NAME to a descriptive name (e.g., Stellar Wallet), RP_ID to the server domain (e.g., localhost for development), and ORIGIN to the server URL (e.g., http://localhost:3000).
- Ensure the functions produce valid WebAuthn options compatible with browser-based authenticators (e.g., fingerprint or Face ID).
- Ensure the code adheres to ESLint and Prettier rules (from Issue 3).
- Commit changes to the
feat/webauthn-config branch with a message like feat: configure webauthn.
- Verify that the CI pipeline (from Issue 1) passes, with linting succeeding (no tests required for this issue).
π Expected Outcomes
@simplewebauthn/server is installed and listed in package.json.
src/auth/webauthn.js contains configureWebAuthn, generateRegistrationOptions, and generateAuthenticationOptions functions.
- WebAuthn is configured as a Relying Party with values from environment variables.
.env.example includes RP_NAME, RP_ID, and ORIGIN for WebAuthn configuration.
- Code passes ESLint and Prettier checks.
- Changes are committed to the
feat/webauthn-config branch with a descriptive lowercase commit message.
- CI pipeline runs successfully, with linting passing for
src/auth/webauthn.js.
π References
π Notes
- The
RP_ID should be set to localhost for development but updated to the production domain later.
- The
ORIGIN must match the serverβs URL to ensure compatibility with WebAuthn clients.
- No unit tests are required in this issue, as testing will be covered in subsequent issues for registration and authentication.
- Ensure environment variables are documented in
.env.example without sensitive values.
- Commit messages must be in lowercase and start with
feat, change, fix, chore, or refactor.
- The CI pipeline should validate the new code, ensuring ESLint passes for
src/auth/webauthn.js.
π Configure WebAuthn for Biometric Authentication π οΈ
π Description
Configure the WebAuthn library to enable biometric authentication (e.g., fingerprint or Face ID) for the Stellar wallet service. This setup will provide secure user authentication by leveraging WebAuthnβs public key cryptography, preparing the service for registering and verifying user credentials in subsequent issues. The configuration will establish the server as a Relying Party (RP) for WebAuthn.
π― Objective
Set up WebAuthn in
services/stellar-wallet/src/auth/webauthn.jsto initialize the server as a Relying Party and provide functions for generating registration and verification options.π Structure
services/stellar-walletsrc/auth/webauthn.jspackage.json(updated)β Requirements
feat/webauthn-configfor this task.npm install @simplewebauthn/server.package.jsonto include@simplewebauthn/serveras a dependency.src/auth/webauthn.jswith functions:configureWebAuthn: Initializes the WebAuthn server as a Relying Party with configuration (e.g., RP name, ID, and origin from.env).generateRegistrationOptions: Generates WebAuthn registration options for a user.generateAuthenticationOptions: Generates WebAuthn authentication options for a user..env.examplefor WebAuthn configuration (e.g.,RP_NAME,RP_ID,ORIGIN).RP_NAMEto a descriptive name (e.g.,Stellar Wallet),RP_IDto the server domain (e.g.,localhostfor development), andORIGINto the server URL (e.g.,http://localhost:3000).feat/webauthn-configbranch with a message likefeat: configure webauthn.π Expected Outcomes
@simplewebauthn/serveris installed and listed inpackage.json.src/auth/webauthn.jscontainsconfigureWebAuthn,generateRegistrationOptions, andgenerateAuthenticationOptionsfunctions..env.exampleincludesRP_NAME,RP_ID, andORIGINfor WebAuthn configuration.feat/webauthn-configbranch with a descriptive lowercase commit message.src/auth/webauthn.js.π References
π Notes
RP_IDshould be set tolocalhostfor development but updated to the production domain later.ORIGINmust match the serverβs URL to ensure compatibility with WebAuthn clients..env.examplewithout sensitive values.feat,change,fix,chore, orrefactor.src/auth/webauthn.js.