Skip to content
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

Allowing setting callbacks via string or explicit function #1203

Merged
merged 10 commits into from
May 15, 2024
5 changes: 4 additions & 1 deletion demos/client-bundle-example/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
class="procaptcha"
data-theme="light"
data-sitekey="5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw"
data-callback="onCaptchaVerified"
></div>
</div>
<input type="submit" class="mui-btn mui-btn--raised" />
Expand All @@ -40,13 +41,15 @@
console.log('Captcha verified, output: ' + JSON.stringify(output))
}

window.onCaptchaVerified = onCaptchaVerified

// Get the Element using elementId
const captchaContainer = document.getElementById('procaptcha-container')
// Render the CAPTCHA explicitly on a container with id "procaptcha-container"
render(captchaContainer, {
siteKey: '5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw',
theme: 'dark',
callback: onCaptchaVerified,
callback: 'onCaptchaVerified',
})
</script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion demos/client-bundle-example/src/jsBundleTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div
class="procaptcha"
data-theme="light"
data-sitekey="5HUBceb4Du6dvMA9BiwN5VzUrzUsX9Zp7z7nSR2cC1TCv5jg"
data-sitekey="5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw"
forgetso marked this conversation as resolved.
Show resolved Hide resolved
></div>
</form>
</body>
Expand Down
9 changes: 7 additions & 2 deletions packages/api/src/api/ProviderApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
CaptchaSolutionBody,
CaptchaSolutionBodyType,
CaptchaSolutionResponse,
GetPowCaptchaChallengeRequestBodyType,
GetPowCaptchaResponse,
ImageVerificationResponse,
NetworkConfig,
Expand Down Expand Up @@ -96,8 +97,12 @@ export default class ProviderApi extends HttpClientBase implements ProviderApi {
return this.post(ApiPaths.VerifyCaptchaSolution, payload as VerifySolutionBodyType)
}

public getPowCaptchaChallenge(userAccount: AccountId, dappAccount: AccountId): Promise<GetPowCaptchaResponse> {
return this.post(ApiPaths.GetPowCaptchaChallenge, { userAccount, dappAccount })
public getPowCaptchaChallenge(user: AccountId, dapp: AccountId): Promise<GetPowCaptchaResponse> {
const body: GetPowCaptchaChallengeRequestBodyType = {
[ApiParams.user]: user.toString(),
[ApiParams.dapp]: dapp.toString(),
}
return this.post(ApiPaths.GetPowCaptchaChallenge, body)
}

public submitPowCaptchaSolution(
Expand Down
Loading
Loading