{"id":15066899,"url":"https://github.com/line/webauthn-swift","last_synced_at":"2025-04-10T13:53:35.965Z","repository":{"id":256739976,"uuid":"855639190","full_name":"line/webauthn-swift","owner":"line","description":"WebAuthn client SDK for iOS/macOS","archived":false,"fork":false,"pushed_at":"2024-10-16T05:33:04.000Z","size":47,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-24T12:39:22.316Z","etag":null,"topics":["authenticator","fido2","swift","webauthn"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/line.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2024-09-11T07:57:44.000Z","updated_at":"2025-03-11T12:23:17.000Z","dependencies_parsed_at":"2025-02-17T10:41:56.089Z","dependency_job_id":null,"html_url":"https://github.com/line/webauthn-swift","commit_stats":null,"previous_names":["line/webauthn-swift"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/line%2Fwebauthn-swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/line%2Fwebauthn-swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/line%2Fwebauthn-swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/line%2Fwebauthn-swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/line","download_url":"https://codeload.github.com/line/webauthn-swift/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248229120,"owners_count":21068835,"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":["authenticator","fido2","swift","webauthn"],"created_at":"2024-09-25T01:13:44.229Z","updated_at":"2025-04-10T13:53:35.944Z","avatar_url":"https://github.com/line.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WebAuthn Swift\n\nWebAuthn Swift is an open-source implementation of the WebAuthn 2.0 standard for\nsecure and password-less authentication in mobile applications. It is built with\nSwift and seamlessly integrates with native iOS apps. The WebAuthn Swift enables\ndevelopers to effortlessly integrate advanced authentication mechanisms,\nstreamlining the login process and providing strong security solutions for a\nwide range of application requirements and user scenarios.\n\n## Components\n\n### PublicKeyCredential\n\n`PublicKeyCredential` [protocol](./Sources/WebAuthn/PublicKeyCredential/PublicKeyCredential.swift)\nis based on the WebAuthn 2.0 standard. This credential can be used for secure\nauthentication using an asymmetric key pair instead of using a password. The\nprotocol includes `create()` and `get()` methods for registration and\nauthentication.\n\n- `create()`: This method allows you to register a user credential by generating\nan asymmetric key pair. The private key is securely stored on the client side,\nwhile the public key is stored by the relying party.\n- `get()`: This method allows you to authenticate a user by communicating with a\nrelying party using a previously registered credential.\n\nWe offer two classes that inherit from `PublicKeyCredential`. Each class uses\ndifferent types of authenticators.\n\n- [Biometric](./Sources/WebAuthn/PublicKeyCredential/Biometric.swift):\nManages public key credentials using [the biometric authenticator](./Sources/WebAuthn/Authenticator/BiometricAuthenticator.swift).\nIt facilitates secure user authentication by leveraging biometric features such\nas Touch ID or Face ID on supported devices.\n- [DeviceCredential](./Sources/WebAuthn/PublicKeyCredential/DeviceCredential.swift):\nManages public key credentials using [the device credential authenticator](./Sources/WebAuthn/Authenticator/DeviceCredentialAuthenticator.swift).\nIt enables secure user authentication by utilizing biometry or a passcode. If\nbiometry is available, the system uses that first. If not, the system prompts\nthe user for the device passcode or user's password.\n\n### RelyingParty\n\n`RelyingParty` [protocol](./Sources/WebAuthn/RelyingParty/RelyingParty.swift) is\nessential for facilitating communication with your relying party which is a\nserver providing access to a secured software application.\n\n### CredentialSourceStorage\n\n`CredentialSourceStorage` is a [protocol](./Sources/WebAuthn/Storage/CredentialSourceStorage.swift)\nthat defines the behavior of a database for handling a public key credential\nsource and its [signature counter](https://www.w3.org/TR/webauthn-3/#signature-counter).\n\n## Requirements\n\n- Swift \u003e= 5.9\n\n## Getting Started\n\n### Adding the dependency\n\nAdd the following entry in your `Package.swift` to start using `WebAuthn`:\n\n```swift\n.package(url: \"https://github.com/line/webauthn-swift.git\", from: \"1.0.0\")\n```\n\nand `WebAuthn` dependency to your target:\n```swift\n.target(name: \"MyApp\", dependencies: [.product(name: \"WebAuthn\", package: \"webauthn-swift\")])\n```\n\n## Usage\n\nIf you want to use a public key credential, you need to define your relying\nparty and credential source storage in advance. To get started\nwith your implementation, we recommend checking out a sample application\navailable on [GitHub](https://github.com/line/webauthndemo-swift). This sample\nprovides a practical example of how to implement each class inheriting each\nprotocol in a real-world application.\n\n### Step 1: Implement a relying party class inheriting `RelyingParty` protocol\n\nYou need to create a relying party class inheriting `RelyingParty` protocol. We\nstrongly recommend to see the real implementation of relying party.\n\n- [webauthndemo-swift/RelyingParty](https://github.com/line/webauthndemo-swift/blob/main/Shared/Authn/Network/RelyingParty.swift)\n\n### Step 2: Implement a credential source storage class inheriting `CredentialSourceStorage` protocol\n\nYou need to create a credential source storage class inheriting\n`CredentialSourceStorage` protocol. You need to store the following data\ncontained in [PublicKeyCredentialSource](./Sources/WebAuthn/Model/PublicKeyCredentialSource.swift)\nand a signature counter for each credential source at a minimum.\n\nWe strongly recommend to see the real implementation using SQLite3.\n\n- [webauthndemo-swift/CredentialSourceStorage](https://github.com/line/webauthndemo-swift/blob/main/Shared/Authn/Storage/CredentialSourceStorage.swift)\n\n### Step 4: Initialize a public key credential class\n\nOnce you have your relying party, credential storage, and key storage\nimplementation ready, you can initialize the public key credential.\n\n```swift\nlet rp = YourRelyingParty()\nlet db = YourCredentialSourceStorage()\n\n// You can use a biometric for public key credential.\nlet credential = Biometric(rp, db)\n\n// ,or you can use a device credential for public key credential.\nlet credential = DeviceCredential(rp, db) \n```\n\n### Step 5: Create an asymmetric key pair and register a user\n\nCall `create()` method to create an asymmetric key pair and register a user.\n\n```swift\nlet options: yourRegistrationOptions = ...\nlet signUp: Result\u003cBool, Error\u003e = await credential.create(options)\n```\n\nYou can use the `performAsyncTask` method to execute the task asynchronously.\n\n```swift\ncredential.performAsyncTask {\n    let signUp = await credential.create(options)\n}\n```\n\n### Step 6: Authenticate a user\n\nCall `get()` method to authenticate a user using existing credential.\n\n```swift\nlet options: yourAuthenticationOptions = ...\nlet signIn: Result\u003cBool, Error\u003e = await credential.get(options)\n```\n\nYou can also use the `performAsyncTask` method to execute the task\nasynchronously.\n\n```swift\ncredential.performAsyncTask {\n    let signIn = await credential.get(options)\n}\n```\n\n## Contact Information\n\nWe are committed to open-sourcing our work to support your use cases. We want to\nknow how you use this library and what problems it helps you to solve. For\ncommunication, we encourage you to use the [Issues](https://github.com/line/webauthn-swift/issues)\nsection of our GitHub repository to report issues, suggest enhancements, or ask\nquestions about the library. This will help us to address your concerns more\nefficiently and allow the community to benefit from your input.\n\nPlease refrain from posting any sensitive or confidential information in the\nissues. If you need to discuss something sensitive, please mention that in your\nissue, and we will find a more secure way to communicate.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fline%2Fwebauthn-swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fline%2Fwebauthn-swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fline%2Fwebauthn-swift/lists"}