Types

HTTP Methods

The Web2 proxy supports standard HTTP methods through the Web2Method type:

type Web2Method = "GET" | "POST" | "PUT" | "DELETE" | "PATCH"

Request Parameters

When making requests through the proxy, use the IStartProxyParams interface to structure your request:

interface IStartProxyParams {
    url: string                        // Target URL
    method: Web2Method                 // HTTP method to use
    options?: {                        // Optional parameters
        headers?: OutgoingHttpHeaders  // Request headers
        payload?: any                  // Request body (for POST/PUT/PATCH)
        authorization?: string         // Authorization header
    }
}

Response Types

Basic Response

The IWeb2Attestation interface provides verification data for the request:

interface IWeb2Result {
    status: number                    // HTTP status code
    statusText: string                // Status message
    headers: Record<string, string>   // Response headers
    data: any                         // Response body
}

Complete Response

All proxy requests return an IAttestationWithResponse, which combines the HTTP response with its attestation:

interface IAttestationWithResponse extends IWeb2Attestation {
    web2Response: IWeb2Result  // The HTTP response
}

Usage Examples

Handling Responses

const response = await dahr.startProxy({
    url: "https://api.example.com/data",
    method: "GET"
}) as IAttestationWithResponse

// Access HTTP response data
console.log(response.web2Response.status)   // 200
console.log(response.web2Response.data)     // Response body

// Access attestation data
console.log(response.hash)                  // Request hash
console.log(response.timestamp)             // Attestation time
console.log(response.valid)                 // Attestation validity

Type Checking

// Type guard for checking response type
function isAttestationResponse(response: any): response is IAttestationWithResponse {
    return 'web2Response' in response && 'hash' in response && 'valid' in response;
}

Last updated