# atproto-client

HTTP client library for AT Protocol services with DPoP authentication support.

## Overview

`atproto-client` provides HTTP client functionality specifically designed for interacting with AT Protocol endpoints. This library handles both basic HTTP operations and DPoP-authenticated requests required for secure AT Protocol communication.

## Binaries

- **atproto-client-auth**: OAuth authentication flow helper
- **atproto-client-app-password**: App password management tool
- **atproto-client-dpop**: DPoP authentication testing tool

## Usage

### Basic HTTP Operations

```rust
use atproto_client::client;
use reqwest::Client;

let http_client = Client::new();
let response = client::get_json(&http_client, "https://api.example.com/data").await?;
```

### DPoP Authentication

```rust
use atproto_client::client::{DPoPAuth, get_dpop_json};
use atproto_identity::key::identify_key;

let dpop_auth = DPoPAuth {
    dpop_private_key_data: identify_key("did:key:zQ3sh...")?,
    oauth_access_token: "your_access_token".to_string(),
};

let response = get_dpop_json(&http_client, &dpop_auth, "https://pds.example.com/xrpc/...").await?;
```

### Repository Operations

```rust
use atproto_client::com::atproto::repo::{create_record, CreateRecordRequest};

let create_request = CreateRecordRequest {
    repo: "did:plc:user123".to_string(),
    collection: "app.bsky.feed.post".to_string(),
    record: json!({"$type": "app.bsky.feed.post", "text": "Hello!"}),
    // ...
};

let response = create_record(&http_client, &dpop_auth, pds_url, create_request).await?;
```

## Command Line Examples

```bash
# Test DPoP authentication
cargo run --bin atproto-client-dpop \
  --private-key did:key:zQ3sh... \
  --access-token token \
  --issuer did:plc:issuer \
  --url https://pds.example.com/xrpc/... \
  --method GET
```

## License

MIT License