{"id":20675593,"url":"https://github.com/bitwarden/passwordless-nodejs","last_synced_at":"2025-04-19T20:34:11.541Z","repository":{"id":183958768,"uuid":"671010715","full_name":"bitwarden/passwordless-nodejs","owner":"bitwarden","description":"Bitwarden Passwordless.dev Node.js SDK.","archived":false,"fork":false,"pushed_at":"2025-04-14T04:51:27.000Z","size":387,"stargazers_count":16,"open_issues_count":6,"forks_count":6,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-04-14T05:35:16.001Z","etag":null,"topics":["bitwarden","nodejs"],"latest_commit_sha":null,"homepage":"https://bitwarden.com/","language":"TypeScript","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/bitwarden.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2023-07-26T10:36:44.000Z","updated_at":"2025-04-05T00:09:42.000Z","dependencies_parsed_at":"2023-07-26T14:54:12.481Z","dependency_job_id":"2b96e472-0257-4274-b3a6-c11141e75255","html_url":"https://github.com/bitwarden/passwordless-nodejs","commit_stats":null,"previous_names":["passwordless/passwordless-nodejs","bitwarden/passwordless-nodejs"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitwarden%2Fpasswordless-nodejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitwarden%2Fpasswordless-nodejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitwarden%2Fpasswordless-nodejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitwarden%2Fpasswordless-nodejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitwarden","download_url":"https://codeload.github.com/bitwarden/passwordless-nodejs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249794919,"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","nodejs"],"created_at":"2024-11-16T21:09:56.025Z","updated_at":"2025-04-19T20:34:11.523Z","avatar_url":"https://github.com/bitwarden.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Passwordless Node.js SDK\n![Build](https://github.com/bitwarden/passwordless-nodejs/actions/workflows/ci.yml/badge.svg)\n[![Maven Central](https://img.shields.io/npm/v/@passwordlessdev/passwordless-nodejs.svg)](https://www.npmjs.com/package/@passwordlessdev/passwordless-nodejs)\n[![Downloads](https://img.shields.io/npm/dm/@passwordlessdev/passwordless-nodejs.svg)]([https://pypi.org/project/passwordless/](https://www.npmjs.com/package/@passwordlessdev/passwordless-nodejs))\n\nThe official Bitwarden Passwordless.dev Node.js library.\n\n## Installation\n```bash\n$ npm i @@passwordlessdev/passwordless-nodejs\n```\n\n## Dependencies \u0026 Requirements\n- ES2018 or newer, read more [here](https://node.green/).\n- Supported JavaScript modules: CommonJS, ES\n- Node.js 10 or newer\n\n## Getting Started\nFollow the [Get started guide](https://docs.passwordless.dev/guide/get-started.html).\n\n### Customization\nWhen using `.env` to configure your web application you'll need to set the following properties:\n\n| Key                   | Value example                                  | Description                                                  | Optional |\n|-----------------------|------------------------------------------------|--------------------------------------------------------------|----------|\n| `PASSWORDLESS_API`    | `https://v4.passwordless.dev`                  | The base url where your Passwordless.dev back-end is running | Yes      |\n| `PASSWORDLESS_SECRET` | `demo:secret:f831e39c29e64b77aba547478a4b3ec6` | This is your secret obtained from the AdminConsole.          | No       |\n\nYou would then use the PasswordlessClient as:\n\n### Creating a `PasswordlessClient` instance\nSpecifying the `baseUrl` would be optional, and will contain `https://v4.passwordless.dev` as its default value.\n\n```TSX\nconst options: PasswordlessOptions = {\n  baseUrl: 'https://v4.passwordless.dev'\n};\nthis._passwordlessClient = new PasswordlessClient('demo:secret:f831e39c29e64b77aba547478a4b3ec6', options);\n```\n\n```TSX\nconst options: PasswordlessOptions = {};\nthis._passwordlessClient = new PasswordlessClient('demo:secret:f831e39c29e64b77aba547478a4b3ec6', options);\n```\n\n### Registration\nIf you had for example a 'UserController.ts' with a 'signup' arrow function. You could register a new token as shown below.\n\nYou'll first want to proceed to store the new user in your database and verifying it has succeeded, before registering the token.\n\n```TSX\nsignup = async (request: express.Request, response: express.Response) =\u003e {\n        const signupRequest: SignupRequest = request.body;\n        const repository: UserRepository = new UserRepository();\n        let id: string = null;\n        try {\n            id = repository.create(signupRequest.username, signupRequest.firstName, signupRequest.lastName);\n        } catch {\n            // do error handling, creating user failed.\n        } finally {\n            repository.close();\n        }\n\n        if (!id) {\n            // Do not proceed to create a token, we failed to create a user.\n            response.send(400);\n        }\n\n        let registerOptions = new RegisterOptions();\n        registerOptions.userId = id;\n        registerOptions.username = signupRequest.username;\n        if (signupRequest.deviceName) {\n            registerOptions.aliases = new Array(1);\n            registerOptions.aliases[0] = signupRequest.deviceName;\n        }\n        \n        registerOptions.discoverable = true;\n        \n        const token: RegisterTokenResponse = await this._passwordlessClient.createRegisterToken(registerOptions);\n        response.send(token);\n    }\n```\n\n### Logging in\n\n```TSX\nsignin = async (request: express.Request, response: express.Response) =\u003e {\n        try {\n            const token: string = request.query.token as string;\n            const verifiedUser: VerifiedUser = await this._passwordlessClient.verifyToken(token);\n\n            if (verifiedUser \u0026\u0026 verifiedUser.success === true) {\n                // If you want to build a JWT token for SPA that are rendered client-side, you can do this here.\n                response.send(JSON.stringify(verifiedUser));\n                return;\n            }\n        } catch (error) {\n            console.error(error.message);\n        }\n        response.send(401);\n    }\n```\n\n### Examples\nSee [Passwordless Node.js Example](https://github.com/bitwarden/passwordless-nodejs/blob/main/examples/simple-example) for a Node.js Web application.\n\n## Documentation\nFor a comprehensive list of examples, check out the [API documentation](https://docs.passwordless.dev/guide/get-started.html).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitwarden%2Fpasswordless-nodejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitwarden%2Fpasswordless-nodejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitwarden%2Fpasswordless-nodejs/lists"}