6
6
use Lcobucci \JWT \Signer \InvalidKeyProvided ;
7
7
use Lcobucci \JWT \Signer \Key ;
8
8
use Lcobucci \JWT \SodiumBase64Polyfill ;
9
+ use SensitiveParameter ;
9
10
use SplFileObject ;
10
11
use Throwable ;
11
12
15
16
final class InMemory implements Key
16
17
{
17
18
/** @param non-empty-string $contents */
18
- private function __construct (public readonly string $ contents , public readonly string $ passphrase )
19
- {
19
+ private function __construct (
20
+ #[SensitiveParameter]
21
+ public readonly string $ contents ,
22
+ #[SensitiveParameter]
23
+ public readonly string $ passphrase ,
24
+ ) {
20
25
}
21
26
22
27
/** @param non-empty-string $contents */
23
- public static function plainText (string $ contents , string $ passphrase = '' ): self
24
- {
28
+ public static function plainText (
29
+ #[SensitiveParameter]
30
+ string $ contents ,
31
+ #[SensitiveParameter]
32
+ string $ passphrase = '' ,
33
+ ): self {
25
34
self ::guardAgainstEmptyKey ($ contents );
26
35
27
36
return new self ($ contents , $ passphrase );
28
37
}
29
38
30
39
/** @param non-empty-string $contents */
31
- public static function base64Encoded (string $ contents , string $ passphrase = '' ): self
32
- {
40
+ public static function base64Encoded (
41
+ #[SensitiveParameter]
42
+ string $ contents ,
43
+ #[SensitiveParameter]
44
+ string $ passphrase = '' ,
45
+ ): self {
33
46
$ decoded = SodiumBase64Polyfill::base642bin (
34
47
$ contents ,
35
48
SodiumBase64Polyfill::SODIUM_BASE64_VARIANT_ORIGINAL ,
@@ -45,8 +58,11 @@ public static function base64Encoded(string $contents, string $passphrase = ''):
45
58
*
46
59
* @throws FileCouldNotBeRead
47
60
*/
48
- public static function file (string $ path , string $ passphrase = '' ): self
49
- {
61
+ public static function file (
62
+ string $ path ,
63
+ #[SensitiveParameter]
64
+ string $ passphrase = '' ,
65
+ ): self {
50
66
try {
51
67
$ file = new SplFileObject ($ path );
52
68
} catch (Throwable $ exception ) {
0 commit comments