{"id":20675582,"url":"https://github.com/bitwarden/passwordless-blazor-webassembly","last_synced_at":"2025-04-19T20:34:13.859Z","repository":{"id":233527237,"uuid":"786358093","full_name":"bitwarden/passwordless-blazor-webassembly","owner":"bitwarden","description":"Bitwarden Passwordless.dev Blazor WebAssembly SDK.","archived":false,"fork":false,"pushed_at":"2025-03-31T00:45:05.000Z","size":180,"stargazers_count":4,"open_issues_count":3,"forks_count":2,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-04-15T16:26:46.500Z","etag":null,"topics":["bitwarden","blazor","blazor-webassembly"],"latest_commit_sha":null,"homepage":"https://bitwarden.com/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitwarden.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE_BITWARDEN.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-14T07:54:05.000Z","updated_at":"2025-01-21T17:18:12.000Z","dependencies_parsed_at":"2024-04-16T15:21:20.521Z","dependency_job_id":"2900ad95-9278-4010-83dc-700b515a8518","html_url":"https://github.com/bitwarden/passwordless-blazor-webassembly","commit_stats":null,"previous_names":["bitwarden/passwordless-blazor-webassembly"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitwarden%2Fpasswordless-blazor-webassembly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitwarden%2Fpasswordless-blazor-webassembly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitwarden%2Fpasswordless-blazor-webassembly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitwarden%2Fpasswordless-blazor-webassembly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitwarden","download_url":"https://codeload.github.com/bitwarden/passwordless-blazor-webassembly/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249794932,"owners_count":21326776,"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":["bitwarden","blazor","blazor-webassembly"],"created_at":"2024-11-16T21:09:53.274Z","updated_at":"2025-04-19T20:34:13.839Z","avatar_url":"https://github.com/bitwarden.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Build](https://github.com/bitwarden/passwordless-blazor-webassembly/actions/workflows/ci.yml/badge.svg)\n\n# Passwordless.dev Blazor WebAssembly Client SDK\n\n## Requirements\n\n- A Blazor WebAssembly application using .NET 6 or higher.\n\n## Installation\n\nTODO\n\n## Configuration\n\n## Using\n\nBe mindful that the code below are simple representations of how to use the SDK. To properly secure your Blazor WebAssembly application, check the [Secure ASP.NET Core Blazor WebAssembly](https://learn.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/) guide.\n\n### Dependency Injection\n\nYou can use the following extension methods on `WebApplicationBuilder` to add configure the Passwordless client to your\nBlazor WebAssembly application:\n\n```csharp\npublic static void AddPasswordlessClient(this IServiceCollection services, Action\u003cPasswordlessOptions\u003e configureOptions);\n\npublic static void AddPasswordlessClient(this IServiceCollection services, IConfiguration configuration);\n\npublic static void AddPasswordlessClient(this IServiceCollection services, string section);\n```\n\n### Registration\n\nInject the `IPasswordlessClient` into your component and call the `RegisterAsync` method to register a new user.\n\n```\n@inject IPasswordlessClient PasswordlessClient\n```\n\nYour form could look like the one below.\n\n```html\n\u003cEditForm FormName=\"@RegisterFormName\" Model=\"@RegisterViewModel\" OnValidSubmit=\"OnRegistrationAsync\"\u003e\n    \u003cDataAnnotationsValidator/\u003e\n    \u003cInputText class=\"form-control\" DisplayName=\"Username\" @bind-Value=\"RegisterViewModel.Username\" placeholder=\"Username\"/\u003e\n    \u003cValidationMessage class=\"validation-message\" For=\"@(() =\u003e RegisterViewModel.Username)\"/\u003e\n    \u003cInputText class=\"form-control\" DisplayName=\"Alias\" @bind-Value=\"RegisterViewModel.Alias\" placeholder=\"Alias (optional)\"/\u003e\n    \u003cValidationMessage class=\"validation-message\" For=\"@(() =\u003e RegisterViewModel.Alias)\"/\u003e\n    \u003cbutton class=\"btn btn-primary\" type=\"submit\"\u003eRegister\u003c/button\u003e\n\u003c/EditForm\u003e\n```\n\nIn the form submission event handlers, handle the registration.\n\n```csharp\nprivate const string RegisterFormName = \"RegisterForm\";\n\n[SupplyParameterFromForm(FormName = RegisterFormName)]\npublic RegisterViewModel RegisterViewModel { get; set; } = new();\n\n\nprivate async Task OnRegistrationAsync()\n{\n    if (RegisterViewModel?.Username == null) return;\n    \n    // 1. Call your backend to obtain the `register_` token.\n    var registrationToken = await PasswordlessClient.RegisterAsync(new RegisterRequest(RegisterViewModel.Username, RegisterViewModel.Alias));\n    \n    // 2. Call the Passwordless client to create and store the credentials.\n    var token = await WebAuthnClient.RegisterAsync(registrationToken.Token, RegisterViewModel.Alias!);\n}\n```\n\n### Logging in\n\nInject the `IPasswordlessClient` into your component and call the `RegisterAsync` method to register a new user.\n\n```\n@inject IPasswordlessClient PasswordlessClient\n```\n\nYour form could look like the one below.\n\n```html\n\u003cEditForm FormName=\"@LoginFormName\" Model=\"@LoginViewModel\" OnValidSubmit=\"OnSignInAsync\"\u003e\n    \u003cDataAnnotationsValidator /\u003e\n    \u003cInputText class=\"form-control\" DisplayName=\"Alias\" @bind-Value=\"LoginViewModel.Alias\" placeholder=\"Alias (optional)\"/\u003e\n    \u003cValidationMessage class=\"validation-message\" For=\"@(() =\u003e LoginViewModel.Alias)\"/\u003e\n    \u003cbutton class=\"btn btn-primary\" type=\"submit\"\u003eSign In\u003c/button\u003e\n\u003c/EditForm\u003e\n```\n\nIn the form submission event handlers, handle the login.\n\n```csharp\nprivate const string LoginFormName = \"LoginForm\";\n\n[SupplyParameterFromForm(FormName = LoginFormName)]\npublic LoginViewModel LoginViewModel { get; set; } = new();\n\nprivate async Task OnSignInAsync()\n{\n    // 1. Call Passwordless.dev to initiate the login process.\n    var token = await PasswordlessClient.LoginAsync(LoginViewModel.Alias!);\n\n    // 2. Once a valid credential is selected, call your backend to authenticate the user.\n    // `backendResponse` can contain a JWT token or any other authentication information.\n    var backendRequest = new SignInRequest(token.Token);\n    var backendResponse = await BackendClient.SignInAsync(backendRequest);\n}\n```\n\n## References\n\n- [Get Started - Passwordless.dev](https://docs.passwordless.dev/guide/get-started.html)\n- [Integration with your backend - Passwordless.dev](https://docs.passwordless.dev/guide/backend)\n- [Secure ASP.NET Core Blazor WebAssembly](https://learn.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitwarden%2Fpasswordless-blazor-webassembly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitwarden%2Fpasswordless-blazor-webassembly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitwarden%2Fpasswordless-blazor-webassembly/lists"}