Skip to content

Commit f79594d

Browse files
Change x-synthetic-trusted-server header to x-psid-ts
1 parent a133c99 commit f79594d

File tree

7 files changed

+15
-14
lines changed

7 files changed

+15
-14
lines changed

crates/common/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ Behavior is covered by an extensive test suite in `crates/common/src/creative.rs
5151

5252
- `synthetic.rs` generates a deterministic synthetic identifier per user request and exposes helpers:
5353
- `generate_synthetic_id` — creates a fresh HMAC-based ID using request signals.
54-
- `get_synthetic_id` — extracts an existing ID from the `X-Synthetic-Trusted-Server` header or `synthetic_id` cookie.
54+
- `get_synthetic_id` — extracts an existing ID from the `x-psid-ts` header or `synthetic_id` cookie.
5555
- `get_or_generate_synthetic_id` — reuses the existing ID when present, otherwise creates one.
56-
- `publisher.rs::handle_publisher_request` stamps proxied origin responses with `X-Synthetic-Fresh`, `X-Synthetic-Trusted-Server`, and (when absent) issues the `synthetic_id` cookie so the browser keeps the identifier on subsequent requests.
56+
- `publisher.rs::handle_publisher_request` stamps proxied origin responses with `X-Synthetic-Fresh`, `x-psid-ts`, and (when absent) issues the `synthetic_id` cookie so the browser keeps the identifier on subsequent requests.
5757
- `proxy.rs::handle_first_party_proxy` replays the identifier to third-party creative origins by appending `synthetic_id=<value>` to the reconstructed target URL, follows redirects (301/302/303/307/308) up to four hops, and keeps downstream fetches linked to the same user scope.
5858
- `proxy.rs::handle_first_party_click` adds `synthetic_id=<value>` to outbound click redirect URLs so analytics endpoints can associate clicks with impressions without third-party cookies.

crates/common/src/constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pub const HEADER_SYNTHETIC_FRESH: HeaderName = HeaderName::from_static("x-synthe
44
pub const HEADER_SYNTHETIC_PUB_USER_ID: HeaderName = HeaderName::from_static("x-pub-user-id");
55
pub const HEADER_X_PUB_USER_ID: HeaderName = HeaderName::from_static("x-pub-user-id");
66
pub const HEADER_SYNTHETIC_TRUSTED_SERVER: HeaderName =
7-
HeaderName::from_static("x-synthetic-trusted-server");
7+
HeaderName::from_static("x-psid-ts");
88
pub const HEADER_X_CONSENT_ADVERTISING: HeaderName =
99
HeaderName::from_static("x-consent-advertising");
1010
pub const HEADER_X_FORWARDED_FOR: HeaderName = HeaderName::from_static("x-forwarded-for");

crates/common/src/gam.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::collections::HashMap;
66
use std::io::Read;
77
use uuid::Uuid;
88

9+
use crate::constants::HEADER_SYNTHETIC_TRUSTED_SERVER;
910
use crate::error::TrustedServerError;
1011
use crate::gdpr::get_consent_from_request;
1112
use crate::settings::Settings;
@@ -35,7 +36,7 @@ impl GamRequest {
3536

3637
// Get synthetic ID from request headers
3738
let synthetic_id = req
38-
.get_header("X-Synthetic-Trusted-Server")
39+
.get_header(HEADER_SYNTHETIC_TRUSTED_SERVER)
3940
.and_then(|h| h.to_str().ok())
4041
.unwrap_or("unknown")
4142
.to_string();
@@ -1077,12 +1078,12 @@ mod tests {
10771078
use super::*;
10781079
use serde_json::json;
10791080

1080-
use crate::test_support::tests::create_test_settings;
1081+
use crate::{constants::HEADER_SYNTHETIC_TRUSTED_SERVER, test_support::tests::create_test_settings};
10811082

10821083
fn create_test_request() -> Request {
10831084
let mut req = Request::new(Method::GET, "https://example.com/test");
10841085
req.set_header(header::USER_AGENT, "Mozilla/5.0 Test Browser");
1085-
req.set_header("X-Synthetic-Trusted-Server", "test-synthetic-id-123");
1086+
req.set_header(HEADER_SYNTHETIC_TRUSTED_SERVER, "test-synthetic-id-123");
10861087
req
10871088
}
10881089

@@ -1171,7 +1172,7 @@ mod tests {
11711172
Method::GET,
11721173
"https://example.com/test?param=value&special=test%20space",
11731174
);
1174-
req.set_header("X-Synthetic-Trusted-Server", "test-id");
1175+
req.set_header(HEADER_SYNTHETIC_TRUSTED_SERVER, "test-id");
11751176

11761177
let gam_req = GamRequest::new(&settings, &req).unwrap();
11771178
let url = gam_req.build_golden_url();
@@ -1215,7 +1216,7 @@ mod tests {
12151216
let settings = create_test_settings();
12161217
let mut req = Request::new(Method::GET, "https://example.com/gam-test");
12171218
req.set_header("X-Consent-Advertising", "true");
1218-
req.set_header("X-Synthetic-Trusted-Server", "test-synthetic-id");
1219+
req.set_header(HEADER_SYNTHETIC_TRUSTED_SERVER, "test-synthetic-id");
12191220

12201221
// Note: This test will fail when actually sending to GAM backend
12211222
// In a real test environment, we'd mock the backend response

crates/common/src/publisher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub fn handle_main_page(
126126
let fresh_id = generate_synthetic_id(settings, &req)?;
127127

128128
// Check for existing Trusted Server ID in this specific order:
129-
// 1. X-Synthetic-Trusted-Server header
129+
// 1. x-psid-ts header
130130
// 2. Cookie
131131
// 3. Fall back to fresh ID
132132
let synthetic_id = get_or_generate_synthetic_id(settings, &req)?;

crates/common/src/synthetic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub fn generate_synthetic_id(
8383
/// Gets or creates a synthetic ID from the request.
8484
///
8585
/// Attempts to retrieve an existing synthetic ID from:
86-
/// 1. The `X-Synthetic-Trusted-Server` header
86+
/// 1. The `x-psid-ts` header
8787
/// 2. The `synthetic_id` cookie
8888
///
8989
/// If neither exists, generates a new synthetic ID.

crates/common/src/templates.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ pub const GAM_TEST_TEMPLATE: &str = r#"
12081208
try {
12091209
const response = await fetch('/');
12101210
const freshId = response.headers.get('X-Synthetic-Fresh');
1211-
const trustedServerId = response.headers.get('X-Synthetic-Trusted-Server');
1211+
const trustedServerId = response.headers.get('x-psid-ts');
12121212
12131213
const statusDiv = document.getElementById('syntheticStatus');
12141214
statusDiv.className = 'status success';
@@ -1280,14 +1280,14 @@ pub const GAM_TEST_TEMPLATE: &str = r#"
12801280
// First get the main page to ensure we have synthetic IDs
12811281
const mainResponse = await fetch('/');
12821282
const freshId = mainResponse.headers.get('X-Synthetic-Fresh');
1283-
const trustedServerId = mainResponse.headers.get('X-Synthetic-Trusted-Server');
1283+
const trustedServerId = mainResponse.headers.get('x-psid-ts');
12841284
12851285
// Now test the GAM request
12861286
const response = await fetch('/gam-test', {
12871287
headers: {
12881288
'X-Consent-Advertising': 'true',
12891289
'X-Synthetic-Fresh': freshId || '',
1290-
'X-Synthetic-Trusted-Server': trustedServerId || ''
1290+
'x-psid-ts': trustedServerId || ''
12911291
}
12921292
});
12931293

crates/js/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ The Rust services (`trusted-server-common`) expose several proxy entry points th
111111

112112
- Endpoint: `handle_publisher_request` (`crates/common/src/publisher.rs`).
113113
- Retrieves or generates the trusted synthetic identifier before Fastly consumes the request body.
114-
- Always stamps the proxied response with `X-Synthetic-Fresh` and `X-Synthetic-Trusted-Server` headers and, when the browser does not already present one, sets the `synthetic_id=<value>` cookie (Secure + SameSite=Lax) bound to the configured publisher domain.
114+
- Always stamps the proxied response with `X-Synthetic-Fresh` and `x-psid-ts` headers and, when the browser does not already present one, sets the `synthetic_id=<value>` cookie (Secure + SameSite=Lax) bound to the configured publisher domain.
115115
- Result: downstream assets fetched through the same first-party origin automatically include the synthetic ID header/cookie so subsequent proxy layers can read it.
116116

117117
### Creative Asset Proxy

0 commit comments

Comments
 (0)