diff --git a/types/grecaptcha/grecaptcha-tests.ts b/types/grecaptcha/grecaptcha-tests.ts index 970660cc6c..9b8c475e17 100644 --- a/types/grecaptcha/grecaptcha-tests.ts +++ b/types/grecaptcha/grecaptcha-tests.ts @@ -41,3 +41,7 @@ grecaptcha.reset(id1); grecaptcha.execute(); grecaptcha.execute(id1); + +grecaptcha.execute('foo', { action: 'bar' }).then((token: string) => {}); + +grecaptcha.ready(() => {}); diff --git a/types/grecaptcha/index.d.ts b/types/grecaptcha/index.d.ts index 4430aa90e9..f150c340c2 100644 --- a/types/grecaptcha/index.d.ts +++ b/types/grecaptcha/index.d.ts @@ -1,9 +1,10 @@ -// Type definitions for Google Recaptcha 2.0 +// Type definitions for Google Recaptcha 3.0 // Project: https://www.google.com/recaptcha // Definitions by: Kristof Mattei // Martin Costello // Ruslan Arkhipau // Rafael Tavares +// Florian Rohrer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare var grecaptcha: ReCaptchaV2.ReCaptcha; @@ -35,6 +36,19 @@ declare namespace ReCaptchaV2 { * @param opt_widget_id Optional widget ID, defaults to the first widget created if unspecified. */ execute(opt_widget_id?: number): void; + /** + * Programatically invoke the reCAPTCHA check. Used if the invisible reCAPTCHA is on a div instead of a button. + * @param siteKey the key of your site + * @param action the action + * + * @return a promise containing the token + */ + execute(siteKey: string, action: Action): Promise; + /** + * will run the given function as soon as the reCAPTCHA library has loaded + * @param callback the function to coll + */ + ready(callback: () => void): void; } type Theme = "light" | "dark"; @@ -42,6 +56,13 @@ declare namespace ReCaptchaV2 { type Size = "normal" | "compact" | "invisible"; type Badge = "bottomright" | "bottomleft" | "inline"; + interface Action { + /** + * the name of the action. Actions may only contain alphanumeric characters and slashes, and must not be user-specific. + */ + action: string; + } + interface Parameters { /** * Your sitekey.