Compare commits

..

5 Commits

Author SHA1 Message Date
de61055967 feat(ImageToText): add ImageToText task support 2023-08-31 18:55:24 +03:00
881c82bd12 fix(FunCaptcha): make data optional 2023-08-14 18:02:17 +03:00
0d98890463 fix(package): fix esm module location 2023-08-14 18:01:51 +03:00
ab8bdbbe33 feat(Sati): add projectId support 2023-08-10 07:29:03 +03:00
54962f9db5 feat: add geetest support 2023-08-01 07:42:26 +03:00
4 changed files with 29 additions and 8 deletions

5
package-lock.json generated
View File

@ -1,12 +1,13 @@
{
"name": "sati",
"version": "1.0.0",
"version": "0.3.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "sati",
"version": "1.0.0",
"version": "0.3.2",
"license": "MIT",
"dependencies": {
"@types/node": "^20.1.1",
"@types/ws": "^8.5.4",

View File

@ -1,6 +1,6 @@
{
"name": "sati",
"version": "0.2.4",
"version": "0.3.3",
"description": "next generation anti-captcha",
"license": "MIT",
"repository": {
@ -37,7 +37,7 @@
"types": "./dist/src/index.d.ts",
"exports": {
".": {
"import": "./dist/sati.node.esm.js",
"import": "./dist/sati.node.esm.mjs",
"require": "./dist/sati.node.cjs.js",
"types": "./dist/src/index.d.ts"
},

View File

@ -23,6 +23,7 @@ import { events, methods, tasks, Task } from './types'
export class Sati extends EventEmitter<events> {
private socket: SatiSocket
private shortLogging: boolean
private projectId: number | undefined
private awaitedTasks: {
[ index: number ]: {
resolve(data: any): void,
@ -31,9 +32,18 @@ export class Sati extends EventEmitter<events> {
} = Object.create(null)
/** @param token your api token. get it at https://sati.ac/dashboard */
constructor({ token, shortLogging = false }: { token: string, shortLogging?: boolean }) {
constructor({
token,
shortLogging = false,
projectId
}: {
token: string,
shortLogging?: boolean,
projectId?: number
}) {
super()
this.shortLogging = shortLogging
this.projectId = projectId
this.socket = new SatiSocket(token)
this.socket.on('event', ({ type, data }) => {
this.emit(type as keyof events, data)
@ -102,7 +112,7 @@ export class Sati extends EventEmitter<events> {
* @throws {SatiError} if unable to solve
*/
public async solve<T extends keyof tasks>(type: T, data: tasks[T]['params']): Promise<Task<T, 'success'>> {
const task = await this.call('createTask', { type, data })
const task = await this.call('createTask', { type, data, projectId: this.projectId })
return new Promise((resolve, reject) => {
this.awaitedTasks[task.id] = { resolve, reject }

View File

@ -25,7 +25,7 @@ export type tasks = {
params: {
siteKey: string,
pageUrl: string,
data: Record<string, string>
data?: Record<string, string>
serviceUrl?: string,
proxy?: string
},
@ -46,6 +46,15 @@ export type tasks = {
validate: string,
seccode: string
}
},
ImageToText: {
params: {
image: string,
type?: string,
},
result: {
result: string
}
}
}
@ -59,7 +68,8 @@ export type methods = {
createTask: {
request: {
type: keyof tasks,
data: tasks[keyof tasks]['params']
data: tasks[keyof tasks]['params'],
projectId?: number
},
response: Task
},