Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

1.3 KB
Raw Blame
pub mod copy_document;
pub mod delete;
pub mod document_state;
pub mod exists;
pub mod get_raw;
pub mod initialize;
pub mod metadata;
pub mod surface;
pub mod wakeup;

pub(crate) static INTERNAL_ACCESS_HEADER: &str = "x-internal-auth-key";

#[allow(dead_code)]
#[derive(Clone)]
pub struct SyncServiceClient {
    url: String,
    client: reqwest::Client,
}

impl SyncServiceClient {
    pub fn new(internal_auth_key: String, url: String) -> Self {
        let mut headers = reqwest::header::HeaderMap::new();
        headers.insert(INTERNAL_ACCESS_HEADER, internal_auth_key.parse().unwrap());

        let client = {
            let mut builder = reqwest::Client::builder().default_headers(headers);
            if is_local_https(&url) {
                let ca = reqwest::Certificate::from_pem(include_bytes!(
                    "../../../infra/local/certs/ca.pem"
                ))
                .expect("checked-in local CA must be valid PEM");
                builder = builder.add_root_certificate(ca);
            }
            builder.build().unwrap()
        };

        Self { url, client }
    }
}

fn is_local_https(url: &str) -> bool {
    url.starts_with("https://localhost:")
        || url.starts_with("https://localhost/")
        || url == "https://localhost"
        || url.starts_with("https://127.0.0.1:")
        || url.starts_with("https://127.0.0.1/")
}