Skip to content

Commit b7d47e5

Browse files
authored
refactor: separate CDN wire format from WASM RPC proto (#484)
1 parent 353a4e3 commit b7d47e5

31 files changed

Lines changed: 554 additions & 263 deletions

‎confidence-cloudflare-resolver/CLAUDE.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ RUSTFLAGS='--cfg getrandom_backend="wasm_js"' cargo build --target wasm32-unknow
6262
## Compile-Time Data
6363

6464
Two files are embedded at compile time from `../../data/`:
65-
- `resolver_state_current.pb` — Protobuf-encoded `SetResolverStateRequest` containing resolver state + account ID
65+
- `resolver_state_current.pb` — Protobuf-encoded `ClientResolverState` containing resolver state + account ID
6666
- `encryption_key` — Base64-encoded encryption key for resolve tokens
6767

6868
## Deployer

‎confidence-cloudflare-resolver/src/lib.rs‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,12 @@ use confidence_resolver::proto::confidence::flags::resolver::v1::{
2727
use confidence_resolver::Client;
2828
use once_cell::sync::Lazy;
2929

30-
/// SetResolverStateRequest message from the CDN.
31-
/// This matches the protobuf message format returned by the CDN.
3230
#[derive(Clone, PartialEq, Message)]
33-
pub struct SetResolverStateRequest {
31+
pub struct ClientResolverState {
3432
#[prost(bytes = "bytes", tag = "1")]
3533
pub state: Bytes,
3634
#[prost(string, tag = "2")]
37-
pub account_id: String,
35+
pub account: String,
3836
}
3937

4038
/// The CDN response containing both the state and account_id
@@ -58,16 +56,16 @@ static FLAGS_LOGS_QUEUE: OnceLock<Queue> = OnceLock::new();
5856
static CONFIDENCE_CLIENT_SECRET: OnceLock<String> = OnceLock::new();
5957

6058
/// Parsed CDN state request containing both state and account_id
61-
static CDN_STATE_REQUEST: Lazy<SetResolverStateRequest> = Lazy::new(|| {
62-
SetResolverStateRequest::decode(Bytes::from_static(CDN_STATE_BYTES))
63-
.expect("Failed to decode SetResolverStateRequest from CDN state")
59+
static CDN_STATE_REQUEST: Lazy<ClientResolverState> = Lazy::new(|| {
60+
ClientResolverState::decode(Bytes::from_static(CDN_STATE_BYTES))
61+
.expect("Failed to decode ClientResolverState from CDN state")
6462
});
6563

6664
static RESOLVER_STATE: Lazy<ResolverState> = Lazy::new(|| {
6765
let cdn_request = &*CDN_STATE_REQUEST;
6866
ResolverState::from_proto(
6967
cdn_request.state.to_vec().try_into().unwrap(),
70-
&cdn_request.account_id,
68+
&cdn_request.account,
7169
None,
7270
)
7371
.unwrap()

0 commit comments

Comments
 (0)