File tree Expand file tree Collapse file tree 3 files changed +18
-20
lines changed Expand file tree Collapse file tree 3 files changed +18
-20
lines changed Original file line number Diff line number Diff line change 6
6
"node" : " >=20.0.0"
7
7
},
8
8
"type" : " module" ,
9
- "funding" : [
10
- " https://github.com/sponsors/sergiodxa"
11
- ],
9
+ "funding" : [" https://github.com/sponsors/sergiodxa" ],
12
10
"exports" : {
13
11
"./package.json" : " ./package.json" ,
14
12
"./promise" : {
258
256
"dependencies" : {
259
257
"type-fest" : " ^4.33.0"
260
258
},
261
- "files" : [
262
- " build" ,
263
- " package.json" ,
264
- " README.md"
265
- ]
259
+ "files" : [" build" , " package.json" , " README.md" ]
266
260
}
Original file line number Diff line number Diff line change @@ -7,19 +7,22 @@ const HoneypotContext = React.createContext<HoneypotContextType>({});
7
7
8
8
export function HoneypotInputs ( {
9
9
label = "Please leave this field blank" ,
10
- nonce,
11
- className = "__honeypot_inputs" ,
12
10
} : HoneypotInputs . Props ) {
13
11
let context = React . useContext ( HoneypotContext ) ;
14
12
15
13
let {
14
+ nonce,
16
15
nameFieldName = "name__confirm" ,
17
16
validFromFieldName = "from__confirm" ,
18
17
encryptedValidFrom,
19
18
} = context ;
20
19
21
20
return (
22
- < div id = { `${ nameFieldName } _wrap` } className = { className } aria-hidden = "true" >
21
+ < div
22
+ id = { `${ nameFieldName } _wrap` }
23
+ className = "__honeypot_inputs"
24
+ aria-hidden = "true"
25
+ >
23
26
< style nonce = { nonce } > { ".__honeypot_inputs { display: none; }" } </ style >
24
27
< label htmlFor = { nameFieldName } > { label } </ label >
25
28
< input
@@ -49,15 +52,7 @@ export function HoneypotInputs({
49
52
}
50
53
51
54
export namespace HoneypotInputs {
52
- export type Props = {
53
- label ?: string ;
54
- nonce ?: string ;
55
- /**
56
- * The classname used to link the Honeypot input with the CSS that hides it.
57
- * @default "__honeypot_inputs"
58
- */
59
- className ?: string ;
60
- } ;
55
+ export type Props = { label ?: string } ;
61
56
}
62
57
63
58
export type HoneypotProviderProps = HoneypotContextType & {
Original file line number Diff line number Diff line change 1
1
import { decrypt , encrypt , randomString } from "../common/crypto.js" ;
2
2
3
3
export interface HoneypotInputProps {
4
+ /**
5
+ * The nonce for the style tag that will be used to hide the honeypot input.
6
+ */
7
+ nonce ?: string ;
4
8
/**
5
9
* The name expected to be used by the honeypot input field.
6
10
*/
@@ -21,6 +25,10 @@ export interface HoneypotConfig {
21
25
* name will be different for each request.
22
26
*/
23
27
randomizeNameFieldName ?: boolean ;
28
+ /**
29
+ * The nonce for the style tag that will be used to hide the honeypot input.
30
+ */
31
+ nonce ?: string ;
24
32
/**
25
33
* The name of the field that will be used for the honeypot input.
26
34
*/
@@ -71,6 +79,7 @@ export class Honeypot {
71
79
validFromTimestamp = Date . now ( ) ,
72
80
} = { } ) : Promise < HoneypotInputProps > {
73
81
return {
82
+ nonce : this . config . nonce ,
74
83
nameFieldName : this . nameFieldName ,
75
84
validFromFieldName : this . validFromFieldName ,
76
85
encryptedValidFrom : await this . encrypt ( validFromTimestamp . toString ( ) ) ,
You can’t perform that action at this time.
0 commit comments