Browse Source

Update exports and dependencies

master
NGnius (Graham) 4 weeks ago
parent
commit
582ffffd09
10 changed files with 57 additions and 30 deletions
  1. +13
    -13
      Cargo.toml
  2. +1
    -1
      parsable_macro_derive/Cargo.toml
  3. +25
    -0
      src/cardlife/client_json.rs
  4. +2
    -2
      src/cardlife/live.rs
  5. +2
    -2
      src/cardlife/live_json.rs
  6. +4
    -2
      src/cardlife/mod.rs
  7. +2
    -1
      src/robocraft/account.rs
  8. +3
    -5
      src/robocraft/cubes.rs
  9. +4
    -3
      src/robocraft2/portal.rs
  10. +1
    -1
      src/techblox/gamesave.rs

+ 13
- 13
Cargo.toml View File

@@ -1,6 +1,6 @@
[package]
name = "libfj"
version = "0.7.4"
version = "0.7.5"
authors = ["NGnius (Graham) <ngniusness@gmail.com>"]
edition = "2018"
description = "An unofficial collection of APIs used in FreeJam games and mods"
@@ -16,22 +16,22 @@ exclude = [
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = { version = "^1", features = ["derive"]}
serde_json = "^1"
reqwest = { version = "^0.11", features = ["json", "rustls-tls"], optional = true, default-features=false}
url = "^2.2"
ureq = { version = "^2", features = ["json"], optional = true}
serde = { version = "1", features = ["derive"]}
serde_json = "1"
reqwest = { version = "0.12", features = ["json", "rustls-tls"], optional = true, default-features=false}
url = "2"
ureq = { version = "2", features = ["json"], optional = true}
async-trait = { version = "0.1", optional = true }
base64 = "^0.13"
num_enum = "^0.5"
chrono = {version = "^0.4", optional = true}
base64 = "0.22"
num_enum = "0.5"
chrono = {version = "0.4", optional = true}
highhash = {version = "^0.1", optional = true}
half = {version = "^1.7", optional = true}
half = {version = "2", optional = true}
libfj_parsable_macro_derive = {version = "0.5.3", optional = true}
#libfj_parsable_macro_derive = {path = "./parsable_macro_derive", optional = true}
obj = {version = "^0.10", optional = true}
genmesh = {version = "^0.6", optional = true}
cgmath = {version = "^0.18", optional = true}
obj = {version = "0.10", optional = true}
genmesh = {version = "0.6", optional = true}
cgmath = {version = "0.18", optional = true}

[dev-dependencies]
tokio = { version = "1.4.0", features = ["macros"]}


+ 1
- 1
parsable_macro_derive/Cargo.toml View File

@@ -12,5 +12,5 @@ repository = "https://github.com/NGnius/libfj"
proc-macro = true

[dependencies]
syn = "1.0"
syn = "2.0"
quote = "1.0"

+ 25
- 0
src/cardlife/client_json.rs View File

@@ -0,0 +1,25 @@
use std::path::PathBuf;
use serde::{Deserialize, Serialize};

/// ServerConfig.json format in the root of the game files
#[derive(Deserialize, Serialize, Clone)]
pub struct ServerConfig {
#[serde(rename = "AuthUrl")]
pub auth_url: String,
#[serde(rename = "LobbyUrl")]
pub lobby_url: String,
#[serde(rename = "InventoryUrl")]
pub inventory_url: String,
#[serde(rename = "FallbackAuthUrl")]
pub fallback_auth_url: String,
#[serde(rename = "FallbackLobbyUrl")]
pub fallback_lobby_url: String,
#[serde(rename = "FallbackInventoryUrl")]
pub fallback_inventory_url: String,
#[serde(rename = "GameServerPath")]
pub game_server_path: PathBuf,
#[serde(rename = "GameServerExe")]
pub game_server_exe: PathBuf,
#[serde(rename = "PhotonUrl")]
pub photon_url: String,
}

+ 2
- 2
src/cardlife/live.rs View File

@@ -3,8 +3,8 @@ use url::{Url};

use crate::cardlife::{AuthenticationInfo, AuthenticationPayload, LobbyInfo, LobbyPayload};

const AUTHENTICATION_DOMAIN: &str = "https://live-auth.cardlifegame.com/";
const LOBBY_DOMAIN: &str = "https://live-lobby.cardlifegame.com/";
pub const AUTHENTICATION_DOMAIN: &str = "https://live-auth.cardlifegame.com/";
pub const LOBBY_DOMAIN: &str = "https://live-lobby.cardlifegame.com/";

/// Cardlife live information API
pub struct LiveAPI {


+ 2
- 2
src/cardlife/live_json.rs View File

@@ -1,7 +1,7 @@
use serde::{Deserialize, Serialize};

#[derive(Deserialize, Serialize, Clone)]
pub(crate) struct AuthenticationPayload {
pub struct AuthenticationPayload {
#[serde(rename = "EmailAddress")]
pub email_address: String,
#[serde(rename = "Password")]
@@ -49,7 +49,7 @@ impl std::string::ToString for AuthenticationInfo {
}

#[derive(Deserialize, Serialize, Clone)]
pub(crate) struct LobbyPayload {
pub struct LobbyPayload {
#[serde(rename = "PublicId")]
pub public_id: String,
}


+ 4
- 2
src/cardlife/mod.rs View File

@@ -2,6 +2,8 @@
//! LiveAPI and CLreServer are mostly complete, but some other APIs are missing.

mod client;
mod client_json;
pub use client_json::ServerConfig;

mod server;
mod server_json;
@@ -10,6 +12,6 @@ pub use self::server::{CLreServer};

mod live;
mod live_json;
pub use self::live::{LiveAPI};
pub use self::live::{LiveAPI, AUTHENTICATION_DOMAIN, LOBBY_DOMAIN};
pub use self::live_json::{AuthenticationInfo, LobbyInfo, LiveGameInfo};
pub(crate) use self::live_json::{AuthenticationPayload, LobbyPayload};
pub use self::live_json::{AuthenticationPayload, LobbyPayload};

+ 2
- 1
src/robocraft/account.rs View File

@@ -1,6 +1,7 @@
use serde::{Deserialize, Serialize};
use ureq::{Agent, Error};
use serde_json::{to_string, from_slice};
use base64::Engine;

use crate::robocraft::ITokenProvider;

@@ -101,7 +102,7 @@ impl AuthenticationResponseInfo {
// header is before dot, signature is after dot.
// data is sandwiched in the middle, and it's all we care about
let data = self.token.split(".").collect::<Vec<&str>>()[1];
let data_vec = base64::decode(data).unwrap();
let data_vec = base64::engine::general_purpose::STANDARD.decode(data).unwrap();
from_slice::<AccountInfo>(&data_vec).unwrap()
}
}


+ 3
- 5
src/robocraft/cubes.rs View File

@@ -1,5 +1,5 @@
use base64::{decode_config_buf, STANDARD};
use std::io::Read;
use base64::Engine;

// TODO(maybe) parse iteratively instead of one-shot

@@ -203,10 +203,8 @@ impl std::default::Default for Cube {

impl std::convert::From<crate::robocraft::FactoryRobotGetInfo> for Cubes {
fn from(other: crate::robocraft::FactoryRobotGetInfo) -> Self {
let mut cube_buf = Vec::new();
let mut colour_buf = Vec::new();
decode_config_buf(other.cube_data, STANDARD, &mut cube_buf).unwrap();
decode_config_buf(other.colour_data, STANDARD, &mut colour_buf).unwrap();
let mut cube_buf = base64::engine::general_purpose::STANDARD.decode(other.cube_data).unwrap();
let mut colour_buf = base64::engine::general_purpose::STANDARD.decode(other.colour_data).unwrap();
Self::parse(&mut cube_buf, &mut colour_buf).unwrap()
}
}


+ 4
- 3
src/robocraft2/portal.rs View File

@@ -4,7 +4,8 @@ use reqwest::{Client, Error};
//use cookie_store::CookieStore;
//use url::{Url};
use serde_json::from_slice;
use chrono::{DateTime, naive::NaiveDateTime, Utc};
use chrono::{DateTime, Utc};
use base64::Engine;

const GAME_VERSION: &str = "100.0"; // currently, this accepts any version >= current public release
const GAME_TARGET: &str = "Techblox";
@@ -172,7 +173,7 @@ impl PortalTokenProvider {
impl ITokenProvider for PortalTokenProvider {
async fn token(&mut self) -> Result<String, Error> {
let decoded_jwt = self.jwt.decode_jwt_data();
let expiry = DateTime::<Utc>::from_utc(NaiveDateTime::from_timestamp(decoded_jwt.exp as i64, 0), Utc);
let expiry = DateTime::<Utc>::from_timestamp(decoded_jwt.exp as i64, 0).unwrap();
let now = Utc::now();
if now >= expiry || self.token.token.is_none() {
// refresh token when expired
@@ -255,7 +256,7 @@ impl PortalCheckResponse {
// header is before dot, signature is after dot.
// data is sandwiched in the middle, and it's all we care about
let data = self.token.split(".").collect::<Vec<&str>>()[1];
let data_vec = base64::decode(data).unwrap();
let data_vec = base64::engine::general_purpose::STANDARD.decode(data).unwrap();
from_slice::<AccountInfo>(&data_vec).unwrap()
}
}


+ 1
- 1
src/techblox/gamesave.rs View File

@@ -74,7 +74,7 @@ impl Parsable for GameSave {
let year = parse_u32(data)?; // parsed as i32 in-game for some reason
let month = parse_u32(data)?;
let day = parse_u32(data)?;
let date = NaiveDate::from_ymd(year as i32, month, day);
let date = NaiveDate::from_ymd_opt(year as i32, month, day).unwrap();
let ticks = parse_i64(data)?; // unused
let cube_count = parse_u32(data)?; // parsed as i32 in-game for some reason
let max_e_id = parse_u32(data)?; // unused


Loading…
Cancel
Save