Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
34d4796
Moved handlers to separate files
aram356 Jul 9, 2025
8870004
Fixed formatting
aram356 Jul 9, 2025
9fcb0e0
Initalize logger with formatting
aram356 Jul 9, 2025
67ce18b
Use env variables during build
aram356 Jul 9, 2025
433554c
Fixed clippy
aram356 Jul 9, 2025
21b03f1
Use updated depedencies
aram356 Jul 9, 2025
b0001ef
Proxy publisher content
aram356 Jul 9, 2025
d4618ef
Fixed Cargo.lock
aram356 Jul 10, 2025
0540e07
Fixed warning
aram356 Jul 10, 2025
f9f8eb1
Replace origin host
aram356 Jul 10, 2025
ce4a890
Implemented stream replacer
aram356 Jul 10, 2025
212bc8d
Fixed streaming
aram356 Jul 10, 2025
2cfb096
Detect TLS connection
aram356 Jul 15, 2025
9f7bcbf
Merge branch 'main' into feature/move-handlers
aram356 Jul 15, 2025
feb896c
Merge branch 'feature/move-handlers' into feature/init-logger
aram356 Jul 15, 2025
eeecaa0
Merge branch 'feature/init-logger' into feature/use-env-vars-during-b…
aram356 Jul 15, 2025
04d763d
Merge branch 'feature/use-env-vars-during-build' into feature/publish…
aram356 Jul 15, 2025
9862ec6
Updated packages
aram356 Jul 15, 2025
4c42783
Removed unnecessary files
aram356 Jul 16, 2025
1fd1fcc
Output logs to stdout
aram356 Jul 17, 2025
b589d41
Output logs to stdout
aram356 Jul 17, 2025
f7c73e5
Merge branch 'feature/init-logger' into feature/use-env-vars-during-b…
aram356 Jul 17, 2025
381471c
Merge branch 'feature/use-env-vars-during-build' into feature/publish…
aram356 Jul 17, 2025
94b80e0
Merge branch 'main' into feature/publisher-proxy
aram356 Jul 18, 2025
4247e30
Simplify streaming replacer logic
aram356 Jul 22, 2025
ee471e2
Proxy to prebid server
aram356 Aug 5, 2025
20d7da8
Merge branch 'main' into feature/publisher-proxy
aram356 Aug 7, 2025
ae93b43
Fixed formatting
aram356 Aug 11, 2025
61bfcfe
Added flag for enable edge pubs
aram356 Aug 11, 2025
7923fc8
Merge branch 'feature/publisher-proxy' into feature/proxy-to-prebidse…
aram356 Aug 11, 2025
0bf3ee7
Added loggin
aram356 Aug 13, 2025
3a8c21c
Changed to handle srcset
aram356 Aug 13, 2025
d4841b8
Removed unnecessary files
aram356 Aug 13, 2025
a5e3f04
Loggin prebidjs detection
aram356 Aug 13, 2025
cb90ca8
Improved parsing
aram356 Aug 15, 2025
ff91bc3
Debug console
aram356 Aug 15, 2025
ff764fd
More debugging
aram356 Aug 15, 2025
23ab57b
More debugging
aram356 Aug 15, 2025
1e77d45
More debugging
aram356 Aug 15, 2025
478e82b
Fixed streaming processor
aram356 Aug 15, 2025
3ceaa50
More debuggin
aram356 Aug 15, 2025
f3861c3
Refactored tests
aram356 Aug 16, 2025
e8cf823
Fixed html processor
aram356 Aug 16, 2025
bcca909
Append prebid in the beggining
aram356 Aug 16, 2025
18e5c8c
Fixed prebidjs insertion
aram356 Aug 16, 2025
2921a54
Disable prebidjs insertion
aram356 Aug 16, 2025
58cc6d9
Fixed issue with Prebid integration by serving Prebid.js via a dedica…
aram356 Sep 5, 2025
a40f3cc
Simplify prebidjs shim
aram356 Sep 5, 2025
96a999a
Fixed parsing bidders from environment variable.
aram356 Sep 5, 2025
0ed3b6a
Fixed detected prebidjs
aram356 Sep 5, 2025
68562d7
Fixed formatting
aram356 Sep 5, 2025
d48521f
Used handlebars for tempalates
aram356 Sep 8, 2025
3d589e6
Added js crate
aram356 Sep 9, 2025
248dac3
Restrucuted JS library
aram356 Sep 10, 2025
9d1fd04
Render result in iframe
aram356 Sep 10, 2025
ee8e887
Renamed to lib directory and added Prebid integration
aram356 Sep 10, 2025
4a7617e
Added proxy for ad
aram356 Sep 11, 2025
0353c00
Added sequence diagram
aram356 Sep 11, 2025
e6d37e4
Removed cookie sync
aram356 Sep 11, 2025
3bc5c15
Fixed SEQUENCE.md styling
aram356 Sep 11, 2025
40cb63e
Formatting
aram356 Sep 11, 2025
57e63cb
Clarified text resources
aram356 Sep 11, 2025
6843977
Fixed proxying click tracking
aram356 Sep 16, 2025
9f98484
Added test and format for Typescrcipt library
aram356 Sep 16, 2025
b396e48
Fixed copying headers from backend response to client response.
aram356 Sep 16, 2025
5911a63
Fixed working directory for finding Node version
aram356 Sep 16, 2025
39680fb
Updated node packages and linting workflow
aram356 Sep 16, 2025
d7ac23c
Added test for JS library
aram356 Sep 16, 2025
48bd83a
Added synthetic trusted server ID header and cookies to publisher pro…
aram356 Sep 23, 2025
973c2c1
Changed to pass synthetic ID
aram356 Sep 23, 2025
47dd910
Added logging for synthetic ID handling in proxy mode; updated .env.d…
aram356 Sep 23, 2025
60c5716
Updated to respect redirects
aram356 Sep 30, 2025
e9fef10
Fixed lint errors
aram356 Sep 30, 2025
00c4677
Enable click guard by default
aram356 Sep 30, 2025
30511d8
Fixed viceroy installation
aram356 Sep 30, 2025
550fb32
Organized dependencies and updated Rust version to 1.90.0.
aram356 Sep 30, 2025
e147d4e
Added changelog
aram356 Sep 30, 2025
ce94276
Updated CHANGELOG
aram356 Oct 7, 2025
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
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# [ad_server]
TRUSTED_SERVER__AD_SERVER__AD_PARTNER_URL=http://127.0.0.1:10180

