npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@yyyyu/react-native-geetest-sensebot

v2.1.1

Published

geetest sensebot for react native.

Downloads

11

Readme

react-native-geetest-sensebot

GEETEST极验行为验证 npm version Build Status

SDK Version iOS: v0.11.7_20190314 Android: v4.0.7_20190311

测试环境 Xcode 10.2.1 react-native 0.59.5

Getting Started

yarn add @yyyyu/react-native-geetest-sensebot
# or
npm i @yyyyu/react-native-geetest-sensebot --save
react-native link @yyyyu/react-native-geetest-sensebot

iOS 不使用 CocoaPods

在 Linked Frameworks and Libraries 中添加 node_modules/@yyyyu/react-native-geetest-sensebot/ios/SDK/GT3Captcha.framework

add framework

Android

在 AndroidManifest.xml 文件中添加权限

// ...
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

Example

import React, { Component } from 'react'
import { View, Button } from 'react-native'
import * as RNGeetestSensebot from '@yyyyu/react-native-geetest-sensebot'

export default class App extends Component {
  geetest = async () => {
    let api1Result
    try {
      const api1Response = await fetch('http://www.geetest.com/demo/gt/register-test')
      api1Result = await api1Response.json()
    } catch (e) {
      return console.log('API1 request failed, message: %s.', e.message)
    }

    let geetestResult
    try {
      geetestResult = await RNGeetestSensebot.start({
        api1Result,
        // optional default false
        debug: true,
        // optional default 10s
        loadTimeout: 10000,
        // optional default 10s
        reqTimeout: 10000,
        // optional default system
        lang: RNGeetestSensebot.Lang.System,
        // optional default false
        enableBackgroundCancel: true,
        // optional default transparent
        backgroundColorIOS: 'red',
        // optional default none
        backgroundBlurEffectIOS: RNGeetestSensebot.BackgroundBlurEffectIOS.Regular,
        // optional
        onEvent: (code, data) => {
          if (code === RNGeetestSensebot.Events.FAILED) {
            console.log('Validate failed, reason: %s', data[0])
          } else {
            console.log(RNGeetestSensebot.Events[code], data)
          }
        }
      })
    } catch (e) {
      return console.log('Error, code: %d, message: %s.', e.code, e.message)
    }

    let api2Result
    try {
      const api2Response = await fetch('http://www.geetest.com/demo/gt/validate-test', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json;charset=UTF-8' },
        body: JSON.stringify(geetestResult)
      })
      api2Result = await api2Response.json()
    } catch (e) {
      return console.log('API2 request failed, message: %s.', e.message)
    }

    console.log('Validate result: %o.', api2Result)
  }

  render() {
    return (
      <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
        <Button title='StartGeetest' onPress={this.geetest} color='#26c6aa' />
      </View>
    )
  }
}

Option

export interface IOption {
    // API1
    api1Result: IAPI1Result;
    // debug
    debug?: boolean;
    // view 加载超时时间,默认10000
    loadTimeout?: number;
    // 第二步向极验服务器发送请求超时时间,默认10000
    reqTimeout?: number;
    // 语言,如果为null则使用系统默认语言
    lang?: Lang;
    // 点击背景是否可以取消验证
    enableBackgroundCancel?: boolean;
    // 背景色 IOS Only
    backgroundColorIOS?: any;
    // 背景模糊类型 IOS Only
    backgroundBlurEffectIOS?: BackgroundBlurEffectIOS;
    // 事件监听
    onEvent?: (code: Events, data?: Array<number | string>) => void;
}

export interface IAPI1Result {
    success: 0 | 1;
    challenge: string;
    gt: string;
    new_captcha: boolean;
    [key: string]: any;
}

export enum Lang {
    System = "system", // 跟随系统
    ZH = "zh", // 简体中文
    ZH_TW = "zh-tw", // 繁体中文
    ZH_HK = "zh-hk", // 繁体中文
    EN = "en", // 英语
    ID = "id", // 印尼语
    JA = "ja", // 日语
    KO = "ko", // 韩语
    RU = "ru", // 俄语
    AR = "ar", // 阿拉伯语
    ES = "es", // 西班牙语
    PT_PT = "pt-pt", // 葡萄牙语
    FR = "fr", // 法语
    DE = "de", // 德语
}

export enum BackgroundBlurEffectIOS {
    None = -1,
    ExtraLight = 0,
    Light,
    Dark,
    Regular, // NS_ENUM_AVAILABLE_IOS(10_0)
    Prominent, // NS_ENUM_AVAILABLE_IOS(10_0)
}

export enum Events {
    // 验证结果
    RESULT = 1,
    // 验证窗口关闭
    CLOSED = 2,
    // 验证失败
    FAILED = 3,
    // 发生错误
    ERROR = 0,
}

export enum Errors {
    // 参数解析错误
    PARAMETER_PARSE_FAILED = -1,
    // 安卓 activity 已经销毁
    ANDROID_ACTIVITY_DESTROYED = -2,
    // 重复启动
    DUPLICATE_START = -3,
}

export interface IResult {
    geetest_challenge: string;
    geetest_seccode: string;
    geetest_validate: string;
    [key: string]: any;
}