PHPackages                             sarkhanrasimoghlu/laravel-asanimza - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. sarkhanrasimoghlu/laravel-asanimza

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

sarkhanrasimoghlu/laravel-asanimza
==================================

Laravel package for Asan İmza mobile authentication and digital signing via JSON-RPC 2.0 proxy API

v1.0.0(3mo ago)21MITPHPPHP ^8.3

Since Mar 16Pushed 3mo agoCompare

[ Source](https://github.com/Rasimoghlu/laravel-asanimza)[ Packagist](https://packagist.org/packages/sarkhanrasimoghlu/laravel-asanimza)[ Docs](https://github.com/Rasimoghlu/laravel-asanimza)[ RSS](/packages/sarkhanrasimoghlu-laravel-asanimza/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

Laravel Asan İmza
=================

[](#laravel-asan-i̇mza)

Laravel package for Asan İmza — Azerbaijan's mobile authentication and digital signing system. Communicates with the Asan İmza proxy server via JSON-RPC 2.0 protocol.

Requirements
------------

[](#requirements)

- PHP ^8.3
- Laravel ^12.0
- Asan İmza proxy server running (default: `http://localhost:8090`)

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

[](#installation)

```
composer require sarkhanrasimoghlu/laravel-asanimza
```

Publish the configuration file:

```
php artisan vendor:publish --tag=asanimza-config
```

Configuration
-------------

[](#configuration)

Add the following to your `.env` file:

```
ASANIMZA_BASE_URL=http://localhost:8090
ASANIMZA_SERVICE_NAME=AsanDoc
ASANIMZA_LANGUAGE=aze
ASANIMZA_TIMEOUT=30
ASANIMZA_LOG_ENABLED=true
ASANIMZA_LOG_CHANNEL=stack
```

VariableDefaultDescription`ASANIMZA_BASE_URL``http://localhost:8090`Asan İmza proxy server URL`ASANIMZA_SERVICE_NAME``AsanDoc`Registered service name`ASANIMZA_LANGUAGE``aze`Default language (`aze`, `rus`, `eng`)`ASANIMZA_TIMEOUT``30`HTTP request timeout (seconds)`ASANIMZA_LOG_ENABLED``true`Enable/disable request logging`ASANIMZA_LOG_CHANNEL``stack`Laravel log channelUsage
-----

[](#usage)

Inject `AsanImzaInterface` via constructor or method injection:

```
use Sarkhanrasimoghlu\AsanImza\Contracts\AsanImzaInterface;
```

### Authentication

[](#authentication)

#### Step 1: Start authentication

[](#step-1-start-authentication)

```
public function login(AsanImzaInterface $asanImza)
{
    $result = $asanImza->authenticate('+994501234567', 'userId123');

    // Show verification code to the user
    // $result->verificationCode — user must confirm this on their phone
    // $result->transactionId — needed for status check
    // $result->certificate — needed for status check
    // $result->challenge — needed for status check

    return response()->json([
        'transactionId' => $result->transactionId,
        'verificationCode' => $result->verificationCode,
        'certificate' => $result->certificate,
        'challenge' => $result->challenge,
    ]);
}
```

#### Step 2: Check authentication status (polling)

[](#step-2-check-authentication-status-polling)

```
public function checkAuth(AsanImzaInterface $asanImza, Request $request)
{
    $status = $asanImza->getAuthStatus(
        transactionId: $request->input('transactionId'),
        certificate: $request->input('certificate'),
        challenge: $request->input('challenge'),
    );

    if ($status->status === \Sarkhanrasimoghlu\AsanImza\Enums\AuthStatus::USER_AUTHENTICATED) {
        // Authentication successful
        // $status->signature contains the base64-encoded signature
    }

    return response()->json([
        'status' => $status->status->value,
    ]);
}
```

### Get Certificate Data

[](#get-certificate-data)

Extract user information from a certificate:

```
$certData = $asanImza->getCertificateData($certificate);

$certData->firstName;       // "John"
$certData->surname;         // "Doe"
$certData->personalCode;    // "1234567"
$certData->organizationName; // nullable
$certData->certType;        // CertType enum (AUTHENTICATION, CITIZEN_SIGNING, etc.)
```

### Digital Signing

[](#digital-signing)

#### Step 1: Get signing certificates

[](#step-1-get-signing-certificates)

```
$certs = $asanImza->getSigningCertificates('+994501234567', 'userId123');
// Returns: ['certId1' => 'base64cert1', 'certId2' => 'base64cert2']
```

#### Step 2: Sign files

[](#step-2-sign-files)

```
use Sarkhanrasimoghlu\AsanImza\DTOs\DataFile;

$dataFiles = [
    new DataFile(
        content: base64_encode(file_get_contents('/path/to/document.pdf')),
        fileName: 'document.pdf',
        mimeType: 'application/pdf',
    ),
];

$result = $asanImza->signFiles(
    dataFiles: $dataFiles,
    phoneNumber: '+994501234567',
    userId: 'userId123',
    certIdentifier: 'certId1',
    certificate: $certs['certId1'],
);

// $result->transactionId
// $result->verificationCode — show to user
// $result->hash — needed for status check
// $result->container — needed for status check
```

#### Step 3: Check signing status (polling)

[](#step-3-check-signing-status-polling)

```
$status = $asanImza->getSignFileStatus(
    transactionId: $result->transactionId,
    hash: $result->hash,
    container: $result->container,
    certificate: $certs['certId1'],
);

if ($status->status === \Sarkhanrasimoghlu\AsanImza\Enums\SignStatus::SIGNATURE_CREATED) {
    // $status->container — signed container (base64)
    $signedContent = base64_decode($status->container);
}
```

Error Handling
--------------

[](#error-handling)

All exceptions extend `AsanImzaException`:

```
use Sarkhanrasimoghlu\AsanImza\Exceptions\AsanImzaException;
use Sarkhanrasimoghlu\AsanImza\Exceptions\JsonRpcException;

try {
    $result = $asanImza->authenticate('+994501234567', 'userId123');
} catch (JsonRpcException $e) {
    // JSON-RPC error from Asan İmza proxy
    $e->getErrorCode();    // e.g., 2004
    $e->getErrorMessage(); // e.g., "Unknown phone number"
    $e->getContext();      // ['error_code' => 2004, 'error_message' => '...']
} catch (AsanImzaException $e) {
    // HTTP or parsing error
    $e->getMessage();
    $e->getContext();
}
```

### Common Error Codes

[](#common-error-codes)

CodeDescription1002Service overloaded2004Unknown phone number2013No authentication certificate2017Phone number and user ID are not related2018Authentication certificate is not valid2020No signing certificate2021Signing certificate is not valid2022Forbidden service name-32700JSON-RPC parse error-32600Invalid request-32601Method not foundEnums
-----

[](#enums)

### AuthStatus

[](#authstatus)

ValueDescription`USER_AUTHENTICATED`Authentication successful`OUTSTANDING_TRANSACTION`Waiting for user confirmation`NOT_VALID`Transaction not valid`EXPIRED_TRANSACTION`Transaction expired`USER_CANCEL`User cancelled on phone`MID_NOT_READY`Mobile ID not ready`SENDING_ERROR`Error sending to phone`SIM_ERROR`SIM card error`INTERNAL_ERROR`Internal system error### SignStatus

[](#signstatus)

Same values as AuthStatus, except `USER_AUTHENTICATED` is replaced by `SIGNATURE_CREATED`.

### CertType

[](#certtype)

ValueDescription0Authentication1Citizen signing2Business signing3Governmental signing4Youth personal5Digital stampLicense
-------

[](#license)

MIT

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance81

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

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

Unknown

Total

1

Last Release

102d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/45317065?v=4)[Sarkhan Nasibli](/maintainers/Rasimoghlu)[@Rasimoghlu](https://github.com/Rasimoghlu)

---

Top Contributors

[![Rasimoghlu](https://avatars.githubusercontent.com/u/45317065?v=4)](https://github.com/Rasimoghlu "Rasimoghlu (1 commits)")

---

Tags

laravelAuthenticationazerbaijandigital-signaturee-signatureasan-imzaasanimza

### Embed Badge

![Health badge](/badges/sarkhanrasimoghlu-laravel-asanimza/health.svg)

```
[![Health](https://phpackages.com/badges/sarkhanrasimoghlu-laravel-asanimza/health.svg)](https://phpackages.com/packages/sarkhanrasimoghlu-laravel-asanimza)
```

###  Alternatives

[statamic/cms

The Statamic CMS Core Package

4.8k3.5M920](/packages/statamic-cms)[backpack/crud

Quickly build admin interfaces using Laravel, Bootstrap and JavaScript.

3.4k3.6M217](/packages/backpack-crud)[unopim/unopim

UnoPim Laravel PIM

10.3k2.2k](/packages/unopim-unopim)[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

121242.9k1](/packages/ellaisys-aws-cognito)[mi-lopez/laravel-sso

Simple PHP SSO integration for Laravel

621.1k](/packages/mi-lopez-laravel-sso)[maicol07/laravel-oidc-client

OpenID Connect Client for Laravel

281.3k](/packages/maicol07-laravel-oidc-client)

PHPackages © 2026

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