Compare commits
1 Commits
master
...
fdf1c4f628
Author | SHA1 | Date | |
---|---|---|---|
fdf1c4f628 |
5
package-lock.json
generated
5
package-lock.json
generated
@ -1,13 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "sati",
|
"name": "sati",
|
||||||
"version": "0.3.2",
|
"version": "1.0.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "sati",
|
"name": "sati",
|
||||||
"version": "0.3.2",
|
"version": "1.0.0",
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "^20.1.1",
|
"@types/node": "^20.1.1",
|
||||||
"@types/ws": "^8.5.4",
|
"@types/ws": "^8.5.4",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sati",
|
"name": "sati",
|
||||||
"version": "0.3.3",
|
"version": "0.2.4",
|
||||||
"description": "next generation anti-captcha",
|
"description": "next generation anti-captcha",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
@ -37,7 +37,7 @@
|
|||||||
"types": "./dist/src/index.d.ts",
|
"types": "./dist/src/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
"import": "./dist/sati.node.esm.mjs",
|
"import": "./dist/sati.node.esm.js",
|
||||||
"require": "./dist/sati.node.cjs.js",
|
"require": "./dist/sati.node.cjs.js",
|
||||||
"types": "./dist/src/index.d.ts"
|
"types": "./dist/src/index.d.ts"
|
||||||
},
|
},
|
||||||
|
14
src/Sati.ts
14
src/Sati.ts
@ -23,7 +23,6 @@ import { events, methods, tasks, Task } from './types'
|
|||||||
export class Sati extends EventEmitter<events> {
|
export class Sati extends EventEmitter<events> {
|
||||||
private socket: SatiSocket
|
private socket: SatiSocket
|
||||||
private shortLogging: boolean
|
private shortLogging: boolean
|
||||||
private projectId: number | undefined
|
|
||||||
private awaitedTasks: {
|
private awaitedTasks: {
|
||||||
[ index: number ]: {
|
[ index: number ]: {
|
||||||
resolve(data: any): void,
|
resolve(data: any): void,
|
||||||
@ -32,18 +31,9 @@ export class Sati extends EventEmitter<events> {
|
|||||||
} = Object.create(null)
|
} = Object.create(null)
|
||||||
|
|
||||||
/** @param token your api token. get it at https://sati.ac/dashboard */
|
/** @param token your api token. get it at https://sati.ac/dashboard */
|
||||||
constructor({
|
constructor({ token, shortLogging = false }: { token: string, shortLogging?: boolean }) {
|
||||||
token,
|
|
||||||
shortLogging = false,
|
|
||||||
projectId
|
|
||||||
}: {
|
|
||||||
token: string,
|
|
||||||
shortLogging?: boolean,
|
|
||||||
projectId?: number
|
|
||||||
}) {
|
|
||||||
super()
|
super()
|
||||||
this.shortLogging = shortLogging
|
this.shortLogging = shortLogging
|
||||||
this.projectId = projectId
|
|
||||||
this.socket = new SatiSocket(token)
|
this.socket = new SatiSocket(token)
|
||||||
this.socket.on('event', ({ type, data }) => {
|
this.socket.on('event', ({ type, data }) => {
|
||||||
this.emit(type as keyof events, data)
|
this.emit(type as keyof events, data)
|
||||||
@ -112,7 +102,7 @@ export class Sati extends EventEmitter<events> {
|
|||||||
* @throws {SatiError} if unable to solve
|
* @throws {SatiError} if unable to solve
|
||||||
*/
|
*/
|
||||||
public async solve<T extends keyof tasks>(type: T, data: tasks[T]['params']): Promise<Task<T, 'success'>> {
|
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, projectId: this.projectId })
|
const task = await this.call('createTask', { type, data })
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.awaitedTasks[task.id] = { resolve, reject }
|
this.awaitedTasks[task.id] = { resolve, reject }
|
||||||
|
14
src/types.ts
14
src/types.ts
@ -25,7 +25,7 @@ export type tasks = {
|
|||||||
params: {
|
params: {
|
||||||
siteKey: string,
|
siteKey: string,
|
||||||
pageUrl: string,
|
pageUrl: string,
|
||||||
data?: Record<string, string>
|
data: Record<string, string>
|
||||||
serviceUrl?: string,
|
serviceUrl?: string,
|
||||||
proxy?: string
|
proxy?: string
|
||||||
},
|
},
|
||||||
@ -46,15 +46,6 @@ export type tasks = {
|
|||||||
validate: string,
|
validate: string,
|
||||||
seccode: string
|
seccode: string
|
||||||
}
|
}
|
||||||
},
|
|
||||||
ImageToText: {
|
|
||||||
params: {
|
|
||||||
image: string,
|
|
||||||
type?: string,
|
|
||||||
},
|
|
||||||
result: {
|
|
||||||
result: string
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,8 +59,7 @@ export type methods = {
|
|||||||
createTask: {
|
createTask: {
|
||||||
request: {
|
request: {
|
||||||
type: keyof tasks,
|
type: keyof tasks,
|
||||||
data: tasks[keyof tasks]['params'],
|
data: tasks[keyof tasks]['params']
|
||||||
projectId?: number
|
|
||||||
},
|
},
|
||||||
response: Task
|
response: Task
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user