-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement async hcaptcha execute #91
Conversation
@brdlyptrs Done. Not sure how to approach tests tbh. |
@ajmnz Since the Something to consider is creating and exposing a custom Error. Something like TestingYou are going to want to use the it("Async execute should return token with test sitekey", async () => {
const { token } = await instance.execute();
expect(token).toBe("10000000-aaaa-bbbb-cccc-000000000001");
}); Since you are also storing the it("Async execute should reject with correct message", async () => {
const instance = ReactTestUtils.renderIntoDocument(
<HCaptcha
sitekey={TEST_PROPS.sitekey}
onOpen={() => instance.reject(new Error("hCaptcha expired"))}
/>);
try {
await instance.execute();
} catch (e) {
expect(e.message).toBe("hCaptcha expired");
}
}); |
@brdlyptrs Everything is done except for tests. For some reason callbacks aren't firing and the promise never gets resolved/rejected, triggering a Jest timeout error. Everything works fine in the examples though. If you have time, please pull the code and see if you can give me a hand here. |
@ajmnz Sorry for the late reply, I wanted to let you know we will be deploying an option to make |
Awesome, will wait for any updates |
@ajmnz We've updated the native JS and it is now live. We should be updating the docs soon to reflect this change. Here is an example: const { response, key } = await hcaptcha.execute(id, { async: true }); |
Hey @brdlyptrs 👋 Sorry for the delay, I've had a pretty crazy month. I've implemented a new method that passes |
@brdlyptrs I think we're ready to merge now. Here's a TS Playground with the overloads. Let me know if you need any more changes. |
@ajmnz this looks good, nice job and good tests! Last thing we need to do is bump the version number. |
@brdlyptrs Done |
ping. is there any more work on this? It is worth noting that this is the behavior reflected in the official hCaptcha docs, and this library's example points to official hCaptcha docs, so it is misleading if this behavior is not yet integrated. |
@pagarazzi |
@brdlyptrs |
@ajmnz I built your library but couldn't get it to work. There must have been some transpiling error or an error in the code. Only the first parameter The official library asks for passing |
The low level |
@ajmnz I understand that but it is not intuitive as it goes against the docs in the official library, which are the only docs existent. Also the usage was pointed out here #91 (comment) and I assumed that was meant for this library. If we want to keep it to one parameter we should mention it at least in the README, otherwise many people will stumble upon this |
@ajmnz @brdlyptrs Any news with this? This feature would help me a lot! |
This looks good @ajmnz. Let's wait to bump to version 1.0 after this PR once we know all is good. |
Thanks for all the help @ajmnz again. |
Anytime! This was fun 🤘 |
@brdlyptrs Could you trigger a release for |
Could you guys help me? I can't seem to make the async execute to work. I even tried the example provided by you here but the |
I think I missed updating the example. This should work const res = await captchaRef.current.execute({ async: true });
console.log("Verified asynchronously: ", res); |
Tried that as well but it isn't working 😞 . It's like it doesn't wait for the execute fn to execute the captcha |
Are you on version |
Now it looks like it's working. I think the compiler was getting the previous version. Thank you so much!! |
Implements #55
Extras
package.json
plugin-transform-runtime
to deal withawait
,async
and promisesTodo
error
andclose
.Help/Feedback appreciated