refactor(webapi,types)!: make challenge type extensive

We may allow more challenge types other than PoW in the future, eg.
captcha. So make the relevent types more generic.

Now the challenge is returned in JSON response as a individual top-level
field `register_challenge` instead of in HTTP headers.
This commit is contained in:
oxalica 2024-10-01 05:26:00 -04:00
parent 364e517b7d
commit bc6e6c2056
11 changed files with 206 additions and 130 deletions

View file

@ -2,7 +2,7 @@
use std::hint::black_box;
use std::time::Instant;
use blah_types::msg::{ChatPayload, UserRegisterPayload};
use blah_types::msg::{ChatPayload, UserRegisterChallengeResponse, UserRegisterPayload};
use blah_types::{get_timestamp, Id, PubKey, SignExt, Signee, UserKey};
use criterion::{criterion_group, criterion_main, Criterion};
use ed25519_dalek::SigningKey;
@ -24,7 +24,7 @@ fn bench_register_pow(c: &mut Criterion) {
id_key: id_key.clone(),
server_url: "http://some.example.com".parse().unwrap(),
id_url: "http://another.example.com".parse().unwrap(),
challenge_nonce: rng.gen(),
challenge: Some(UserRegisterChallengeResponse::Pow { nonce: rng.gen() }),
};
let mut signee = Signee {
nonce: 0,