promise-geetest
v1.0.2
Published
geetest ad promise wapper
Downloads
4
Readme
base on geetest
useage
npm i geetest promise-geetest --save
const privateKey = 'privateKey'
const publicKey = 'publicKey'
const Geetest = require('promise-geetest')
const geetest = new Geetest(privateKey, publicKey)
router.get('/register', async (ctx) => {
// 向极验申请一次验证所需的challenge
const data = await geetest.register().catch(err => null)
if (data)
ctx.body = data
else
ctx.body = 'error'
})
router.post('/validate', async (ctx) => {
const {
geetest_challenge: challenge,
geetest_validate: validate,
geetest_seccode: seccode
} = ctx.request.body
// 对ajax提交的验证结果值进行验证
const result = await geetest.validate({ challenge, validate, seccode }).catch(err => null)
if (result)
ctx.body = JSON.stringify(result)
else
ctx.body = 'error'
})