@@ -21,6 +21,13 @@ public function getConfigTreeBuilder(): TreeBuilder
2121
2222 // @phpstan-ignore-next-line
2323 $ rootNode
24+ ->beforeNormalization ()
25+ ->ifTrue (static fn ($ v ): bool => \is_array ($ v ) && isset ($ v ['hmacKey ' ]) && !isset ($ v ['hmacSignature ' ]))
26+ ->then (static function ($ v ): array {
27+ $ v ['hmacSignature ' ] = $ v ['hmacKey ' ];
28+ return $ v ;
29+ })
30+ ->end ()
2431 ->children ()
2532 ->booleanNode ('enable ' )->defaultTrue ()->end ()
2633 ->booleanNode ('floating ' )->defaultFalse ()->end ()
@@ -41,7 +48,14 @@ public function getConfigTreeBuilder(): TreeBuilder
4148 ->end ()
4249 ->end () // end arrayNode('overlay')
4350 ->booleanNode ('use_stimulus ' )->defaultNull ()->end ()
44- ->integerNode ('max_number ' )->defaultValue (100000 )->end ()
51+ ->integerNode ('cost ' )->defaultValue (5000 )->end ()
52+ ->integerNode ('counter_min ' )->defaultValue (5000 )->end ()
53+ ->integerNode ('counter_max ' )->defaultValue (10000 )->end ()
54+ ->floatNode ('timeout ' )->defaultValue (30.0 )->end ()
55+ ->integerNode ('max_number ' )
56+ ->setDeprecated ('tito10047/altcha-bundle ' , '1.1 ' , 'The "%node%" option is deprecated and will be removed. ' )
57+ ->defaultValue (100000 )
58+ ->end ()
4559 ->scalarNode ('expires ' )
4660 ->defaultValue ('+15 minute ' )
4761 ->cannotBeEmpty ()
@@ -53,9 +67,21 @@ public function getConfigTreeBuilder(): TreeBuilder
5367 ->booleanNode ('include_script ' )->defaultNull ()->end ()
5468 ->booleanNode ('hide_logo ' )->defaultFalse ()->end ()
5569 ->booleanNode ('hide_footer ' )->defaultFalse ()->end ()
56- ->scalarNode ('altcha_js_path ' )->defaultValue ('https://eu.altcha.org/js/latest/altcha.min.js ' )->end ()
57- ->scalarNode ('altcha_js_i18n_path ' )->defaultValue ('https://cdn.jsdelivr.net/gh/altcha-org/altcha/dist_i18n/all.min.js ' )->end ()
58- ->scalarNode ('hmacKey ' )->isRequired ()->cannotBeEmpty ()->end ()
70+ ->scalarNode ('altcha_js_path ' )->defaultValue ('https://cdn.jsdelivr.net/npm/altcha/dist/main/altcha.min.js ' )->end ()
71+ ->scalarNode ('altcha_js_i18n_path ' )->defaultValue ('https://cdn.jsdelivr.net/npm/altcha/dist/i18n/all.min.js ' )->end ()
72+ ->scalarNode ('hmacKey ' )
73+ ->setDeprecated ('tito10047/altcha-bundle ' , '1.1 ' , 'The "%node%" option is deprecated, use "hmacSignature" instead. ' )
74+ ->defaultValue (null )
75+ ->end ()
76+ ->scalarNode ('hmacAlgorithm ' )
77+ ->defaultValue ('SHA-256 ' )
78+ ->validate ()
79+ ->ifNotInArray (['SHA-256 ' , 'SHA-384 ' , 'SHA-512 ' ])
80+ ->thenInvalid ('Invalid HMAC algorithm "%s". Permitted values are SHA-256, SHA-384, SHA-512. ' )
81+ ->end ()
82+ ->end ()
83+ ->scalarNode ('hmacSignature ' )->isRequired ()->cannotBeEmpty ()->end ()
84+ ->scalarNode ('hmacKeySignature ' )->defaultNull ()->end ()
5985 ->arrayNode ('sentinel ' )->info (<<<TXT
6086 Enable usage of sentinel, if enabled:
6187 - the widget will use the /v1/challenge endpoint to retrieve a new challenge instead of your app;
0 commit comments