You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+43-37Lines changed: 43 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,9 +45,9 @@ Try out the login button at the [Federated Test Page](https://authduo.org/federa
45
45
- Customize that second script to handle logins/logouts your way.
46
46
- When the user logs in, the `login` object looks like this:
47
47
```js
48
-
login.name // Kaylim Bojrumaj
49
-
login.thumbprint // "4e77bccf..."
50
-
login.expiry // 1729381451374
48
+
login.name // Cetdok Pizafoaba
49
+
login.thumbprint // "0d196fc3..."
50
+
login.expiry // 1731740481065
51
51
```
52
52
- When the user logs out, `login` is `null`.
53
53
1. **Put this button in your `<body>`:**
@@ -67,10 +67,12 @@ Try out the login button at the [Federated Test Page](https://authduo.org/federa
67
67
```
68
68
1. **Register components and listen for auth changes.** `main.ts`
69
69
```ts
70
-
import {auth, components, register_to_dom} from "@authduo/authduo"
70
+
import {Auth, components, register_to_dom} from "@authduo/authduo"
71
71
72
72
register_to_dom(components)
73
73
74
+
const auth = Auth.get()
75
+
74
76
auth.onChange(login => {
75
77
if (login) console.log("logged in", login)
76
78
else console.log("logged out")
@@ -124,62 +126,66 @@ Try out the login button at the [Federated Test Page](https://authduo.org/federa
124
126
125
127
### Understanding the Authduo flow and tokens
126
128
127
-

129
+

130
+
131
+
- When a user on your app clicks to login, this opens an Authduo.org popup for them to login.
132
+
- The authduo signs some tokens with your user's passport keypair, and sends them back to your application.
133
+
- Your app receives a `Login` object, which has some useful things:
134
+
-`login.proof.token` -- this is a `Proof` token and it's public, so you can send it around anywhere so your user can prove their identity
135
+
-`login.keys.signClaimToken(~)` -- you can use this to sign arbitrary data into a token, which is verifiably signed on behalf of the user's passport
128
136
129
-
- When your user logs in, you receive a *Login* object (a verified *login token*).
130
-
- Don't pass this around, anybody with the login token can impersonate your user.
131
-
- Instead of passing the login token around, you can use the login object to *sign* your own *challenge tokens*.
132
-
- Let's consider an example: you're making a player-hosted multiplayer game.
133
-
- Your user logs in, and you get a *Login* object.
134
-
- You want to send your user's identity to the host of the game, so they can verify it, and nobody can impersonate your user.
135
-
- So you use your *Login* object to sign a fresh *challenge token* containing your user's name and other info.
136
-
- You send this *challenge token* along with your *login.proof.token* to the game host.
137
-
- The game host receives your `challengeToken` and `proofToken`, and now can verify that your challenge was authentically signed on behalf of the user's passport.
137
+
#### Example of signing and verifying claim tokens
0 commit comments