Captcha

AV. Captcha

new Captcha()

Source:
Example
AV.Captcha.request().then(captcha => {
  captcha.bind({
    textInput: 'code', // the id for textInput
    image: 'captcha',
    verifyButton: 'verify',
  }, {
    success: (validateCode) => {}, // next step
    error: (error) => {}, // present error.message to user
  });
});

Members

captchaToken :string

Source:
The captchaToken of the captcha.
Type:
  • string

url :string

Source:
The image url of the captcha
Type:
  • string

validateToken :string

Source:
The validateToken of the captcha.
Type:
  • string

Methods

(static) request(optionsopt) → {Promise.<AV.Captcha>}

Source:
Request a captcha
Parameters:
Name Type Attributes Description
options <optional>
Properties
Name Type Attributes Default Description
width Number <optional>
width(px) of the captcha, ranged 60-200
height Number <optional>
height(px) of the captcha, ranged 30-100
size Number <optional>
4 length of the captcha, ranged 3-6. MasterKey required.
ttl Number <optional>
60 time to live(s), ranged 10-180. MasterKey required.
Returns:
Type
Promise.<AV.Captcha>

bind(elementsopt, callbacksopt)

Source:
Bind the captcha to HTMLElements. ONLY AVAILABLE in browsers.
Parameters:
Name Type Attributes Description
elements <optional>
Properties
Name Type Attributes Description
textInput String | HTMLInputElement <optional>
An input element typed text, or the id for the element.
image String | HTMLImageElement <optional>
An image element, or the id for the element.
verifyButton String | HTMLElement <optional>
A button element, or the id for the element.
callbacks <optional>
Properties
Name Type Attributes Description
success function <optional>
Success callback will be called if the code is verified. The param `validateCode` can be used for further SMS request.
error function <optional>
Error callback will be called if something goes wrong, detailed in param `error.message`.

refresh() → {Promise.<string>}

Source:
Refresh the captcha
Returns:
a new capcha url
Type
Promise.<string>

unbind()

Source:
unbind the captcha from HTMLElements. ONLY AVAILABLE in browsers.

verify(code) → {Promise.<string>}

Source:
Verify the captcha
Parameters:
Name Type Description
code String The code from user input
Returns:
validateToken if the code is valid
Type
Promise.<string>