Skip to content

Commit 79f0ea9

Browse files
committed
Add upgrade instructions - replaces changelog
1 parent 830a1f9 commit 79f0ea9

File tree

7 files changed

+27
-16
lines changed

7 files changed

+27
-16
lines changed

CHANGELOG.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

UPGRADE.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
UPGRADE
2+
=======
3+
4+
## Upgrade from 0.1.2
5+
6+
* Support for PHP 8.1 and lower was dropped;
7+
8+
* Now always uses Aragon2id instead of Aragon2i;
9+
10+
* The `Argon2SplitTokenFactory` now expects a `DateInterval` or string with a date-interval
11+
as second argument to constructor. Previously this required a `DateTimeImmutable`;
12+
13+
* The `SplitTokenFactory::generate()` now allows a `DateTimeImmutable` or `DateInterval`
14+
which is calculated relative to "now" or the `now()` as provided by the `ClockInterface`.
15+
16+
Use `setClock()` on the factory to set an active Clock instance, this is also the recommended
17+
way for using the `FakeSplitTokenFactory()`.

src/AbstractSplitTokenFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
namespace Rollerworks\Component\SplitToken;
1212

1313
use Psr\Clock\ClockInterface;
14+
use Symfony\Contracts\Service\Attribute\Required;
1415

1516
abstract class AbstractSplitTokenFactory implements SplitTokenFactory
1617
{

src/Argon2SplitToken.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ protected function verifyHash(string $hash, string $verifier): bool
3434
return password_verify($verifier, $hash);
3535
}
3636

37-
/**
38-
* @codeCoverageIgnore
39-
*/
37+
/** @codeCoverageIgnore */
4038
protected function hashVerifier(string $verifier): string
4139
{
4240
$passwordHash = password_hash($verifier, \PASSWORD_ARGON2ID, $this->config);

src/FakeSplitTokenFactory.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static function randomInstance(): self
3030
return new self(random_bytes(FakeSplitToken::TOKEN_DATA_LENGTH));
3131
}
3232

33-
public function __construct(string $randomValue = null, \DateInterval | string | null $defaultLifeTime = null)
33+
public function __construct(string $randomValue = null, \DateInterval | string $defaultLifeTime = null)
3434
{
3535
parent::__construct($defaultLifeTime);
3636

@@ -39,9 +39,8 @@ public function __construct(string $randomValue = null, \DateInterval | string |
3939

4040
public function generate(\DateTimeImmutable | \DateInterval $expiresAt = null): SplitToken
4141
{
42-
$splitToken = FakeSplitToken::create(new HiddenString($this->randomValue, false, true));
43-
44-
return $splitToken->expireAt($this->getExpirationTimestamp($expiresAt));
42+
return FakeSplitToken::create(new HiddenString($this->randomValue, false, true))
43+
->expireAt($this->getExpirationTimestamp($expiresAt));
4544
}
4645

4746
public function fromString(string $token): SplitToken

src/SplitTokenFactory.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@
1111
namespace Rollerworks\Component\SplitToken;
1212

1313
use ParagonIE\HiddenString\HiddenString;
14+
use Psr\Clock\ClockInterface;
15+
use Symfony\Contracts\Service\Attribute\Required;
1416

1517
interface SplitTokenFactory
1618
{
19+
#[Required]
20+
public function setClock(ClockInterface $clock): void;
21+
1722
/**
1823
* Generates a new SplitToken object.
1924
*

tests/FakeSplitTokenFactoryTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
99
*/
1010

11-
1211
use PHPUnit\Framework\Attributes\Test;
1312
use PHPUnit\Framework\TestCase;
1413
use Rollerworks\Component\SplitToken\FakeSplitTokenFactory;

0 commit comments

Comments
 (0)