@kylin-public/kylin-autosolve-client
v1.0.5
Published
The client library of kylin autosolve
Downloads
9
Readme
The client library of Kylin Autosolve
by Kylin Inc.
This is a client library of Kylin Autosolve based on the WebSocket protocol.
Installation
npm install --save @kylin-public/kylin-autosolve-client
Usage
Initialize a client
const { KylinAutosolveClient } = require('kylin-autosolve-client')
const client = new KylinAutosolveClient()
Connect to the autosolve service
client.start('ACCESS_TOKEN', 'CLIENT_KEY')
Add a listener to receive result
const TASK_RESULT = kylinAutoSolveProto.Notification.PayloadCase.TASK_RESULT
client.on('notification-' + TASK_RESULT, (evt) => {
/** @type {proto.kylinautosolve.Notification} */
const notification = evt.notification
const taskResult = notification.getTaskResult()
evt.handled++
const response = taskResult.toObject()
console.log('received task result:', response)
callback(response)
})
Create a task to solve a challenge
const options = {
siteKey: '6Lfv-q0ZAAAAADy0U9JUaCPCZI15U-7jhbAiYa0U',
version: '3',
action: 'login'
}
const createTaskMessage = client.makeCreateTaskMessage({
challengeType: 'google',
url: 'https://recaptcha-test.kylinbot.io/',
timeout: options.timeout,
options: JSON.stringify(options)
})
await client.whenReady()
const createTaskResponse = await client.invoke(createTaskMessage)
console.log('response:', createTaskResponse.toObject())
Poll the result of task
You don't have to poll the result usually, the autosolve server will notify client when it got the result from Kylin One Click, install a notification handler to receive result instead.
await client.invoke(client.makeGetTaskResultMessage({
taskId: createTaskResponse.getCreateTask().getTaskId()
}))
Cancel a request
await client.invoke(client.makeCancelTaskMessage({
taskId: createTaskResponse.getCreateTask().getTaskId()
}))
Cancel all requests
await client.invoke(client.makeCancelTaskMessage({}))