From ab8bdbbe3341fc4657654f0387811c9caffb68b1 Mon Sep 17 00:00:00 2001 From: "sati.ac" Date: Thu, 10 Aug 2023 07:29:03 +0300 Subject: [PATCH] feat(Sati): add projectId support --- package.json | 2 +- src/Sati.ts | 14 ++++++++++++-- src/types.ts | 3 ++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 60fb64f..1aaf105 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sati", - "version": "0.3.0", + "version": "0.3.1", "description": "next generation anti-captcha", "license": "MIT", "repository": { diff --git a/src/Sati.ts b/src/Sati.ts index 0507bfb..594662a 100644 --- a/src/Sati.ts +++ b/src/Sati.ts @@ -23,6 +23,7 @@ import { events, methods, tasks, Task } from './types' export class Sati extends EventEmitter { 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 { } = 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 { * @throws {SatiError} if unable to solve */ public async solve(type: T, data: tasks[T]['params']): Promise> { - 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 } diff --git a/src/types.ts b/src/types.ts index 90678cf..ba65a72 100644 --- a/src/types.ts +++ b/src/types.ts @@ -59,7 +59,8 @@ export type methods = { createTask: { request: { type: keyof tasks, - data: tasks[keyof tasks]['params'] + data: tasks[keyof tasks]['params'], + projectId?: number }, response: Task },