Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
84 changes: 84 additions & 0 deletions fixture/client.html.tee.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"mode": "TEE",
"notary_host": "localhost",
"notary_port": 7443,
"notary_ca_cert": "MIIFszCCA5ugAwIBAgIUeXLQmnjeXsHpGji7xA8oJjjw7WwwDQYJKoZIhvcNAQELBQAwaTELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExEjAQBgNVBAcMCVBhbG8gQWx0bzEVMBMGA1UECgwMT3JnYW5pemF0aW9uMRowGAYDVQQDDBFMb2NhbGhvc3QgUm9vdCBDQTAeFw0yNDA2MDcyMjUyNDBaFw0yOTA2MDYyMjUyNDBaMGkxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRIwEAYDVQQHDAlQYWxvIEFsdG8xFTATBgNVBAoMDE9yZ2FuaXphdGlvbjEaMBgGA1UEAwwRTG9jYWxob3N0IFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDIHMEL9gVSxT/J0qS4xDkDZs1d1UG0+z6NFLLsGdV7gu0ZJbDPlNd0kpjWsisVNB7TcqWoq5ROK5CR+6lZxXC8nbqr2YAJ2O8mHIXcYv7msAN3UYxtM6v1M7K+vNMJdDjZVAxcOKq5R7uUDUPw1weePz6eVEjntAW8mUjqkfnCqYml943Ud3724SkI5wyUT9rKS3bk6hvneq1ah/b1zRGDF2gp+T/oNe4ieS/LGoIUluE2csGRXtt542gpJnw5L54JASmGgt6hunUSWtoaht7Qxv6hYpieu4iHqZY1kfcFDjDH2WI16g1YqrWHzk1l7vWNLVDEcK3kdSQ1GmYAij8ZjAi0LJizLwtN//EkfxiOPlV435itK3uugY+etxrk77BeA6PmVcpZeLLXYuKSrzfaBh0ifP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m3ERd7gNRqvYP5GrjCtUIbOTEc=",
"target_method": "GET",
"target_url": "https://en.wikipedia.org/wiki/Claude_Shannon",
"target_headers": {},
"target_body": "",
"max_sent_data": 10000,
"max_recv_data": 10000,
"manifest": {
"manifestVersion": "1",
"id": "wikipedia-claude-shannon",
"title": "Wikipedia Claude Shannon",
"description": "Generate a proof that you have visited the Claude Shannon Wikipedia page",
"prepareUrl": "https://en.wikipedia.org/wiki/Claude_Shannon",
"request": {
"method": "GET",
"version": "HTTP/1.1",
"url": "https://en.wikipedia.org/wiki/Claude_Shannon",
"headers": {}
},
"response": {
"status": "200",
"version": "HTTP/1.1",
"message": "OK",
"headers": {
"Content-Type": "text/html; charset=UTF-8"
},
"body": {
"format": "html",
"extractors": [
{
"id": "pageTitle",
"description": "Extract the page title",
"selector": [
"title"
],
"type": "string",
"predicates": [
{
"type": "value",
"comparison": "contains",
"value": "Claude Shannon"
}
]
},
{
"id": "roles",
"description": "Extract his professional roles",
"selector": [
"div#mw-content-text",
"div.mw-parser-output",
"p",
"a"
],
"type": "array",
"predicates": [
{
"type": "value",
"comparison": "contains",
"value": "mathematician",
"case_sensitive": false
},
{
"type": "value",
"comparison": "contains",
"value": "electrical engineer",
"case_sensitive": false
},
{
"type": "value",
"comparison": "contains",
"value": "cryptographer",
"case_sensitive": false
}
]
}
]
}
}
}
}
92 changes: 0 additions & 92 deletions fixture/client.html.tee_tcp_local.json

This file was deleted.

