Compare commits
2 Commits
5931e51f84
...
fdf1c4f628
Author | SHA1 | Date | |
---|---|---|---|
fdf1c4f628 | |||
6e6db166b4 |
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sati",
|
||||
"version": "0.2.3",
|
||||
"version": "0.2.4",
|
||||
"description": "next generation anti-captcha",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
|
10
src/Sati.ts
10
src/Sati.ts
@ -22,6 +22,7 @@ import { events, methods, tasks, Task } from './types'
|
||||
*/
|
||||
export class Sati extends EventEmitter<events> {
|
||||
private socket: SatiSocket
|
||||
private shortLogging: boolean
|
||||
private awaitedTasks: {
|
||||
[ index: number ]: {
|
||||
resolve(data: any): void,
|
||||
@ -30,8 +31,9 @@ export class Sati extends EventEmitter<events> {
|
||||
} = Object.create(null)
|
||||
|
||||
/** @param token your api token. get it at https://sati.ac/dashboard */
|
||||
constructor({ token }: { token: string }) {
|
||||
constructor({ token, shortLogging = false }: { token: string, shortLogging?: boolean }) {
|
||||
super()
|
||||
this.shortLogging = shortLogging
|
||||
this.socket = new SatiSocket(token)
|
||||
this.socket.on('event', ({ type, data }) => {
|
||||
this.emit(type as keyof events, data)
|
||||
@ -63,7 +65,11 @@ export class Sati extends EventEmitter<events> {
|
||||
const awaited = this.awaitedTasks[task.id]
|
||||
|
||||
if(task.state === 'error') {
|
||||
awaited.reject(new SatiError(`unable to solve ${task.type} task #${task.id}`))
|
||||
let message = `unable to solve ${task.type} task`
|
||||
if(!this.shortLogging) {
|
||||
message += ` #${task.id}`
|
||||
}
|
||||
awaited.reject(new SatiError(message))
|
||||
} else if(task.state === 'success') {
|
||||
awaited.resolve(task)
|
||||
}
|
||||
|
14
src/types.ts
14
src/types.ts
@ -32,6 +32,20 @@ export type tasks = {
|
||||
result: {
|
||||
token: string
|
||||
}
|
||||
},
|
||||
GeeTest3: {
|
||||
params: {
|
||||
siteKey: string,
|
||||
pageUrl: string,
|
||||
challenge: string,
|
||||
apiServer?: string,
|
||||
proxy?: string
|
||||
},
|
||||
result: {
|
||||
challenge: string,
|
||||
validate: string,
|
||||
seccode: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user