Skip to content

Commit

Permalink
Update all dependecies to meet php version >= 8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ekojs committed Jan 30, 2025
1 parent 0205333 commit 134bc23
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3']
php-versions: ['8.2', '8.3']

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -74,13 +74,13 @@ jobs:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: |
## [2.0.0] - 2024-06-11
## [3.0.0] - 2025-01-30
### Add
- Github Pages for PCOV Code Coverage php 8.2, 8.3
### Change
- Fixing Create Secret
- Using php >= 8.2, for php below that use version 2 "composer require ekojs/otp:2.0.0"
draft: false
prerelease: false
Expand Down
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
language: php
dist: xenial
php:
- 7.4.13
- 8.0
- 8.1
- 8.2
- 8.3

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ TOTP and HOTP Library with backup codes, compatible with google authenticator. C
[![Coverage Status](https://coveralls.io/repos/ekojs/ejsotp/badge.svg?branch=master)](https://coveralls.io/r/ekojs/ejsotp?branch=master)
[![Latest Stable Version](http://poser.pugx.org/ekojs/otp/v)](https://packagist.org/packages/ekojs/otp) [![Total Downloads](http://poser.pugx.org/ekojs/otp/downloads)](https://packagist.org/packages/ekojs/otp) [![Latest Unstable Version](http://poser.pugx.org/ekojs/otp/v/unstable)](https://packagist.org/packages/ekojs/otp) [![License](http://poser.pugx.org/ekojs/otp/license)](https://packagist.org/packages/ekojs/otp) [![PHP Version Require](http://poser.pugx.org/ekojs/otp/require/php)](https://packagist.org/packages/ekojs/otp)

## Coverage

Check this code coverage on [http://ekojunaidisalam.com/ejsotp/](http://ekojunaidisalam.com/ejsotp/)

## Install

For PHP version **`>= 7.4.13`**:
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
"test": "phpunit -c phpunit.xml --testdox tests"
},
"require": {
"php": ">=7.4.13",
"spomky-labs/otphp": "^10.0",
"endroid/qr-code": "^4.4",
"furqansiddiqui/bip39-mnemonic-php": "^0.1.4"
"php": "^8.2",
"spomky-labs/otphp": "^11.3",
"endroid/qr-code": "^6.0",
"furqansiddiqui/bip39-mnemonic-php": "^0.1.7"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
Expand Down
39 changes: 33 additions & 6 deletions src/HOTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
use ParagonIE\ConstantTime\Base32;

use Endroid\QrCode\QrCode;
use Endroid\QrCode\Encoding\Encoding;
use Endroid\QrCode\ErrorCorrectionLevel;
use Endroid\QrCode\Label\LabelAlignment;
use Endroid\QrCode\Label\Font\OpenSans;
use Endroid\QrCode\RoundBlockSizeMode;
use Endroid\QrCode\Writer\PngWriter;
use Endroid\QrCode\Logo\Logo;
use Endroid\QrCode\Label\Label;
Expand Down Expand Up @@ -51,14 +56,36 @@ public function createOTP(?array $params=null): OTPInterface {
}

public function generateQr(?string $logo=null, bool $setLabel=false, int $size=200): ResultInterface {
$label = null;
$qrCode = QrCode::create($this->otp->getProvisioningUri());
$qrCode->setSize($size);
$qlogo = null;
$qlabel = null;

if(!empty($logo)) $logo = Logo::create($logo)->setResizeToWidth(50);
if(!empty($this->otp->getLabel()) && $setLabel) $label = Label::create($this->otp->getLabel())->setTextColor(new Color(0, 0, 255));
$qrCode = new QrCode(
data: $this->otp->getProvisioningUri(),
encoding: new Encoding('UTF-8'),
errorCorrectionLevel: ErrorCorrectionLevel::Low,
size: $size,
margin: 10,
roundBlockSizeMode: RoundBlockSizeMode::Margin,
foregroundColor: new Color(0, 0, 0),
backgroundColor: new Color(255, 255, 255)
);

return $this->writer->write($qrCode, $logo, $label);
if(!empty($logo)) {
$qlogo = new Logo(
path: $logo,
resizeToWidth: 50,
punchoutBackground: true
);
}

if(!empty($this->otp->getLabel()) && $setLabel) {
$qlabel = new Label(
text: $this->otp->getLabel(),
textColor: new Color(0, 0, 255)
);
}

return $this->writer->write($qrCode, $qlogo, $qlabel);
}

public function generateBackupCodes(string $entropy, ?WordList $wordList=null): array {
Expand Down
39 changes: 33 additions & 6 deletions src/TOTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
use ParagonIE\ConstantTime\Base32;

use Endroid\QrCode\QrCode;
use Endroid\QrCode\Encoding\Encoding;
use Endroid\QrCode\ErrorCorrectionLevel;
use Endroid\QrCode\Label\LabelAlignment;
use Endroid\QrCode\Label\Font\OpenSans;
use Endroid\QrCode\RoundBlockSizeMode;
use Endroid\QrCode\Writer\PngWriter;
use Endroid\QrCode\Logo\Logo;
use Endroid\QrCode\Label\Label;
Expand Down Expand Up @@ -51,14 +56,36 @@ public function createOTP(?array $params=null): OTPInterface {
}

public function generateQr(?string $logo=null, bool $setLabel=false, int $size=200): ResultInterface {
$label = null;
$qrCode = QrCode::create($this->otp->getProvisioningUri());
$qrCode->setSize($size);
$qlogo = null;
$qlabel = null;

if(!empty($logo)) $logo = Logo::create($logo)->setResizeToWidth(50);
if(!empty($this->otp->getLabel()) && $setLabel) $label = Label::create($this->otp->getLabel())->setTextColor(new Color(0, 0, 255));
$qrCode = new QrCode(
data: $this->otp->getProvisioningUri(),
encoding: new Encoding('UTF-8'),
errorCorrectionLevel: ErrorCorrectionLevel::Low,
size: $size,
margin: 10,
roundBlockSizeMode: RoundBlockSizeMode::Margin,
foregroundColor: new Color(0, 0, 0),
backgroundColor: new Color(255, 255, 255)
);

return $this->writer->write($qrCode, $logo, $label);
if(!empty($logo)) {
$qlogo = new Logo(
path: $logo,
resizeToWidth: 50,
punchoutBackground: true
);
}

if(!empty($this->otp->getLabel()) && $setLabel) {
$qlabel = new Label(
text: $this->otp->getLabel(),
textColor: new Color(0, 0, 255)
);
}

return $this->writer->write($qrCode, $qlogo, $qlabel);
}

public function generateBackupCodes(string $entropy, ?WordList $wordList=null): array {
Expand Down

0 comments on commit 134bc23

Please sign in to comment.