feat(Sati): add projectId support
This commit is contained in:
		@ -1,6 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
	"name": "sati",
 | 
			
		||||
	"version": "0.3.0",
 | 
			
		||||
	"version": "0.3.1",
 | 
			
		||||
	"description": "next generation anti-captcha",
 | 
			
		||||
	"license": "MIT",
 | 
			
		||||
	"repository": {
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										14
									
								
								src/Sati.ts
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/Sati.ts
									
									
									
									
									
								
							@ -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 }
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user