# [publisher]
TRUSTED_SERVER__PUBLISHER__ORIGIN_URL=http://localhost:9090

# [synthetic]
TRUSTED_SERVER__SYNTHETIC__COUNTER_STORE=counter_store
TRUSTED_SERVER__SYNTHETIC__OPID_STORE=opid_store
33 changes: 31 additions & 2 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ on:
pull_request:
branches: [main]

# Check formatting with rustfmt
jobs:
format:
format-rust:
name: cargo fmt
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -45,3 +44,33 @@ jobs:
- name: Run cargo clipply
run: cargo clippy --all-targets --all-features

format-typescript:
runs-on: ubuntu-latest
defaults:
run:
working-directory: crates/js/lib

steps:
- uses: actions/checkout@v4

- name: Retrieve Node.js version
id: node-version
working-directory: .
run: echo "node-version=$(grep '^nodejs ' .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT
shell: bash

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ steps.node-version.outputs.node-version }}
cache: 'npm'
cache-dependency-path: crates/js/lib/package.json

- name: Install dependencies
run: npm ci

- name: Run ESLint
run: npm run lint

- name: Run Prettier (check)
run: npm run format
37 changes: 34 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [main]

jobs:
test:
test-rust:
name: cargo test
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -37,8 +37,39 @@ jobs:
- name: Add wasm32-wasi target
run: rustup target add wasm32-wasip1

- name: Setup Viceroy
run: cargo install viceroy
- name: Setup Viceroy (from main since 0.14.3 is broken)
run: cargo install --git https://github.com/fastly/Viceroy viceroy

- name: Run tests
run: cargo test

test-typescript:
name: vitest
runs-on: ubuntu-latest
defaults:
run:
working-directory: crates/js/lib
steps:
- uses: actions/checkout@v4

- name: Retrieve Node.js version
id: node-version
working-directory: .
run: echo "node-version=$(grep '^nodejs ' .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT
shell: bash

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ steps.node-version.outputs.node-version }}
cache: 'npm'
cache-dependency-path: crates/js/lib/package.json

