Skip to content

fix: implement Encrypter and StringEncrypter interfaces on XChaChaPoly1305Encryptor class #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 93 additions & 85 deletions composer.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
<testsuite name="Architecture">
<directory suffix="Test.php">./tests/Architecture</directory>
</testsuite>
</testsuites>
<php>
<server name="APP_ENV" value="testing"/>
Expand Down
4 changes: 0 additions & 4 deletions src/Console/GenerateCryptoKeysCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@

namespace CodeLieutenant\LaravelCrypto\Console;

use CodeLieutenant\LaravelCrypto\Keys\AppKey;
use CodeLieutenant\LaravelCrypto\Keys\Blake2bHashingKey;
use CodeLieutenant\LaravelCrypto\Keys\EdDSASignerKey;
use CodeLieutenant\LaravelCrypto\Keys\Generators\AppKeyGenerator;
use CodeLieutenant\LaravelCrypto\Keys\Generators\Blake2bHashingKeyGenerator;
use CodeLieutenant\LaravelCrypto\Keys\Generators\EdDSASignerKeyGenerator;
use CodeLieutenant\LaravelCrypto\Keys\Generators\HmacKeyGenerator;
use CodeLieutenant\LaravelCrypto\Keys\HmacKey;
use Exception;
use Illuminate\Console\Command;
use Illuminate\Console\ConfirmableTrait;
Expand Down
5 changes: 4 additions & 1 deletion src/Encryption/XChaCha20Poly1305Encryptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@

namespace CodeLieutenant\LaravelCrypto\Encryption;

use CodeLieutenant\LaravelCrypto\Contracts\KeyGeneration;
use CodeLieutenant\LaravelCrypto\Encoder\Encoder;
use CodeLieutenant\LaravelCrypto\Encoder\JsonEncoder;
use CodeLieutenant\LaravelCrypto\Keys\Loader;
use CodeLieutenant\LaravelCrypto\Support\Base64;
use Exception;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Contracts\Encryption\Encrypter;
use Illuminate\Contracts\Encryption\EncryptException;
use Illuminate\Contracts\Encryption\StringEncrypter;
use Psr\Log\LoggerInterface;

final class XChaCha20Poly1305Encryptor
final class XChaCha20Poly1305Encryptor implements Encrypter, KeyGeneration, StringEncrypter
{
use Crypto;

Expand Down
16 changes: 0 additions & 16 deletions src/Exceptions/KeyPathNotFound.php

This file was deleted.

13 changes: 13 additions & 0 deletions tests/Architecture/CommandsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

use Illuminate\Console\Command;
use Symfony\Component\Console\Attribute\AsCommand;

arch('commands')
->expect('CodeLieutenant\LaravelCrypto\Console')
->toHaveAttribute(AsCommand::class)
->toExtend(Command::class)
->toHaveMethod('handle')
->toHaveSuffix('Command');
8 changes: 8 additions & 0 deletions tests/Architecture/ContractsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

declare(strict_types=1);

arch('contracts')
->expect('CodeLieutenant\LaravelCrypto\Contracts')
->toBeInterfaces();

31 changes: 31 additions & 0 deletions tests/Architecture/EncryptionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

use CodeLieutenant\LaravelCrypto\Contracts\KeyGeneration;
use CodeLieutenant\LaravelCrypto\Encryption\AesGcm256Encryptor;
use CodeLieutenant\LaravelCrypto\Encryption\Crypto;
use CodeLieutenant\LaravelCrypto\Encryption\Encryption;
use CodeLieutenant\LaravelCrypto\Encryption\XChaCha20Poly1305Encryptor;
use Illuminate\Contracts\Encryption\Encrypter;
use Illuminate\Contracts\Encryption\StringEncrypter;

arch('encryption xchacha')
->expect(XChaCha20Poly1305Encryptor::class)
->toImplement([Encrypter::class, StringEncrypter::class, KeyGeneration::class])
->toBeClass()
->toBeFinal();

arch('encryption aesgcm256')
->expect(AesGcm256Encryptor::class)
->toImplement([Encrypter::class, StringEncrypter::class, KeyGeneration::class])
->toBeClass()
->toBeFinal();

arch('encryption enum')
->expect(Encryption::class)
->toBeStringBackedEnum();

arch('encryption crypto')
->expect(Crypto::class)
->toBeTrait();
10 changes: 10 additions & 0 deletions tests/Architecture/FacadesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

use Illuminate\Support\Facades\Facade;

arch('facades')
->expect('CodeLieutenant\LaravelCrypto\Facades')
->toBeClasses()
->toExtend(Facade::class);
11 changes: 11 additions & 0 deletions tests/Architecture/GlobalTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

arch('globals')
->expect(['dd', 'dump', 'ray'])
->not->toBeUsed();

arch('strict types')
->expect('CodeLieutenant\LaravelCrypto')
->toUseStrictTypes();
8 changes: 8 additions & 0 deletions tests/Architecture/TraitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

declare(strict_types=1);

arch('traits')
->expect('CodeLieutenant\LaravelCrypto\Traits')
->toBeTraits();