Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

egg-gt3

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-gt3

egg geetest3 plugin

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

egg-gt3

NPM version build status Test coverage David deps Known Vulnerabilities

Install

npm i egg-gt3 --save

Usage

// {app_root}/config/plugin.js
exports.geetest = {
  enable: true,
  package: 'egg-gt3',
};

Configuration

// {app_root}/config/config.default.js
exports.geetest = {
  geetest_id: '',
  geetest_key: '',
};

Example

// {app_root}/app/router.js
// api添加geetest拦截校验,errorMsg[可选项]为自定义错误返回值,校验错误默认返回{ code: -1, error }
router.post('/a', app.middleware.geetest(app[, errorMsg]), controller.home.a);

// geetest注册
this.ctx.geetest.register(data, callback);

// geetest校验
this.ctx.geetest.validate(fallback, result, callback)
// 前端注册初始化geetest,cb为callback,传人校验成功发送的真正请求
function registerInitGT(cb) {
  API.registerGT().then(res => {
    window.initGeetest({
      // 以下 4 个配置参数为必须,不能缺少
      gt: res.gt,
      challenge: res.challenge,
      offline: !res.success, // 表示用户后台检测极验服务器是否宕机
      new_captcha: res.new_captcha, // 用于宕机时表示是新验证码的宕机
      product: "bind", // 产品形式,包括:float,popup
      width: "300px"
      // 更多配置参数说明请参见:http://docs.geetest.com/install/client/web-front/
    }, (captchaObj) => {
      this.captchaObj = captchaObj;
      captchaObj.onReady(() => {
        captchaObj.verify();
      }).onSuccess(() => {
        const result = captchaObj.getValidate();
        if (result){
          cb(result);
        }
      });
    });
  })
}
// 发送校验码
function confirmSendCode(gt) {
  const { geetest_challenge, geetest_validate, geetest_seccode } = gt;
  API.getCaptcha(email, {
    geetest_challenge,
    geetest_validate,
    geetest_seccode
  }).then(res => {
  })
}
// 使用
registerInitGT(confirmSendCode)

Questions & Suggestions

Please open an issue here.

License

MIT

Keywords

FAQs

Package last updated on 19 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc