(feat): add max message size to wasm
Some checks failed
CI / rustfmt (push) Successful in 17s
CI / wasm build (push) Successful in 1m15s
CI / clippy (push) Successful in 1m30s
CI / test (push) Successful in 1m48s
CI / example (push) Successful in 1m32s
CI / duplicate code (push) Failing after 29s
CI / web client (push) Failing after 30s
CI / cargo-machete (push) Successful in 1m7s
CI / cargo-deny (push) Failing after 2m23s
Some checks failed
CI / rustfmt (push) Successful in 17s
CI / wasm build (push) Successful in 1m15s
CI / clippy (push) Successful in 1m30s
CI / test (push) Successful in 1m48s
CI / example (push) Successful in 1m32s
CI / duplicate code (push) Failing after 29s
CI / web client (push) Failing after 30s
CI / cargo-machete (push) Successful in 1m7s
CI / cargo-deny (push) Failing after 2m23s
(feat): add pq key generation to wasm (qol): update gitignores
This commit is contained in:
parent
15cc1d4c5e
commit
d9ad5e5b3d
23 changed files with 341 additions and 1996 deletions
|
|
@ -131,6 +131,18 @@ let id = conn.client_id;
|
|||
let keyring_bytes = keyring.to_bytes();
|
||||
```
|
||||
|
||||
When callers already know whether a saved client id exists, the convenience
|
||||
helper chooses login or registration:
|
||||
|
||||
```rust
|
||||
let conn = MTPClient::auth_connect_or_register(
|
||||
config,
|
||||
saved_client_id, // Option<u64>
|
||||
&keyring,
|
||||
&host_pk,
|
||||
).await?;
|
||||
```
|
||||
|
||||
Protocol (challenge-response):
|
||||
1. Client sends an unsigned `Register` hello (version, public key bundle)
|
||||
2. Host replies with a `Challenge` carrying a fresh random `server_challenge`
|
||||
|
|
@ -207,6 +219,19 @@ type-map configuration.
|
|||
conn.sender.send(&msg).await?;
|
||||
```
|
||||
|
||||
For request/response flows, `MTPConnection::request` sends one frame and waits
|
||||
for a response with the same non-zero frame id. An expected response type can be
|
||||
provided for validation:
|
||||
|
||||
```rust
|
||||
let response = conn
|
||||
.request(&msg, Some(mtp::codec::CommunicationType::Pong))
|
||||
.await?;
|
||||
```
|
||||
|
||||
Frames with other ids are consumed by this helper. Applications that need
|
||||
subscriptions or broad routing should use one receive task and correlate there.
|
||||
|
||||
Two send modes (configured via `mtp::transport::Policy`):
|
||||
- `PersistentStream` (default) -- reuses one QUIC uni-directional stream
|
||||
- `SingleStreamPerMessage` -- opens a new stream per message
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ const client = await MTPClient.create({
|
|||
credentials,
|
||||
storage,
|
||||
serverCertificateHashes: ["sha-256:abcd1234..."],
|
||||
maxMessageSize: 1_000_000,
|
||||
authTimeoutMs: 30_000,
|
||||
pings: true,
|
||||
logger: (event) => console.log(event),
|
||||
});
|
||||
|
|
@ -139,6 +141,9 @@ await MTPClient.create({
|
|||
|
||||
If hashes are omitted, the browser uses its normal TLS root store.
|
||||
|
||||
`maxMessageSize` caps inbound and outbound MTP frames before buffering/sending.
|
||||
`authTimeoutMs` bounds connect/login/register promises at the SDK layer.
|
||||
|
||||
## Sending, Requests, Subscriptions, And Pings
|
||||
|
||||
`send` accepts either a typed message or a prebuilt raw frame:
|
||||
|
|
@ -157,7 +162,7 @@ await client.send("SomeType", { value: "hello" }, {
|
|||
});
|
||||
```
|
||||
|
||||
`request` sends one frame and resolves with the matching parsed response from the WASM layer:
|
||||
`request` sends one frame and resolves with the parsed response carrying the same frame id. `responseType` is validated after the id match:
|
||||
|
||||
```typescript
|
||||
const response = await client.request(
|
||||
|
|
@ -252,6 +257,7 @@ Raw crypto and key helpers include:
|
|||
|
||||
- `ed25519_generate()`
|
||||
- `ed25519_verify(publicKey, message, signature)`
|
||||
- `keyring_generate()`
|
||||
- `keyring_from_ed25519(secretKey, publicKey)`
|
||||
- `WasmKeyring.from_bytes(bytes)` and `keyring.to_bytes()`
|
||||
- `WasmPublicKeyBundle.from_bytes(bytes)` and `bundle.to_bytes()`
|
||||
|
|
|
|||
Loading…
Reference in a new issue