├── .github └── FUNDING.yml ├── LICENSE ├── README.md ├── index.html ├── sign-in-with.css └── sign-in-with.js /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: passwordless-id 4 | #patreon: # Replace with a single Patreon username 5 | #open_collective: # Replace with a single Open Collective username 6 | #ko_fi: # Replace with a single Ko-fi username 7 | #tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | #community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | #liberapay: # Replace with a single Liberapay username 10 | #issuehunt: # Replace with a single IssueHunt username 11 | #otechie: # Replace with a single Otechie username 12 | #lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | #custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Passwordless.ID 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Passwordless.ID Demo 2 | -------------------- 3 | 4 | Try the simple demo of a "Sign in with Passwordless.ID" here: 5 | 6 | > https://passwordless-id.github.io/demo/ 7 | 8 | 9 | It uses the OAuth2 / OpenID flow using the [@passwordless-id/connect](https://github.com/passwordless-id/connect) library. 10 | 11 | 12 | The code for that looks as follows. 13 | 14 | ```js 15 | import passwordless from 'https://unpkg.com/@passwordless-id/connect@1.2.0/dist/connect.min.js' 16 | 17 | // the information requested from the profile 18 | const scope = 'openid avatar email' 19 | 20 | function onClickSignIn() => { 21 | // performs a redirect to let the user authenticate and/or authorize this app 22 | passwordless.auth({ scope }) 23 | } 24 | 25 | function onClickSignOut = async () => { 26 | // performs a redirect to let the user sign out 27 | passwordless.logout() 28 | } 29 | 30 | async function init() { 31 | // retrieves the user profile and `id_token` if available 32 | const user = await passwordless.id({ scope }) 33 | if (user.signedIn && user.scopeGranted) 34 | showUser(user) 35 | else 36 | showSignIn() 37 | } 38 | init() 39 | ``` 40 | 41 | The retrieved `user` has the following structure. 42 | 43 | ```json 44 | { 45 | "signedIn": true, 46 | "scopeGranted": true, 47 | "id_token": "eyJ0eXAiOiJK...", 48 | "profile": { 49 | "nickname": "Johny", 50 | "picture": "https://ui.passwordless.id/avatars/sam.svg", 51 | "preferred_username": "johndoe", 52 | "...": "...more attributes depending on requested scope" 53 | } 54 | } 55 | ``` 56 | 57 | Once you obtain the user, you can also send the `token_id` to your server API as proof of the user's authenticity. This is a Json Web Token containing a signature that can be verified by common libraries. 58 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 |
32 |