├── .styleci.yml ├── CHANGELOG.md ├── config └── e-sign-bsre.php ├── .gitignore ├── src ├── Facades │ └── ESignBSrE.php ├── ESignBSreResponse.php ├── ESignBSrE.php └── Providers │ └── ESignBSrEServiceProvider.php ├── LICENSE.md ├── composer.json ├── .github └── workflows │ └── main.yml ├── CONTRIBUTING.md └── README.md /.styleci.yml: -------------------------------------------------------------------------------- 1 | preset: laravel 2 | 3 | disabled: 4 | - single_class_element_per_statement 5 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `e-sign-bsre` will be documented in this file 4 | 5 | ## 1.0.0 - 201X-XX-XX 6 | 7 | - initial release 8 | -------------------------------------------------------------------------------- /config/e-sign-bsre.php: -------------------------------------------------------------------------------- 1 | env('TTE_URL'), 5 | 'username' => env('TTE_USERNAME'), 6 | 'password' => env('TTE_PASSWORD'), 7 | ]; 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public/build 3 | /public/hot 4 | /public/storage 5 | /storage/*.key 6 | /vendor 7 | .env 8 | .env.backup 9 | /.vscode 10 | auth.json 11 | .idea/ 12 | -------------------------------------------------------------------------------- /src/Facades/ESignBSrE.php: -------------------------------------------------------------------------------- 1 | response = $response; 18 | 19 | $this->setStatus(); 20 | $this->setErrors(); 21 | $this->setData(); 22 | } 23 | 24 | private function setStatus(): void 25 | { 26 | $this->status = $this->response->status(); 27 | } 28 | 29 | /** 30 | * @return mixed 31 | */ 32 | public function getStatus(): int 33 | { 34 | return $this->status; 35 | } 36 | 37 | /** 38 | * @param mixed $errors 39 | */ 40 | public function setErrors(): void 41 | { 42 | if ($this->status != self::STATUS_OK){ 43 | $this->errors = json_decode($this->response->body())->error; 44 | } 45 | } 46 | 47 | /** 48 | * @return mixed 49 | */ 50 | public function getErrors() 51 | { 52 | return $this->errors; 53 | } 54 | 55 | /** 56 | * @param mixed $data 57 | */ 58 | public function setData(): void 59 | { 60 | if ($this->status == self::STATUS_OK){ 61 | $this->data = $this->response->body(); 62 | } 63 | } 64 | 65 | /** 66 | * @return mixed 67 | */ 68 | public function getData() 69 | { 70 | return $this->data; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/ESignBSrE.php: -------------------------------------------------------------------------------- 1 | nik = $nik; 22 | 23 | $this->url = config('e-sign-bsre.url'); 24 | $this->http = Http::withBasicAuth($username, $password); 25 | } 26 | 27 | public function setNIK($nik): ESignBSrE { 28 | $this->nik = $nik; 29 | 30 | return $this; 31 | } 32 | 33 | public function signInvisible($nik, $passphrase, $file, $fileName) { 34 | $response = $this->http->attach( 35 | 'file', 36 | $file, 37 | $fileName) 38 | ->post($this->url . 'api/sign/pdf', [ 39 | 'nik' => $nik, 40 | 'passphrase' => $passphrase, 41 | 'tampilan' => 'invisible', 42 | ]); 43 | 44 | return new ESignBSreResponse($response); 45 | } 46 | 47 | public function signVerification($file, $fileName){ 48 | $response = $this->http->attach( 49 | 'signed_file', 50 | $file, 51 | $fileName) 52 | ->post($this->url . 'api/sign/verify'); 53 | 54 | return new ESignBSreResponse($response); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "diskominfotik-banda-aceh/e-sign-bsre-laravel", 3 | "description": "Layanan tanda tangan elektronik", 4 | "keywords": [ 5 | "diskominfotik-banda-aceh", 6 | "e-sign-bsre-laravel" 7 | ], 8 | "homepage": "https://github.com/diskominfotik-banda-aceh/e-sign-bsre-laravel", 9 | "license": "MIT", 10 | "type": "library", 11 | "authors": [ 12 | { 13 | "name": "Diskominfotik Banda Aceh", 14 | "email": "diskominfotikbna@gmail.com", 15 | "role": "Company" 16 | } 17 | ], 18 | "require": { 19 | "php": "^7.4|^8.0", 20 | "illuminate/support": "^8.0" 21 | }, 22 | "require-dev": { 23 | "orchestra/testbench": "^6.0", 24 | "phpunit/phpunit": "^9.0" 25 | }, 26 | "autoload": { 27 | "psr-4": { 28 | "DiskominfotikBandaAceh\\ESignBSrE\\": "src" 29 | } 30 | }, 31 | "autoload-dev": { 32 | "psr-4": { 33 | "DiskominfotikBandaAceh\\ESignBSrE\\Tests\\": "tests" 34 | } 35 | }, 36 | "scripts": { 37 | "test": "vendor/bin/phpunit", 38 | "test-coverage": "vendor/bin/phpunit --coverage-html coverage" 39 | 40 | }, 41 | "config": { 42 | "sort-packages": true 43 | }, 44 | "extra": { 45 | "laravel": { 46 | "providers": [ 47 | "DiskominfotikBandaAceh\\ESignBSrE\\Providers\\ESignBSrEServiceProvider" 48 | ], 49 | "aliases": { 50 | "ESignBSrE": "DiskominfotikBandaAceh\\ESignBSrE\\Facades\\EsignBSre" 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: run-tests 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | pull_request: 7 | branches: [master] 8 | 9 | jobs: 10 | test: 11 | runs-on: ${{ matrix.os }} 12 | strategy: 13 | fail-fast: true 14 | matrix: 15 | os: [ubuntu-latest, windows-latest] 16 | php: [7.4, 8.0] 17 | laravel: [8.*] 18 | stability: [prefer-lowest, prefer-stable] 19 | include: 20 | - laravel: 8.* 21 | testbench: ^6.6 22 | 23 | name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} 24 | 25 | steps: 26 | - name: Checkout code 27 | uses: actions/checkout@v2 28 | 29 | - name: Setup PHP 30 | uses: shivammathur/setup-php@v2 31 | with: 32 | php-version: ${{ matrix.php }} 33 | extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo 34 | coverage: none 35 | 36 | - name: Setup problem matchers 37 | run: | 38 | echo "::add-matcher::${{ runner.tool_cache }}/php.json" 39 | echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" 40 | - name: Install dependencies 41 | run: | 42 | composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update 43 | composer update --${{ matrix.stability }} --prefer-dist --no-interaction 44 | - name: Execute tests 45 | run: vendor/bin/phpunit 46 | -------------------------------------------------------------------------------- /src/Providers/ESignBSrEServiceProvider.php: -------------------------------------------------------------------------------- 1 | loadTranslationsFrom(__DIR__.'/../resources/lang', 'e-sign-bsre'); 19 | // $this->loadViewsFrom(__DIR__.'/../resources/views', 'e-sign-bsre'); 20 | // $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); 21 | // $this->loadRoutesFrom(__DIR__.'/routes.php'); 22 | 23 | if ($this->app->runningInConsole()) { 24 | $this->publishes([ 25 | __DIR__.'/../../config/e-sign-bsre.php' => config_path('e-sign-bsre.php'), 26 | ], 'config'); 27 | 28 | // Publishing the views. 29 | /*$this->publishes([ 30 | __DIR__.'/../resources/views' => resource_path('views/vendor/e-sign-bsre'), 31 | ], 'views');*/ 32 | 33 | // Publishing assets. 34 | /*$this->publishes([ 35 | __DIR__.'/../resources/assets' => public_path('vendor/e-sign-bsre'), 36 | ], 'assets');*/ 37 | 38 | // Publishing the translation files. 39 | /*$this->publishes([ 40 | __DIR__.'/../resources/lang' => resource_path('lang/vendor/e-sign-bsre'), 41 | ], 'lang');*/ 42 | 43 | // Registering package commands. 44 | // $this->commands([]); 45 | } 46 | } 47 | 48 | /** 49 | * Register the application services. 50 | */ 51 | public function register() 52 | { 53 | // Automatically apply the package configuration 54 | $this->mergeConfigFrom(__DIR__.'/../../config/e-sign-bsre.php', 'e-sign-bsre'); 55 | 56 | // Register the main class to use with the facade 57 | $this->app->singleton('e-sign-bsre', function () { 58 | return new ESignBSrE; 59 | }); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | Please read and understand the contribution guide before creating an issue or pull request. 6 | 7 | ## Etiquette 8 | 9 | This project is open source, and as such, the maintainers give their free time to build and maintain the source code 10 | held within. They make the code freely available in the hope that it will be of use to other developers. It would be 11 | extremely unfair for them to suffer abuse or anger for their hard work. 12 | 13 | Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the 14 | world that developers are civilized and selfless people. 15 | 16 | It's the duty of the maintainer to ensure that all submissions to the project are of sufficient 17 | quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. 18 | 19 | ## Viability 20 | 21 | When requesting or submitting new features, first consider whether it might be useful to others. Open 22 | source projects are used by many developers, who may have entirely different needs to your own. Think about 23 | whether or not your feature is likely to be used by other users of the project. 24 | 25 | ## Procedure 26 | 27 | Before filing an issue: 28 | 29 | - Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. 30 | - Check to make sure your feature suggestion isn't already present within the project. 31 | - Check the pull requests tab to ensure that the bug doesn't have a fix in progress. 32 | - Check the pull requests tab to ensure that the feature isn't already in progress. 33 | 34 | Before submitting a pull request: 35 | 36 | - Check the codebase to ensure that your feature doesn't already exist. 37 | - Check the pull requests to ensure that another person hasn't already submitted the feature or fix. 38 | 39 | ## Requirements 40 | 41 | If the project maintainer has any additional requirements, you will find them listed here. 42 | 43 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer). 44 | 45 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 46 | 47 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 48 | 49 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. 50 | 51 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 52 | 53 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 54 | 55 | **Happy coding**! 56 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Table of contents 2 | ================= 3 | 4 | * [Table of contents](#table-of-contents) 5 | * [E-Sign BSrE](#e-sign-bsre) 6 | * [Instalisasi](#instalisasi) 7 | * [Penggunaan](#penggunaan) 8 | * [Konfigurasi](#konfigurasi) 9 | * [Kode](#kode) 10 | * [Changelog](#changelog) 11 | * [Contributing](#contributing) 12 | * [Keamanan](#keamanan) 13 | * [Credits](#credits) 14 | * [License](#license) 15 | 16 | 17 | # E-Sign BSrE 18 | 19 | [![Latest Version on Packagist](https://img.shields.io/packagist/v/diskominfotik-banda-aceh/e-sign-bsre-laravel.svg?style=flat-square)](https://packagist.org/packages/diskominfotik-banda-aceh/e-sign-bsre-laravel) 20 | [![Total Downloads](https://img.shields.io/packagist/dt/diskominfotik-banda-aceh/e-sign-bsre-laravel.svg?style=flat-square)](https://packagist.org/packages/diskominfotik-banda-aceh/e-sign-bsre-laravel) 21 | 22 | 23 | [E-Sign BSrE](https://bsre.bssn.go.id/) adalah package untuk memudahkan penggunaan API E-Sign dari BSSN dengan bahasa PHP. Package ini digunakan untuk framework Laravel. 24 | 25 | ## Instalisasi 26 | 27 | Anda bisa install package via composer: 28 | 29 | ```bash 30 | composer require diskominfotik-banda-aceh/e-sign-bsre-laravel 31 | ``` 32 | 33 | ## Penggunaan 34 | 35 | ### Konfigurasi 36 | Copy dan paste konfigurasi ini ke dalam file `.env` 37 | ```php 38 | TTE_URL="esign.example.go.id" 39 | TTE_USERNAME="username" 40 | TTE_PASSWORD="password" 41 | ``` 42 | 43 | ### Kode 44 | Kode yang disediakan ada beberapa yaitu tanda tangan digital invisible, verifikasi tanda tangan digital dan tanda tangan visible (soon) 45 | 46 | - **Tanda tangan digital invisible** 47 | ```php 48 | $esign = ESignBSrE::signInvisible($nik, $passphrase, $file, $filename); 49 | $esign->getStatus(); //Get status response (int) 50 | $esign->getErrors(); //Get error response 51 | $esign->getData(); //Get data as blob pdf 52 | ``` 53 | 54 | - **Verifikasi tanda tangan digital** 55 | ```php 56 | $esign = ESignBSrE::signVerification($file, $fileName); 57 | $esign->getStatus(); //Get status response (int) 58 | $esign->getErrors(); //Get error response 59 | $esign->getData(); //Get data as array (tergantung dari API BSrE) 60 | ``` 61 | 62 | - **Tanda tangan digital visible** 63 | ```php 64 | //Soon 65 | ``` 66 | 67 | 73 | 74 | ### Changelog 75 | 76 | Lihat [CHANGELOG](CHANGELOG.md) untuk informasi lebih lanjut terkait perubahan terbaru. 77 | 78 | ## Contributing 79 | 80 | Lihat [CONTRIBUTING](CONTRIBUTING.md) untuk lebih detailnya. 81 | 82 | ### Keamanan 83 | 84 | Jika anda menemukan masalah kerentanan keamanan pada package, tolong email ke diskominfotikbna[at]gmail.com 85 | 86 | ## Credits 87 | 88 | - [Maulidan Nashuha](https://github.com/maulidandev) 89 | - [Rayhan Yulanda](https://github.com/RayhanYulanda) 90 | - [All Contributors](../../contributors) 91 | 92 | ## License 93 | 94 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 95 | --------------------------------------------------------------------------------