88 changes: 33 additions & 55 deletions fixture/client.proxy.json → fixture/client.json.proxy.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,40 @@
"notary_port": 7443,
"notary_ca_cert": "MIIFszCCA5ugAwIBAgIUeXLQmnjeXsHpGji7xA8oJjjw7WwwDQYJKoZIhvcNAQELBQAwaTELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExEjAQBgNVBAcMCVBhbG8gQWx0bzEVMBMGA1UECgwMT3JnYW5pemF0aW9uMRowGAYDVQQDDBFMb2NhbGh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FAAOCAgEARliSCLdjNI5fFkNwXDK6k6jN5hITrY07XIawUIEwinjQqgLkYFvzXbMtfLwsWmxMPjDVYYDa5Y2NAGcH08b//2z9EuHxMOTOFTKr59BEcVxV1cxV+lspAunH8DLSlLJhf/EeR+MhIIHAfhlE8V7lvlE1EbM+Uj5JYIeefV/4omsGrphyHD3oSJAQDae0su200I/i2yAaTrwXLZ4HtaXsnxKZ4PMPFWaLvMQ8DsLgx2VB3/vQJn74Xepau6mYEWlRnUu90mj79gJOnwBKPlLojF6dJOMIJ2YHr9fI8sUfkVwPFVlkDKJcr0ll5RL3O/naNlLQZuOgijOM5YF5iTrefliVodEHpBPID2mhtq/E+ZIQWLpik8ulsJ8ufN9YfrbjbsiC/KeoMqoFCImRSyMGQDMADo4EV3DNfDFvfrHx0qBMmJ0nkhuGobphegMPCjZ3axvQwQulKuHXmFpAvGYcpK/twBMC1MJkV04tIwVEDZG6id5oKYtrIXHdSFshf6r3z4bbgq6kJnOxZ8Vo4cEw/dgc3hRivr+HnxOJcEk2CTQlCVOiCQAg64OqDEOoswVg6nzoO3RJhFatu+abO22MIXPNGma02zBoQZLYpGzL9z6pMnPKjL15G9H1SYVSTGhmq+GVtdRibg8rLBciSm3ERd7gNRqvYP5GrjCtUIbOTEc=",
"target_body": "",
"proving": {
"manifest": {
"manifestVersion": "1",
"id": "reddit-user-karma",
"title": "Total Reddit Karma",
"description": "Generate a proof that you have a certain amount of karma",
"prepareUrl": "https://www.reddit.com/login/",
"request": {
"method": "GET",
"version": "HTTP/1.1",
"url": "https://gist.githubusercontent.com/mattes/23e64faadb5fd4b5112f379903d2572e/raw/74e517a60c21a5c11d94fec8b572f68addfade39/example.json",
"headers": {
},
"body": {
"userId": "<% userId %>"
},
"vars": {
"userId": {
"description": "Reddit username",
"required": true,
"pattern": "^[A-Za-z0-9_-]{3,20}$"
},
"authToken": {
"description": "Authentication token",
"required": false,
"default": "abcdef1234567890abcdef1234567890",
"pattern": "^[A-Za-z0-9]{32}$"
}
},
"extra": {
"headers": {
"User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Mobile Safari/537.36",
"Content-Type": "application/json"
}
}
"target_method": "GET",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think we need these now, after the cleanup PR: #515

Copy link
Contributor Author

@piotr-roslaniec piotr-roslaniec Mar 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes are not in anymore, I may have messed-up a rebase. I will address it later.

"target_url": "https://gist.githubusercontent.com/mattes/23e64faadb5fd4b5112f379903d2572e/raw/74e517a60c21a5c11d94fec8b572f68addfade39/example.json",
"target_headers": {},
"manifest": {
"manifestVersion": "1",
"id": "hello-world",
"title": "Hello World example",
"description": "Prove that a gist contains a hello world message",
"prepareUrl": "https://gist.githubusercontent.com/mattes/23e64faadb5fd4b5112f379903d2572e/raw/74e517a60c21a5c11d94fec8b572f68addfade39/example.json",
"request": {
"method": "GET",
"version": "HTTP/1.1",
"url": "https://gist.githubusercontent.com/mattes/23e64faadb5fd4b5112f379903d2572e/raw/74e517a60c21a5c11d94fec8b572f68addfade39/example.json",
"headers": {}
},
"response": {
"status": "200",
"version": "HTTP/1.1",
"message": "OK",
"headers": {
"Content-Type": "text/plain; charset=utf-8"
},
"response": {
"status": "200",
"version": "HTTP/1.1",
"message": "OK",
"headers": {
"Content-Type": "text/plain; charset=utf-8"
},
"body": {
"format": "json",
"extractors": [
{
"id": "helloValue",
"description": "Extract the hello value",
"selector": [
"hello"
],
"type": "string"
}
]
}
"body": {
"format": "json",
"extractors": [
{
"id": "helloValue",
"description": "Extract the hello value",
"selector": [
"hello"
],
"type": "string"
}
]
}
}
}
Expand Down
28 changes: 20 additions & 8 deletions notary/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use axum::{
use reqwest::{Request, Response};
use serde::Deserialize;
use serde_json::Value;
use tracing::info;
use tracing::{debug, info};
use uuid::Uuid;
use web_prover_core::{
hash::keccak_digest,
Expand All @@ -19,10 +19,11 @@ use web_prover_core::{
};

use crate::{
error::NotaryServerError,
error::{NotaryServerError, ProxyError},
verifier::{sign_verification, VerifyOutput},
SharedState,
};

#[derive(Deserialize)]
pub struct NotarizeQuery {
session_id: Uuid,
Expand Down Expand Up @@ -54,7 +55,7 @@ pub async fn proxy(
let request = from_reqwest_request(&reqwest_request);
// debug!("{:?}", request);

let response = from_reqwest_response(reqwest_response).await;
let response = from_reqwest_response(reqwest_response).await?;
// debug!("{:?}", response);

let tee_proof = create_tee_proof(&payload.manifest, &request, &response, State(state))?;
Expand All @@ -64,7 +65,7 @@ pub async fn proxy(

// TODO: This, similarly to other from_* methods, should be a trait
// Requires adding reqwest to proofs crate
async fn from_reqwest_response(response: Response) -> NotaryResponse {
async fn from_reqwest_response(response: Response) -> Result<NotaryResponse, NotaryServerError> {
let status = response.status().as_u16().to_string();
let version = format!("{:?}", response.version());
let message = response.status().canonical_reason().unwrap_or("").to_string();
Expand All @@ -73,8 +74,17 @@ async fn from_reqwest_response(response: Response) -> NotaryResponse {
.iter()
.map(|(k, v)| (capitalize_header(k.as_ref()), v.to_str().unwrap_or("").to_string()))
.collect();
let json = response.json().await.ok();
NotaryResponse {
let body = response
.bytes()
.await
.map_err(|_| {
NotaryServerError::ProxyError(ProxyError::Io(std::io::Error::new(
std::io::ErrorKind::Other,
"Failed to read response body",
)))
})?
.to_vec();
Ok(NotaryResponse {
response: ManifestResponse {
status,
version,
Expand All @@ -83,8 +93,9 @@ async fn from_reqwest_response(response: Response) -> NotaryResponse {
// TODO: This makes me think that perhaps this should be an optional field or something else
body: ManifestResponseBody::default(),
},
notary_response_body: NotaryResponseBody { body: json },
}
// TODO: Should we remove Option<_> on body?
notary_response_body: NotaryResponseBody { body: Some(body) },
})
}

fn from_reqwest_request(request: &Request) -> ManifestRequest {
Expand Down Expand Up @@ -142,6 +153,7 @@ fn validate_notarization_legal(
request: &ManifestRequest,
response: &NotaryResponse,
) -> Result<ManifestValidationResult, NotaryServerError> {
debug!("Validating manifest");
let result = manifest.validate_with(request, response)?;
if !result.is_success() {
info!("Manifest validation failed: {:?}", result.errors());
Expand Down
Loading
Loading