From 45e40e17538e23f912c890aa9a0e095f44f367cb Mon Sep 17 00:00:00 2001 From: Brady McDonough Date: Thu, 15 Feb 2024 17:27:21 -0700 Subject: [PATCH] secret fields should be secret --- TODOS.md | 1 + src/URI/Otpauth.php | 4 +++- tests/URITest.php | 2 -- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/TODOS.md b/TODOS.md index 5e8be54..32a0815 100644 --- a/TODOS.md +++ b/TODOS.md @@ -3,3 +3,4 @@ - Display is awful to code an open ended interface for, but I still should - Error reporting should be enhanced, either through a messaging object or via `throw` - The hash fed into the `_6238` object should be based on the hash referenced in the provisioning uri + - URI tests must be rewritten due to public/private changes in the Otpauth object diff --git a/src/URI/Otpauth.php b/src/URI/Otpauth.php index 9e7f139..cd951b9 100644 --- a/src/URI/Otpauth.php +++ b/src/URI/Otpauth.php @@ -6,10 +6,12 @@ use InvalidArgumentException; class Otpauth { + private readonly string $secret; + public function __construct( public readonly string $userid, public readonly string $issuer, - public readonly string $secret, + string $secret, public readonly string $algorithm, public readonly int $digits, public readonly int $period, diff --git a/tests/URITest.php b/tests/URITest.php index a7f2395..7e4a87d 100644 --- a/tests/URITest.php +++ b/tests/URITest.php @@ -40,7 +40,6 @@ final class URITest extends TestCase $provisioningUri = Otpauth::fromString($string); - $this->assertSame($provisioningUri->secret, $queryComponents['secret']); $this->assertSame($provisioningUri->issuer, $queryComponents['issuer']); $this->assertSame($provisioningUri->digits, $queryComponents['digits']); $this->assertSame($provisioningUri->period, $queryComponents['period']); @@ -76,7 +75,6 @@ final class URITest extends TestCase $provisioningUri = Otpauth::fromString($string); - $this->assertSame($provisioningUri->secret, $queryComponents['secret']); $this->assertSame($provisioningUri->algorithm, $queryComponents['algorithm']); $this->assertSame($provisioningUri->digits, $queryComponents['digits']); $this->assertSame($provisioningUri->period, $queryComponents['period']);