You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: add orientation param #62
* feat: expose reset into even object to allow retry #62
* feat: emit expired after 120 sec if token is not markUsed #62
* docs: update README.md #62
* docs: add orientatin param to table and markUsed snippet
* @param {string} imghost: Points loaded hCaptcha challenge images to a user defined image location, used for proxies. Default: https://imgs.hcaptcha.com (Override only if using first-party hosting feature.)
61
61
* @param {string} host: hCaptcha SDK host identifier. null value means that it will be generated by SDK
Copy file name to clipboardExpand all lines: README.md
+35-8Lines changed: 35 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,28 +35,54 @@ Also, please note the following special message strings that can be returned via
35
35
36
36
| name | purpose |
37
37
| --- | --- |
38
-
| expired | passcode response expired and the user must re-verify |
38
+
| expired | passcode response expired and the user must re-verify, or did not answer before session expired|
39
39
| error | there was an error displaying the challenge |
40
-
| cancel | the user closed the challenge, or did not answer before session expired|
40
+
| cancel | the user closed the challenge |
41
41
| open | the visual challenge was opened |
42
42
43
43
44
44
Any other string returned by `onMessage` will be a passcode.
45
45
46
+
46
47
### Handling the post-issuance expiration lifecycle
47
48
48
49
This extension is a lightweight wrapper, and does not currently attempt to manage post-verification state in the same way as the web JS API, e.g. with an on-expire callback.
49
50
50
51
In particular, if you do **not** plan to immediately consume the passcode returned by submitting it to your backend, you should start a timer to let your application state know that a new passcode is required when it expires.
51
52
52
-
By default, this value is 120 seconds. Thus, you would want code similar to the following in your app when handling `onMessage` responses that return a passcode:
53
-
54
-
```
55
-
this.timeoutCheck = setTimeout(() => {
56
-
this.setPasscodeExpired();
57
-
}, 120000);
53
+
By default, this value is 120 seconds. So, an `expired` error will be emitted to `onMessage` if you haven't called `event.markUsed()`.
54
+
55
+
Once you've utilized hCaptcha's token, call `markUsed` on the event object in `onMessage`:
56
+
57
+
```js
58
+
onMessage=event=> {
59
+
if (event&&event.nativeEvent.data) {
60
+
if (['cancel'].includes(event.nativeEvent.data)) {
0 commit comments