Skip to content

Commit a1540af

Browse files
committed
chore: update README with new nested classes
1 parent 1d012f8 commit a1540af

File tree

1 file changed

+11
-24
lines changed

1 file changed

+11
-24
lines changed

README.md

+11-24
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,6 @@ Find more details about Passkey Flex on our [Passkey Flex Documentation](https:/
5959

6060
## API Reference
6161

62-
### Retrieve App Info
63-
64-
To retrieve information about the app, use the `get_app` method.
65-
66-
```rust
67-
use passage_flex::PassageFlex;
68-
69-
let passage_flex = PassageFlex::new(
70-
std::env::var("PASSAGE_APP_ID").unwrap(),
71-
std::env::var("PASSAGE_API_KEY").unwrap(),
72-
);
73-
74-
let app_info = passage_flex.get_app().await.unwrap();
75-
println!("{}", app_info.auth_origin);
76-
```
77-
7862
### Create a Registration Transaction
7963

8064
To create a transaction to start a user passkey registration, use the `create_register_transaction` method.
@@ -92,6 +76,7 @@ let passkey_display_name =
9276
"the label for the user's passkey that they will see when logging in".to_string();
9377

9478
let transaction = passage_flex
79+
.auth
9580
.create_register_transaction(external_id, passkey_display_name)
9681
.await
9782
.unwrap();
@@ -112,6 +97,7 @@ let passage_flex = PassageFlex::new(
11297
let external_id = "a unique immutable string that represents your user".to_string();
11398

11499
let transaction = passage_flex
100+
.auth
115101
.create_authenticate_transaction(external_id)
116102
.await
117103
.unwrap();
@@ -132,7 +118,7 @@ let passage_flex = PassageFlex::new(
132118
let nonce =
133119
"a unique single-use value received from the client after a passkey ceremony".to_string();
134120

135-
match passage_flex.verify_nonce(nonce).await {
121+
match passage_flex.auth.verify_nonce(nonce).await {
136122
Ok(external_id) => {
137123
// use external_id to do things like generate and send your own auth token
138124
}
@@ -144,7 +130,7 @@ match passage_flex.verify_nonce(nonce).await {
144130

145131
## Retrieve User Info
146132

147-
To retrieve information about a user by their external ID -- which is the unique, immutable ID you supply to associate the Passage user with your user -- use the `get_user` method.
133+
To retrieve information about a user by their external ID -- which is the unique, immutable ID you supply to associate the Passage user with your user -- use the `get` method.
148134

149135
```rust
150136
use passage_flex::PassageFlex;
@@ -158,13 +144,13 @@ let passage_flex = PassageFlex::new(
158144
let external_id = your_user.id;
159145

160146
// get user info
161-
let user_info = passage_flex.get_user(external_id).await.unwrap();
147+
let user_info = passage_flex.user.get_user(external_id).await.unwrap();
162148
println!("{:?}", user_info.webauthn_devices);
163149
```
164150

165151
## Retrieve a user's passkey devices
166152

167-
To retrieve information about a user's passkey devices, use the `get_devices` method.
153+
To retrieve information about a user's passkey devices, use the `list_devices` method.
168154

169155
```rust
170156
use passage_flex::PassageFlex;
@@ -177,8 +163,8 @@ let passage_flex = PassageFlex::new(
177163
// this is the same value used when creating a transaction
178164
let external_id = your_user.id;
179165

180-
// get devices
181-
let passkey_devices = passage_flex.get_devices(external_id).await.unwrap();
166+
// list devices
167+
let passkey_devices = passage_flex.user.list_devices(external_id).await.unwrap();
182168
for device in passkey_devices {
183169
println!("{}", device.usage_count);
184170
}
@@ -201,8 +187,8 @@ let passage_flex = PassageFlex::new(
201187
let external_id = your_user.id;
202188
let last_year = Utc::now().naive_utc().date() - Duration::days(365);
203189

204-
// get devices
205-
let passkey_devices = passage_flex.get_devices(external_id.clone()).await.unwrap();
190+
// list devices
191+
let passkey_devices = passage_flex.user.list_devices(external_id.clone()).await.unwrap();
206192

207193
for device in passkey_devices {
208194
// revoke old devices that haven't been used in the last year
@@ -211,6 +197,7 @@ for device in passkey_devices {
211197

212198
if last_login_at_parsed < last_year {
213199
if let Err(err) = passage_flex
200+
.user
214201
.revoke_device(external_id.clone(), device.id)
215202
.await
216203
{

0 commit comments

Comments
 (0)