# Client-gateway

## Client-Gateway

The Client-Gateway is a pre-built Node.js service designed to simplify the On-Demand implementation. It acts as an intermediary between the SDK Client and the client's infrastructure, managing operations like credential creation, import, revoke, and verification.

### Prerequisites

1. **On-Demand Configuration:**
   * Access the dashboard of your account on our API platform.
   * Enable the "On-Demand" mode.
   * Configure the necessary webhook URLs or set the **Client-Gateway** mode.
   * Generate the following keys:
     * `API_KEY`: For secure communication between your infrastructure and our API.
     * `CLIENT_SECRET`: For internal authentication within your infrastructure.
2. **Install Docker:**
   * Ensure Docker is installed on the server where the Gateway will run.

### How to Get Started

1. **Clone or Download the Client-Gateway:**
   * Clone the repository or download the source code from GitHub:

     ```bash
     git clone https://github.com/your-repo/client-gateway.git
     cd client-gateway
     ```
2. **Or Pull the Pre-built Docker Image:**
   * Pull the official Docker image directly from our registry:

     ```bash
     docker pull your-registry/client-gateway:latest
     ```
3. **Run the Gateway with Docker:**
   * Configure the environment variables and start the container:

     ```bash
     docker run -d -p 8080:8080 \
       -e API_BASE_URL=https://api.example.com \
       -e API_KEY=your-api-key \
       -e CLIENT_SECRET=your-client-secret \
       your-registry/client-gateway:latest
     ```
4. **Test the Gateway:**
   * Once the container is running, test the endpoints:

     ```bash
     curl -X POST http://localhost:8080/create \
       -H "Authorization: Bearer your-client-secret" \
       -H "Content-Type: application/json" \
       -d '{"name": "test_credential", "type": "temporary"}'
     ```

### Available Endpoints

The Client-Gateway exposes the following endpoints:

| **Endpoint**  | **HTTP Method** | **Description**                      |
| ------------- | --------------- | ------------------------------------ |
| `/create`     | POST            | Create a new credential.             |
| `/importBulk` | POST            | Import an existing credential.       |
| `/revoke`     | POST            | Revoke an existing credential.       |
| `/verify`     | POST            | Verify the validity of a credential. |

The gateway will also communicate with the central API to log operations and ensure auditability.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wallid.io/certishop-on-prem/client-gateway.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
