mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 18:15:39 +00:00
Compare commits
198 Commits
v0.1.0
...
update-dep
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b624c7d326 | ||
|
|
60a6ad92d9 | ||
|
|
3c0ed48aac | ||
|
|
a05f8ec6f0 | ||
|
|
5c29c2e71e | ||
|
|
721d880a7a | ||
|
|
4ad2fe36cc | ||
|
|
140889ff6d | ||
|
|
324d13f0d4 | ||
|
|
840f14868a | ||
|
|
5c476090d1 | ||
|
|
f1661d0f7f | ||
|
|
6eda1e8a34 | ||
|
|
848c3f80bf | ||
|
|
a66f27c084 | ||
|
|
c886989c25 | ||
|
|
982243aff0 | ||
|
|
31f96081a2 | ||
|
|
8507d130b0 | ||
|
|
355853b5ea | ||
|
|
ca6193241b | ||
|
|
1a73c2d10b | ||
|
|
c0695a8b40 | ||
|
|
4c71f3ae5e | ||
|
|
fb0b9ff71c | ||
|
|
29d4cfff7d | ||
|
|
85466e360c | ||
|
|
df242c8fda | ||
|
|
628166ea15 | ||
|
|
45c7b39c32 | ||
|
|
1b379f47ac | ||
|
|
d54404a493 | ||
|
|
464b25d957 | ||
|
|
9aa5789591 | ||
|
|
e5dd0711ca | ||
|
|
c472cf678b | ||
|
|
adfb887657 | ||
|
|
a4de37c7d2 | ||
|
|
ef1afa1fa9 | ||
|
|
839444834e | ||
|
|
9c20f2d222 | ||
|
|
8c8dd9c1d3 | ||
|
|
624e95f3ec | ||
|
|
5b7e4ba1b6 | ||
|
|
bb18229263 | ||
|
|
1ce1ac3b48 | ||
|
|
a0c9790203 | ||
|
|
e19bcc88ee | ||
|
|
1f7326cacc | ||
|
|
d390bb10a8 | ||
|
|
1f7bcf018f | ||
|
|
ed5885f7bf | ||
|
|
dcc9c4c540 | ||
|
|
a9f97ec423 | ||
|
|
5f556c3c21 | ||
|
|
9a8c9c46f2 | ||
|
|
9b62a7cd13 | ||
|
|
e8b3debfde | ||
|
|
f54cfb42ff | ||
|
|
8f9db61b5f | ||
|
|
adb71c19c0 | ||
|
|
2d26c58dc8 | ||
|
|
c91c265ab2 | ||
|
|
7cdbf18fd1 | ||
|
|
ba601720f4 | ||
|
|
8fe6f8ce13 | ||
|
|
aa3451a1de | ||
|
|
13158c4660 | ||
|
|
81016e6c66 | ||
|
|
a319325f5a | ||
|
|
af78594b75 | ||
|
|
e87681086d | ||
|
|
bf82127d58 | ||
|
|
a63ac30afd | ||
|
|
210e08dbec | ||
|
|
dba69111bf | ||
|
|
dc746388c6 | ||
|
|
53fd774a3f | ||
|
|
3f8a4cacd2 | ||
|
|
acd6eebcfe | ||
|
|
adef372720 | ||
|
|
4b025a94c8 | ||
|
|
d38fd374f4 | ||
|
|
6ee914e797 | ||
|
|
37799184bf | ||
|
|
e5690ff4ea | ||
|
|
9662d03450 | ||
|
|
151aba467a | ||
|
|
d010eb000d | ||
|
|
69fc6c0d90 | ||
|
|
fa6493ec43 | ||
|
|
e849ae43e7 | ||
|
|
9fa1c45492 | ||
|
|
76ba9ded00 | ||
|
|
403a47856e | ||
|
|
d352bc691d | ||
|
|
127c61b455 | ||
|
|
16da3d258f | ||
|
|
4c5401941c | ||
|
|
80f9748aa7 | ||
|
|
44efdd3541 | ||
|
|
1dcad0d507 | ||
|
|
7f6a703556 | ||
|
|
f8da5ca3bf | ||
|
|
7c643e013e | ||
|
|
be4c7779fa | ||
|
|
a9e11a8c56 | ||
|
|
567a8c6b60 | ||
|
|
5da73093c4 | ||
|
|
0d37495a61 | ||
|
|
c7a30fe62e | ||
|
|
26f23f6700 | ||
|
|
b851bdb2b0 | ||
|
|
83c90c78e2 | ||
|
|
9768998926 | ||
|
|
78186f13e6 | ||
|
|
5500483e1b | ||
|
|
0a82a62adc | ||
|
|
fac6c92812 | ||
|
|
3fea35b481 | ||
|
|
7d564973b7 | ||
|
|
718d8d4c37 | ||
|
|
b8143fb634 | ||
|
|
9ca6992e16 | ||
|
|
cfd88cd20b | ||
|
|
4f28931875 | ||
|
|
3f3fd3ce83 | ||
|
|
26c83e1af1 | ||
|
|
8ea48c6f2a | ||
|
|
6f9489403a | ||
|
|
1effdc5a18 | ||
|
|
8bfa53cc4f | ||
|
|
4046d389ac | ||
|
|
09d2ab4e75 | ||
|
|
20dbcb5b8f | ||
|
|
2a71dfe459 | ||
|
|
047a0d1e2c | ||
|
|
7584d2a574 | ||
|
|
beb3d8a8e2 | ||
|
|
d59ce15043 | ||
|
|
d350f8d2a9 | ||
|
|
f02a79637f | ||
|
|
ce0eb26422 | ||
|
|
1ee5f01444 | ||
|
|
0ab3599c63 | ||
|
|
4278335fdd | ||
|
|
ef5e2fee27 | ||
|
|
795d29bcb0 | ||
|
|
b5766622fb | ||
|
|
ab679e71d2 | ||
|
|
ac9aecdb95 | ||
|
|
22bd14056c | ||
|
|
8810931d10 | ||
|
|
e11d71a5fa | ||
|
|
d9509cc4ce | ||
|
|
0c2915f334 | ||
|
|
71fc1b4d46 | ||
|
|
36dc200193 | ||
|
|
589b476e43 | ||
|
|
43da103f34 | ||
|
|
c0899265c2 | ||
|
|
c827208144 | ||
|
|
58e2dcb9d4 | ||
|
|
a0c89d0e59 | ||
|
|
86a12c5c6a | ||
|
|
30fa1bb165 | ||
|
|
4606da212d | ||
|
|
8d6de7ed5a | ||
|
|
2ae9c51da3 | ||
|
|
2b6f039dd4 | ||
|
|
eb65259bc1 | ||
|
|
3fdf215459 | ||
|
|
ef8e07c44b | ||
|
|
bacdbdc9e8 | ||
|
|
d9cf53d399 | ||
|
|
d619092598 | ||
|
|
54ed53e03d | ||
|
|
6bd8cfb711 | ||
|
|
ef652541ee | ||
|
|
474437c360 | ||
|
|
1956e97503 | ||
|
|
a5d4dad508 | ||
|
|
afb281c93a | ||
|
|
182635bad1 | ||
|
|
9922c23322 | ||
|
|
2a92e8f672 | ||
|
|
581e6f9440 | ||
|
|
3a7e71b499 | ||
|
|
91955501e2 | ||
|
|
cb72b0adfa | ||
|
|
c1fe45d409 | ||
|
|
59e339f287 | ||
|
|
ddcde9cf18 | ||
|
|
65c92ee96e | ||
|
|
40766ff44f | ||
|
|
ddc3008009 | ||
|
|
cba056aba6 | ||
|
|
16c975d2ec |
@@ -13,7 +13,7 @@ MCAPTCHA_redis_URL=redis://mcaptcha_redis
|
|||||||
MCAPTCHA_redis_POOL=4
|
MCAPTCHA_redis_POOL=4
|
||||||
|
|
||||||
# server
|
# server
|
||||||
PORT=7001
|
PORT=7000
|
||||||
MCAPTCHA_server_DOMAIN=localhost
|
MCAPTCHA_server_DOMAIN=localhost
|
||||||
MCAPTCHA__server_COOKIE_SECRET=pleasereplacethiswithrandomstring # PLEASE SET RANDOM STRING. MIN LENGTH=32
|
MCAPTCHA__server_COOKIE_SECRET=pleasereplacethiswithrandomstring # PLEASE SET RANDOM STRING. MIN LENGTH=32
|
||||||
MCAPTCHA__server_IP= 0.0.0.0
|
MCAPTCHA__server_IP= 0.0.0.0
|
||||||
@@ -26,8 +26,8 @@ MCAPTCHA_captcha_RUNNERS=4
|
|||||||
MCAPTCHA_captcha_QUEUE_LENGTH=2000
|
MCAPTCHA_captcha_QUEUE_LENGTH=2000
|
||||||
MCAPTCHA_captcha_ENABLE_STATS=true
|
MCAPTCHA_captcha_ENABLE_STATS=true
|
||||||
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_avg_traffic_difficulty=50000 # almost instant solution
|
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_avg_traffic_difficulty=50000 # almost instant solution
|
||||||
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_broke_my_site_traffic_difficulty=3000000 # roughly 1.5s
|
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_peak_sustainable_traffic_difficulty=3000000 # greater than 3.5s
|
||||||
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_peak_sustainable_traffic_difficulty=5000000 # greater than 3.5s
|
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_broke_my_site_traffic_difficulty=5000000 # roughly 1.5s
|
||||||
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_duration=30 # cooldown period in seconds
|
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_duration=30 # cooldown period in seconds
|
||||||
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_avg_traffic_time=1 # almost instant solution
|
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_avg_traffic_time=1 # almost instant solution
|
||||||
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_peak_sustainable_traffic_time=3
|
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_peak_sustainable_traffic_time=3
|
||||||
|
|||||||
2
.github/workflows/linux.yml
vendored
2
.github/workflows/linux.yml
vendored
@@ -84,7 +84,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: actions/setup-node@v2
|
- uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: "20.0.0"
|
node-version: "22"
|
||||||
|
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
|
||||||
|
|||||||
29
.woodpecker.yaml
Normal file
29
.woodpecker.yaml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
steps:
|
||||||
|
frontend:
|
||||||
|
image: node:22
|
||||||
|
commands:
|
||||||
|
- make frontend
|
||||||
|
when:
|
||||||
|
- event: [pull_request, push]
|
||||||
|
- branch:
|
||||||
|
include: [woodpecker-pipeline]
|
||||||
|
exclude:
|
||||||
|
- renovate/\*
|
||||||
|
volumes:
|
||||||
|
- /var/lib/woodpercker-cache/mcaptcha/yarn:/root/.cache/yarn
|
||||||
|
|
||||||
|
backend:
|
||||||
|
image: rust:latest
|
||||||
|
when:
|
||||||
|
- event: [pull_request, push]
|
||||||
|
- branch:
|
||||||
|
include: [woodpecker-pipeline]
|
||||||
|
exclude:
|
||||||
|
- renovate/\*
|
||||||
|
commands:
|
||||||
|
- cargo --version
|
||||||
|
- make cache-bust
|
||||||
|
- cargo build --release
|
||||||
|
volumes:
|
||||||
|
- /var/lib/woodpercker-cache/mcaptcha/cargo:/root/.cargo
|
||||||
|
- /var/lib/woodpercker-cache/mcaptcha/target:/woodpecker/src/git.batsense.net/mCaptcha/mCaptcha/target
|
||||||
2962
Cargo.lock
generated
2962
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
22
Cargo.toml
22
Cargo.toml
@@ -28,23 +28,23 @@ actix = "0.13"
|
|||||||
actix-identity = "0.4.0"
|
actix-identity = "0.4.0"
|
||||||
actix-http = "3.0.4"
|
actix-http = "3.0.4"
|
||||||
actix-rt = "2"
|
actix-rt = "2"
|
||||||
actix-cors = "0.6.1"
|
actix-cors = "0.7.0"
|
||||||
actix-service = "2.0.0"
|
actix-service = "2.0.0"
|
||||||
async-trait = "0.1.51"
|
async-trait = "0.1.51"
|
||||||
mime_guess = "2.0.3"
|
mime_guess = "2.0.3"
|
||||||
rust-embed = "6.4.0"
|
rust-embed = "8.0.0"
|
||||||
libcachebust = "0.3.0"
|
libcachebust = "0.3.0"
|
||||||
|
|
||||||
futures = "0.3.15"
|
futures = "0.3.15"
|
||||||
tokio = { version = "1.14", features = ["sync"]}
|
tokio = { version = "1.14", features = ["sync"]}
|
||||||
|
|
||||||
sqlx = { version = "0.7", features = [ "runtime-tokio-rustls", "postgres", "time", "mysql"] }
|
sqlx = { version = "0.8", features = [ "runtime-tokio-rustls", "postgres", "time", "mysql"] }
|
||||||
argon2-creds = { branch = "master", git = "https://github.com/realaravinth/argon2-creds"}
|
argon2-creds = { branch = "master", git = "https://github.com/realaravinth/argon2-creds"}
|
||||||
#argon2-creds = { version="*", path = "../../argon2-creds/" }
|
#argon2-creds = { version="*", path = "../../argon2-creds/" }
|
||||||
config = "0.13"
|
config = "0.15"
|
||||||
validator = { version = "0.15", features = ["derive"]}
|
validator = { version = "0.20", features = ["derive"]}
|
||||||
|
|
||||||
derive_builder = "0.11"
|
derive_builder = "0.20"
|
||||||
derive_more = "0.99"
|
derive_more = "0.99"
|
||||||
|
|
||||||
serde = "1"
|
serde = "1"
|
||||||
@@ -53,7 +53,7 @@ serde_json = "1"
|
|||||||
url = "2.2"
|
url = "2.2"
|
||||||
urlencoding = "2.1.0"
|
urlencoding = "2.1.0"
|
||||||
|
|
||||||
pretty_env_logger = "0.4"
|
pretty_env_logger = "0.5"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
@@ -69,7 +69,7 @@ mime = "0.3.16"
|
|||||||
|
|
||||||
num_cpus = "1.13.1"
|
num_cpus = "1.13.1"
|
||||||
|
|
||||||
lettre = { version = "0.10.0-rc.3", features = [
|
lettre = { version = "0.11.0", features = [
|
||||||
"builder",
|
"builder",
|
||||||
"tokio1",
|
"tokio1",
|
||||||
"tokio1-native-tls",
|
"tokio1-native-tls",
|
||||||
@@ -78,7 +78,7 @@ lettre = { version = "0.10.0-rc.3", features = [
|
|||||||
|
|
||||||
openssl = { version = "0.10.48", features = ["vendored"] }
|
openssl = { version = "0.10.48", features = ["vendored"] }
|
||||||
uuid = { version = "1.4.0", features = ["v4", "serde"] }
|
uuid = { version = "1.4.0", features = ["v4", "serde"] }
|
||||||
reqwest = { version = "0.11.18", features = ["json", "gzip"] }
|
reqwest = { version = "0.12.0", features = ["json", "gzip"] }
|
||||||
|
|
||||||
|
|
||||||
[dependencies.db-core]
|
[dependencies.db-core]
|
||||||
@@ -101,10 +101,10 @@ features = ["actix_identity_backend"]
|
|||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
sqlx = { version = "0.7", features = [ "runtime-tokio-rustls", "postgres", "time", "mysql" ] }
|
sqlx = { version = "0.8", features = [ "runtime-tokio-rustls", "postgres", "time", "mysql" ] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
mcaptcha_pow_sha256 = "0.4"
|
mcaptcha_pow_sha256 = "0.5"
|
||||||
awc = "3.0.0"
|
awc = "3.0.0"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
# SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
FROM node:20 as frontend
|
FROM node:22 as frontend
|
||||||
RUN set -ex; \
|
RUN set -ex; \
|
||||||
apt-get update; \
|
apt-get update; \
|
||||||
DEBIAN_FRONTEND=noninteractive \
|
DEBIAN_FRONTEND=noninteractive \
|
||||||
@@ -29,8 +29,12 @@ RUN cargo --version
|
|||||||
RUN make cache-bust
|
RUN make cache-bust
|
||||||
RUN cargo build --release
|
RUN cargo build --release
|
||||||
|
|
||||||
FROM debian:bookworm as mCaptcha
|
FROM debian:trixie as mCaptcha
|
||||||
LABEL org.opencontainers.image.source https://github.com/mCaptcha/mCaptcha
|
LABEL org.opencontainers.image.source https://github.com/mCaptcha/mCaptcha
|
||||||
|
RUN set -ex; \
|
||||||
|
apt-get update; \
|
||||||
|
DEBIAN_FRONTEND=noninteractive \
|
||||||
|
apt-get install -y --no-install-recommends curl
|
||||||
RUN useradd -ms /bin/bash -u 1001 mcaptcha
|
RUN useradd -ms /bin/bash -u 1001 mcaptcha
|
||||||
WORKDIR /home/mcaptcha
|
WORKDIR /home/mcaptcha
|
||||||
COPY --from=rust /src/target/release/mcaptcha /usr/local/bin/
|
COPY --from=rust /src/target/release/mcaptcha /usr/local/bin/
|
||||||
|
|||||||
@@ -34,11 +34,11 @@ enable_stats = true
|
|||||||
|
|
||||||
[captcha.default_difficulty_strategy]
|
[captcha.default_difficulty_strategy]
|
||||||
avg_traffic_difficulty = 50000 # almost instant solution
|
avg_traffic_difficulty = 50000 # almost instant solution
|
||||||
#avg_traffic_time = 1 # almost instant solution
|
avg_traffic_time = 1 # almost instant solution
|
||||||
peak_sustainable_traffic_difficulty = 3000000 # roughly 1.5s
|
peak_sustainable_traffic_difficulty = 3000000 # roughly 1.5s
|
||||||
#peak_sustainable_traffic_time = 3
|
peak_sustainable_traffic_time = 3
|
||||||
broke_my_site_traffic_difficulty = 5000000 # greater than 3.5s
|
broke_my_site_traffic_difficulty = 5000000 # greater than 3.5s
|
||||||
#broke_my_site_traffic_time = 5
|
broke_my_site_traffic_time = 5
|
||||||
duration = 30 # cooldown period in seconds
|
duration = 30 # cooldown period in seconds
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ authors = ["realaravinth <realaravinth@batsense.net>"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-trait = "0.1.51"
|
async-trait = "0.1.51"
|
||||||
thiserror = "1.0.30"
|
thiserror = "2.0.0"
|
||||||
serde = { version = "1", features = ["derive"]}
|
serde = { version = "1", features = ["derive"]}
|
||||||
url = { version = "2.2.2", features = ["serde"] }
|
url = { version = "2.2.2", features = ["serde"] }
|
||||||
libmcaptcha = "0.2.4"
|
libmcaptcha = "0.2.4"
|
||||||
|
|||||||
@@ -10,4 +10,4 @@ authors = ["realaravinth <realaravinth@batsense.net>"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-rt = "2"
|
actix-rt = "2"
|
||||||
sqlx = { version = "0.7", features = [ "runtime-tokio-rustls", "postgres", "time", "mysql" ] }
|
sqlx = { version = "0.8", features = [ "runtime-tokio-rustls", "postgres", "time", "mysql" ] }
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use std::env;
|
|||||||
use sqlx::postgres::PgPoolOptions;
|
use sqlx::postgres::PgPoolOptions;
|
||||||
use sqlx::mysql::MySqlPoolOptions;
|
use sqlx::mysql::MySqlPoolOptions;
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
#[actix_rt::main]
|
#[actix_rt::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
//TODO featuregate sqlite and postgres
|
//TODO featuregate sqlite and postgres
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ authors = ["realaravinth <realaravinth@batsense.net>"]
|
|||||||
async-trait = "0.1.51"
|
async-trait = "0.1.51"
|
||||||
db-core = {path = "../db-core"}
|
db-core = {path = "../db-core"}
|
||||||
futures = "0.3.15"
|
futures = "0.3.15"
|
||||||
sqlx = { version = "0.7", features = [ "runtime-tokio-rustls", "mysql", "time"] }
|
sqlx = { version = "0.8", features = [ "runtime-tokio-rustls", "mysql", "time"] }
|
||||||
uuid = { version = "1.4.0", features = ["v4", "serde"] }
|
uuid = { version = "1.4.0", features = ["v4", "serde"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-rt = "2"
|
actix-rt = "2"
|
||||||
sqlx = { version = "0.7", features = [ "runtime-tokio-rustls", "mysql", "time" ] }
|
sqlx = { version = "0.8", features = [ "runtime-tokio-rustls", "mysql", "time" ] }
|
||||||
db-core = {path = "../db-core", features = ["test"]}
|
db-core = {path = "../db-core", features = ["test"]}
|
||||||
url = { version = "2.2.2", features = ["serde"] }
|
url = { version = "2.2.2", features = ["serde"] }
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ authors = ["realaravinth <realaravinth@batsense.net>"]
|
|||||||
async-trait = "0.1.51"
|
async-trait = "0.1.51"
|
||||||
db-core = {path = "../db-core"}
|
db-core = {path = "../db-core"}
|
||||||
futures = "0.3.15"
|
futures = "0.3.15"
|
||||||
sqlx = { version = "0.7", features = [ "runtime-tokio-rustls", "postgres", "time" ] }
|
sqlx = { version = "0.8", features = [ "runtime-tokio-rustls", "postgres", "time" ] }
|
||||||
uuid = { version = "1.4.0", features = ["v4", "serde"] }
|
uuid = { version = "1.4.0", features = ["v4", "serde"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-rt = "2"
|
actix-rt = "2"
|
||||||
sqlx = { version = "0.7", features = [ "runtime-tokio-rustls", "postgres", "time"] }
|
sqlx = { version = "0.8", features = [ "runtime-tokio-rustls", "postgres", "time"] }
|
||||||
db-core = {path = "../db-core", features = ["test"]}
|
db-core = {path = "../db-core", features = ["test"]}
|
||||||
url = { version = "2.2.2", features = ["serde"] }
|
url = { version = "2.2.2", features = ["serde"] }
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ services:
|
|||||||
- mcaptcha_redis
|
- mcaptcha_redis
|
||||||
|
|
||||||
mcaptcha_postgres:
|
mcaptcha_postgres:
|
||||||
image: postgres:13.2
|
image: postgres:18.0
|
||||||
volumes:
|
volumes:
|
||||||
- mcaptcha-data:/var/lib/postgresql/
|
- mcaptcha-data:/var/lib/postgresql/
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
2357
docs/openapi/package-lock.json
generated
2357
docs/openapi/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -17,6 +17,6 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/mCaptcha/mCaptcha#readme",
|
"homepage": "https://github.com/mCaptcha/mCaptcha#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@redocly/cli": "^1.4.0"
|
"@redocly/cli": "^2.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
46
eslint.config.js
Normal file
46
eslint.config.js
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
const {
|
||||||
|
defineConfig,
|
||||||
|
} = require("eslint/config");
|
||||||
|
|
||||||
|
const globals = require("globals");
|
||||||
|
const tsParser = require("@typescript-eslint/parser");
|
||||||
|
const typescriptEslint = require("@typescript-eslint/eslint-plugin");
|
||||||
|
const js = require("@eslint/js");
|
||||||
|
|
||||||
|
const {
|
||||||
|
FlatCompat,
|
||||||
|
} = require("@eslint/eslintrc");
|
||||||
|
|
||||||
|
const compat = new FlatCompat({
|
||||||
|
baseDirectory: __dirname,
|
||||||
|
recommendedConfig: js.configs.recommended,
|
||||||
|
allConfig: js.configs.all
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = defineConfig([{
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.browser,
|
||||||
|
},
|
||||||
|
|
||||||
|
parser: tsParser,
|
||||||
|
ecmaVersion: 12,
|
||||||
|
sourceType: "module",
|
||||||
|
parserOptions: {},
|
||||||
|
},
|
||||||
|
|
||||||
|
extends: compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"),
|
||||||
|
|
||||||
|
plugins: {
|
||||||
|
"@typescript-eslint": typescriptEslint,
|
||||||
|
},
|
||||||
|
|
||||||
|
rules: {
|
||||||
|
"@typescript-eslint/no-explicit-any": "off",
|
||||||
|
"@typescript-eslint/ban-types": "off",
|
||||||
|
indent: ["error", 2],
|
||||||
|
"linebreak-style": ["error", "unix"],
|
||||||
|
quotes: ["error", "double"],
|
||||||
|
semi: ["error", "always"],
|
||||||
|
},
|
||||||
|
}]);
|
||||||
19958
package-lock.json
generated
19958
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
41
package.json
41
package.json
@@ -2,7 +2,7 @@
|
|||||||
"name": "vanilla",
|
"name": "vanilla",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0-or-later",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack --mode production",
|
"build": "webpack --mode production",
|
||||||
"lint": "yarn run eslint templates",
|
"lint": "yarn run eslint templates",
|
||||||
@@ -10,35 +10,38 @@
|
|||||||
"test": "jest"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.5.6",
|
"@eslint/eslintrc": "^3.3.1",
|
||||||
"@types/jsdom": "^21.1.4",
|
"@eslint/js": "^9.36.0",
|
||||||
"@types/node": "^20.8.9",
|
"@types/jest": "^30.0.0",
|
||||||
"@types/sinon": "^10.0.20",
|
"@types/jsdom": "^27.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^6.9.0",
|
"@types/node": "^22.0.0",
|
||||||
"@typescript-eslint/parser": "^6.9.0",
|
"@types/sinon": "^17.0.0",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
||||||
|
"@typescript-eslint/parser": "^8.0.0",
|
||||||
"@wasm-tool/wasm-pack-plugin": "^1.7.0",
|
"@wasm-tool/wasm-pack-plugin": "^1.7.0",
|
||||||
"css-loader": "^6.8.1",
|
"css-loader": "^7.0.0",
|
||||||
"css-minimizer-webpack-plugin": "^5.0.1",
|
"css-minimizer-webpack-plugin": "^7.0.0",
|
||||||
"eslint": "^8.52.0",
|
"eslint": "^9.0.0",
|
||||||
"jest": "^29.7.0",
|
"globals": "^16.4.0",
|
||||||
"jest-environment-jsdom": "^29.7.0",
|
"jest": "^30.0.0",
|
||||||
|
"jest-environment-jsdom": "^30.0.0",
|
||||||
"jest-fetch-mock": "^3.0.3",
|
"jest-fetch-mock": "^3.0.3",
|
||||||
"jsdom": "^22.1.0",
|
"jsdom": "^27.0.0",
|
||||||
"mini-css-extract-plugin": "^2.7.6",
|
"mini-css-extract-plugin": "^2.7.6",
|
||||||
"sass": "^1.69.5",
|
"sass": "^1.69.5",
|
||||||
"sass-loader": "^13.3.2",
|
"sass-loader": "^16.0.0",
|
||||||
"sinon": "^17.0.0",
|
"sinon": "^21.0.0",
|
||||||
"ts-jest": "^29.1.1",
|
"ts-jest": "^29.1.1",
|
||||||
"ts-loader": "^9.5.0",
|
"ts-loader": "^9.5.0",
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
"typescript": "^5.2.2",
|
"typescript": "^5.2.2",
|
||||||
"webpack": "^5.89.0",
|
"webpack": "^5.89.0",
|
||||||
"webpack-cli": "^5.1.4",
|
"webpack-cli": "^6.0.0",
|
||||||
"webpack-dev-server": "^4.15.1"
|
"webpack-dev-server": "^5.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mcaptcha/pow_sha256-polyfill": "^0.1.0-rc2",
|
"@mcaptcha/pow_sha256-polyfill": "^0.1.0-rc2",
|
||||||
"@mcaptcha/vanilla-glue": "^0.1.0-rc1",
|
"@mcaptcha/pow-wasm": "^0.1.0-rc2",
|
||||||
"@mcaptcha/pow-wasm": "^0.1.0-rc2"
|
"@mcaptcha/vanilla-glue": "^0.1.0-rc1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
21
renovate.json
Normal file
21
renovate.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
|
"extends": [
|
||||||
|
"config:recommended",
|
||||||
|
":dependencyDashboard"
|
||||||
|
],
|
||||||
|
"labels": [
|
||||||
|
"renovate-bot"
|
||||||
|
],
|
||||||
|
"prHourlyLimit": 0,
|
||||||
|
"timezone": "Asia/kolkata",
|
||||||
|
"prCreation": "immediate",
|
||||||
|
"vulnerabilityAlerts": {
|
||||||
|
"enabled": true,
|
||||||
|
"labels": [
|
||||||
|
"renovate-bot",
|
||||||
|
"renovate-security",
|
||||||
|
"security"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,8 +22,8 @@ is_ci(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
docker-compose down -v --remove-orphans || true
|
docker compose down -v --remove-orphans || true
|
||||||
docker-compose up -d
|
docker compose up -d
|
||||||
cd $(mktemp -d)
|
cd $(mktemp -d)
|
||||||
pwd
|
pwd
|
||||||
find
|
find
|
||||||
@@ -40,4 +40,4 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
cd $PROJECT_ROOT
|
cd $PROJECT_ROOT
|
||||||
docker-compose down -v --remove-orphans || true
|
docker compose down -v --remove-orphans || true
|
||||||
|
|||||||
@@ -188,7 +188,6 @@ impl Data {
|
|||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
/// create new instance of app data
|
/// create new instance of app data
|
||||||
pub async fn new(s: &Settings, survey_secrets: SecretsStore) -> Arc<Self> {
|
pub async fn new(s: &Settings, survey_secrets: SecretsStore) -> Arc<Self> {
|
||||||
let creds = Self::get_creds();
|
let creds = Self::get_creds();
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ impl UpdateEasyCaptcha {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut patterns = data.db.get_all_easy_captchas(limit, offset).await?;
|
let mut patterns = data.db.get_all_easy_captchas(limit, offset).await?;
|
||||||
|
if patterns.is_empty() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
for pattern in patterns.drain(0..) {
|
for pattern in patterns.drain(0..) {
|
||||||
if !Self::can_run(rx) {
|
if !Self::can_run(rx) {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@@ -85,6 +88,7 @@ impl UpdateEasyCaptcha {
|
|||||||
}
|
}
|
||||||
page += 1;
|
page += 1;
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn can_run(rx: &mut Receiver<()>) -> bool {
|
fn can_run(rx: &mut Receiver<()>) -> bool {
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ impl std::cmp::PartialEq for SmtpErrorWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Display, PartialEq, Error)]
|
#[derive(Debug, Display, PartialEq, Error)]
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
pub enum ServiceError {
|
pub enum ServiceError {
|
||||||
#[display(fmt = "internal server error")]
|
#[display(fmt = "internal server error")]
|
||||||
InternalServerError,
|
InternalServerError,
|
||||||
@@ -114,14 +113,11 @@ pub enum ServiceError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
pub struct ErrorToResponse {
|
pub struct ErrorToResponse {
|
||||||
pub error: String,
|
pub error: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
impl ResponseError for ServiceError {
|
impl ResponseError for ServiceError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn error_response(&self) -> HttpResponse {
|
fn error_response(&self) -> HttpResponse {
|
||||||
HttpResponseBuilder::new(self.status_code())
|
HttpResponseBuilder::new(self.status_code())
|
||||||
.append_header((header::CONTENT_TYPE, "application/json; charset=UTF-8"))
|
.append_header((header::CONTENT_TYPE, "application/json; charset=UTF-8"))
|
||||||
@@ -133,7 +129,6 @@ impl ResponseError for ServiceError {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn status_code(&self) -> StatusCode {
|
fn status_code(&self) -> StatusCode {
|
||||||
match self {
|
match self {
|
||||||
ServiceError::ClosedForRegistration => StatusCode::FORBIDDEN,
|
ServiceError::ClosedForRegistration => StatusCode::FORBIDDEN,
|
||||||
@@ -177,7 +172,6 @@ impl ResponseError for ServiceError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl From<CredsError> for ServiceError {
|
impl From<CredsError> for ServiceError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn from(e: CredsError) -> ServiceError {
|
fn from(e: CredsError) -> ServiceError {
|
||||||
match e {
|
match e {
|
||||||
CredsError::UsernameCaseMappedError => ServiceError::UsernameCaseMappedError,
|
CredsError::UsernameCaseMappedError => ServiceError::UsernameCaseMappedError,
|
||||||
@@ -192,7 +186,6 @@ impl From<CredsError> for ServiceError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl From<DBError> for ServiceError {
|
impl From<DBError> for ServiceError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn from(e: DBError) -> ServiceError {
|
fn from(e: DBError) -> ServiceError {
|
||||||
println!("from conversin: {}", e);
|
println!("from conversin: {}", e);
|
||||||
match e {
|
match e {
|
||||||
@@ -208,57 +201,46 @@ impl From<DBError> for ServiceError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl From<ValidationErrors> for ServiceError {
|
impl From<ValidationErrors> for ServiceError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn from(_: ValidationErrors) -> ServiceError {
|
fn from(_: ValidationErrors) -> ServiceError {
|
||||||
ServiceError::NotAnEmail
|
ServiceError::NotAnEmail
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ParseError> for ServiceError {
|
impl From<ParseError> for ServiceError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn from(_: ParseError) -> ServiceError {
|
fn from(_: ParseError) -> ServiceError {
|
||||||
ServiceError::NotAUrl
|
ServiceError::NotAUrl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
impl From<CaptchaError> for ServiceError {
|
impl From<CaptchaError> for ServiceError {
|
||||||
fn from(e: CaptchaError) -> ServiceError {
|
fn from(e: CaptchaError) -> ServiceError {
|
||||||
ServiceError::CaptchaError(e)
|
ServiceError::CaptchaError(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
impl From<SmtpError> for ServiceError {
|
impl From<SmtpError> for ServiceError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn from(e: SmtpError) -> Self {
|
fn from(e: SmtpError) -> Self {
|
||||||
ServiceError::UnableToSendEmail(SmtpErrorWrapper(e))
|
ServiceError::UnableToSendEmail(SmtpErrorWrapper(e))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
impl From<RecvError> for ServiceError {
|
impl From<RecvError> for ServiceError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn from(e: RecvError) -> Self {
|
fn from(e: RecvError) -> Self {
|
||||||
log::error!("{:?}", e);
|
log::error!("{:?}", e);
|
||||||
ServiceError::InternalServerError
|
ServiceError::InternalServerError
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
impl From<MailboxError> for ServiceError {
|
impl From<MailboxError> for ServiceError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn from(e: MailboxError) -> Self {
|
fn from(e: MailboxError) -> Self {
|
||||||
log::error!("{:?}", e);
|
log::error!("{:?}", e);
|
||||||
ServiceError::InternalServerError
|
ServiceError::InternalServerError
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
pub type ServiceResult<V> = std::result::Result<V, ServiceError>;
|
pub type ServiceResult<V> = std::result::Result<V, ServiceError>;
|
||||||
|
|
||||||
#[derive(Debug, Display, PartialEq, Error)]
|
#[derive(Debug, Display, PartialEq, Error)]
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
pub enum PageError {
|
pub enum PageError {
|
||||||
#[display(fmt = "Something weng wrong: Internal server error")]
|
#[display(fmt = "Something weng wrong: Internal server error")]
|
||||||
InternalServerError,
|
InternalServerError,
|
||||||
@@ -267,17 +249,13 @@ pub enum PageError {
|
|||||||
ServiceError(ServiceError),
|
ServiceError(ServiceError),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
impl From<ServiceError> for PageError {
|
impl From<ServiceError> for PageError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn from(e: ServiceError) -> Self {
|
fn from(e: ServiceError) -> Self {
|
||||||
PageError::ServiceError(e)
|
PageError::ServiceError(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
impl From<DBError> for PageError {
|
impl From<DBError> for PageError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn from(e: DBError) -> Self {
|
fn from(e: DBError) -> Self {
|
||||||
let se: ServiceError = e.into();
|
let se: ServiceError = e.into();
|
||||||
se.into()
|
se.into()
|
||||||
@@ -297,7 +275,6 @@ impl ResponseError for PageError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn status_code(&self) -> StatusCode {
|
fn status_code(&self) -> StatusCode {
|
||||||
match self {
|
match self {
|
||||||
PageError::InternalServerError => StatusCode::INTERNAL_SERVER_ERROR,
|
PageError::InternalServerError => StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
@@ -306,7 +283,6 @@ impl ResponseError for PageError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
pub type PageResult<V> = std::result::Result<V, PageError>;
|
pub type PageResult<V> = std::result::Result<V, PageError>;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -92,7 +92,6 @@ pub const CACHE_AGE: u32 = 604800;
|
|||||||
pub type ArcData = Arc<crate::data::Data>;
|
pub type ArcData = Arc<crate::data::Data>;
|
||||||
pub type AppData = actix_web::web::Data<ArcData>;
|
pub type AppData = actix_web::web::Data<ArcData>;
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
@@ -185,7 +184,6 @@ async fn main() -> std::io::Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
pub fn get_json_err() -> JsonConfig {
|
pub fn get_json_err() -> JsonConfig {
|
||||||
JsonConfig::default().error_handler(|err, _| {
|
JsonConfig::default().error_handler(|err, _| {
|
||||||
//debug!("JSON deserialization error: {:?}", &err);
|
//debug!("JSON deserialization error: {:?}", &err);
|
||||||
@@ -193,7 +191,6 @@ pub fn get_json_err() -> JsonConfig {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
pub fn get_identity_service(
|
pub fn get_identity_service(
|
||||||
settings: &Settings,
|
settings: &Settings,
|
||||||
) -> IdentityService<CookieIdentityPolicy> {
|
) -> IdentityService<CookieIdentityPolicy> {
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ pub fn get_middleware() -> Authentication<routes::Routes> {
|
|||||||
Authentication::with_identity(routes::ROUTES)
|
Authentication::with_identity(routes::ROUTES)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use actix_web::http::StatusCode;
|
use actix_web::http::StatusCode;
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ pub struct Smtp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Server {
|
impl Server {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
pub fn get_ip(&self) -> String {
|
pub fn get_ip(&self) -> String {
|
||||||
format!("{}:{}", self.ip, self.port)
|
format!("{}:{}", self.ip, self.port)
|
||||||
}
|
}
|
||||||
@@ -205,7 +204,6 @@ const DEPRECATED_ENV_VARS: [(&str, &str); 23] = [
|
|||||||
("smtp.port", "MCAPTCHA_SMTP_PORT"),
|
("smtp.port", "MCAPTCHA_SMTP_PORT"),
|
||||||
];
|
];
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
impl Settings {
|
impl Settings {
|
||||||
pub fn new() -> Result<Self, ConfigError> {
|
pub fn new() -> Result<Self, ConfigError> {
|
||||||
let mut s = Config::builder();
|
let mut s = Config::builder();
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
"use strict";
|
||||||
|
|
||||||
import createError from "./index";
|
import createError from "./index";
|
||||||
import * as e from "./index";
|
import * as e from "./index";
|
||||||
|
|
||||||
import setup from "./setUpTests";
|
import setup from "./setUpTests";
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
"use strict";
|
||||||
|
|
||||||
import {Router} from "./router";
|
import {Router} from "./router";
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
const result = {
|
const result = {
|
||||||
result: "",
|
result: "",
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
"use strict";
|
||||||
|
|
||||||
import genJsonPayload from "./genJsonPayload";
|
import genJsonPayload from "./genJsonPayload";
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
username: "Jhon",
|
username: "Jhon",
|
||||||
|
|||||||
@@ -2,12 +2,11 @@
|
|||||||
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
"use strict";
|
||||||
|
|
||||||
import getFormUrl from "./getFormUrl";
|
import getFormUrl from "./getFormUrl";
|
||||||
import {getLoginFormHtml} from "../setUpTests";
|
import {getLoginFormHtml} from "../setUpTests";
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
const formClassName = "form__box";
|
const formClassName = "form__box";
|
||||||
const formURL = "/api/v1/signin";
|
const formURL = "/api/v1/signin";
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
"use strict";
|
||||||
|
|
||||||
import isBlankString from "./isBlankString";
|
import isBlankString from "./isBlankString";
|
||||||
import {mockAlert} from "../setUpTests";
|
import {mockAlert} from "../setUpTests";
|
||||||
@@ -9,7 +10,6 @@ import {mockAlert} from "../setUpTests";
|
|||||||
|
|
||||||
import setup from "../components/error/setUpTests";
|
import setup from "../components/error/setUpTests";
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
mockAlert();
|
mockAlert();
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,10 @@
|
|||||||
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
"use strict";
|
||||||
|
|
||||||
import isNumber from "./isNumber";
|
import isNumber from "./isNumber";
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
it("getFromUrl workds", () => {
|
it("getFromUrl workds", () => {
|
||||||
expect(isNumber("test")).toBe(false);
|
expect(isNumber("test")).toBe(false);
|
||||||
expect(isNumber("1test213")).toBe(false);
|
expect(isNumber("1test213")).toBe(false);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ SPDX-License-Identifier: MIT OR Apache-2.0
|
|||||||
<label class="widget__verification-container" for="widget__verification-checkbox">
|
<label class="widget__verification-container" for="widget__verification-checkbox">
|
||||||
<span id="widget__verification-text"
|
<span id="widget__verification-text"
|
||||||
>I'm not a robot</span>
|
>I'm not a robot</span>
|
||||||
<input
|
<input disabled
|
||||||
id="widget__verification-checkbox"
|
id="widget__verification-checkbox"
|
||||||
aria-valuenow="I'm not a robot"
|
aria-valuenow="I'm not a robot"
|
||||||
aria-checked="false"
|
aria-checked="false"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||||
|
|
||||||
import { Work, ServiceWorkerMessage } from "./types";
|
import {Work, ServiceWorkerMessage} from "./types";
|
||||||
import fetchPoWConfig from "./fetchPoWConfig";
|
import fetchPoWConfig from "./fetchPoWConfig";
|
||||||
import sendWork from "./sendWork";
|
import sendWork from "./sendWork";
|
||||||
import sendToParent from "./sendToParent";
|
import sendToParent from "./sendToParent";
|
||||||
@@ -12,7 +12,17 @@ import * as CONST from "./const";
|
|||||||
import "./main.scss";
|
import "./main.scss";
|
||||||
|
|
||||||
let LOCK = false;
|
let LOCK = false;
|
||||||
const worker = new Worker("/bench.js");
|
|
||||||
|
const workerPromise = new Promise<Worker>((res) => {
|
||||||
|
const worker = new Worker("/bench.js");
|
||||||
|
worker.onmessage = (event: MessageEvent) => {
|
||||||
|
const message: ServiceWorkerMessage = event.data;
|
||||||
|
if(message.type === "ready") {
|
||||||
|
console.log("worker ready");
|
||||||
|
res(worker);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
/** add mcaptcha widget element to DOM */
|
/** add mcaptcha widget element to DOM */
|
||||||
export const registerVerificationEventHandler = (): void => {
|
export const registerVerificationEventHandler = (): void => {
|
||||||
@@ -20,10 +30,14 @@ export const registerVerificationEventHandler = (): void => {
|
|||||||
document.querySelector(".widget__verification-container")
|
document.querySelector(".widget__verification-container")
|
||||||
);
|
);
|
||||||
verificationContainer.style.display = "flex";
|
verificationContainer.style.display = "flex";
|
||||||
CONST.btn().addEventListener("click", (e) => solveCaptchaRunner(e));
|
workerPromise.then((worker: Worker) => {
|
||||||
|
const btn = CONST.btn();
|
||||||
|
btn.disabled = false;
|
||||||
|
btn.addEventListener("click", (e) => solveCaptchaRunner(worker, e));
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const solveCaptchaRunner = async (e: Event): Promise<void> => {
|
export const solveCaptchaRunner = async (worker: Worker, e: Event): Promise<void> => {
|
||||||
const PROGRESS_FILL = <HTMLElement>document.querySelector(".progress__fill");
|
const PROGRESS_FILL = <HTMLElement>document.querySelector(".progress__fill");
|
||||||
|
|
||||||
const setWidth = (width: number) => {
|
const setWidth = (width: number) => {
|
||||||
@@ -94,7 +108,7 @@ export const solveCaptchaRunner = async (e: Event): Promise<void> => {
|
|||||||
}
|
}
|
||||||
if (resp.type === "progress") {
|
if (resp.type === "progress") {
|
||||||
if (width < 80) {
|
if (width < 80) {
|
||||||
width = Number(resp.nonce / max_recorded_nonce) * 100;
|
width = resp.nonce / max_recorded_nonce * 100;
|
||||||
setWidth(width);
|
setWidth(width);
|
||||||
}
|
}
|
||||||
console.log(`received nonce ${resp.nonce}`);
|
console.log(`received nonce ${resp.nonce}`);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ const prove = async (
|
|||||||
config.string,
|
config.string,
|
||||||
config.difficulty_factor,
|
config.difficulty_factor,
|
||||||
STEPS,
|
STEPS,
|
||||||
progress
|
(nonce: bigint | number) => progress(Number(nonce))
|
||||||
);
|
);
|
||||||
const t1 = performance.now();
|
const t1 = performance.now();
|
||||||
time = t1 - t0;
|
time = t1 - t0;
|
||||||
|
|||||||
@@ -9,6 +9,12 @@ import prove from "./prove";
|
|||||||
import { PoWConfig, ServiceWorkerMessage, ServiceWorkerWork } from "./types";
|
import { PoWConfig, ServiceWorkerMessage, ServiceWorkerWork } from "./types";
|
||||||
|
|
||||||
log.log("worker registered");
|
log.log("worker registered");
|
||||||
|
|
||||||
|
const ready: ServiceWorkerMessage = {
|
||||||
|
type: "ready",
|
||||||
|
};
|
||||||
|
postMessage(ready);
|
||||||
|
|
||||||
onmessage = async (e) => {
|
onmessage = async (e) => {
|
||||||
console.debug("message received at worker");
|
console.debug("message received at worker");
|
||||||
const config: PoWConfig = e.data;
|
const config: PoWConfig = e.data;
|
||||||
|
|||||||
@@ -40,5 +40,6 @@ export type Token = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type ServiceWorkerMessage =
|
export type ServiceWorkerMessage =
|
||||||
|
| { type: "ready" }
|
||||||
| { type: "work"; value: ServiceWorkerWork }
|
| { type: "work"; value: ServiceWorkerWork }
|
||||||
| { type: "progress"; nonce: number };
|
| { type: "progress"; nonce: number };
|
||||||
|
|||||||
46
utils/cache-bust/Cargo.lock
generated
46
utils/cache-bust/Cargo.lock
generated
@@ -1,6 +1,6 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "block-buffer"
|
name = "block-buffer"
|
||||||
@@ -177,6 +177,12 @@ dependencies = [
|
|||||||
"walkdir",
|
"walkdir",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memchr"
|
||||||
|
version = "2.7.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mime"
|
name = "mime"
|
||||||
version = "0.3.17"
|
version = "0.3.17"
|
||||||
@@ -195,18 +201,18 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.69"
|
version = "1.0.92"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da"
|
checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.33"
|
version = "1.0.38"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
|
checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
@@ -228,33 +234,45 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.189"
|
version = "1.0.228"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537"
|
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
||||||
|
dependencies = [
|
||||||
|
"serde_core",
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_core"
|
||||||
|
version = "1.0.228"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.189"
|
version = "1.0.228"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5"
|
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.38",
|
"syn 2.0.93",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.107"
|
version = "1.0.145"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65"
|
checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
|
"memchr",
|
||||||
"ryu",
|
"ryu",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -287,9 +305,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.38"
|
version = "2.0.93"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b"
|
checksum = "9c786062daee0d6db1132800e623df74274a0a87322d8e183338e01b3d98d058"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|||||||
Reference in New Issue
Block a user