Skip to content

Commit 1ed4695

Browse files
authored
Merge pull request #27 from infocyph/feature/enhancement
updated suite
2 parents bb001aa + ac594fd commit 1ed4695

10 files changed

Lines changed: 305 additions & 277 deletions

File tree

.gitattributes

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
tests export-ignore
2-
docs export-ignore
3-
.github export-ignore
4-
.readthedocs.yaml export-ignore
5-
captainhook.json export-ignore
6-
phpunit.xml export-ignore
7-
pint.json export-ignore
8-
rector.php export-ignore
1+
.editorconfig export-ignore
2+
.gitignore export-ignore
3+
tests export-ignore
4+
docs export-ignore
5+
.github export-ignore
6+
.readthedocs.yaml export-ignore
7+
captainhook.json export-ignore
8+
phpunit.xml export-ignore
9+
pint.json export-ignore
10+
rector.php export-ignore
11+
.gitattributes export-ignore
12+
13+
* text eol=lf

.github/workflows/build.yml

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
name: "Security & Standards"
2-
3-
on:
4-
schedule:
5-
- cron: '0 0 * * 0'
6-
push:
7-
branches: [ '*' ]
8-
pull_request:
9-
branches: [ "main", "master", "develop" ]
10-
11-
jobs:
12-
run:
13-
runs-on: ${{ matrix.operating-system }}
14-
strategy:
15-
matrix:
16-
operating-system: [ ubuntu-latest ]
17-
php-versions: [ '8.2', '8.3' ]
18-
dependency-version: [ prefer-lowest, prefer-stable ]
19-
20-
name: PHP ${{ matrix.php-versions }} - ${{ matrix.operating-system }} - ${{ matrix.dependency-version }}
21-
steps:
22-
- name: Checkout
23-
uses: actions/checkout@v4
24-
25-
- name: Setup PHP
26-
uses: shivammathur/setup-php@v2
27-
with:
28-
php-version: ${{ matrix.php-versions }}
29-
tools: composer:v2
30-
coverage: xdebug
31-
32-
- name: Check PHP Version
33-
run: php -v
34-
35-
- name: Validate Composer
36-
run: composer validate --strict
37-
38-
- name: Install dependencies
39-
run: composer install --no-interaction --prefer-dist --optimize-autoloader
40-
41-
- name: Package Audit
42-
run: composer audit
43-
44-
- name: Test
45-
run: composer tests
1+
name: "Security & Standards"
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * 0'
6+
push:
7+
branches: [ "main", "master" ]
8+
pull_request:
9+
branches: [ "main", "master", "develop", "development" ]
10+
11+
jobs:
12+
run:
13+
runs-on: ${{ matrix.operating-system }}
14+
strategy:
15+
matrix:
16+
operating-system: [ ubuntu-latest ]
17+
php-versions: [ '8.3', '8.4', '8.5' ]
18+
dependency-version: [ prefer-lowest, prefer-stable ]
19+
20+
name: PHP ${{ matrix.php-versions }} - ${{ matrix.operating-system }} - ${{ matrix.dependency-version }}
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Setup PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: ${{ matrix.php-versions }}
29+
tools: composer:v2
30+
coverage: xdebug
31+
32+
- name: Check PHP Version
33+
run: php -v
34+
35+
- name: Validate Composer
36+
run: composer validate --strict
37+
38+
- name: Install dependencies
39+
run: composer install --no-interaction --prefer-dist --optimize-autoloader
40+
41+
- name: Package Audit
42+
run: composer audit
43+
44+
- name: Test
45+
run: composer tests

.gitignore

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
vendor
2-
example
3-
.idea
4-
example.php
5-
test.php
6-
composer.lock
7-
git-story_media
1+
vendor
2+
example
3+
.idea
4+
example.php
5+
test.php
6+
composer.lock
7+
git-story_media
8+
*~
9+
*.txt
10+
!docs/requirements.txt
11+
.windsurf
12+
.vscode
13+
.phpunit.cache
14+
*.patch
15+
patch.php

