Compare commits
35 Commits
4d6d6d3515
...
renovate/v
Author | SHA1 | Date | |
---|---|---|---|
8dfc4f2694 | |||
b2da9b5dc5 | |||
ff578ab849
|
|||
0cffafcd77 | |||
e88ad47af9 | |||
bf6c3d5cb0
|
|||
2f101bedc3 | |||
30b118a621 | |||
cf359b4950
|
|||
c101fba07c | |||
01778866e0 | |||
2bfa5161ee | |||
ae57282dda | |||
0e022fabef | |||
b0623a3f1b | |||
56afe2688d | |||
66179ba858 | |||
63f82eab07
|
|||
f00adf9276
|
|||
216b4cee80
|
|||
cdc02a601d
|
|||
8bcb479b57
|
|||
b9d5c25137 | |||
e9fb20ad6e
|
|||
d98222cd4a | |||
c6effdfa15
|
|||
f17986fa16 | |||
cc65e7d5ff
|
|||
1f42eaa37c | |||
acbe15ed69
|
|||
4671a5ee51
|
|||
9e7ba84576
|
|||
a8a7b16e9f
|
|||
8684086c74
|
|||
cd0a763c0a
|
18
.woodpecker/.audit.yaml
Normal file
18
.woodpecker/.audit.yaml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
variables:
|
||||||
|
- shared-config: &shared-config
|
||||||
|
image: rg.fr-par.scw.cloud/asr-projects/beau-gosse-du-92/ci-lint-audit:latest
|
||||||
|
pull: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: dependencies
|
||||||
|
<<: *shared-config
|
||||||
|
commands: |
|
||||||
|
cargo deny check
|
||||||
|
# Not ready to block PR on fail
|
||||||
|
failure: ignore
|
||||||
|
|
||||||
|
when:
|
||||||
|
- event: pull_request
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- lint
|
@@ -2,7 +2,6 @@ steps:
|
|||||||
- name: renovate
|
- name: renovate
|
||||||
image: renovate/renovate
|
image: renovate/renovate
|
||||||
pull: true
|
pull: true
|
||||||
settings:
|
|
||||||
commands:
|
commands:
|
||||||
- renovate $${CI_REPO}
|
- renovate $${CI_REPO}
|
||||||
environment:
|
environment:
|
||||||
|
17
.woodpecker/.lint-audit-image.yaml
Normal file
17
.woodpecker/.lint-audit-image.yaml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
steps:
|
||||||
|
dockerize:
|
||||||
|
image: woodpeckerci/plugin-kaniko
|
||||||
|
settings:
|
||||||
|
registry: rg.fr-par.scw.cloud
|
||||||
|
repo: asr-projects/beau-gosse-du-92/ci-lint-audit
|
||||||
|
dockerfile: ./docker/Dockerfile.ci-lint-audit
|
||||||
|
tags: latest
|
||||||
|
auto_tag: false
|
||||||
|
cache: false
|
||||||
|
username: nologin
|
||||||
|
password:
|
||||||
|
from_secret: registry-password
|
||||||
|
|
||||||
|
when:
|
||||||
|
- event: push
|
||||||
|
path: ./docker/Dockerfile.ci-lint-audit
|
45
.woodpecker/.lint.yaml
Normal file
45
.woodpecker/.lint.yaml
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
variables:
|
||||||
|
- shared-config: &shared-config
|
||||||
|
image: rg.fr-par.scw.cloud/asr-projects/beau-gosse-du-92/ci-lint-audit:latest
|
||||||
|
pull: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: format
|
||||||
|
<<: *shared-config
|
||||||
|
commands: |
|
||||||
|
cargo fmt --all --check
|
||||||
|
|
||||||
|
- name: sort derives
|
||||||
|
<<: *shared-config
|
||||||
|
commands: |
|
||||||
|
cargo sort-derives --check
|
||||||
|
|
||||||
|
- name: clippy
|
||||||
|
<<: *shared-config
|
||||||
|
commands: |
|
||||||
|
cargo clippy --all --all-features -- -D warnings
|
||||||
|
# Not ready to block PR on fail
|
||||||
|
failure: ignore
|
||||||
|
|
||||||
|
- name: spellcheck
|
||||||
|
<<: *shared-config
|
||||||
|
commands: |
|
||||||
|
cargo spellcheck
|
||||||
|
|
||||||
|
- name: dependencies
|
||||||
|
<<: *shared-config
|
||||||
|
commands: |
|
||||||
|
cargo udeps
|
||||||
|
|
||||||
|
- name: dockerizable (web)
|
||||||
|
image: woodpeckerci/plugin-kaniko
|
||||||
|
settings:
|
||||||
|
registry: rg.fr-par.scw.cloud
|
||||||
|
repo: asr-projects/beau-gosse-du-92-web
|
||||||
|
username: nologin
|
||||||
|
password:
|
||||||
|
from_secret: registry-password
|
||||||
|
dry-run: true
|
||||||
|
|
||||||
|
when:
|
||||||
|
- event: pull_request
|
@@ -1,44 +0,0 @@
|
|||||||
steps:
|
|
||||||
- name: lint - format
|
|
||||||
image: rust:1.86
|
|
||||||
commands: |
|
|
||||||
rustup component add rustfmt
|
|
||||||
cargo fmt --all --check
|
|
||||||
|
|
||||||
- name: lint - clippy
|
|
||||||
image: rust:latest
|
|
||||||
commands: |
|
|
||||||
apt update && apt install -y libgtk-3-dev libjavascriptcoregtk-4.1-dev libwebkit2gtk-4.1-dev
|
|
||||||
rustup component add clippy
|
|
||||||
cargo clippy --all --all-features -- -D warnings
|
|
||||||
# Not ready to block PR on fail
|
|
||||||
failure: ignore
|
|
||||||
|
|
||||||
- name: lint - dependencies
|
|
||||||
image: rust:latest
|
|
||||||
commands: |
|
|
||||||
cargo install --locked cargo-udeps
|
|
||||||
cargo udeps
|
|
||||||
|
|
||||||
- name: build - web (dockerize)
|
|
||||||
image: woodpeckerci/plugin-kaniko
|
|
||||||
settings:
|
|
||||||
registry: rg.fr-par.scw.cloud
|
|
||||||
repo: asr-projects/beau-gosse-du-92-web
|
|
||||||
username: nologin
|
|
||||||
password:
|
|
||||||
from_secret: registry-password
|
|
||||||
dry-run: true
|
|
||||||
|
|
||||||
- name: audit - dependencies
|
|
||||||
image: rust:1.86
|
|
||||||
commands: |
|
|
||||||
cargo install --locked cargo-deny
|
|
||||||
cargo deny check
|
|
||||||
# Not ready to block PR on fail
|
|
||||||
failure: ignore
|
|
||||||
|
|
||||||
when:
|
|
||||||
- event: pull_request
|
|
||||||
# - event: push
|
|
||||||
# branch: ${CI_REPO_DEFAULT_BRANCH}
|
|
34
Cargo.toml
34
Cargo.toml
@@ -7,10 +7,13 @@ license = "AGPL-3.0-or-later"
|
|||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
|
|
||||||
|
[package.metadata.spellcheck]
|
||||||
|
config = "./spellcheck.toml"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Errors
|
# Errors
|
||||||
anyhow = "1.0.75"
|
anyhow = "1.0.75"
|
||||||
thiserror = "1.0.50"
|
thiserror = "2.0.0"
|
||||||
|
|
||||||
# Async
|
# Async
|
||||||
async-std = "1.12.0"
|
async-std = "1.12.0"
|
||||||
@@ -23,12 +26,12 @@ tokio-stream = "0.1.15"
|
|||||||
# Utils
|
# Utils
|
||||||
base64 = "0.22.0"
|
base64 = "0.22.0"
|
||||||
const_format = "0.2.32"
|
const_format = "0.2.32"
|
||||||
rand = "0.8.5"
|
rand = "0.9.1"
|
||||||
validator = { version = "0.17.0", features = ["derive"] }
|
validator = { version = "0.20.0", features = ["derive"] }
|
||||||
# Http client
|
# Http client
|
||||||
reqwest = "0.11.24"
|
reqwest = "0.12.0"
|
||||||
# Password strength estimation
|
# Password strength estimation
|
||||||
zxcvbn = "2.2.2"
|
zxcvbn = { version = "3.0.0", features = ["ser"] }
|
||||||
# Image processing/conversion
|
# Image processing/conversion
|
||||||
image = "0.25.1"
|
image = "0.25.1"
|
||||||
# Get the application version
|
# Get the application version
|
||||||
@@ -41,13 +44,16 @@ tracing = "0.1.40"
|
|||||||
tracing-forest = "0.1.6"
|
tracing-forest = "0.1.6"
|
||||||
|
|
||||||
# SCSS -> CSS + usage in rust code
|
# SCSS -> CSS + usage in rust code
|
||||||
turf = "0.9.3"
|
turf = "0.10.0"
|
||||||
|
|
||||||
# Dioxus
|
# Dioxus
|
||||||
dioxus-free-icons = { version = "0.9", features = ["ionicons", "font-awesome-solid"] }
|
dioxus-free-icons = { version = "0.9", features = ["ionicons", "font-awesome-solid"] }
|
||||||
modx = "0.1.4"
|
modx = "0.1.4"
|
||||||
|
|
||||||
[target.'cfg(target_family = "wasm")'.dependencies]
|
[target.'cfg(target_family = "wasm")'.dependencies]
|
||||||
|
# Utils
|
||||||
|
getrandom = { version = "0.3.2", features = ["wasm_js"] }
|
||||||
|
|
||||||
# Logging/tracing
|
# Logging/tracing
|
||||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||||
tracing-web = "0.1.3"
|
tracing-web = "0.1.3"
|
||||||
@@ -62,6 +68,7 @@ matrix-sdk = { git = "https://github.com/matrix-org/matrix-rust-sdk.git", rev =
|
|||||||
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
||||||
# Utils
|
# Utils
|
||||||
time = "0.3.36"
|
time = "0.3.36"
|
||||||
|
getrandom = { version = "0.3.2" }
|
||||||
|
|
||||||
# Logging/tracing
|
# Logging/tracing
|
||||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "time"] }
|
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "time"] }
|
||||||
@@ -72,9 +79,24 @@ dioxus = { version = "0.6.3", features = ["desktop"] }
|
|||||||
# Matrix
|
# Matrix
|
||||||
matrix-sdk = { git = "https://github.com/matrix-org/matrix-rust-sdk.git", rev = "fa6066b8", default-features = false, features = ["rustls-tls"] }
|
matrix-sdk = { git = "https://github.com/matrix-org/matrix-rust-sdk.git", rev = "fa6066b8", default-features = false, features = ["rustls-tls"] }
|
||||||
|
|
||||||
|
[target.wasm32-unknown-unknown]
|
||||||
|
rustflags = ['--cfg', 'getrandom_backend="wasm_js"']
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
regex = "1.10.3"
|
regex = "1.10.3"
|
||||||
|
|
||||||
|
[profile]
|
||||||
|
|
||||||
|
[profile.wasm-dev]
|
||||||
|
inherits = "dev"
|
||||||
|
opt-level = 1
|
||||||
|
|
||||||
|
[profile.server-dev]
|
||||||
|
inherits = "dev"
|
||||||
|
|
||||||
|
[profile.android-dev]
|
||||||
|
inherits = "dev"
|
||||||
|
|
||||||
[package.metadata.turf]
|
[package.metadata.turf]
|
||||||
minify = true
|
minify = true
|
||||||
|
|
||||||
|
@@ -9,11 +9,13 @@ WORKDIR /usr/src/beau-gosse-du-92
|
|||||||
|
|
||||||
# git is required by the git-version crate
|
# git is required by the git-version crate
|
||||||
RUN apt update \
|
RUN apt update \
|
||||||
&& apt install -y --no-install-recommends git \
|
&& apt install -y --no-install-recommends git git-lfs \
|
||||||
&& apt clean
|
&& apt clean
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# Workaround waiting for the dioxus 0.7 release (cf. https://github.com/DioxusLabs/dioxus/issues/4238)
|
||||||
|
ENV RUSTFLAGS="--cfg getrandom_backend=\"wasm_js\""
|
||||||
RUN dx build -r --platform web -- -j ${JOBS_NB}
|
RUN dx build -r --platform web -- -j ${JOBS_NB}
|
||||||
|
|
||||||
|
|
||||||
|
12
README.md
12
README.md
@@ -14,8 +14,8 @@ reinvent the wheel. This solution provides:
|
|||||||
- [Open-source protocol](https://spec.matrix.org/v1.9/).
|
- [Open-source protocol](https://spec.matrix.org/v1.9/).
|
||||||
- Features expected for a messaging solution in 2024 (multi-devices management, emojis, integrations, redaction,
|
- Features expected for a messaging solution in 2024 (multi-devices management, emojis, integrations, redaction,
|
||||||
spaces, ...).
|
spaces, ...).
|
||||||
- Multi-platforms clients (Android, iOS and Webclient).
|
- Multi-platforms clients (Android, iOS and web-client).
|
||||||
- SDK available for each platform and a new Rust sdk supporting all the previously listed platforms.
|
- SDK available for each platform and a new Rust SDK supporting all the previously listed platforms.
|
||||||
- Conference stack ([Element Call](https://github.com/element-hq/element-call)).
|
- Conference stack ([Element Call](https://github.com/element-hq/element-call)).
|
||||||
- End-to-end encryption.
|
- End-to-end encryption.
|
||||||
- Federation management.
|
- Federation management.
|
||||||
@@ -28,16 +28,16 @@ API)](https://spec.matrix.org/v1.9/client-server-api/) protocol.
|
|||||||
|
|
||||||
Even if the Rust SDK is still in beta, it seems to be the future one (cf. [Element X - experience the future of
|
Even if the Rust SDK is still in beta, it seems to be the future one (cf. [Element X - experience the future of
|
||||||
Element!](https://element.io/blog/element-x-experience-the-future-of-element/)) and a good choice for someone starting a
|
Element!](https://element.io/blog/element-x-experience-the-future-of-element/)) and a good choice for someone starting a
|
||||||
new client... from my point of vue.
|
new client... from my point of view.
|
||||||
|
|
||||||
The SDK choosen, a Rust (to avoid to use the bindings provided by the matrix-rust-sdk and mostly because I want to
|
The SDK chosen, a Rust (to avoid to use the bindings provided by the matrix-rust-sdk and mostly because I want to
|
||||||
learn Rust) graphical library should be selected. The [Dioxus](https://dioxuslabs.com/) one seems to do the job:
|
learn Rust) graphical library should be selected. The [Dioxus](https://dioxuslabs.com/) one seems to do the job:
|
||||||
|
|
||||||
- React-inspired library for Rust.
|
- React-inspired library for Rust.
|
||||||
- Multi-platforms (use of Webview or WGPU-enabled renderers).
|
- Multi-platforms (use of Web-view or WGPU-enabled renderers).
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
- [ ] Test dioxus-radio.
|
- [ ] Test dioxus-radio.
|
||||||
- [ ] Design system ?
|
- [ ] Design system ?
|
||||||
- [ ] Implement MSN messenger features using Matrix.org sdk...
|
- [ ] Implement MSN messenger features using Matrix.org SDK...
|
||||||
|
8
build.rs
8
build.rs
@@ -124,7 +124,7 @@ fn export_variables(tasks: Vec<Task>) {
|
|||||||
"#[allow(dead_code)]\nmod {} {{\n",
|
"#[allow(dead_code)]\nmod {} {{\n",
|
||||||
task.module_name
|
task.module_name
|
||||||
)) {
|
)) {
|
||||||
println!("{}", err);
|
println!("{err}");
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -143,14 +143,14 @@ fn export_variables(tasks: Vec<Task>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for variable in variables {
|
for variable in variables {
|
||||||
if let Err(err) = dst_file.write_fmt(format_args!(" pub {}\n", variable)) {
|
if let Err(err) = dst_file.write_fmt(format_args!(" pub {variable}\n")) {
|
||||||
println!("{}", err);
|
println!("{err}");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(err) = dst_file.write(b"}\n") {
|
if let Err(err) = dst_file.write(b"}\n") {
|
||||||
println!("{}", err);
|
println!("{err}");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
26
docker/Dockerfile.ci-lint-audit
Normal file
26
docker/Dockerfile.ci-lint-audit
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
FROM rust:1.88 AS builder
|
||||||
|
|
||||||
|
RUN apt update \
|
||||||
|
&& apt install -y --no-install-recommends libclang-dev hunspell \
|
||||||
|
&& apt clean
|
||||||
|
|
||||||
|
RUN rustup default nightly \
|
||||||
|
&& rustup component add rustfmt clippy
|
||||||
|
|
||||||
|
RUN cargo install cargo-binstall
|
||||||
|
|
||||||
|
RUN cargo binstall cargo-sort-derives cargo-spellcheck cargo-udeps cargo-deny
|
||||||
|
|
||||||
|
|
||||||
|
FROM debian:trixie-slim
|
||||||
|
|
||||||
|
RUN apt update \
|
||||||
|
&& apt install -y --no-install-recommends ca-certificates git rustup build-essential \
|
||||||
|
libssl-dev pkg-config libglib2.0-0 libpango-1.0-0 libatk1.0-dev libgdk-pixbuf-2.0-dev \
|
||||||
|
libcairo2-dev libgtk-3-dev libsoup-3.0-dev libwebkit2gtk-4.1-dev \
|
||||||
|
&& apt clean
|
||||||
|
|
||||||
|
COPY --from=builder /usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/ /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/
|
||||||
|
COPY --from=builder /usr/local/cargo/bin /root/.cargo/bin/
|
||||||
|
|
||||||
|
RUN rustup default nightly
|
@@ -220,25 +220,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="module" async>
|
|
||||||
import init from "{base_path}/wasm/beau-gosse-du-92.js";
|
|
||||||
|
|
||||||
// Ensure that everything needed to render preloader has been downloaded
|
|
||||||
// before fetching the wasm bundle.
|
|
||||||
window.onload=function() {
|
|
||||||
init("{base_path}/wasm/beau-gosse-du-92_bg.wasm").then(
|
|
||||||
wasm => {
|
|
||||||
const preloader = document.getElementById("preloader");
|
|
||||||
if (preloader !== undefined) {
|
|
||||||
preloader.style.display = 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wasm.__wbindgen_start == undefined) {
|
|
||||||
wasm.main();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
6
spellcheck.dic
Normal file
6
spellcheck.dic
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
5
|
||||||
|
Dioxus
|
||||||
|
MSN
|
||||||
|
renderers
|
||||||
|
SDK
|
||||||
|
TODO
|
10
spellcheck.toml
Normal file
10
spellcheck.toml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Also take into account developer comments
|
||||||
|
dev_comments = false
|
||||||
|
|
||||||
|
# Skip the README.md file as defined in the cargo manifest
|
||||||
|
skip_readme = false
|
||||||
|
|
||||||
|
[Hunspell]
|
||||||
|
lang = "en_US"
|
||||||
|
search_dirs = [ "." ]
|
||||||
|
extra_dictionaries = [ "./spellcheck.dic" ]
|
@@ -21,7 +21,7 @@ use crate::infrastructure::services::mozaik_builder::create_mozaik;
|
|||||||
|
|
||||||
pub type RoomId = OwnedRoomId;
|
pub type RoomId = OwnedRoomId;
|
||||||
|
|
||||||
#[derive(PartialEq, Clone)]
|
#[derive(Clone, PartialEq)]
|
||||||
pub struct Invitation {
|
pub struct Invitation {
|
||||||
invitee_id: UserId,
|
invitee_id: UserId,
|
||||||
sender_id: UserId,
|
sender_id: UserId,
|
||||||
|
@@ -43,7 +43,7 @@ use super::{
|
|||||||
};
|
};
|
||||||
use crate::utils::oneshot;
|
use crate::utils::oneshot;
|
||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum ClientError {
|
pub enum ClientError {
|
||||||
#[error("Matrix client error: {0}")]
|
#[error("Matrix client error: {0}")]
|
||||||
Matrix(#[from] matrix_sdk::Error),
|
Matrix(#[from] matrix_sdk::Error),
|
||||||
|
@@ -3,7 +3,7 @@ use std::future::Future;
|
|||||||
use std::sync::OnceLock;
|
use std::sync::OnceLock;
|
||||||
use std::{collections::HashMap, future::IntoFuture};
|
use std::{collections::HashMap, future::IntoFuture};
|
||||||
|
|
||||||
use rand::distributions::{Alphanumeric, DistString};
|
use rand::distr::{Alphanumeric, SampleString};
|
||||||
use reqwest::Result as RequestResult;
|
use reqwest::Result as RequestResult;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ cfg_if! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq, Hash)]
|
#[derive(Eq, Hash, PartialEq)]
|
||||||
pub enum AvatarFeeling {
|
pub enum AvatarFeeling {
|
||||||
Ok,
|
Ok,
|
||||||
Warning,
|
Warning,
|
||||||
@@ -124,7 +124,7 @@ async fn fetch_dicebear_svg(
|
|||||||
// TODO: Use configuration file
|
// TODO: Use configuration file
|
||||||
let url = "dicebear.tools.adrien.run";
|
let url = "dicebear.tools.adrien.run";
|
||||||
|
|
||||||
let seed = Alphanumeric.sample_string(&mut rand::thread_rng(), 16);
|
let seed = Alphanumeric.sample_string(&mut rand::rng(), 16);
|
||||||
let type_str = r#type.to_string();
|
let type_str = r#type.to_string();
|
||||||
let url = format!(
|
let url = format!(
|
||||||
"https://{url}/8.x/{type_str}/svg?seed={seed}&randomizeIds=true{}{}",
|
"https://{url}/8.x/{type_str}/svg?seed={seed}&randomizeIds=true{}{}",
|
||||||
|
@@ -214,6 +214,11 @@ input {
|
|||||||
font-family: inherit;
|
font-family: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hide the preloader as soon as the application is loaded and ready to be rendered
|
||||||
|
#preloader {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
#main {
|
#main {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@@ -3,7 +3,7 @@ use dioxus_free_icons::{Icon, IconShape};
|
|||||||
|
|
||||||
turf::style_sheet!("src/ui/components/button.scss");
|
turf::style_sheet!("src/ui/components/button.scss");
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Props)]
|
#[derive(Clone, PartialEq, Props)]
|
||||||
struct _ButtonProps {
|
struct _ButtonProps {
|
||||||
children: Element,
|
children: Element,
|
||||||
#[props(default = false)]
|
#[props(default = false)]
|
||||||
@@ -15,7 +15,7 @@ struct _ButtonProps {
|
|||||||
|
|
||||||
macro_rules! svg_text_icon {
|
macro_rules! svg_text_icon {
|
||||||
($name:ident,$text:literal) => {
|
($name:ident,$text:literal) => {
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
struct $name;
|
struct $name;
|
||||||
impl IconShape for $name {
|
impl IconShape for $name {
|
||||||
fn view_box(&self) -> &str {
|
fn view_box(&self) -> &str {
|
||||||
@@ -67,7 +67,7 @@ macro_rules! svg_text_button {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Props)]
|
#[derive(Clone, PartialEq, Props)]
|
||||||
pub struct ButtonProps {
|
pub struct ButtonProps {
|
||||||
#[props(default = false)]
|
#[props(default = false)]
|
||||||
focus: bool,
|
focus: bool,
|
||||||
|
@@ -87,7 +87,7 @@ const _PYRAMID_VIEWBOX_HEIGHT: i64 = (_PYRAMID_CENTRAL_EDGE_E2_Y + _PYRAMID_STRO
|
|||||||
const _PYRAMID_VIEWBOX_WIDTH: i64 = (_PYRAMID_RIGHT_EDGE_E2_X + _PYRAMID_STROKE_WIDTH) as i64;
|
const _PYRAMID_VIEWBOX_WIDTH: i64 = (_PYRAMID_RIGHT_EDGE_E2_X + _PYRAMID_STROKE_WIDTH) as i64;
|
||||||
const _PYRAMID_VIEWBOX: &str = formatcp!("0 0 {_PYRAMID_VIEWBOX_WIDTH} {_PYRAMID_VIEWBOX_HEIGHT}");
|
const _PYRAMID_VIEWBOX: &str = formatcp!("0 0 {_PYRAMID_VIEWBOX_WIDTH} {_PYRAMID_VIEWBOX_HEIGHT}");
|
||||||
|
|
||||||
#[derive(PartialEq, Clone)]
|
#[derive(Clone, PartialEq)]
|
||||||
struct PyramidShape {
|
struct PyramidShape {
|
||||||
color: String,
|
color: String,
|
||||||
ratio: f64,
|
ratio: f64,
|
||||||
@@ -154,7 +154,7 @@ impl IconShape for PyramidShape {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Props)]
|
#[derive(Clone, PartialEq, Props)]
|
||||||
pub struct PyramidProps {
|
pub struct PyramidProps {
|
||||||
color: Option<String>,
|
color: Option<String>,
|
||||||
#[props(default = 0.5)]
|
#[props(default = 0.5)]
|
||||||
|
@@ -4,7 +4,7 @@ use const_format::formatcp;
|
|||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
use tracing::{debug, error, warn};
|
use tracing::{debug, error, warn};
|
||||||
use validator::{Validate, ValidateArgs, ValidateEmail, ValidationError, ValidationErrors};
|
use validator::{Validate, ValidateArgs, ValidateEmail, ValidationError, ValidationErrors};
|
||||||
use zxcvbn::zxcvbn;
|
use zxcvbn::{zxcvbn, Score};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
domain::model::session::Session,
|
domain::model::session::Session,
|
||||||
@@ -348,14 +348,14 @@ fn validate_id(id: &Option<String>, process: &Process) -> Result<(), ValidationE
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct PasswordValidationResult {
|
struct PasswordValidationResult {
|
||||||
score: u8,
|
score: Score,
|
||||||
rating: f64, // 0 <= rating <= 1
|
rating: f64, // 0 <= rating <= 1
|
||||||
suggestions: Vec<String>,
|
suggestions: Vec<String>,
|
||||||
}
|
}
|
||||||
impl PasswordValidationResult {
|
impl PasswordValidationResult {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
PasswordValidationResult {
|
PasswordValidationResult {
|
||||||
score: 0,
|
score: Score::Zero,
|
||||||
rating: 0.0,
|
rating: 0.0,
|
||||||
suggestions: Vec::<String>::new(),
|
suggestions: Vec::<String>::new(),
|
||||||
}
|
}
|
||||||
@@ -366,9 +366,7 @@ fn compute_password_score(
|
|||||||
password: &str,
|
password: &str,
|
||||||
with_suggestions: Option<bool>,
|
with_suggestions: Option<bool>,
|
||||||
) -> Option<PasswordValidationResult> {
|
) -> Option<PasswordValidationResult> {
|
||||||
let Ok(estimate) = zxcvbn(password, &[]) else {
|
let estimate = zxcvbn(password, &[]);
|
||||||
return None;
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut result = PasswordValidationResult::new();
|
let mut result = PasswordValidationResult::new();
|
||||||
result.score = estimate.score();
|
result.score = estimate.score();
|
||||||
@@ -396,7 +394,7 @@ fn validate_password(password: &Option<String>, process: &Process) -> Result<(),
|
|||||||
if let Some(password) = password {
|
if let Some(password) = password {
|
||||||
if let Some(result) = compute_password_score(password, Some(true)) {
|
if let Some(result) = compute_password_score(password, Some(true)) {
|
||||||
// TODO: To configuration?
|
// TODO: To configuration?
|
||||||
if result.score <= 2 {
|
if [Score::Zero, Score::One, Score::Two].contains(&result.score) {
|
||||||
let mut err = ValidationError::new(TOO_WEAK_PASSWORD_ERROR_NAME);
|
let mut err = ValidationError::new(TOO_WEAK_PASSWORD_ERROR_NAME);
|
||||||
err.add_param(Cow::from("score"), &result.score);
|
err.add_param(Cow::from("score"), &result.score);
|
||||||
err.add_param(Cow::from("rating"), &result.rating);
|
err.add_param(Cow::from("rating"), &result.rating);
|
||||||
|
@@ -15,7 +15,7 @@ use style::{COLOR_CRITICAL_100, COLOR_SUCCESS_100, COLOR_WARNING_100};
|
|||||||
|
|
||||||
turf::style_sheet!("src/ui/components/modal.scss");
|
turf::style_sheet!("src/ui/components/modal.scss");
|
||||||
|
|
||||||
#[derive(Clone, Copy, Eq, PartialEq, Hash)]
|
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
|
||||||
pub enum Severity {
|
pub enum Severity {
|
||||||
Ok,
|
Ok,
|
||||||
Warning,
|
Warning,
|
||||||
@@ -42,7 +42,7 @@ fn avatar_configs() -> &'static HashMap<Severity, AvatarConfig<'static>> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Props, Clone, PartialEq)]
|
#[derive(Clone, PartialEq, Props)]
|
||||||
pub struct ModalProps {
|
pub struct ModalProps {
|
||||||
pub severity: Severity,
|
pub severity: Severity,
|
||||||
#[props(optional)]
|
#[props(optional)]
|
||||||
|
@@ -5,7 +5,7 @@ use crate::ui::components::icons::LogoShape;
|
|||||||
|
|
||||||
turf::style_sheet!("src/ui/components/spinner.scss");
|
turf::style_sheet!("src/ui/components/spinner.scss");
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Props)]
|
#[derive(Clone, PartialEq, Props)]
|
||||||
pub struct SpinnerProps {
|
pub struct SpinnerProps {
|
||||||
#[props(default = true)]
|
#[props(default = true)]
|
||||||
animate: bool,
|
animate: bool,
|
||||||
|
@@ -9,7 +9,7 @@ turf::style_sheet!("src/ui/components/text_input.scss");
|
|||||||
|
|
||||||
pub trait InputPropsData {}
|
pub trait InputPropsData {}
|
||||||
|
|
||||||
#[derive(Props, Clone, PartialEq)]
|
#[derive(Clone, PartialEq, Props)]
|
||||||
pub struct InputProps<D: InputPropsData + 'static + std::cmp::PartialEq + std::clone::Clone> {
|
pub struct InputProps<D: InputPropsData + 'static + std::cmp::PartialEq + std::clone::Clone> {
|
||||||
value: Option<String>,
|
value: Option<String>,
|
||||||
placeholder: Option<String>,
|
placeholder: Option<String>,
|
||||||
@@ -97,7 +97,7 @@ pub fn TextInput(props: InputProps<TextInputState>) -> Element {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Props, Clone, PartialEq)]
|
#[derive(Clone, PartialEq, Props)]
|
||||||
pub struct PasswordInputState {
|
pub struct PasswordInputState {
|
||||||
text_input_state: TextInputState,
|
text_input_state: TextInputState,
|
||||||
#[props(default = 0.0)]
|
#[props(default = 0.0)]
|
||||||
|
Reference in New Issue
Block a user