@hcaptcha/react-hcaptcha 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/index.js +25 -0
- package/package.json +4 -1
- package/src/index.js +22 -0
- package/types/index.d.ts +5 -2
package/README.md
CHANGED
|
@@ -149,7 +149,10 @@ return <HCaptcha ref={captchaRef} onLoad={onLoad} sitekey={sitekey} {...props} /
|
|
|
149
149
|
|Method|Description|
|
|
150
150
|
|---|---|
|
|
151
151
|
|`execute()`|Programmatically trigger a challenge request. Additionally, this method can be run asynchronously and returns a promise with the `token` and `eKey` when the challenge is completed.|
|
|
152
|
+
|`getRespKey()`|Get the current challenge reference ID|
|
|
153
|
+
|`getResponse()`|Get the current challenge response token from completed challenge|
|
|
152
154
|
|`resetCaptcha()`|Reset the current challenge|
|
|
155
|
+
|`setData()`|See enterprise docs.|
|
|
153
156
|
|
|
154
157
|
|
|
155
158
|
**NOTE**: Make sure to reset the hCaptcha state when you submit your form by calling the method `.resetCaptcha` on your hCaptcha React Component! Passcodes are one-time use, so if your user submits the same passcode twice then it will be rejected by the server the second time.
|
package/dist/index.js
CHANGED
|
@@ -329,6 +329,31 @@ var HCaptcha = /*#__PURE__*/function (_React$Component) {
|
|
|
329
329
|
|
|
330
330
|
return hcaptcha.execute(captchaId, opts);
|
|
331
331
|
}
|
|
332
|
+
}, {
|
|
333
|
+
key: "setData",
|
|
334
|
+
value: function setData(data) {
|
|
335
|
+
var captchaId = this.state.captchaId;
|
|
336
|
+
|
|
337
|
+
if (!this.isReady()) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (data && (0, _typeof2["default"])(data) !== "object") {
|
|
342
|
+
data = null;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
hcaptcha.setData(captchaId, data);
|
|
346
|
+
}
|
|
347
|
+
}, {
|
|
348
|
+
key: "getResponse",
|
|
349
|
+
value: function getResponse() {
|
|
350
|
+
return hcaptcha.getResponse(this.state.captchaId);
|
|
351
|
+
}
|
|
352
|
+
}, {
|
|
353
|
+
key: "getRespKey",
|
|
354
|
+
value: function getRespKey() {
|
|
355
|
+
return hcaptcha.getRespKey(this.state.captchaId);
|
|
356
|
+
}
|
|
332
357
|
}, {
|
|
333
358
|
key: "render",
|
|
334
359
|
value: function render() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hcaptcha/react-hcaptcha",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"types": "types/index.d.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -43,5 +43,8 @@
|
|
|
43
43
|
"webpack": "^4.44.2",
|
|
44
44
|
"webpack-cli": "^3.3.12",
|
|
45
45
|
"webpack-dev-server": "^3.11.0"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@babel/runtime": "^7.17.9"
|
|
46
49
|
}
|
|
47
50
|
}
|
package/src/index.js
CHANGED
|
@@ -265,6 +265,28 @@ class HCaptcha extends React.Component {
|
|
|
265
265
|
return hcaptcha.execute(captchaId, opts);
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
+
setData (data) {
|
|
269
|
+
const { captchaId } = this.state;
|
|
270
|
+
|
|
271
|
+
if (!this.isReady()) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (data && typeof data !== "object") {
|
|
276
|
+
data = null;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
hcaptcha.setData(captchaId, data);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
getResponse() {
|
|
283
|
+
return hcaptcha.getResponse(this.state.captchaId);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
getRespKey() {
|
|
287
|
+
return hcaptcha.getRespKey(this.state.captchaId)
|
|
288
|
+
}
|
|
289
|
+
|
|
268
290
|
render () {
|
|
269
291
|
const { elementId } = this.state;
|
|
270
292
|
return <div ref={this.ref} id={elementId}></div>
|
package/types/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ interface HCaptchaProps {
|
|
|
19
19
|
onClose?: () => any;
|
|
20
20
|
onChalExpired?: () => any;
|
|
21
21
|
onError?: (event: string) => any;
|
|
22
|
-
onVerify?: (token: string) => any;
|
|
22
|
+
onVerify?: (token: string, ekey: string) => any;
|
|
23
23
|
onLoad?: () => any;
|
|
24
24
|
languageOverride?: string;
|
|
25
25
|
sitekey: string;
|
|
@@ -39,7 +39,10 @@ declare class HCaptcha extends React.Component<HCaptchaProps, HCaptchaState> {
|
|
|
39
39
|
resetCaptcha(): void;
|
|
40
40
|
renderCaptcha(): void;
|
|
41
41
|
removeCaptcha(): void;
|
|
42
|
-
|
|
42
|
+
getRespKey(): string;
|
|
43
|
+
getResponse(): string;
|
|
44
|
+
setData(data: object): void;
|
|
45
|
+
execute(opts: { async: true }): Promise<ExecuteResponse>;
|
|
43
46
|
execute(opts?: { async: false }): void;
|
|
44
47
|
execute(opts?: { async: boolean }): Promise<ExecuteResponse> | void;
|
|
45
48
|
}
|