composer.json

Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,75 @@
1-
{
2-
"name": "infocyph/otp",
3-
"description": "Simple & Secure Generic OTP, OCRA (RFC6287), TOTP (RFC6238) & HOTP (RFC4226) solution!",
4-
"type": "library",
5-
"license": "MIT",
6-
"authors": [
7-
{
8-
"name": "abmmhasan",
9-
"email": "abmmhasan@gmail.com"
10-
}
11-
],
12-
"keywords": [
13-
"otp",
14-
"hotp",
15-
"totp",
16-
"hmac",
17-
"sha",
18-
"ocra",
19-
"rfc4226",
20-
"rfc6238",
21-
"rfc6287",
22-
"sms-otp",
23-
"email-otp"
24-
],
25-
"autoload": {
26-
"psr-4": {
27-
"Infocyph\\OTP\\": "src/"
28-
}
29-
},
30-
"minimum-stability": "stable",
31-
"prefer-stable": true,
32-
"config": {
33-
"sort-packages": true,
34-
"optimize-autoloader": true,
35-
"allow-plugins": {
36-
"pestphp/pest-plugin": true
37-
}
38-
},
39-
"require": {
40-
"php": ">=8.2",
41-
"bacon/bacon-qr-code": "^3.0",
42-
"paragonie/constant_time_encoding": "^3.0",
43-
"symfony/cache": "^7.0"
44-
},
45-
"require-dev": {
46-
"captainhook/captainhook": "^5.23",
47-
"laravel/pint": "^1.15",
48-
"pestphp/pest": "^2.34",
49-
"rector/rector": "^1.0",
50-
"symfony/var-dumper": "^7.0"
51-
},
52-
"scripts": {
53-
"test:code": "pest --parallel --processes=10",
54-
"test:refactor": "rector process --dry-run",
55-
"test:lint": "pint --test",
56-
"test:hook": [
57-
"captainhook hook:post-checkout",
58-
"captainhook hook:pre-commit",
59-
"captainhook hook:post-commit",
60-
"captainhook hook:post-merge",
61-
"captainhook hook:post-rewrite",
62-
"captainhook hook:pre-push"
63-
],
64-
"tests": [
65-
"@test:code",
66-
"@test:lint",
67-
"@test:refactor"
68-
],
69-
"git:hook": "captainhook install --only-enabled -nf",
70-
"test": "pest",
71-
"refactor": "rector process",
72-
"lint": "pint",
73-
"post-autoload-dump": "@git:hook"
74-
}
75-
}
1+
{
2+
"name": "infocyph/otp",
3+
"description": "Simple & Secure Generic OTP, OCRA (RFC6287), TOTP (RFC6238) & HOTP (RFC4226) solution!",
4+
"type": "library",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "abmmhasan",
9+
"email": "abmmhasan@gmail.com"
10+
}
11+
],
12+
"keywords": [
13+
"otp",
14+
"hotp",
15+
"totp",
16+
"hmac",
17+
"sha",
18+
"ocra",
19+
"rfc4226",
20+
"rfc6238",
21+
"rfc6287",
22+
"sms-otp",
23+
"email-otp"
24+
],
25+
"autoload": {
26+
"psr-4": {
27+
"Infocyph\\OTP\\": "src/"
28+
}
29+
},
30+
"minimum-stability": "stable",
31+
"prefer-stable": true,
32+
"config": {
33+
"sort-packages": true,
34+
"optimize-autoloader": true,
35+
"allow-plugins": {
36+
"pestphp/pest-plugin": true
37+
}
38+
},
39+
"require": {
40+
"php": ">=8.2",
41+
"bacon/bacon-qr-code": "^3.0",
42+
"paragonie/constant_time_encoding": "^3.0",
43+
"symfony/cache": "^7.0"
44+
},
45+
"require-dev": {
46+
"captainhook/captainhook": "^5.27",
47+
"laravel/pint": "^1.27",
48+
"pestphp/pest": "^4.3",
49+
"rector/rector": "^2.3",
50+
"symfony/var-dumper": "^7.4"
51+
},
52+
"scripts": {
53+
"test:code": "pest --parallel --processes=10",
54+
"test:refactor": "rector process --dry-run",
55+
"test:lint": "pint --test",
56+
"test:hook": [
57+
"captainhook hook:post-checkout",
58+
"captainhook hook:pre-commit",
59+
"captainhook hook:post-commit",
60+
"captainhook hook:post-merge",
61+
"captainhook hook:post-rewrite",
62+
"captainhook hook:pre-push"
63+
],
64+
"tests": [
65+
"@test:code",
66+
"@test:lint",
67+
"@test:refactor"
68+
],
69+
"git:hook": "captainhook install --only-enabled -nf",
70+
"test": "pest",
71+
"refactor": "rector process",
72+
"lint": "pint",
73+
"post-autoload-dump": "captainhook install --only-enabled -nf"
74+
}
75+
}

rector.php

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
1-
<?php
2-
3-
declare(strict_types=1);
4-
5-
use Rector\Config\RectorConfig;
6-
use Rector\Php80\Rector\FunctionLike\MixedTypeRector;
7-
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
8-
9-
return static function (RectorConfig $rectorConfig): void {
10-
$rectorConfig->paths([
11-
__DIR__ . '/src'
12-
]);
13-
$rectorConfig->sets([
14-
constant("Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_82")
15-
]);
16-
$rectorConfig->skip([
17-
ReadOnlyPropertyRector::class,
18-
MixedTypeRector::class
19-
]);
20-
};
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
7+
return RectorConfig::configure()
8+
->withPaths([
9+
__DIR__.'/src',
10+
])
11+
->withSets([
12+
constant("Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_82"),
13+
]);

src/HOTP.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ final class HOTP
88
{
99
use Common;
1010

11-
1211
/**
1312
* Initializes a new instance of the class.
1413
*
15-
* @param string $secret The secret key.
16-
* @param int $digitCount The number of digits in the generated code. Default is 6.
14+
* @param string $secret The secret key.
15+
* @param int $digitCount The number of digits in the generated code. Default is 6.
1716
*/
1817
public function __construct(
1918
string $secret,
@@ -30,19 +29,19 @@ public function __construct(
3029
*
3130
* Required if Provisioning resources need to manipulate based on a specific counter.
3231
*
33-
* @param int $counter The new value for the counter.
34-
* @return static
32+
* @param int $counter The new value for the counter.
3533
*/
3634
public function setCounter(int $counter): static
3735
{
3836
$this->counter = $counter;
37+
3938
return $this;
4039
}
4140

4241
/**
4342
* Generates a one-time password (OTP) based on the given Counter.
4443
*
45-
* @param int $counter The input value used to generate the OTP.
44+
* @param int $counter The input value used to generate the OTP.
4645
* @return string The generated OTP.
4746
*/
4847
public function getOTP(int $counter): string
@@ -53,8 +52,8 @@ public function getOTP(int $counter): string
5352
/**
5453
* Verifies if the given OTP matches the OTP generated based on the given Counter.
5554
*
56-
* @param string $otp The OTP to be verified.
57-
* @param int $counter The input used to generate the OTP.
55+
* @param string $otp The OTP to be verified.
56+
* @param int $counter The input used to generate the OTP.
5857
* @return bool Returns true if the OTP matches the generated one, otherwise false.
5958
*/
6059
public function verify(string $otp, int $counter): bool

0 commit comments

Comments
 (0)