mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
feat: add types of geetest (#23069)
This commit is contained in:
parent
27b74af5a2
commit
7a3a2f77d5
41
types/geetest/geetest-tests.ts
Normal file
41
types/geetest/geetest-tests.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import Geetest = require('geetest');
|
||||
|
||||
const captcha = new Geetest({
|
||||
geetest_id: 'xxx',
|
||||
geetest_key: 'xxx',
|
||||
});
|
||||
|
||||
captcha.register((err, data) => {
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
const body = {
|
||||
gt: data.geetest_id,
|
||||
challenge: data.challenge,
|
||||
success: data.success,
|
||||
};
|
||||
});
|
||||
|
||||
captcha.register().then((data) => {
|
||||
const body = {
|
||||
gt: data.geetest_id,
|
||||
challenge: data.challenge,
|
||||
success: data.success,
|
||||
};
|
||||
}, (err) => {
|
||||
});
|
||||
|
||||
captcha.validate({
|
||||
challenge: 'xxx',
|
||||
validate: 'xxx',
|
||||
seccode: 'xxx',
|
||||
}, (err, success) => {
|
||||
});
|
||||
|
||||
captcha.validate({
|
||||
challenge: 'xxx',
|
||||
validate: 'xxx',
|
||||
seccode: 'xxx',
|
||||
}).then((success) => {
|
||||
}, (err) => {
|
||||
});
|
||||
37
types/geetest/index.d.ts
vendored
Normal file
37
types/geetest/index.d.ts
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
// Type definitions for geetest 4.1
|
||||
// Project: https://github.com/GeeTeam/gt-node-sdk#readme
|
||||
// Definitions by: York Yao <https://github.com/plantain-00>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface Options {
|
||||
geetest_id: string;
|
||||
geetest_key: string;
|
||||
protocol?: string;
|
||||
api_server?: string;
|
||||
}
|
||||
|
||||
type Success = 0 | 1;
|
||||
|
||||
interface Data {
|
||||
geetest_id: string;
|
||||
gt: string;
|
||||
challenge: string;
|
||||
success: Success;
|
||||
new_captcha: string;
|
||||
}
|
||||
|
||||
interface Result {
|
||||
challenge: string;
|
||||
validate: string;
|
||||
seccode: string;
|
||||
}
|
||||
|
||||
declare class Geetest {
|
||||
constructor(options: Options);
|
||||
register(callback: (error: Error, data: Data) => void): void;
|
||||
register(): Promise<Data>;
|
||||
validate(result: Result, callback: (error: Error, success: Success) => void): void;
|
||||
validate(result: Result): Promise<Success>;
|
||||
}
|
||||
|
||||
export = Geetest;
|
||||
23
types/geetest/tsconfig.json
Normal file
23
types/geetest/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"geetest-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/geetest/tslint.json
Normal file
1
types/geetest/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user