Skip to content

Commit 4999c29

Browse files
committed
chore: update deps
1 parent 892711c commit 4999c29

File tree

4 files changed

+23
-22
lines changed

4 files changed

+23
-22
lines changed

Cargo.toml

+8-6
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@ license = "Apache-2.0 OR MIT"
55
repository = "https://github.com/loopystudios/bevy_key_rotation"
66
authors = ["Spencer C. Imbleau"]
77
keywords = ["gamedev"]
8-
version = "0.2.0"
8+
version = "0.3.0"
99
edition = "2021"
1010

1111
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1212
[dependencies]
1313
web-time = "1.1.0"
14-
thiserror = "1.0.61"
15-
bevy_async_task = "0.2.0"
16-
async-trait = "0.1.79"
17-
bevy = { version = "0.14", default-features = false, features = ["bevy_state"] }
14+
thiserror = "2.0.3"
15+
bevy_async_task = "0.3.0"
16+
async-trait = "0.1.83"
17+
bevy = { version = "0.15.0", default-features = false, features = [
18+
"bevy_state",
19+
] }
1820

1921
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
2022
getrandom = { version = "0.2.15" }
2123

2224
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
23-
wasm-bindgen-test = "0.3.42"
25+
wasm-bindgen-test = "0.3.47"
2426
getrandom = { version = "0.2.15", features = ["js"] }

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ There is full API support for **wasm** and **native**. Android and iOS are untes
1212

1313
|bevy|bevy_key_rotation|
1414
|---|---|
15-
|0.14|0.2, main|
15+
|0.15|0.3, main|
16+
|0.14|0.2|
1617
|0.13|0.1|
1718
|< 0.13|Unsupported|
1819

src/commands.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::{data_types::Keygen, KeyRotationEvent, Keystore, KeystoreState};
22
use bevy::{ecs::world::Command, prelude::*};
3-
use bevy_async_task::AsyncTask;
43

54
struct StartKeyRotation {
65
username: String,
@@ -11,13 +10,13 @@ impl Command for StartKeyRotation {
1110
fn apply(self, world: &mut bevy::prelude::World) {
1211
info!("starting key rotation, authenticating credentials...");
1312
let keygen = world.resource::<Keygen>();
14-
let keystore = AsyncTask::new({
13+
14+
let keystore = bevy::tasks::block_on({
1515
let username = self.username.clone();
1616
let password = self.password.clone();
1717
let auth_provider = keygen.0.clone();
1818
async move { auth_provider.authenticate(username, password).await }
1919
})
20-
.blocking_recv()
2120
.unwrap();
2221
info!("credentials authenticated!");
2322
if keystore.access_token_valid_for() > crate::Duration::ZERO {
@@ -62,10 +61,10 @@ pub trait StartKeyRotationExt {
6261

6362
impl<'w, 's> StartKeyRotationExt for Commands<'w, 's> {
6463
fn start_key_rotation(&mut self, username: String, password: String) {
65-
self.add(StartKeyRotation { username, password })
64+
self.queue(StartKeyRotation { username, password })
6665
}
6766
fn start_key_rotation_with_keystore(&mut self, keystore: Keystore) {
68-
self.add(StartKeyRotationWithKeystore { keystore })
67+
self.queue(StartKeyRotationWithKeystore { keystore })
6968
}
7069
}
7170

@@ -87,6 +86,6 @@ pub trait StopKeyRotationExt {
8786

8887
impl<'w, 's> StopKeyRotationExt for Commands<'w, 's> {
8988
fn stop_key_rotation(&mut self) {
90-
self.add(StopKeyRotation);
89+
self.queue(StopKeyRotation);
9190
}
9291
}

src/systems.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@ use crate::{
44
Duration, KeystoreState,
55
};
66
use bevy::prelude::*;
7-
use bevy_async_task::{AsyncTask, AsyncTaskRunner, AsyncTaskStatus, TimeoutError};
7+
use bevy_async_task::{AsyncTask, AsyncTaskRunner, TaskError};
8+
use std::task::Poll;
89

910
pub(crate) fn rotate_tokens(
1011
keygen: Res<Keygen>,
1112
settings: Res<KeyRotationSettings>,
1213
mut keystore: ResMut<Keystore>,
13-
mut tr_rotate: AsyncTaskRunner<Result<Result<Keystore, TokenRotationError>, TimeoutError>>,
14+
mut tr_rotate: AsyncTaskRunner<Result<Result<Keystore, TokenRotationError>, TaskError>>,
1415
mut event_writer: EventWriter<KeyRotationEvent>,
1516
mut rotation_timer: Local<Option<Timer>>,
1617
time: Res<Time>,
1718
) {
18-
if let AsyncTaskStatus::Finished(resp) = tr_rotate.poll() {
19+
if let Poll::Ready(resp) = tr_rotate.poll() {
1920
match resp {
2021
Ok(Ok(keys)) => {
2122
info!("token rotation successful");
@@ -52,22 +53,20 @@ pub(crate) fn rotate_tokens(
5253

5354
if rtoken_expiring {
5455
info!("rotating refresh token...");
55-
let task = AsyncTask::new({
56+
let task = AsyncTask::new_with_timeout(settings.rotation_timeout, {
5657
let username = keystore.username.clone();
5758
let password = keystore.password.clone();
5859
let auth_provider = keygen.0.clone();
5960
async move { auth_provider.authenticate(username, password).await }
60-
})
61-
.with_timeout(settings.rotation_timeout);
61+
});
6262
tr_rotate.start(task);
6363
} else if atoken_expiring {
6464
info!("rotating access token...");
65-
let task = AsyncTask::new({
65+
let task = AsyncTask::new_with_timeout(settings.rotation_timeout, {
6666
let keystore = (*keystore).clone();
6767
let auth_provider = keygen.0.clone();
6868
async move { auth_provider.refresh(keystore).await }
69-
})
70-
.with_timeout(settings.rotation_timeout);
69+
});
7170
tr_rotate.start(task);
7271
}
7372
}

0 commit comments

Comments
 (0)