PHPackages                             mozhuilungdsuo/laravel-cdac-e-hastakshar - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. mozhuilungdsuo/laravel-cdac-e-hastakshar

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

mozhuilungdsuo/laravel-cdac-e-hastakshar
========================================

Laravel package for CDAC e-Hastakshar PDF request and response handling.

v1.0.6(3w ago)077↓85.7%MITPHPPHP ^8.2

Since Jun 9Pushed 3w agoCompare

[ Source](https://github.com/mozhuilungdsuo/laravel-cdac-e-hastakshar)[ Packagist](https://packagist.org/packages/mozhuilungdsuo/laravel-cdac-e-hastakshar)[ RSS](/packages/mozhuilungdsuo-laravel-cdac-e-hastakshar/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (6)Dependencies (22)Versions (7)Used By (0)

Laravel CDAC e-Hastakshar
=========================

[](#laravel-cdac-e-hastakshar)

Laravel package for preparing CDAC e-Hastakshar PDF requests, signing request XML, handling eSign responses, and storing signed PDFs.

This package intentionally does not register routes, controllers, or views. Host applications should implement their own user flow and call the package service.

Installation
------------

[](#installation)

From Packagist:

```
composer require mozhuilungdsuo/laravel-cdac-e-hastakshar
php artisan vendor:publish --tag=cdac-e-hastakshar-config
```

### Install Requirements

[](#install-requirements)

This package requires the PHP Imagick extension because uploaded PDFs/images are converted to page images before the signature placeholder is prepared. It also requires the PHP OpenSSL extension to parse the signer certificate and extract the eSign UID token from successful responses.

Composer will fail with `requires ext-imagick * but it is not present` or `requires ext-openssl * but it is not present` until the extensions are installed for the same PHP binary used by Composer.

On macOS with Homebrew:

```
brew install imagemagick
pecl install imagick
php --ini
php -m | grep -i imagick
php -m | grep -i openssl
```

On Ubuntu/Debian:

```
sudo apt-get update
sudo apt-get install php-imagick
sudo systemctl restart apache2
# or, for PHP-FPM:
sudo systemctl restart php*-fpm
php -m | grep -i imagick
php -m | grep -i openssl
```

If you use a versioned PHP package on Ubuntu/Debian, install the matching extension package:

```
sudo apt-get install php8.3-imagick
# replace 8.3 with your PHP version
```

On RHEL/CentOS/Fedora:

```
sudo dnf install php-pecl-imagick
sudo systemctl restart httpd
php -m | grep -i imagick
php -m | grep -i openssl
```

Confirm PHP can see the extension:

```
php -v
composer -vvv about
php -m | grep imagick
php -m | grep openssl
```

Keys
----

[](#keys)

Private keys and certificates are intentionally not shipped with the package. Add them to the root folder of the app, commonly:

```
keys/
  eSign_Staging_Private.key
```

Configure the path:

```
ESIGN_ASP_ID=your-asp-id
ESIGN_PRIVATE_KEY=keys/eSign_Staging_Private.key
ESIGN_PRIVATE_KEY_PASSPHRASE=
ESIGN_SIGNATURE_PAGES=last
```

`ESIGN_SIGNATURE_PAGES` controls where the visible signer text is placed. Use `last` for the last page only, or `all` for every page.

Usage
-----

[](#usage)

Inject `Mozhuilungdsuo\LaravelCdacEHastakshar\Services\EsignService` in your own controller.

```
use Illuminate\Http\Request;
use Mozhuilungdsuo\LaravelCdacEHastakshar\Services\EsignService;
use RuntimeException;

class EsignController
{
    public function index()
    {
        return view('esign.index');
    }

    public function store(Request $request, EsignService $esign)
    {
        $validated = $request->validate([
            'document' => ['required', 'file', 'mimes:pdf,jpg,jpeg,png', 'max:20480'],
            'signer_name' => ['nullable', 'string', 'max:120'],
            'signature_pages' => ['nullable', 'in:last,all'],
        ]);
        $signerName = $validated['signer_name'] ?? $request->user()?->name;
        $signaturePages = $validated['signature_pages'] ?? null;
        $uidToken = $request->user()?->esign_uid_token;

        $payload = $esign->createRequest($validated['document'], $signerName, $signaturePages, $uidToken);

        // Optional but recommended: persist $payload['transaction_id'] against
        // the current officer/user so the unauthenticated callback can save
        // $result['uid_token'] to the correct account.

        return view('esign.redirect', $payload);
    }

    public function response(Request $request, EsignService $esign)
    {
        $responseXml = (string) $request->input('eSignResponse', '');

        if ($responseXml === '') {
            return view('esign.result', [
                'status' => 'failed',
                'message' => 'The eSign response was empty.',
            ]);
        }

        try {
            $result = $esign->completeResponse($responseXml);
        } catch (RuntimeException $exception) {
            return view('esign.result', [
                'status' => 'failed',
                'message' => $exception->getMessage(),
            ]);
        }

        if ($result['uid_token'] !== null) {
            // Look up the officer/user by $result['transaction_id'] and save
            // this 72-character token for future createRequest() calls.
        }

        if ($result['signer_name'] !== null) {
            // Optional: store or display the signer name from the certificate CN.
        }

        return view('esign.result', [
            'status' => 'completed',
            'transactionId' => $result['transaction_id'],
            'downloadUrl' => route('esign.download', $result['transaction_id']),
        ]);
    }

    public function download(string $transactionId, EsignService $esign)
    {
        return $esign->signedDownloadResponse($transactionId);
    }
}
```

Create `resources/views/esign/index.blade.php` in the host app for the upload form:

```

        {{ __('eSign document') }}

            {{ __('eSign document') }}
            {{ __('Upload a PDF or image to prepare it for CDAC e-Hastakshar.') }}

                @csrf

                    {{ __('Signer name') }}

                @error('signer_name')
                    {{ $message }}
                @enderror

                    {{ __('Signer text pages') }}

                            {{ __('Last page') }}

                            {{ __('All pages') }}

                @error('signature_pages')
                    {{ $message }}
                @enderror

                    {{ __('Document') }}

                @error('document')
                    {{ $message }}
                @enderror

                    {{ __('Start eSign') }}

```

Create `resources/views/esign/redirect.blade.php` in the host app to submit the generated request to CDAC:

```

        {{ __('Redirecting to eSign') }}

                {{ __('Continue to eSign') }}

            document.getElementById('esign-request-form').submit();

```

Create `resources/views/esign/result.blade.php` in the host app for success/failure responses:

```

        {{ __('eSign result') }}

            @if ($status === 'completed')
                {{ __('eSign completed') }}
                {{ __('The signed PDF has been saved and is ready to download.') }}
                {{ __('Transaction') }}: {{ $transactionId }}
                {{ __('Download') }}
            @else
                {{ __('eSign failed') }}
                {{ $message }}
            @endif

```

Example host-app routes:

```
use App\Http\Controllers\EsignController;
use Illuminate\Support\Facades\Route;

Route::get('esign', [EsignController::class, 'index'])->name('esign.index');
Route::post('esign', [EsignController::class, 'store'])->name('esign.store');
Route::post('esign/response', [EsignController::class, 'response'])->name('esign.response');
Route::get('esign/{transactionId}/download', [EsignController::class, 'download'])->name('esign.download');
```

For Laravel's application bootstrap middleware configuration, exclude the callback route from CSRF validation:

```
$middleware->validateCsrfTokens(except: [
    'esign/response',
]);
```

UID Token Reuse
---------------

[](#uid-token-reuse)

For the first eSign by an officer/user, call `createRequest()` without a UID token. The generated request XML will keep `ekycId=""`, so CDAC will perform the normal Aadhaar authentication flow.

After CDAC posts back a successful response, `completeResponse()` returns `uid_token` when it can extract the 72-character token from `UserX509Certificate`. It also returns `signer_name` from the certificate common name (`CN`) when available:

```
$result = $esign->completeResponse($responseXml);

if ($result['uid_token'] !== null) {
    // Save this against the officer/eSign user in your application.
}

if ($result['signer_name'] !== null) {
    // Example: YANGER LONGKUMER
}
```

If you only need to inspect the response certificate and do not need to complete the PDF signing flow, use:

```
$details = $esign->certificateDetailsFromResponse($responseXml);

$details['uid_token'];   // 72-character UID token, or null
$details['signer_name']; // certificate CN, or null
```

For the next eSign by the same officer/user, pass the saved token as the fourth argument:

```
$payload = $esign->createRequest(
    document: $validated['document'],
    signerName: $signerName,
    signaturePages: $signaturePages,
    uidToken: $user->esign_uid_token,
);
```

The package validates supplied UID tokens as exactly 72 characters and places the token in the request XML as `ekycId="..."`.

The response callback is commonly excluded from authentication and CSRF protection, so do not rely on `auth()->user()` inside the callback. Persist the returned `$payload['transaction_id']` before redirecting to CDAC, map it to your officer/user, then use `$result['transaction_id']` in the callback to find the same user and save `$result['uid_token']`.

Dependencies
------------

[](#dependencies)

The package declares its runtime dependencies in `composer.json`, including:

- `robrichards/xmlseclibs`
- `tecnickcom/tc-lib-pdf`
- `tecnickcom/tc-font-mirror`
- `ext-imagick`
- `ext-openssl`

Composer will install those dependencies when this package is installed.

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance95

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

6

Last Release

24d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6372fbb59453de0c379e7e99663f75a624f87ae7136dbe57e857452d8e30fc8b?d=identicon)[mozhui](/maintainers/mozhui)

---

Top Contributors

[![mozhuilungdsuo](https://avatars.githubusercontent.com/u/33083654?v=4)](https://github.com/mozhuilungdsuo "mozhuilungdsuo (15 commits)")

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/mozhuilungdsuo-laravel-cdac-e-hastakshar/health.svg)

```
[![Health](https://phpackages.com/badges/mozhuilungdsuo-laravel-cdac-e-hastakshar/health.svg)](https://phpackages.com/packages/mozhuilungdsuo-laravel-cdac-e-hastakshar)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77922.3M186](/packages/laravel-mcp)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M133](/packages/roots-acorn)[api-platform/laravel

API Platform support for Laravel

58174.6k17](/packages/api-platform-laravel)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M246](/packages/laravel-ai)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
