{"id":24905725,"url":"https://github.com/espaciofuturoio/stellar-passkey","last_synced_at":"2025-04-14T08:12:44.141Z","repository":{"id":274996615,"uuid":"924745042","full_name":"espaciofuturoio/stellar-passkey","owner":"espaciofuturoio","description":"Stellar - NextJS - Passkey Demo - How to use passkeys to perform a stellar authentication","archived":false,"fork":false,"pushed_at":"2025-03-08T00:59:40.000Z","size":4882,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T21:48:09.524Z","etag":null,"topics":["demo","nextjs","passkeys","reactjs","stellar"],"latest_commit_sha":null,"homepage":"https://stellar-passkey-demo.espaciofuturo.io","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/espaciofuturoio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-30T15:26:20.000Z","updated_at":"2025-03-19T10:21:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"779b4e1a-ab71-45e0-a828-c1888f81cef6","html_url":"https://github.com/espaciofuturoio/stellar-passkey","commit_stats":null,"previous_names":["espaciofuturoio/stellar-passkey"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/espaciofuturoio%2Fstellar-passkey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/espaciofuturoio%2Fstellar-passkey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/espaciofuturoio%2Fstellar-passkey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/espaciofuturoio%2Fstellar-passkey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/espaciofuturoio","download_url":"https://codeload.github.com/espaciofuturoio/stellar-passkey/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248843882,"owners_count":21170495,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["demo","nextjs","passkeys","reactjs","stellar"],"created_at":"2025-02-02T00:24:29.461Z","updated_at":"2025-04-14T08:12:44.105Z","avatar_url":"https://github.com/espaciofuturoio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Passkey Project\n\n## [Demo](https://passkey-demo.espaciofuturo.io)\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/espaciofuturoio/stellar-passkey/blob/main/assets/stellar-demo.gif\" alt=\"Stellar Passkey Demostration\"\u003e\n\u003c/div\u003e\n\n## Overview\n\nThe Passkey project is a web application that implements WebAuthn for secure user authentication. It leverages the `@simplewebauthn` library to handle registration and authentication processes, using Redis for data storage.\n\n## Features\n\n- User registration and authentication using WebAuthn.\n- Secure storage of user credentials.\n- Mock Redis for local development.\n\n## Prerequisites\n\n- Bun.js or Node.js (version 20 or higher)\n- Redis (for production use)\n\n## Setup\n\n1. **Clone the repository:**\n\n   ```bash\n   git clone git@github.com:espaciofuturoio/stellar-passkey.git\n   cd stellar-passkey\n   ```\n\n2. **Install dependencies:**\n\n   ```bash\n   bun i\n   ```\n\n3. **Environment Configuration:**\n\n   Create a `.env` file in the root directory and configure the following variables:\n\n   ```plaintext\n    PORT=3000\n    ENV=development\n    REDIS_URL=''\n    RP_ID='[\"localhost\"]'\n    RP_NAME='[\"App\"]'\n    EXPECTED_ORIGIN='[\"http://localhost:3000\"]'\n    CHALLENGE_TTL_SECONDS=60\n\n   ```\n\n4. **Run the application:**\n\n   For development:\n\n   ```bash\n   bun run dev\n   ```\n\n## Usage\n\n### API Endpoints\n\n- **Generate Registration Options:**\n\n  `POST /api/generate-registration-options`\n\n  - Request Body: `{ \"identifier\": \"user@example.com\" }`\n  - Response: WebAuthn registration options.\n\n- **Verify Registration:**\n\n  `POST /api/verify-registration`\n\n  - Request Body: `{ \"identifier\": \"user@example.com\", \"registrationResponse\": {...} }`\n  - Response: Verification result.\n\n- **Generate Authentication Options:**\n\n  `POST /api/generate-authentication-options`\n\n  - Request Body: `{ \"identifier\": \"user@example.com\" }`\n  - Response: WebAuthn authentication options.\n\n- **Verify Authentication:**\n\n  `POST /api/verify-authentication`\n\n  - Request Body: `{ \"identifier\": \"user@example.com\", \"authenticationResponse\": {...} }`\n  - Response: Verification result.\n\n### Custom Hooks\n\n#### `usePasskeyAuthentication`\n\nThis hook manages the authentication process using WebAuthn and passkeys.\n\n- **Parameters:**\n  - `identifier`: A string representing the user's identifier.\n\n- **Returns:**\n  - `isAuthenticating`: Boolean indicating if authentication is in progress.\n  - `authSuccess`: String message on successful authentication.\n  - `authError`: String message on authentication error.\n  - `handleAuth`: Function to initiate the authentication process.\n  - `isAuthenticated`: Boolean indicating if the user is authenticated.\n\n#### `usePasskeyRegistration`\n\nThis hook manages the registration process using WebAuthn and passkeys.\n\n- **Parameters:**\n  - `identifier`: A string representing the user's identifier.\n\n- **Returns:**\n  - `isCreatingPasskey`: Boolean indicating if registration is in progress.\n  - `regSuccess`: String message on successful registration.\n  - `regError`: String message on registration error.\n  - `handleRegister`: Function to initiate the registration process.\n  - `isRegistered`: Boolean indicating if the user is registered.\n\n#### `useStellar`\n\nThis hook manages Stellar operations such as deploying contracts and signing transactions.\n\n- **Returns:**\n  - `onRegister`: Function to handle registration with Stellar.\n  - `onSign`: Function to handle signing of transactions.\n  - `prepareSign`: Function to prepare data for signing.\n  - `deployee`: The current deployee address.\n  - `loadingRegister`: Boolean indicating if registration is in progress.\n  - `loadingSign`: Boolean indicating if signing is in progress.\n  - `loadingDeployee`: Boolean indicating if deployee data is being loaded.\n  - `contractData`: Data related to the deployed contract.\n\n## Code Structure\n\n- **`package.json`:** Lists project dependencies and scripts.\n- **`src/app/libs/passkey.ts`:** Handles WebAuthn registration and authentication logic.\n- **`src/app/libs/env.ts`:** Manages environment variables using Zod for validation.\n- **`src/app/libs/redis.ts`:** Provides functions to interact with Redis for storing challenges and user data.\n- **`src/hooks/usePasskeyAuthentication.ts`:** Custom hook for handling user authentication.\n- **`src/hooks/usePasskeyRegistration.ts`:** Custom hook for handling user registration.\n- **`src/app/api`:** Contains API routes for handling registration and authentication requests.\n\n## References\n\n- [WebAuthn Documentation](https://webauthn.guide/)\n- [SimpleWebAuthn](https://simplewebauthn.dev/)\n- [Passkeys Guide](https://www.passkeys.com/guide)\n- [Stellar](https://stellar.org/learn)\n- [Cross platform Stellar smart wallet demo](https://github.com/kalepail/soroban-passkey)\n\n## Stellar Integration\n\n### Derivation Address\n\nThe application uses Stellar for blockchain operations. Each user is associated with a unique derivation address, which is generated using the Stellar SDK. This address is used for various operations such as deploying contracts and voting.\n\n### Signing Process\n\nThe signing process involves creating a transaction that is signed using the user's private key. This ensures that all operations are securely authorized by the user. The application handles signing through the `useStellar` hook, which interacts with the Stellar network to perform operations like deploying contracts and voting.\n\n## Passkey Integration\n\n### Overview\n\nThe Passkey project leverages passkeys for secure and convenient user authentication. Passkeys are a modern authentication method that replaces traditional passwords with cryptographic keys, providing a seamless and secure user experience.\n\n### How Passkeys Work\n\n- **Registration:** During registration, a passkey is generated and stored securely on the user's device. This passkey is used to create a unique derivation address on the Stellar network.\n- **Authentication:** When a user attempts to authenticate, the passkey is used to sign a challenge, verifying the user's identity without transmitting sensitive information.\n\n### Benefits of Passkeys\n\n- **Security:** Passkeys eliminate the need for passwords, reducing the risk of phishing and credential theft.\n- **Convenience:** Users can authenticate with a simple biometric scan or device unlock, streamlining the login process.\n- **Privacy:** Passkeys ensure that sensitive information never leaves the user's device, enhancing privacy.\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.\n\n## License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fespaciofuturoio%2Fstellar-passkey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fespaciofuturoio%2Fstellar-passkey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fespaciofuturoio%2Fstellar-passkey/lists"}