VK Cloud logo

SDK reference for web applications

System requirements

Supported browsers:

  • Google Chrome version 52 and above;
  • Microsoft Edge version 79 and above;
  • Firefox version 57 and above;
  • Safari version 11 and above;
  • Opera version 39 and above;
  • Yandex Browser version 16.9 and above.

Display captcha

The captchaWidget.show() method displays the captcha widget to the user in a web application. The captcha widget is displayed in a popup window (iframe).

Method parameters:

Parameter

Required

Type

Description

container

SDK reference for web applications

HTMLElement

HTML element in which to display the captcha widget

view

SDK reference for web applications

string

Captcha type. Possible values:

  • popup — popup window;
  • block — block

iframeSrc

SDK reference for web applications

string

Link to launch the widget in the frontend of your application, obtained from the link parameter in the response of the method GET /captchaNotRobot.createSession. Contains a session token and metadata:

  • domain — domain where the captcha will be used;
  • session_token — session token;
  • variant — captcha display type (block or popup)

captchaType

SDK reference for web applications

string

Captcha type. Possible value — type_1

autofocus

SDK reference for web applications

boolean

Captcha autofocus flag. Used only for the block value in the view argument. Possible values:

  • true — autofocus enabled (by default), focus on the page will be moved to the web element with the captcha;
  • false — autofocus disabled, focus on the page will remain where it was before the web element with the captcha appeared

scheme

SDK reference for web applications

string

Color scheme of the captcha widget. Possible values:

  • light — light;
  • dark — dark.

By default, matches the color scheme of the page or application where the captcha is integrated

lang

SDK reference for web applications

string

Localization language. If not specified, the value will be determined on the server. Possible values:

  • ru — Russian;
  • be — Belarusian;
  • de — German;
  • en — English;
  • es — Spanish;
  • fr — French;
  • kk — Kazakh;
  • pl — Polish;
  • tr — Turkish;
  • uk — Ukrainian;
  • uz — Uzbek

onClose

SDK reference for web applications

() => void

Callback notification about captcha closing

The method returns a promise object with the captcha pass result:

promise resolve <CAPTCHA_PASS_TOKEN> promise reject <ERROR>

Here:

  • <CAPTCHA_PASS_TOKEN> — successful captcha pass token if the user passed the captcha;
  • <ERROR>close error if the user closed the captcha window.

Close captcha

The captchaWidget.close() method closes the captcha widget. The method returns nothing in the response.

Example of method call:

captchaWidget.close();