> For the complete documentation index, see [llms.txt](https://piramal-swasthya.gitbook.io/uba/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://piramal-swasthya.gitbook.io/uba/toasters/provider-toaster/developer-guide/backend-guide/strapi-provider-mw.md).

# Strapi Provider MW

The UBI Strapi Provider Middleware is a NestJS-based backend service that processes benefit applications through the UBI / ONEST Network.

### Core Features <a href="#core-features" id="core-features"></a>

**Application Management**: Lists and manages benefit applications from Strapi CMS

**Document Verification**: Verifies uploaded application documents using Verification SDK

**VC Verification**: Validates Verifiable Credentials (VCs) for authenticity

**Eligibility Checks**: Performs eligibility verification using Eligibility SDK

**Application Processing**: Approves or rejects benefit applications

**UBI / ONEST Network Protocol**: Implements UBI / ONEST Network provider standards

### System Context <a href="#system-context" id="system-context"></a>

This service connects:

* Strapi CMS (benefits catalog management)
* Verification SDK (verifies VCs and documents)
* Eligibility SDK (performs eligibility checks)
* UBI / ONEST Network (standardized benefit discovery)
* Consumer Applications (end-user interfaces)

### Technology Stack <a href="#technology-stack" id="technology-stack"></a>

**Runtime**: Node.js 20+

**Framework**: NestJS (TypeScript)

**Database**: PostgreSQL with Prisma ORM

**Authentication**: JWT tokens

**File Storage**: Local filesystem or AWS S3

**API Documentation**: Swagger/OpenAPI

### Security Features <a href="#security-features" id="security-features"></a>

**JWT authentication** with role-based access

**Data encryption** with configurable keys

**Input validation** and sanitization

**Secure file upload** handling

**Audit logging** for application changes

#### Data Encryption <a href="#data-encryption" id="data-encryption"></a>

**Algorithm**: AES-256-GCM (Advanced Encryption Standard with Galois/Counter Mode)

**Key Specifications**:

* Key Size: 256-bit (32 bytes)
* IV Length: 12 bytes (recommended for AES-GCM)
* Authentication: Built-in authentication tag (16 bytes)
* Encoding: Base64 for storage and transmission

**Encrypted Data**:

* `Applications.applicationData` field containing:
  * Applicant personal details (name, age, income)
  * Bank account information
  * Sensitive identifiers
  * Disability type information
  * Custom application form data

**Key Management**:

* Environment variable based: `ENCRYPTION_KEY` (current), `OLD_ENCRYPTION_KEY` (for rotation)
* Supports seamless key rotation with fallback mechanism
* Keys must be base64-encoded 32-byte strings

**Implementation**:

* Transparent encryption/decryption via Prisma middleware
* Automatic JSON parsing for `applicationData` field
* Random IV generation for each encryption operation
* Authenticated encryption prevents data tampering

**Key Rotation Support**:

* Dedicated script: `scripts/rotate-encryption-key.ts`
* Batch processing with configurable batch sizes
* Graceful fallback during rotation periods


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://piramal-swasthya.gitbook.io/uba/toasters/provider-toaster/developer-guide/backend-guide/strapi-provider-mw.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
