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
+ public readonly string $ contents ,
21
+ #[SensitiveParameter]
22
+ public readonly string $ passphrase ,
23
+ ) {
20
24
}
21
25
22
26
/** @param non-empty-string $contents */
23
- public static function plainText (string $ contents , string $ passphrase = '' ): self
24
- {
27
+ public static function plainText (
28
+ string $ contents ,
29
+ #[SensitiveParameter]
30
+ string $ passphrase = '' ,
31
+ ): self {
25
32
self ::guardAgainstEmptyKey ($ contents );
26
33
27
34
return new self ($ contents , $ passphrase );
28
35
}
29
36
30
37
/** @param non-empty-string $contents */
31
- public static function base64Encoded (string $ contents , string $ passphrase = '' ): self
32
- {
38
+ public static function base64Encoded (
39
+ string $ contents ,
40
+ #[SensitiveParameter]
41
+ string $ passphrase = '' ,
42
+ ): self {
33
43
$ decoded = SodiumBase64Polyfill::base642bin (
34
44
$ contents ,
35
45
SodiumBase64Polyfill::SODIUM_BASE64_VARIANT_ORIGINAL ,
@@ -45,8 +55,11 @@ public static function base64Encoded(string $contents, string $passphrase = ''):
45
55
*
46
56
* @throws FileCouldNotBeRead
47
57
*/
48
- public static function file (string $ path , string $ passphrase = '' ): self
49
- {
58
+ public static function file (
59
+ string $ path ,
60
+ #[SensitiveParameter]
61
+ string $ passphrase = '' ,
62
+ ): self {
50
63
try {
51
64
$ file = new SplFileObject ($ path );
52
65
} catch (Throwable $ exception ) {
0 commit comments