Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.9 #37

Merged
merged 222 commits into from
Jun 5, 2024
Merged

v0.9 #37

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
222 commits
Select commit Hold shift + click to select a range
d9ee44b
add API feature
bitfl0wer Apr 18, 2024
6282321
create basic file structure
bitfl0wer Apr 18, 2024
1cca784
Add serde, base64 features
bitfl0wer Apr 18, 2024
cca7b28
from_pem, to_pem for IdCsr, IdCert
bitfl0wer Apr 18, 2024
0d136d6
Make Constrained pub trait
bitfl0wer Apr 18, 2024
82a942c
Bump versions, remove base64, add x509_cert:pem
bitfl0wer Apr 18, 2024
f7fae07
Add schemas
bitfl0wer Apr 18, 2024
95f3de9
impl<S: Signature, P: PublicKey<S>> TryFrom<NewIdCertCreated> for IdC…
bitfl0wer Apr 18, 2024
aa1a0e7
rename auth schemas
bitfl0wer Apr 18, 2024
8cfd9d0
Rename feature api to routes
bitfl0wer Apr 18, 2024
3e1e025
Rename IdCertCreationSchema, IdCertCreatedSchema
bitfl0wer Apr 18, 2024
d2e973d
Implement Challenge type
bitfl0wer Apr 18, 2024
f08c367
Add missing documentation for associated functions
bitfl0wer Apr 18, 2024
70ce2b9
impl Challenge over impl std::str::FromStr for Challenge
bitfl0wer Apr 18, 2024
b7e8632
Implement complete() for Challenge
bitfl0wer Apr 18, 2024
6ae96d1
Expand dictionary
bitfl0wer Apr 18, 2024
26a8ed3
Add ToString requirement for Signature trait
bitfl0wer Apr 18, 2024
6726465
Add CompletedChallenge type, make Challenge attributes AT LEAST pub(c…
bitfl0wer Apr 18, 2024
7a8ecd1
Add new schemas, document things
bitfl0wer Apr 18, 2024
74d2612
add todo
bitfl0wer Apr 18, 2024
4201cbf
Add FireDBG support
bitfl0wer Apr 19, 2024
183b709
add firedbg dir to gitignore
bitfl0wer Apr 19, 2024
9b1d617
Add reqwest feature
bitfl0wer Apr 29, 2024
9e42605
Add reqwest note to README
bitfl0wer Apr 29, 2024
74d39c8
move types to src/
bitfl0wer Apr 29, 2024
e31638b
start impl HttpClient
bitfl0wer May 4, 2024
b5866c4
Implement handle_request into HttpClient
bitfl0wer May 4, 2024
2876c79
Implement "Get Challenge" route
bitfl0wer May 5, 2024
0a79c8a
Add Rotate Server ID-Cert route
bitfl0wer May 5, 2024
0686345
Add supplementary info about what "PublicKeyInfo" is
bitfl0wer May 6, 2024
8a4c2a1
0.9.0-alpha.2
bitfl0wer May 15, 2024
fef0f57
0.9.0-alpha.3: Add validate_home_server and validate_actor for IdCsr,…
bitfl0wer May 15, 2024
390ecd6
0.9.0-alpha.3: Normalize from_der() on all Csr, CertTbs, Cert
bitfl0wer May 15, 2024
44d9c28
Rename Signature::from_bitstring to ::from_bytes, since the name is m…
bitfl0wer May 15, 2024
bcd5cec
remove polyproto dev depenency
bitfl0wer May 15, 2024
ed36553
Fix build fail when building without default features
bitfl0wer May 15, 2024
e1d7dfd
0.9.0-alpha.4: re-export x509_cert::name::*;
bitfl0wer May 16, 2024
2608e1d
save work
bitfl0wer May 16, 2024
7e6d7d0
Merge branch 'routes' of https://github.com/bitfl0wer/polyproto into …
bitfl0wer May 16, 2024
7b0f559
bug found 🎉
bitfl0wer May 16, 2024
064b0e0
Add test: ID-CSR to and then from PEM
bitfl0wer May 16, 2024
d14d970
remove debugging crap
bitfl0wer May 16, 2024
3c41d0f
progress
bitfl0wer May 16, 2024
3f26f7f
further problem analysis
bitfl0wer May 16, 2024
1c5d4c2
Fix IdCsrs unable to be built from PEM
bitfl0wer May 16, 2024
0bd08c9
Remove dbg!()
bitfl0wer May 16, 2024
12c0ecb
remove import
bitfl0wer May 16, 2024
5569ef6
Bugfix: IdCSR to & from PEM (#34)
bitfl0wer May 16, 2024
f25dbc9
0.9.0-alpha.5: Fix regression/oversight in alpha.4 causing test failure
bitfl0wer May 16, 2024
e334064
change actions workflow to run on ALL prs
bitfl0wer May 16, 2024
236127b
remove dbg!()
bitfl0wer May 16, 2024
6ccc4b1
add csr_from_der, cert_from_pem tests
bitfl0wer May 19, 2024
6123dee
Add pub fn signature_data()
bitfl0wer May 19, 2024
ba2838d
add logging dependencies
bitfl0wer May 19, 2024
2f9138c
0.9.0-alpha.6: Check if DCs of UID and DC field(s) match
bitfl0wer May 19, 2024
9b82831
Add init_logger method for testing
bitfl0wer May 19, 2024
cf9ec41
Add TODO
bitfl0wer May 19, 2024
ea381ba
Add ActorConstrained, HomeServerConstrained traits
bitfl0wer May 19, 2024
a07a10c
remove unused import
bitfl0wer May 19, 2024
b2c7a3d
Shorten Name::validate(), impl ActorConstrained for Name
bitfl0wer May 19, 2024
71ed426
impl ActorConstrained for IdCert
bitfl0wer May 19, 2024
9c4023f
impl HomeServerConstrained for IdCert
bitfl0wer May 19, 2024
a692faa
impl ActorConstrained, HomeServerConstrained for IdCertTbs
bitfl0wer May 19, 2024
7bc9095
move CSR test to tests/idcsr.rs
bitfl0wer May 19, 2024
76b9c8f
Add `target` parameter to from_pem and from_der methods
bitfl0wer May 19, 2024
8c6f9f4
Fix tests :tada:
bitfl0wer May 19, 2024
ab3b202
Add `target` parameter to `IdCert::new()`
bitfl0wer May 19, 2024
0c6230c
impl actorconstrained, homeserverconstrained for idcsr
bitfl0wer May 19, 2024
5cc8a45
Create directory constraints/
bitfl0wer May 19, 2024
1eb9c78
Remove ActorConstrained and HomeServerConstrained for better Constrai…
bitfl0wer May 19, 2024
e7f79fb
0.9.0-alpha.6
bitfl0wer May 19, 2024
59e2f57
mark TODOs as done
bitfl0wer May 19, 2024
6a7a4b8
Normalize some error messages
bitfl0wer May 19, 2024
5038423
Add logging to tests
bitfl0wer May 19, 2024
1c5a95d
Use mod common to clean up code in tests
bitfl0wer May 19, 2024
d108fdf
Start sprinkling in some logs
bitfl0wer May 19, 2024
d3781ed
Normalize error messages
bitfl0wer May 19, 2024
d7a3e82
Remove redundant checks
bitfl0wer May 19, 2024
574ce27
API changes to from_der, added information about certificate safety
bitfl0wer May 20, 2024
37e0f9b
Add `from_{"der", "pem"}_unchecked` methods for IdCsr, IdCsrInner, Id…
bitfl0wer May 20, 2024
cb3e84e
Improve efficiency by removing double and triple validation of the sa…
bitfl0wer May 20, 2024
70b6e01
Publish v0.9.0-alpha.7
bitfl0wer May 20, 2024
af57fe8
move ChallengePayload to entities dir
bitfl0wer May 20, 2024
9a995a7
move tests to subfolder
bitfl0wer May 20, 2024
247a3c6
Delete API dir to start fresh
bitfl0wer May 20, 2024
0a1d5f9
Start working on API types
bitfl0wer May 20, 2024
f261775
Write some tests to confirm FederationId parsing is working
bitfl0wer May 20, 2024
7434ab9
Normalize REGEX_FEDERATION_ID
bitfl0wer May 20, 2024
b58f0f7
Regex for FederationId parsing
bitfl0wer May 20, 2024
9e2c76c
Change file structure of types/ dir
bitfl0wer May 21, 2024
fa73c6c
Change file structure of constraints/types
bitfl0wer May 21, 2024
bba616f
add todo
bitfl0wer May 21, 2024
a2e275f
Merge submodules of `error` module
bitfl0wer May 23, 2024
a4f7350
Add url, http as optional deps
bitfl0wer May 23, 2024
d6d6b9c
Start defining some routes
bitfl0wer May 23, 2024
d09ade8
add core mod
bitfl0wer May 23, 2024
6072a53
Define routes module
bitfl0wer May 23, 2024
beb82ae
Add stubs for all (non-mls) routes
bitfl0wer May 24, 2024
61b1b6d
Add missing route definitions
bitfl0wer May 25, 2024
e9c1f60
Derive Debug and Clone for Route struct
bitfl0wer May 27, 2024
8f5f106
Add url::ParseError passthrough
bitfl0wer May 27, 2024
fd60f74
impl get_challenge_string fn
bitfl0wer May 27, 2024
2d19a48
impl pub async fn rotate_server_identity_key
bitfl0wer May 27, 2024
3b7ded2
remove todo
bitfl0wer May 27, 2024
09ed3c2
Impl {From,To}{Der,Pem} for PublicKeyInfo struct
bitfl0wer May 27, 2024
88b66fa
impl get_server_id_cert, get_server_public_key_info
bitfl0wer May 27, 2024
e6f277c
impl Display for SessionId
bitfl0wer May 27, 2024
20461b5
impl all "Registration not needed" routes
bitfl0wer May 27, 2024
9953c27
Remove imports, fix "test"
bitfl0wer May 27, 2024
e0dcbe9
Change API of HttpClient
bitfl0wer May 27, 2024
da77b01
Start implementing Core Routes: Registration needed
bitfl0wer May 27, 2024
caca866
impl rest of routes
bitfl0wer May 27, 2024
9a7ae88
Write better documentation, make client in HttpClient pub
bitfl0wer May 28, 2024
c9fd972
improve api design of get_actor_id_certs route
bitfl0wer May 28, 2024
3c13f76
more clear variable naming
bitfl0wer May 28, 2024
9603d7c
Publish alpha 8
bitfl0wer May 28, 2024
44fae93
Include httptest for HTTP server mocking in tests
bitfl0wer May 28, 2024
58395b6
Create tests/api/core
bitfl0wer May 28, 2024
4e41447
fix todo
bitfl0wer May 28, 2024
766b59d
exclude static defs from code cov
bitfl0wer May 28, 2024
0b94d2f
Add tokio for trsting async fns
bitfl0wer May 28, 2024
8e465ac
Add first test for HTTP APIs
bitfl0wer May 28, 2024
aa262cd
update documentation
bitfl0wer May 29, 2024
9dd4ed9
update dev-deps
bitfl0wer May 29, 2024
2977a44
add debug log
bitfl0wer May 29, 2024
2086fbe
start impl rotate_server_identity_key
bitfl0wer May 29, 2024
172fc40
Test converting home server cert from PEM
May 29, 2024
b4fad48
Merge branch 'v0.9' of https://github.com/polyphony-chat/polyproto in…
May 29, 2024
4740dce
bitstring experiments
May 29, 2024
15c2197
experiments with bitstrings
May 29, 2024
4b20f7a
Fix incorrect bitstring conversions
bitfl0wer May 29, 2024
03fa7b3
rename certificates module to certs
bitfl0wer May 29, 2024
fa975d7
define tests for to_bitstring and from_bitstring for KeyUsages
bitfl0wer May 29, 2024
311ac4c
trace logs
bitfl0wer May 29, 2024
96a0bc3
add mod_key usage
bitfl0wer May 29, 2024
2238db9
More from_bitstring testcases
bitfl0wer May 29, 2024
dd7ec87
Fix bitstring encoded and decoding, for the third(?) time
bitfl0wer May 29, 2024
ec34226
Publish alpha 9
bitfl0wer May 29, 2024
d9d2c28
Raise MSRV
bitfl0wer May 29, 2024
568cd07
add cert_from_der test
bitfl0wer May 29, 2024
3b8609a
idcsr tests: also test home server certs
bitfl0wer May 29, 2024
bf7480f
Add test get_server_public_key
bitfl0wer May 30, 2024
fb2f747
Add test get_server_id_cert
bitfl0wer May 30, 2024
f1df0ec
Add Safety section, update rest of README
bitfl0wer May 30, 2024
15652ea
check for mismatching uid and cn
bitfl0wer May 30, 2024
3a58700
Add public fn validate_at() for IdCert
bitfl0wer Jun 1, 2024
2ab7d6f
Change SessionId::new_validated to take &str arg instead
bitfl0wer Jun 1, 2024
de43bbb
Fix body creation in get_actor_id_certs
bitfl0wer Jun 1, 2024
3e26406
Add test get_actor_id_certs
bitfl0wer Jun 1, 2024
27e753a
Provide common methods for creating certs for tests
bitfl0wer Jun 1, 2024
8a32afb
Add test update_session_id_cert
bitfl0wer Jun 2, 2024
8434771
Fix: session id was provided in path, not body
bitfl0wer Jun 2, 2024
b330859
Write test for delete session
bitfl0wer Jun 2, 2024
c3665d7
properly format values in request body
bitfl0wer Jun 2, 2024
c65cc83
add default validity function
bitfl0wer Jun 2, 2024
34e368f
add logging
bitfl0wer Jun 2, 2024
1f9720d
add (unfinished) test rotate_session_id_cert
bitfl0wer Jun 2, 2024
187a8e8
Major fixes (see below)
bitfl0wer Jun 2, 2024
b965151
Reflect API changes in tests
bitfl0wer Jun 2, 2024
04dbe54
Update examples
bitfl0wer Jun 2, 2024
df68bca
Add additional documentation
bitfl0wer Jun 3, 2024
e4404a5
impl From<SessionId> for Ia5String, impl TryFrom<Ia5String> for Sessi…
bitfl0wer Jun 3, 2024
5067fbc
fix upload_encrypted_pkm, add test for that function
bitfl0wer Jun 3, 2024
3494c4e
add TODO
bitfl0wer Jun 3, 2024
46b8608
Add conditional compiling for including serde compatible asn1 type
bitfl0wer Jun 3, 2024
24cc030
alpha.11
bitfl0wer Jun 3, 2024
6c6622f
Remove dependency on ser_der: Integrate ser_der into polyproto
bitfl0wer Jun 3, 2024
ed23c50
Draft up encryptedpkm struct
bitfl0wer Jun 3, 2024
cbeffda
Draft up encryptedpkm struct
bitfl0wer Jun 3, 2024
25d25b4
Remove dependency on ser_der: Integrate ser_der into polyproto
bitfl0wer Jun 3, 2024
25fa947
Make SubjectPublicKeyInfo serde compatible
bitfl0wer Jun 3, 2024
8a8aa44
start working on making AlgorithmIdentifierOwned serde compatible
bitfl0wer Jun 3, 2024
1486e7c
remove period from end of expecting-phrase
bitfl0wer Jun 3, 2024
d0bcef0
impl serde Deserialize and Serialize on wrapper type for AlgorithmIde…
bitfl0wer Jun 3, 2024
066aea4
why was serde_test missing?? strange
bitfl0wer Jun 3, 2024
6aa940d
rename crate::serde to serde_compat, fix code
bitfl0wer Jun 3, 2024
2a6c2e5
Write tests to check if de-/serializing SPKIs works
bitfl0wer Jun 4, 2024
37f5ed0
comment out broken test (dw, it has a TODO attached)
bitfl0wer Jun 4, 2024
91a3f87
comment out broken test (dw, it has a TODO attached)
bitfl0wer Jun 4, 2024
ed22976
Merge branch 'v0.9' of https://github.com/polyphony-chat/polyproto in…
bitfl0wer Jun 4, 2024
80953c7
Merge branch 'v0.9' of https://github.com/polyphony-chat/polyproto in…
bitfl0wer Jun 4, 2024
e12de4c
Merge branch 'v0.9' of https://github.com/polyphony-chat/polyproto in…
bitfl0wer Jun 4, 2024
7e65148
Streamline usages of spki:: and der:: types which we override anyways
bitfl0wer Jun 4, 2024
d1d4531
Document type, especially how expected input looks like for usage wit…
bitfl0wer Jun 4, 2024
4302144
correct incorrect messages when implementing serde::de::Visitor::expe…
bitfl0wer Jun 4, 2024
71df1fc
Add custom wrapper for der::asn1::Uint type
bitfl0wer Jun 4, 2024
d337f02
Add custom wrapper for der::asn1::Uint type
bitfl0wer Jun 4, 2024
e0f7098
correct the "expecting" message in the visitor impl
bitfl0wer Jun 4, 2024
7362cb6
oops - i needed SerialNumber instead of Uint.
bitfl0wer Jun 4, 2024
565ab66
remove .to_string()
bitfl0wer Jun 4, 2024
7c02b94
change ia5string to be SerialNumber
bitfl0wer Jun 4, 2024
6b4f48a
add mod x509_cert
bitfl0wer Jun 4, 2024
9efbffc
remove unneeded import
bitfl0wer Jun 4, 2024
c059035
Replace x509_cert::serialnumber::SerialNumber with own serial number …
bitfl0wer Jun 4, 2024
65d80d1
Add documentation
bitfl0wer Jun 4, 2024
1d41372
add de_serialization tests, add try_as_u128
bitfl0wer Jun 4, 2024
782aa03
fix serde implementation, add test
bitfl0wer Jun 4, 2024
ca46a50
move documentation about json documentation to website
bitfl0wer Jun 4, 2024
ce61972
remove unused clippy annotations
bitfl0wer Jun 4, 2024
6daccc0
Add documentation to *all* types, traits and methods which were not y…
bitfl0wer Jun 4, 2024
e7b9535
Update documentation for the Constrained trait
bitfl0wer Jun 4, 2024
77628a8
add missing documentation
bitfl0wer Jun 5, 2024
15d0d35
remove todos
bitfl0wer Jun 5, 2024
dfe8906
add method to_rdn_sequence to SessionId
bitfl0wer Jun 5, 2024
86c8f36
update IdCsr::new documentation
bitfl0wer Jun 5, 2024
576b6cc
update IdCsr::new documentation
bitfl0wer Jun 5, 2024
875a848
Merge branch 'v0.9' of https://github.com/polyphony-chat/polyproto in…
bitfl0wer Jun 5, 2024
fa4890a
false positiveeeesssss
bitfl0wer Jun 5, 2024
c8fd3fe
fix pkm routes
bitfl0wer Jun 5, 2024
8a423ac
add tests for pkm routes
bitfl0wer Jun 5, 2024
9ea0e3a
impl TryFrom<SerialNumber> for u128, impl From<u128> for SerialNumber
bitfl0wer Jun 5, 2024
bc89810
test_dc_matches_dc_in_uid
bitfl0wer Jun 5, 2024
96485d8
update examples
bitfl0wer Jun 5, 2024
9e18854
Add http client example
bitfl0wer Jun 5, 2024
38c2672
remove unneeded code from example
bitfl0wer Jun 5, 2024
3b430f6
publish beta.1
bitfl0wer Jun 5, 2024
55505a6
Update README
bitfl0wer Jun 5, 2024
07d87d9
Fix grammatical error
bitfl0wer Jun 5, 2024
7b2a176
Merge branch 'main' into v0.9
bitfl0wer Jun 5, 2024
417fa59
change macos runner to ubuntu runner because gecko is unsupported on …
bitfl0wer Jun 5, 2024
8c22fbd
fix Cargo.toml
bitfl0wer Jun 5, 2024
a993b10
boot out wasm tests for now
bitfl0wer Jun 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 21 additions & 23 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: ["main"]
pull_request:
branches: ["main", "dev"]
branches: ["*"]

env:
CARGO_TERM_COLOR: always
Expand All @@ -30,25 +30,23 @@ jobs:
cargo build --verbose --all-features
cargo test --verbose --all-features --tests --examples
fi
wasm:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"
prefix-key: "macos"
- name: Run WASM tests with Safari, Firefox, Chrome
run: |
rustup target add wasm32-unknown-unknown
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
cargo binstall --no-confirm wasm-bindgen-cli --version "0.2.88" --force
cargo binstall --no-confirm wasm-pack --force
wasm-pack test --node -- --features wasm --examples
wasm-pack test --firefox -- --features wasm --examples
wasm-pack test --chrome -- --features wasm --examples
wasm-pack test --safari -- --features wasm --examples
wasm-pack test --node -- --features wasm
wasm-pack test --firefox -- --features wasm
wasm-pack test --chrome -- --features wasm
wasm-pack test --safari -- --features wasm
# wasm:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: Swatinem/rust-cache@v2
# with:
# cache-all-crates: "true"
# prefix-key: "macos"
# - name: Run WASM tests with Safari, Firefox, Chrome
# run: |
# rustup target add wasm32-unknown-unknown
# curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
# cargo binstall --no-confirm wasm-bindgen-cli --version "0.2.88" --force
# cargo binstall --no-confirm wasm-pack --force
# wasm-pack test --node -- --features wasm --examples
# wasm-pack test --firefox -- --features wasm --examples
# wasm-pack test --chrome -- --features wasm --examples
# wasm-pack test --node -- --features wasm
# wasm-pack test --firefox -- --features wasm
# wasm-pack test --chrome -- --features wasm
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
.VSCodeCounter
.coverage
cert.csr
cert.der
cert.der
/firedbg
1 change: 1 addition & 0 deletions .vscode/ltex.dictionary.en-US.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ extnValue
extnID
CSRs
IdCsrInner
TryFrom
5 changes: 5 additions & 0 deletions .vscode/ltex.hiddenFalsePositives.en-US.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@
{"rule":"UNLIKELY_OPENING_PUNCTUATION","sentence":"^\\Q:3\\E$"}
{"rule":"DOUBLE_PUNCTUATION","sentence":"^\\QExtensions ::= SEQUENCE SIZE (1..MAX) OF Extension\\E$"}
{"rule":"COMMA_PARENTHESIS_WHITESPACE","sentence":"^\\QExtension ::= SEQUENCE {\nextnID OBJECT IDENTIFIER,\ncritical BOOLEAN DEFAULT FALSE,\nextnValue OCTET STRING\n-- contains the DER encoding of an ASN.1 value\n-- corresponding to the extension type identified\n-- by extnID\n}\\E$"}
{"rule":"MORFOLOGIK_RULE_EN_US","sentence":"^\\QResponse counterpart of CreateSessionSchema.\\E$"}
{"rule":"MASS_AGREEMENT","sentence":"^\\QThe challenge string.\\E$"}
{"rule":"MORFOLOGIK_RULE_EN_US","sentence":"^\\QResponse counterpart of IdentifyRequest.\\E$"}
{"rule":"EN_A_VS_AN","sentence":"^\\QTry to convert the inner byte slice to a u128.\\E$"}
{"rule":"POSSESSIVE_APOSTROPHE","sentence":"^\\QView the examples directory for a simple example on how to implement and use this crate with the ED25519 signature algorithm.\\E$"}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"markiscodecoverage.searchCriteria": ".coverage/lcov*.info"
"markiscodecoverage.searchCriteria": ".coverage/lcov*.info",
"rust-analyzer.cargo.features": ["types", "reqwest"]
}
36 changes: 26 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,48 @@
[package]
name = "polyproto"
version = "0.9.0-alpha.1"
version = "0.9.0"
edition = "2021"
license = "MPL-2.0"
description = "(Generic) Rust types and traits to quickly get a polyproto implementation up and running"
repository = "https://github.com/polyphony-chat/polyproto"
rust-version = "1.65.0"
rust-version = "1.71.1"

[lib]
crate-type = ["rlib", "cdylib", "staticlib"]

[features]
default = ["types"]
wasm = ["getrandom", "getrandom/js"]
getrandom = ["dep:getrandom"]
types = ["dep:http"]
reqwest = ["dep:reqwest", "types", "serde", "dep:url"]
serde = ["dep:serde", "dep:serde_json"]

[dependencies]
der = { version = "0.7.8", features = ["pem"] }
getrandom = { version = "0.2.12", optional = true }
der = { version = "0.7.9", features = ["pem"] }
getrandom = { version = "0.2.14", optional = true }
regex = "1.10.4"
spki = "0.7.3"
thiserror = "1.0.57"
x509-cert = { version = "0.2.5", default-features = false }
reqwest = { version = "0.12.4", features = ["json"], optional = true }
serde = { version = "1.0.199", optional = true, features = ["derive"] }
serde_json = { version = "1.0.116", optional = true }
spki = { version = "0.7.3", features = ["pem"] }
thiserror = "1.0.59"
x509-cert = "0.2.5"
log = "0.4.21"
url = { version = "2.5.0", optional = true }
http = { version = "1.1.0", optional = true }

[dev-dependencies]
ed25519-dalek = { version = "2.1.1", features = ["rand_core", "signature"] }
env_logger = "0.11.3"
httptest = "0.16.1"
rand = "0.8.5"
polyproto = { path = "./" }
tokio = { version = "1.37.0", features = ["full"] }
serde = { version = "1.0.199", features = ["derive"] }
serde_json = { version = "1.0.116" }
serde_test = "1.0.176"
polyproto = { path = "./", features = ["types", "reqwest", "serde"] }

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.3.39"
wasm-bindgen = "0.2.89"
wasm-bindgen-test = "0.3.42"
wasm-bindgen = "0.2.92"
41 changes: 32 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@

Crate supplying (generic) Rust types and traits to quickly get a
[polyproto](https://docs.polyphony.chat/Protocol%20Specifications/core/) implementation up and
running.
running, as well as an HTTP client for the polyproto API.

## Implementing polyproto
Building upon types offered by the [der](https://crates.io/crates/der),
[x509_cert](https://crates.io/crates/x509_cert) and [spki](https://crates.io/crates/spki) crates,
this crate provides a set of types and traits to quickly implement the polyproto specification.
Simply add cryptography and signature algorithm crates of your choice to the mix, and you are ready
to go.

**The crate is currently in an alpha stage. Some functionality is missing, and
things may break or change at any point in time.**
All polyproto certificate types can be converted to and from the types offered by the `x509_cert`
crate.

This crate extends upon types offered by [der](https://crates.io/crates/der) and
[spki](https://crates.io/crates/spki). As such, these crates are required dependencies for
projects looking to implement polyproto.
## Implementing polyproto

Start by implementing the trait [crate::signature::Signature] for a signature algorithm of your
choice. Popular crates for cryptography and signature algorithms supply their own `PublicKey` and
Expand All @@ -31,8 +33,8 @@ choice. Popular crates for cryptography and signature algorithms supply their ow
You can then use the [crate::certs] types to build certificates using your implementations of the
aforementioned traits.

View the [examples](./examples/) directory for a simple example on how to implement and use this
crate.
**View the [examples](./examples/)** directory for a simple example on how to implement and use this
crate with the ED25519 signature algorithm.

## Cryptography

Expand All @@ -41,6 +43,15 @@ implementing polyproto by transforming the
[polyproto specification](https://docs.polyphony.chat/Protocol%20Specifications/core/) into
well-defined yet adaptable Rust types.

## Safety

Please refer to the documentation of individual functions for information on which safety guarantees
they provide. Methods returning certificates, certificate requests and other types where the
validity and correctness of the data has a chance of impacting the security of a system always
mention the safety guarantees they provide in their respective documentation.

This crate has not undergone any security audits.

## WebAssembly

This crate is designed to work with the `wasm32-unknown-unknown` target. To compile for `wasm`, you
Expand All @@ -51,6 +62,18 @@ will have to use the `wasm` feature:
polyproto = { version = "0", features = ["wasm"] }
```

## HTTP API client through `reqwest`

If the `reqwest` feature is activated, this crate offers a polyproto HTTP API client, using the
`reqwest` crate.

### Alternatives to `reqwest`

If you would like to implement an HTTP client using something other than `reqwest`, simply enable
the `types` and `serde` features. Using these features, you can implement your own HTTP client, with
the polyproto crate acting as a single source of truth for request and response types, as well as
request routes and methods through the exported `static` `Route`s.

[build-shield]: https://img.shields.io/github/actions/workflow/status/polyphony-chat/polyproto/build_and_test.yml?style=flat
[build-url]: https://github.com/polyphony-chat/polyproto/blob/main/.github/workflows/build_and_test.yml
[coverage-shield]: https://coveralls.io/repos/github/polyphony-chat/polyproto/badge.svg?branch=main
Expand Down
24 changes: 12 additions & 12 deletions examples/ed25519_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
// This example is not complete and should not be copy-pasted into a production environment without
// further scrutiny and consideration.

#![allow(unused)]

use std::str::FromStr;

use der::asn1::BitString;
Expand All @@ -17,10 +15,7 @@ use polyproto::key::{PrivateKey, PublicKey};
use polyproto::signature::Signature;
use rand::rngs::OsRng;
use spki::{AlgorithmIdentifierOwned, ObjectIdentifier, SignatureBitStringEncoding};
use thiserror::Error;

#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[cfg_attr(not(target_arch = "wasm32"), test)]
fn main() {
let mut csprng = rand::rngs::OsRng;
// Generate a key pair
Expand Down Expand Up @@ -60,10 +55,6 @@ fn main() {
)
}

#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(test))]
fn main() {}

// As mentioned in the README, we start by implementing the signature trait.

// Here, we start by defining the signature type, which is a wrapper around the signature type from
Expand All @@ -74,6 +65,12 @@ struct Ed25519Signature {
algorithm: AlgorithmIdentifierOwned,
}

impl std::fmt::Display for Ed25519Signature {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.signature)
}
}

// We implement the Signature trait for our signature type.
impl Signature for Ed25519Signature {
// We define the signature type from the ed25519-dalek crate as the associated type.
Expand All @@ -96,7 +93,7 @@ impl Signature for Ed25519Signature {
}

#[cfg(not(tarpaulin_include))]
fn from_bitstring(signature: &[u8]) -> Self {
fn from_bytes(signature: &[u8]) -> Self {
let mut signature_vec = signature.to_vec();
signature_vec.resize(64, 0);
let signature_array: [u8; 64] = {
Expand Down Expand Up @@ -196,8 +193,6 @@ impl PublicKey<Ed25519Signature> for Ed25519PublicKey {
fn try_from_public_key_info(
public_key_info: PublicKeyInfo,
) -> Result<Self, polyproto::errors::composite::ConversionError> {
use polyproto::errors::composite::ConversionError;

let mut key_vec = public_key_info.public_key_bitstring.raw_bytes().to_vec();
key_vec.resize(32, 0);
let signature_array: [u8; 32] = {
Expand All @@ -210,3 +205,8 @@ impl PublicKey<Ed25519Signature> for Ed25519PublicKey {
})
}
}

#[test]
fn test_example() {
main()
}
Loading