- name: Install dependencies
run: npm ci

- name: Build bundle
run: npm run build

- name: Run unit tests
run: npm test -- --run
5 changes: 3 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
fasltly 11.3.0
rust 1.87.0
fasltly 12.0.0
rust 1.90.0
nodejs 24.7.0
117 changes: 117 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# AGENTS.md

Centralized guidelines for AI coding agents working in this repository. Review the
common setup steps before executing tasks, then follow any assistant-specific
instructions.

## Common Setup

- Always read the full coding standards at the start of a session:

```bash
cat .agents/rules/*
```

- Use `cargo fmt`, `cargo clippy`, and `cargo test` where appropriate before
delivering code changes.
- When work touches Fastly behavior or runtime configuration, review
`fastly.toml`, `trusted-server.toml`, and `.env.dev`.

## Claude Code

This section consolidates the guidance previously stored in `CLAUDE.md` for
Claude Code (claude.ai/code).

### Project Overview

Rust-based edge computing application targeting Fastly Compute. Handles
privacy-preserving synthetic ID generation, ad serving with GDPR compliance, and
real-time bidding integration.

### Key Commands

#### Build & Development

```bash
# Standard build
cargo build

# Production build for Fastly
cargo build --bin trusted-server-fastly --release --target wasm32-wasip1

# Run locally with Fastly simulator
fastly compute serve

# Deploy to Fastly
fastly compute publish
```

#### Testing & Quality

```bash
# Run tests (requires viceroy)
cargo test

# Install test runtime if needed
cargo install viceroy

# Format code
cargo fmt

# Lint with clippy
cargo clippy --all-targets --all-features

# Check compilation
cargo check
```

### Architecture Overview

#### Workspace Structure

- **trusted-server-common**: Core library with shared functionality
- Synthetic ID generation (`src/synthetic.rs`)
- Cookie handling (`src/cookies.rs`)
- HTTP abstractions (`src/http_wrapper.rs`)
- GDPR consent management (`src/gdpr.rs`)
- **trusted-server-fastly**: Fastly-specific implementation
- Main application entry point
- Fastly SDK integration
- Request/response handling

### Key Design Patterns

1. **RequestWrapper Trait**: Abstracts HTTP request handling to support different
backends.
2. **Settings-Driven Config**: External configuration via `trusted-server.toml`.
3. **Privacy-First**: All tracking requires GDPR consent checks.
4. **HMAC-Based IDs**: Synthetic IDs generated using HMAC with configurable templates.

### Configuration Files

- `fastly.toml`: Fastly service configuration and build settings.
- `trusted-server.toml`: Application settings (ad servers, KV stores, ID templates).
- `rust-toolchain.toml`: Pins Rust version to 1.90.0.

### Key Functionality Areas

1. Synthetic ID generation using HMAC-based templates.
2. Ad serving integrations (currently Equativ).
3. GDPR consent handling and validation.
4. Geolocation utilities (DMA code extraction).
5. Prebid integration for real-time bidding flows.
6. KV store usage for counters and domain mappings.

### Testing Approach

- Unit tests reside alongside source files under `#[cfg(test)]` modules.
- Uses Viceroy for local Fastly Compute simulation.
- GitHub Actions CI runs format and test workflows.

### Important Notes

- Target platform is WebAssembly (`wasm32-wasip1`).
- Relies on Fastly KV stores for persistence.
- Uses Handlebars templates for dynamic responses.
- Emits detailed logs for edge debugging.
- Follow conventional commit format (see `CONTRIBUTING.md`).
36 changes: 9 additions & 27 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added
- for new features

### Changed
- for changes in existing functionality

### Deprecated
- for soon-to-be removed features.

### Removed
- for now removed features

### Fixed
- for any bug fixes

### Security
- in case of vulnerabilities

## [Unreleased]
## [1.1.0] - 2025-10-05

### Added
- Added basic unit tests
Expand All @@ -36,20 +16,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add more complete e2e GAM (Google Ad Manager) integration with request construction and ad serving capabilities
- Add new partners.rs module for partner-specific configurations
- Created comprehensive publisher IDs audit document identifying hardcoded values
- Enabled first-party ad endpoints that rewrite creatives in first party domain
- Added first-party end point to proxy Prebid auctions
- Added Trusted Server TSJS SDK with bundled build, lint, and test tools for serving creatives in first-party domain

### Changed
- Upgrade to rust 1.87.0
- Upgrade to fastly-cli 11.3.0
- Upgrade to rust 1.90.0
- Upgrade to fastly-cli 12.0.0
- Changed to use constants for headers
- Changed to use log statements
- Updated fastly.toml for local development
- Changed to propagate server errors as HTTP errors
- Reworked Fastly routing so first-party endpoints and synthetic cookies stay in sync
- Added TypeScript CI lint, format, and test jobs for TSJS

### Fixed
- Rebuild when `TRUSTED_SERVER__*` env variables change

### Fixed
- Rebuild when `TRUSTED_SERVER__*` env variables change
- Rebuild when `TRUSTED_SERVER__*` env variables change

## [1.0.6] - 2025-05-29

Expand Down
106 changes: 2 additions & 104 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,106 +1,4 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

This is a Rust-based edge computing application designed for Fastly Compute. It handles privacy-preserving synthetic ID generation, ad serving with GDPR compliance, and real-time bidding integration.

## Key Commands

### Build & Development
```bash
# Standard build
cargo build

# Production build for Fastly
cargo build --bin trusted-server-fastly --release --target wasm32-wasip1

# Run locally with Fastly simulator
fastly compute serve

# Deploy to Fastly
fastly compute publish
```

### Testing & Quality
```bash
# Run tests (requires viceroy)
cargo test

# Install test runtime if needed
cargo install viceroy

# Format code
cargo fmt

# Lint with clippy
cargo clippy --all-targets --all-features

# Check compilation
cargo check
```

## Architecture Overview

### Workspace Structure
- **trusted-server-common**: Core library with shared functionality
- Synthetic ID generation (`src/synthetic.rs`)
- Cookie handling (`src/cookies.rs`)
- HTTP abstractions (`src/http_wrapper.rs`)
- GDPR consent management (`src/gdpr.rs`)

- **trusted-server-fastly**: Fastly-specific implementation
- Main application entry point
- Fastly SDK integration
- Request/response handling

### Key Design Patterns
1. **RequestWrapper Trait**: Abstracts HTTP request handling to support different backends
2. **Settings-Driven Config**: External configuration via `trusted-server.toml`
3. **Privacy-First**: All tracking requires GDPR consent checks
4. **HMAC-Based IDs**: Synthetic IDs generated using HMAC with configurable templates

### Configuration Files
- `fastly.toml`: Fastly service configuration and build settings
- `trusted-server.toml`: Application settings (ad servers, KV stores, ID templates)
- `rust-toolchain.toml`: Pins Rust version to 1.87.0

### Key Functionality Areas
1. **Synthetic ID Generation**: Privacy-preserving user identification using HMAC
2. **Ad Serving**: Integration with ad partners (currently Equativ)
3. **GDPR Compliance**: Consent management via TCF strings
4. **Geolocation**: DMA code extraction for targeted advertising
5. **Prebid Integration**: Real-time bidding support
6. **KV Store Usage**: Persistent storage for counters and domain mappings

### Testing Approach
- Unit tests embedded in source files using `#[cfg(test)]` modules
- Uses Viceroy for local Fastly Compute simulation
- GitHub Actions CI with test and format workflows

### Important Notes
- Target platform is WebAssembly (wasm32-wasip1)
- Uses Fastly KV stores for persistence
- Handlebars templating for dynamic responses
- Comprehensive logging for edge debugging
- Follow conventional commits format (see CONTRIBUTING.md)

## Coding Standards Reference

**IMPORTANT: I must ALWAYS read the full coding standards at the beginning of EACH session using this command:**

```bash
cat .cursor/rules/*
```

The rules in `.cursor/rules/*` contain detailed guidelines for:

- Git commit conventions
- Rust coding style (type system, async patterns, function arguments, etc.)
- Documentation practices (structure, links, error documentation, etc.)
- Error handling with error-stack
- Testing strategy and assertions
- Tracing and instrumentation

These full guidelines contain critical nuances and details that cannot be summarized. Reading the complete rules is essential for ensuring code quality and consistency.
Guidance for Claude Code has moved to `AGENTS.md`. Keep this stub for tooling that
still expects `CLAUDE.md`, but refer to `AGENTS.md` for the canonical instructions.
Loading