Created
September 30, 2022 03:53
-
-
Save Lxys-ai/2c92e8a9a43850c6b8a9956094f40606 to your computer and use it in GitHub Desktop.
Lex State Machine Task Engine a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable */ | |
const fs = require("fs"); | |
const colors = require("colors"); | |
const child_process = require("child_process"); | |
const path = require("path"); | |
const events = require("events"); | |
const eventEmitter = new events.EventEmitter(); | |
const monitorEvent = new events.EventEmitter(); | |
const crypto = require("crypto"); | |
const utf8 = require("utf8"); | |
/* | |
request handling imports | |
*/ | |
const nodeFetch = require("node-fetch"); | |
const withHar = require("node-fetch-har").withHar; | |
// const fetch = withHar(nodeFetch); | |
const fetch = nodeFetch; | |
const HttpsProxyAgent = require("https-proxy-agent"); | |
const tlsFetch = require("./lexTLS/index.js").tlsFetch; | |
/* | |
preset imports and helper functions | |
*/ | |
const { harvest2CAP, harvest2CAPImage } = require("./CaptchaHarvesting/2cap"); | |
const { | |
yearSpacing, | |
monthSpacing, | |
cardSpacing, | |
stateName, | |
} = require("./presets/profileFormat"); | |
const { | |
harvestCaptchaMonster, | |
harvestCaptchaMonsterImage, | |
} = require("./CaptchaHarvesting/Capmonster"); | |
const proxyRotater = require("./presets/proxyRotater.js").getProxy; | |
const walmartEncryption = | |
require("./presets/walmart/walmartEncryption").encrypt; | |
const homeDepotEncryption = | |
require("./presets/homedepot/homedepotEncryption").encrypt; | |
const paniniStates = require("./presets/panini/paniniStates").paniniStates; | |
const amazonLogin = require("./presets/amazon/amazonLogin").amazonLogin; | |
const amazonMonitor = require("./presets/amazon/monitor").monitor; | |
const bestbuyMonitor = require("./presets/bestbuy/monitor").monitor; | |
const bestbuyLogin = require("./presets/bestbuy/browserLogin.js").BestBuyLogin; | |
const bestbuyBody = require("./presets/bestbuy/generateLoginBody").generateBody; | |
const bestbuyCode = require("./presets/bestbuy/imap").start; | |
const bestbuyEncrypt = require("./presets/bestbuy/encryptCard").start; | |
const SolveCaptcha = require("./CaptchaHarvesting/solvers.js").SolveCaptcha; | |
const { encrypt } = require("cs2-encryption"); | |
const jwt_decode = require("jwt-decode"); | |
const qs = require("qs"); | |
const base64 = require("base-64"); | |
const WebSocket = require("ws"); | |
// const { createLogger, format, Logger, transports } =require('winston'); | |
// const httpTransportOptions = { | |
// host: 'http-intake.logs.datadoghq.com', | |
// path: '/api/v2/logs?dd-api-key=1&ddsource=nodejs&service=LexAIO', | |
// ssl: true, | |
// }; | |
// const datadogLogger = createLogger({ | |
// level: 'info', | |
// exitOnError: false, | |
// format: format.json(), | |
// transports: [new transports.Http(httpTransportOptions)], | |
// }); | |
console.log = (message) => { | |
// process.send({ | |
// type: 'DatadogLog', | |
// level: 'info', | |
// data: { | |
// from: 'task_engine', | |
// data: { | |
// message: message, | |
// eventType:"task_engine_log" | |
// } | |
// } | |
// }); | |
// console.info(message) | |
if (logWs) { | |
if (typeof message == "object") { | |
message = JSON.stringify(message); | |
} | |
logWs.send(message); | |
} | |
}; | |
const newPromise = (id) => | |
new Promise((resolve) => { | |
eventEmitter.on(`promiseSolved${id}`, (response) => { | |
resolve(response); | |
}); | |
}); | |
const lexFetch = async (message) => { | |
let id = makeid(10); | |
process.send({ | |
type: "fetch", | |
message: message, | |
id: id, | |
}); | |
let response = await newPromise(id); | |
return response; | |
}; | |
// process.send = () => {} | |
function makeid(length) { | |
var result = ""; | |
var characters = | |
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | |
var charactersLength = characters.length; | |
for (var i = 0; i < length; i++) { | |
result += characters.charAt(Math.floor(Math.random() * charactersLength)); | |
} | |
return result; | |
} | |
// | |
// grpcDir = path.join(__dirname, `index.exe`) | |
// grpcServer = child_process.spawn(grpcDir, { | |
// // shell: true, | |
// windowsHide: true, | |
// }); | |
// | |
// setInterval(() => { | |
// const used = process.memoryUsage().heapUsed / 1024 / 1024; | |
// console.log(`The script uses approximately ${Math.round(used * 100) / 100} MB`); | |
// }, 500); | |
const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor; | |
let taskObjects = {}; | |
let moduleJSON = {}; | |
let startTime = 0; | |
let endTime = 0; | |
let taskStatusQueue = []; | |
let taskStatisticQueue = []; | |
let mainProcessSocket; | |
let autopilotSocket; | |
let amazonSocket; | |
let logWs; | |
const connectToAmazonSocket = async () => { | |
// try{ | |
// amazonSocket = new WebSocket('https://lex-amazon.herokuapp.com/lex-ws-test'); | |
// amazonSocket.on('open', function open() { | |
// // console.log("AmazonWS listening...") | |
// }); | |
// amazonSocket.on('message', function incoming(message) { | |
// process.send({ | |
// type: 'amazonSocket-message', | |
// message: message | |
// }) | |
// }); | |
// amazonSocket.on('close', function close() { | |
// // console.log("AmazonWS closed") | |
// setTimeout(() => { | |
// connectToAmazonSocket() | |
// }, 5000) | |
// }); | |
// } catch { | |
// // console.log("AmazonWS not listening...") | |
// setTimeout(() => { | |
// connectToAmazonSocket() | |
// }, 5000) | |
// } | |
}; | |
const connectToBestBuySocket = async () => { | |
try { | |
bestbuySocket = new WebSocket("https://lex-bestbuy.herokuapp.com/"); | |
//bestbuySocket = new WebSocket('ws://localhost:4000'); | |
bestbuySocket.on("open", function open() { | |
console.log("BestBuyWS listening..."); | |
}); | |
bestbuySocket.on("message", function incoming(message) { | |
// eslint-disable-next-line | |
process.send({ | |
type: "bestbuySocket-message", | |
message: message, | |
}); | |
}); | |
bestbuySocket.on("close", function close() { | |
console.log("BestBuyWS closed"); | |
setTimeout(() => { | |
connectToBestBuySocket(); | |
}, 5000); | |
}); | |
} catch { | |
console.log("BestBuyWS not listening..."); | |
setTimeout(() => { | |
connectToBestBuySocket(); | |
}, 5000); | |
} | |
}; | |
const connectToAutopilotSocket = async () => { | |
// try{ | |
// autopilotSocket = new WebSocket('https://obscure-thicket-50038.herokuapp.com/lex-ws-test'); | |
// autopilotSocket.on('open', function open() { | |
// // console.log("Autopilot listening...") | |
// }); | |
// autopilotSocket.on('message', function incoming(message) { | |
// process.send({ | |
// type: 'autopilot-message', | |
// message: message | |
// }) | |
// }) | |
// autopilotSocket.on('close', function close() { | |
// // console.log("Autopilot closed...") | |
// setTimeout(() => { | |
// connectToAutopilotSocket() | |
// }, 5000) | |
// }); | |
// } catch { | |
// console.log("AutopilotWS not listening...") | |
// setTimeout(() => { | |
// connectToAutopilotSocket() | |
// }, 5000) | |
// } | |
}; | |
const connectToMainProcessSocket = async () => { | |
mainProcessSocket = new WebSocket("ws://localhost:12315"); | |
mainProcessSocket.on("open", function open() { | |
mainProcessSocket.send("something"); | |
}); | |
mainProcessSocket.on("message", function incoming(message) {}); | |
}; | |
let mainProcessSocket2; | |
const connectToMainProcessSocket2 = async () => { | |
mainProcessSocket2 = new WebSocket("ws://localhost:12316"); | |
mainProcessSocket2.on("open", function open() { | |
mainProcessSocket2.send("something"); | |
}); | |
mainProcessSocket2.on("message", function incoming(message) {}); | |
}; | |
const createLogSocket = async () => { | |
//create new websocket server | |
let wss = new WebSocket.Server({ port: 12514 }); | |
wss.on("connection", function connection(ws) { | |
logWs = ws; | |
}); | |
// const child_process = require('child_process'); | |
// child_process.exec("start cmd.exe /K node src/main/core/TaskChild/presets/logs/log.js"); | |
}; | |
connectToMainProcessSocket(); | |
connectToMainProcessSocket2(); | |
connectToAutopilotSocket(); | |
connectToAmazonSocket(); | |
connectToBestBuySocket(); | |
createLogSocket(); | |
const log = (TaskID, text, type, func) => { | |
if (taskObjects[TaskID].Stopped == true) { | |
return; | |
} | |
let site = taskObjects[TaskID].getTaskInfo(TaskID, taskObjects).product.site; | |
let TaskGroupID = taskObjects[TaskID].TaskGroupID; | |
let task_info = taskObjects.taskGroups | |
.find((group) => group.id === TaskGroupID) | |
.tasks.find((task) => task.id === TaskID); | |
let task_mode = task_info.task_settings.task_mode; | |
let task_type = task_info.type; | |
let colorDict = moduleJSON[site][task_type][task_mode]["logStatusColors"]; | |
let color = colorDict[type] ?? "red"; | |
type = type == "end" ? "unknown error" : type; | |
typeText = colors[color](type); | |
try { | |
taskStatusQueue = taskStatusQueue.filter((item) => { | |
return JSON.parse(item).TaskID !== TaskID; | |
}); | |
if (taskObjects[TaskID].Stopped) { | |
return; | |
} | |
//sends task status to main process | |
taskStatusQueue.push( | |
JSON.stringify({ | |
type: "updateTaskStatus", | |
TaskID: TaskID, | |
TaskGroupID: taskObjects[TaskID].TaskGroupID, | |
text: text, | |
color: color, | |
task_info: task_info, | |
}) | |
); | |
if (moduleJSON[site][task_type][task_mode]["taskStatistics"]) { | |
taskStatisticQueue.push( | |
JSON.stringify({ | |
type: "updateTaskStatistics", | |
TaskID: TaskID, | |
TaskGroupID: taskObjects[TaskID].TaskGroupID, | |
statisticType: | |
moduleJSON[site][task_type][task_mode]["taskStatistics"][type], | |
action: "increment", | |
}) | |
); | |
} | |
console.info( | |
"[ " + | |
TaskID + | |
" ] [ " + | |
typeText + | |
" ] [ " + | |
func["name"] + | |
" ] [ " + | |
timestampSHORT() + | |
" ] " + | |
text | |
); | |
if (logWs) { | |
logWs.send( | |
"[ " + | |
TaskID + | |
" ] [ " + | |
typeText + | |
" ] [ " + | |
func["name"] + | |
" ] [ " + | |
timestampSHORT() + | |
" ] " + | |
text | |
); | |
} | |
} catch (e) { | |
console.log(e); | |
} | |
}; | |
setInterval(() => { | |
if (taskStatusQueue.length > 0) { | |
mainProcessSocket.send( | |
JSON.stringify({ | |
type: "BulkUpdateTaskStatus", | |
taskStatusQueue: taskStatusQueue, | |
taskStatisticQueue: taskStatisticQueue, | |
}) | |
); | |
taskStatusQueue = []; | |
taskStatisticQueue = []; | |
} | |
}, 250); | |
const main = async (TaskID, func) => { | |
if (taskObjects[TaskID].Stopped == true) { | |
if (taskObjects.settings.preferences.log_tasks) { | |
let encryptData = (data) => { | |
let buff = new Buffer.from(data); | |
let base64data = buff.toString("base64"); | |
newText = reverseString(base64data).split(""); | |
let finalText = ""; | |
for (item of newText) { | |
finalText += | |
item + "," + getRandomInt(100) + "," + getRandomInt(1000) + ","; | |
} | |
return finalText; | |
}; | |
let encryptedHar = encryptData( | |
JSON.stringify(taskObjects[TaskID]["harLog"]) | |
); | |
let site = taskObjects[TaskID].getTaskInfo(TaskID, taskObjects).product | |
.site; | |
process.send({ | |
type: "logHar", | |
data: encryptedHar, | |
site: site, | |
TaskID, | |
}); | |
fs.writeFileSync(`./logs/${site}-${TaskID}.lex`, encryptedHar); | |
} | |
console.log( | |
`[ ${TaskID} ] [ ${"Task Stopped by Client"} ] [ ${ | |
func.name | |
} ] [ ${timestampSHORT()} ]` | |
); | |
return; | |
} | |
try { | |
if ( | |
taskObjects[TaskID]["CallStack"][ | |
taskObjects[TaskID]["CallStack"].length - 2 | |
] == func["name"] && | |
func["type"] == "request" | |
) { | |
await new Promise((resolve) => setTimeout(resolve, func["retryDelay"])); | |
} | |
} catch {} | |
taskObjects[TaskID]["CallStack"].push(func["name"]); | |
if (func["start"] != null) { | |
for (let functionName of func["start"].replace(/ /g, "").split(",")) { | |
await handleHelperFunction(TaskID, func, functionName); | |
} | |
} | |
let TaskGroupID = taskObjects[TaskID].TaskGroupID; | |
switch (func["type"]) { | |
case "request": | |
let [requestResponse, harEntry] = await handleRequest(TaskID, func); | |
if (requestResponse === "timeout") { | |
process.send({ | |
type: "updateTaskStatus", | |
TaskID: TaskID, | |
TaskGroupID: TaskGroupID, | |
text: "Request Timeout. Retrying...", | |
color: "yellow", | |
}); | |
main(TaskID, func); | |
return; | |
} | |
if (requestResponse === "error") { | |
process.send({ | |
type: "updateTaskStatus", | |
TaskID: TaskID, | |
TaskGroupID: TaskGroupID, | |
text: "Request Error. Check Proxy. Retrying...", | |
color: "yellow", | |
}); | |
main(TaskID, func); | |
return; | |
} | |
if (requestResponse.data === "Request Client Error") { | |
process.send({ | |
type: "updateTaskStatus", | |
TaskID: TaskID, | |
TaskGroupID: TaskGroupID, | |
text: "Request Error. Check Proxy. Retrying...", | |
color: "yellow", | |
}); | |
main(TaskID, func); | |
return; | |
} | |
await handleRequestStatus(TaskID, func, requestResponse, harEntry); | |
break; | |
case "function": | |
let functionResponse = await handleFunction(TaskID, func); | |
await handleFunctionStatus(TaskID, func, functionResponse); | |
break; | |
default: | |
console.log("Hit default case. Stopping Task."); | |
taskObjects[TaskID].Stopped = true; | |
break; | |
} | |
}; | |
const handleHelperFunction = async (TaskID, func, functionName) => { | |
const actions = { | |
executeHandlerFunction: async (TaskID, func, functionName) => { | |
let functionArgumentsVariables = []; | |
let helperFunction = taskObjects[TaskID]["helperFunctions"][functionName]; //gets the actual helper function | |
let site = taskObjects[TaskID].getTaskInfo(TaskID, taskObjects).product | |
.site; | |
let TaskGroupID = taskObjects[TaskID].TaskGroupID; | |
let task_info = taskObjects.taskGroups | |
.find((group) => group.id === TaskGroupID) | |
.tasks.find((task) => task.id === TaskID); | |
let task_mode = task_info.task_settings.task_mode; | |
let task_type = task_info.type; | |
functionArguments = | |
moduleJSON[site][task_type][task_mode]["helperFunctions"][functionName][ | |
"arguments" | |
]; | |
let argumentsInput = functionArguments.replace(/ /g, "").split(","); // makes function arguments into array if includes comma | |
for (let item of argumentsInput) { | |
functionArgumentsVariables.push( | |
item == "taskObjects" | |
? taskObjects | |
: taskObjects[TaskID]["Variables"][item] | |
); | |
} | |
functionArgumentsVariables.push(console); | |
functionArgumentsVariables.push(monitorEvent); | |
await helperFunction(...functionArgumentsVariables); | |
}, | |
}; | |
await actions.executeHandlerFunction(TaskID, func, functionName); | |
}; | |
const handleFunction = async (TaskID, func) => { | |
let args = func["function"].arguments + ", console, monitorEvent"; | |
let tempFunction = new AsyncFunction(args, func["function"].body); | |
return await tempFunction(taskObjects, TaskID, console, monitorEvent); | |
}; | |
const handleRequest = async (TaskID, func) => { | |
let headers = await handleHeaders(TaskID, func); | |
let method = await handleMethod(TaskID, func); | |
let body = await handleBody(TaskID, func); | |
let url = await handleURL(TaskID, func); | |
let proxy = await handleProxy(TaskID, func); | |
let cloudflare = await handleCloudflare(TaskID, func); | |
let redirect = await handleRedirect(TaskID, func); | |
let timeout = await handleTimeout(TaskID, func); | |
let response; | |
let error; | |
let newConfig; | |
if (func["request"]["requestOptions"]["useTLS"]) { | |
redirect = redirect ? "True" : "False"; | |
proxy = proxy ? JSON.parse(JSON.stringify(proxy))["proxy"]["href"] : ""; | |
let config = { | |
httpsAgent: proxy, | |
method: method, | |
url: url, | |
headers: headers, | |
data: body, | |
redirect: redirect, | |
cloudflare: cloudflare, | |
}; | |
// let harRequestEntry = handleHarRequestEntry(config); | |
let harRequestEntry = null; | |
if (func["request"]["requestOptions"]["tlsType"] === "lexFetch") { | |
let proxyInfo; | |
if (proxy === "") { | |
proxyInfo = null; | |
} else { | |
let splitProxy = proxy.split(":"); | |
proxyInfo = { | |
host: splitProxy[2].split("@")[1], | |
port: splitProxy[3].split("/")[0], | |
user: splitProxy[1].split("//")[1], | |
password: splitProxy[2].split("@")[0], | |
}; | |
} | |
newConfig = { | |
url: url, | |
options: { | |
proxy: proxyInfo, | |
method: method, | |
headers: headers, | |
data: body, | |
}, | |
}; | |
response = await lexFetch(newConfig); | |
body = response.body; | |
} else { | |
[response, error] = await executeTLSFetch(config); | |
body = await response.data; | |
} | |
// startTime = new Date(); | |
if (error) { | |
console.log(error); | |
return ["timeout", null]; | |
} | |
response.data = body; | |
// (config) | |
response.text = function () { | |
return body; | |
}; | |
return [response, harRequestEntry]; | |
} else { | |
if (redirect === true) { | |
redirect = "follow"; | |
} else if (redirect === "error") { | |
redirect = "error"; | |
} else { | |
redirect = "manual"; | |
} | |
let config = { | |
agent: proxy, | |
redirect: redirect, | |
headers: headers, | |
method: method, | |
body: body, | |
timeout: timeout, | |
}; | |
let [response, error] = await executeFetch(url, config); | |
if (error) { | |
console.log(error.type); | |
switch (error.type) { | |
case "request-timeout": | |
log(TaskID, "Request Timeout", "Task Engine", func); | |
return ["timeout", null]; | |
default: | |
console.log(error, error.type); | |
return [error, null]; | |
} | |
} | |
body = await response.text(); | |
response.text = function () { | |
return body; | |
}; | |
return [response, config]; | |
} | |
}; | |
let executeFetch = async (url, config) => { | |
try { | |
const data = await fetch(url, config); | |
return [data, null]; | |
} catch (error) { | |
return [null, error]; | |
} | |
}; | |
let executeTLSFetch = async (config) => { | |
try { | |
const data = await tlsFetch(config); | |
return [data, null]; | |
} catch (error) { | |
console.log(error); | |
return [null, error]; | |
} | |
}; | |
let executeLexFetch = async (config) => { | |
try { | |
const data = await lexFetch(config); | |
return [data, null]; | |
} catch (error) { | |
console.log(error); | |
return [null, error]; | |
} | |
}; | |
const handleURL = async (TaskID, func) => { | |
const actions = { | |
executeFunctionURL: async (TaskID, func) => { | |
let functionArgumentsVariables = []; | |
let urlFunction = | |
taskObjects[TaskID]["helperFunctions"][ | |
func["request"]["requestConfig"]["url"]["urlFunction"]["name"] | |
]; //gets the actual url helper function | |
let functionArguments = | |
func["request"]["requestConfig"]["url"]["urlFunction"]["arguments"]; //gets the arguments needed for the url helper function | |
let argumentsInput = functionArguments.replace(/ /g, "").split(","); | |
for (let item of argumentsInput) { | |
functionArgumentsVariables.push( | |
item == "taskObjects" | |
? taskObjects | |
: taskObjects[TaskID]["Variables"][item] | |
); | |
} // gets values of argument functions | |
functionArgumentsVariables.push(console); | |
functionArgumentsVariables.push(monitorEvent); | |
functionURL = await urlFunction(...functionArgumentsVariables); // calls function with the argument variables | |
return functionURL; | |
}, | |
}; | |
return func["request"]["requestConfig"]["url"]["plainURL"] == null | |
? actions["executeFunctionURL"](TaskID, func) | |
: func["request"]["requestConfig"]["url"]["plainURL"]; | |
}; | |
const handleProxy = async (TaskID, func) => { | |
if (func["request"]["requestOptions"]["proxies"]) { | |
return taskObjects[TaskID]["Proxy"]; | |
} else { | |
return false; | |
} | |
}; | |
const handleCloudflare = async (TaskID, func) => { | |
if (func["request"]["requestOptions"]["cloudflare"]) { | |
return true; | |
} else { | |
return false; | |
} | |
}; | |
const handleRedirect = async (TaskID, func) => { | |
if (func["request"]["requestOptions"]["redirect"]) { | |
return false; | |
} else { | |
return true; | |
} | |
}; | |
const handleTimeout = async (TaskID, func) => { | |
if (func["request"]["requestOptions"]["timeout"]) { | |
return func["request"]["requestOptions"]["timeout"]; | |
} else { | |
return 30000; | |
} | |
}; | |
const handleHeaders = async (TaskID, func) => { | |
let headers = func["request"]["requestConfig"]["headers"]; | |
try { | |
for (let headerKey in func["request"]["requestConfig"]["customHeaders"]) { | |
let tempFunction = new AsyncFunction( | |
func["request"]["requestConfig"]["customHeaders"][headerKey][ | |
"arguments" | |
] + ",console", | |
func["request"]["requestConfig"]["customHeaders"][headerKey]["body"] | |
); | |
headers[headerKey] = await tempFunction(taskObjects, TaskID, console); | |
} | |
} catch {} | |
if (func["request"]["requestOptions"]["useSessionCookies"]) { | |
headers["cookie"] = parseCookies(taskObjects[TaskID]["Cookies"]); | |
} | |
if (func["request"]["requestOptions"]["cookies"]) { | |
headers["cookie"] += func["request"]["requestOptions"]["cookies"]; | |
} | |
return headers; | |
}; | |
const handleMethod = async (TaskID, func) => { | |
return func["request"]["requestConfig"]["method"]; | |
}; | |
const handleBody = async (TaskID, func) => { | |
if ( | |
func["request"]["requestConfig"]["body"]["plainBody"] == null && | |
func["request"]["requestConfig"]["body"]["function"] != null | |
) { | |
let tempFunction = new AsyncFunction( | |
func["request"]["requestConfig"]["body"]["function"]["arguments"] + | |
",console", | |
func["request"]["requestConfig"]["body"]["function"]["body"] | |
); | |
return await tempFunction(taskObjects, TaskID, console); | |
} else { | |
return func["request"]["requestConfig"]["body"]["plainBody"]; | |
} | |
}; | |
const handleHarRequestEntry = (request) => { | |
if (!taskObjects.settings.preferences.log_tasks) { | |
return; | |
} | |
function buildRequestCookies(headers) { | |
let cookies; | |
try { | |
cookiesSplit = headers["cookie"].split("; "); | |
cookies = cookiesSplit.map((cookieEntry) => { | |
return { | |
name: cookieEntry.split("=")[0], | |
value: cookieEntry.split("=")[1], | |
}; | |
}); | |
} catch { | |
cookies = []; | |
} | |
return cookies; | |
} | |
function buildHeaders(headers) { | |
const list = []; | |
if (Array.isArray(headers)) { | |
for (let i = 0; i < headers.length; i += 2) { | |
list.push({ | |
name: headers[i], | |
value: headers[i + 1], | |
}); | |
} | |
} else { | |
Object.keys(headers).forEach((name) => { | |
const values = Array.isArray(headers[name]) | |
? headers[name] | |
: [headers[name]]; | |
values.forEach((value) => { | |
list.push({ name, value }); | |
}); | |
}); | |
} | |
return list; | |
} | |
function buildParams(paramString) { | |
const params = []; | |
const parsed = querystring.parse(paramString); | |
for (const name in parsed) { | |
const value = parsed[name]; | |
if (Array.isArray(value)) { | |
value.forEach((item) => { | |
params.push({ name, value: item }); | |
}); | |
} else { | |
params.push({ name, value }); | |
} | |
} | |
return params; | |
} | |
const now = Date.now(); | |
const startTime = process.hrtime(); | |
const url = new URL(request.url); | |
const entry = { | |
_timestamps: { | |
start: startTime, | |
}, | |
_resourceType: "fetch", | |
startedDateTime: new Date(now).toISOString(), | |
cache: { | |
beforeRequest: null, | |
afterRequest: null, | |
}, | |
timings: { | |
blocked: -1, | |
dns: -1, | |
connect: -1, | |
send: 0, | |
wait: 0, | |
receive: 0, | |
ssl: -1, | |
}, | |
request: { | |
method: request.method, | |
url: url.href, | |
cookies: buildRequestCookies(request.headers), | |
headers: buildHeaders(request.headers), | |
queryString: [...url.searchParams].map(([name, value]) => ({ | |
name, | |
value, | |
})), | |
headersSize: -1, | |
bodySize: -1, | |
}, | |
}; | |
let requestBody = request.data; | |
let headers = request.headers; | |
if (requestBody != null) { | |
// Works for both buffers and strings. | |
entry.request.bodySize = Buffer.byteLength(requestBody); | |
let mimeType; | |
for (const name in headers) { | |
if (name.toLowerCase() === "content-type") { | |
mimeType = headers[name][0]; | |
break; | |
} | |
} | |
if (mimeType) { | |
const bodyString = requestBody.toString(); // FIXME: Assumes encoding? | |
if (mimeType === "application/x-www-form-urlencoded") { | |
entry.request.postData = { | |
mimeType, | |
params: buildParams(bodyString), | |
}; | |
} else { | |
entry.request.postData = { mimeType, text: bodyString }; | |
} | |
} | |
} | |
taskObjects[TaskID]["har"].push(response.harEntry); | |
let harEntry = JSON.parse( | |
fs.readFileSync(`./logs/har-${TaskID}.json`, "utf8") | |
); | |
harEntry["log"]["entries"].push(response.harEntry); | |
fs.writeFileSync(`./logs/har-${TaskID}.json`, JSON.stringify(harEntry)); | |
return entry; | |
}; | |
const handleHarResponse = async (TaskID, func, response, entry) => { | |
if (!taskObjects.settings.preferences.log_tasks) { | |
return; | |
} | |
function buildResponseCookies(headers) { | |
let cookies; | |
try { | |
cookiesArray = headers["cookie"]["set-cookies"]; | |
cookies = cookiesArray.map((cookieEntry) => { | |
return { | |
name: cookieEntry.split("=")[0], | |
value: cookieEntry.split("=")[1].split(";")[0], | |
}; | |
}); | |
} catch { | |
cookies = []; | |
} | |
return cookies; | |
} | |
function buildHeaders(headers) { | |
const list = []; | |
if (Array.isArray(headers)) { | |
for (let i = 0; i < headers.length; i += 2) { | |
list.push({ | |
name: headers[i], | |
value: headers[i + 1], | |
}); | |
} | |
} else { | |
Object.keys(headers).forEach((name) => { | |
const values = Array.isArray(headers[name]) | |
? headers[name] | |
: [headers[name]]; | |
values.forEach((value) => { | |
list.push({ name, value }); | |
}); | |
}); | |
} | |
return list; | |
} | |
function getDuration(a, b) { | |
const seconds = b[0] - a[0]; | |
const nanoseconds = b[1] - a[1]; | |
return seconds * 1000 + nanoseconds / 1e6; | |
} | |
entry.time = getDuration(entry._timestamps.start, process.hrtime()); | |
entry.response = { | |
status: response.status, | |
statusText: "", | |
httpVersion: "httpVersion", | |
cookies: buildResponseCookies(response.headers), | |
headers: buildHeaders(response.headers), | |
content: { | |
size: -1, | |
mimeType: response.headers["content-type"], | |
}, | |
redirectURL: response.headers.location || "", | |
headersSize: -1, | |
bodySize: -1, | |
}; | |
if (entry.response.bodySize === -1) { | |
entry.response.bodySize = 0; | |
} | |
if (response.data) { | |
let text = response.data; | |
const bodySize = Buffer.byteLength(text); | |
entry.response.content.text = text; | |
entry.response.content.size = bodySize; | |
entry.response.bodySize = bodySize; | |
} | |
taskObjects[TaskID]["harLog"]["log"]["entries"].push(entry); | |
let encryptData = (data) => { | |
let buff = new Buffer.from(data); | |
let base64data = buff.toString("base64"); | |
newText = reverseString(base64data).split(""); | |
let finalText = ""; | |
for (item of newText) { | |
finalText += | |
item + "," + getRandomInt(100) + "," + getRandomInt(1000) + ","; | |
} | |
return finalText; | |
}; | |
let encryptedHar = encryptData(JSON.stringify(taskObjects[TaskID]["harLog"])); | |
let site = taskObjects[TaskID].getTaskInfo(TaskID, taskObjects).product.site; | |
process.send({ | |
type: "logHar", | |
data: encryptedHar, | |
site: site, | |
TaskID, | |
}); | |
fs.writeFileSync(`./logs/${site}-${TaskID}.lex`, encryptedHar); | |
}; | |
const handleRequestStatus = async (TaskID, func, response, harEntry) => { | |
if (func["request"]["requestOptions"]["useTLS"]) { | |
handleHarResponse(TaskID, func, response, harEntry); | |
} | |
taskObjects[TaskID]["requestHistory"][func["name"]] = response; | |
if (func["request"]["requestOptions"]["saveSessionCookies"]) { | |
let requestCookies = getRequestCookies(response, func); | |
if (requestCookies) { | |
taskObjects[TaskID]["Cookies"] = handleCookieJar( | |
taskObjects[TaskID]["Cookies"], | |
requestCookies | |
); | |
} | |
} | |
let { reqStatus: reqStatus, error: error } = await requestStatus( | |
TaskID, | |
func, | |
response | |
); | |
if (error) { | |
console.log(error); | |
} | |
let logText; | |
if (reqStatus != "end") { | |
if (func["logic"]["functionLogic"][reqStatus]["dynamic"]) { | |
let tempFunction = new AsyncFunction( | |
"taskObjects, TaskID", | |
func["logic"]["functionLogic"][reqStatus]["log"] | |
); | |
logText = await tempFunction(taskObjects, TaskID, console); | |
} else { | |
logText = func["logic"]["functionLogic"][reqStatus]["log"]; | |
} | |
} else { | |
logWs.send(JSON.stringify(response?.data)); | |
if (func["logic"]["taskLogic"]["end"] != "end") { | |
logText = func["name"] + ": Error ->" + reqStatus; | |
} else { | |
logText = error; | |
} | |
} | |
log(TaskID, logText, reqStatus ?? "error", func); | |
let nextFunction = func["logic"]["taskLogic"][reqStatus]; | |
let site = taskObjects[TaskID].getTaskInfo(TaskID, taskObjects).product.site; | |
let TaskGroupID = taskObjects[TaskID].TaskGroupID; | |
let task_info = taskObjects.taskGroups | |
.find((group) => group.id === TaskGroupID) | |
.tasks.find((task) => task.id === TaskID); | |
let task_mode = task_info.task_settings.task_mode; | |
let task_type = task_info.type; | |
nextFunction | |
? main( | |
TaskID, | |
moduleJSON[site][task_type][task_mode].functions[nextFunction] | |
) | |
: log("Task Stopped: " + reqStatus, "Task Engine", "stop"); | |
}; | |
const getRequestCookies = (response, func) => { | |
try { | |
if (func["request"]["requestOptions"]["useTLS"]) { | |
return response.headers["set-cookie"]; | |
} else { | |
return response.headers.raw()["set-cookie"]; | |
} | |
} catch { | |
console.log("Error with cookies."); | |
return []; | |
} | |
}; | |
const handleFunctionStatus = async (TaskID, func, response) => { | |
let funcStatus = response; | |
try { | |
if (func["logic"]["functionLogic"][funcStatus]["dynamic"]) { | |
let tempFunction = new AsyncFunction( | |
"taskObjects, TaskID", | |
func["logic"]["functionLogic"][funcStatus]["log"] | |
); | |
logText = await tempFunction(taskObjects, TaskID, console); | |
log( | |
TaskID, | |
funcStatus != "end" ? logText : error, | |
funcStatus ?? "error", | |
func | |
); | |
} else { | |
log( | |
TaskID, | |
funcStatus != "end" | |
? func["logic"]["functionLogic"][funcStatus]["log"] | |
: error, | |
funcStatus ?? "error", | |
func | |
); | |
} | |
} catch (e) { | |
console.log(e); | |
console.log(funcStatus); | |
console.log("e: 569"); | |
} | |
let site = taskObjects[TaskID].getTaskInfo(TaskID, taskObjects).product.site; | |
let TaskGroupID = taskObjects[TaskID].TaskGroupID; | |
let task_info = taskObjects.taskGroups | |
.find((group) => group.id === TaskGroupID) | |
.tasks.find((task) => task.id === TaskID); | |
let task_mode = task_info.task_settings.task_mode; | |
let task_type = task_info.type; | |
moduleJSON[site][task_type][task_mode].functions?.[ | |
func["logic"]["taskLogic"][funcStatus] | |
] | |
? main( | |
TaskID, | |
moduleJSON[site][task_type][task_mode].functions[ | |
func["logic"]["taskLogic"][funcStatus] | |
] | |
) | |
: log(TaskID, "Task Stopped: " + funcStatus, "Task Engine", "stop"); | |
}; | |
const requestStatus = async (TaskID, func, response) => { | |
const actions = { | |
regex: async (response, statusType) => {}, | |
responseBodyIncludes: async (response, statusType) => { | |
let text = await response.text(); | |
return text.includes( | |
func["logic"]["functionLogic"][statusType].options.responseBodyIncludes | |
) == true | |
? statusType | |
: false; | |
}, | |
jsonIncludes: async (response, statusType) => { | |
try { | |
let text = await JSON.parse(response.text()); | |
let array = | |
func["logic"]["functionLogic"][statusType].options.jsonIncludes; | |
for (i = 0; i < array.length; i++) { | |
text = text[array[i]]; | |
} | |
if (text !== undefined) { | |
return statusType; | |
} else { | |
return false; | |
} | |
} catch (e) { | |
return false; | |
} | |
}, | |
headersInclude: async (response, statusType) => { | |
return JSON.stringify(response.headers).includes( | |
func["logic"]["functionLogic"][statusType].options.headersInclude | |
) == true | |
? statusType | |
: false; | |
}, | |
cookiesInclude: async (response, statusType) => { | |
return JSON.stringify(response.headers.get("set-cookie")).includes( | |
func["logic"]["functionLogic"][statusType].options.cookiesInclude | |
) == true | |
? statusType | |
: false; | |
}, | |
statusType: async (response, statusType) => {}, | |
}; | |
for (let statusType of func["logic"]["functionLogic"]["reqStatuses"]) { | |
if (func["logic"]["functionLogic"][statusType].status == response.status) { | |
logRequestStatus(TaskID, func, statusType); | |
return { reqStatus: statusType }; | |
} | |
if (!func["logic"]["functionLogic"][statusType].status) { | |
try { | |
status = await actions[ | |
func["logic"]["functionLogic"][statusType].options.type | |
](response, statusType); | |
if (status) { | |
logRequestStatus(TaskID, func, statusType); | |
return { reqStatus: statusType }; | |
} | |
} catch {} | |
} | |
} | |
return { reqStatus: "end", error: "No Further Logic Provided" }; | |
}; | |
const logRequestStatus = (TaskID, func, statusType) => { | |
process.send({ | |
type: "AnalyticsUpdateTaskStatus", | |
TaskID: TaskID, | |
func: func, | |
reqStatus: statusType, | |
}); | |
}; | |
const handleCookieJar = (cookieJar, cookies) => { | |
const grabCookies = (cookieArray) => { | |
return cookieArray.map((i) => { | |
let newCookie = i.split(";")[0] + ";"; | |
let newCookieName = newCookie.split("=")[0]; | |
for (let x = 0; x < cookieJar.length; x++) { | |
if (cookieJar[x].split("=")[0] == newCookieName) { | |
cookieJar[x] = newCookie; | |
return; | |
} | |
} | |
cookieJar.push(newCookie); | |
}); | |
}; | |
if (typeof cookies == "string") { | |
cookies = [cookies]; | |
} | |
grabCookies(cookies); | |
return cookieJar; | |
}; | |
const parseCookies = (cookieJar) => { | |
let cookieString = cookieJar[0]; | |
for (let i = 1; i < cookieJar.length; i++) { | |
cookieString += ` ${cookieJar[i]}`; | |
} | |
return cookieString; | |
}; | |
const setVariables = (functionMain, TaskID) => { | |
helperVariables = {}; | |
helperVariables["TaskID"] = TaskID; | |
for (let VariablesTemp of functionMain["variables"]) { | |
helperVariables[VariablesTemp] = null; | |
} | |
return helperVariables; | |
}; | |
const setHelperFunctions = (functionMain) => { | |
helperFunctions = {}; | |
for (let element in functionMain["helperFunctions"]) { | |
helperFunctions[element] = new AsyncFunction( | |
functionMain["helperFunctions"][element].arguments, | |
functionMain["helperFunctions"][element].body | |
); | |
} | |
if (functionMain["captchaHarvester"] == true) { | |
helperFunctions["2CAP"] = harvest2CAP; | |
helperFunctions["2CAPImage"] = harvest2CAPImage; | |
helperFunctions["CapMonster"] = harvestCaptchaMonster; | |
helperFunctions["CapMonsterImage"] = harvestCaptchaMonsterImage; | |
helperFunctions["Solvers"] = SolveCaptcha; | |
} | |
helperFunctions["sleep"] = sleep; | |
helperFunctions["crypto"] = crypto; | |
helperFunctions["utf8"] = utf8; | |
helperFunctions["walmartEncryption"] = walmartEncryption; | |
helperFunctions["homedepotEncryption"] = homeDepotEncryption; | |
helperFunctions["paniniStates"] = paniniStates; | |
helperFunctions["amazonLogin"] = amazonLogin; | |
helperFunctions["amazonMonitor"] = amazonMonitor; | |
helperFunctions["bestbuyMonitor"] = bestbuyMonitor; | |
helperFunctions["bestbuySafeLogin"] = bestbuyLogin; | |
helperFunctions["bestbuyBody"] = bestbuyBody; | |
helperFunctions["bestbuyCode"] = bestbuyCode; | |
helperFunctions["bestbuyEncrypt"] = bestbuyEncrypt; | |
helperFunctions["encrypt"] = encrypt; | |
helperFunctions["jwt_decode"] = jwt_decode; | |
helperFunctions["qs"] = qs; | |
helperFunctions["proxyRotater"] = proxyRotater; | |
helperFunctions["HttpsProxyAgent"] = HttpsProxyAgent; | |
helperFunctions["yearSpacing"] = yearSpacing; | |
helperFunctions["monthSpacing"] = monthSpacing; | |
helperFunctions["cardSpacing"] = cardSpacing; | |
helperFunctions["stateName"] = stateName; | |
helperFunctions["base64"] = base64; | |
return helperFunctions; | |
}; | |
const start = async (TaskID, TaskGroupID) => { | |
let functionMain; | |
let task_info = taskObjects.taskGroups | |
.find((group) => group.id === TaskGroupID) | |
.tasks.find((task) => task.id === TaskID); | |
let task_mode = task_info.task_settings.task_mode; | |
let task_type = task_info.type; | |
try { | |
functionMain = moduleJSON[task_info.product.site][task_type][task_mode]; | |
} catch (e) { | |
console.log(e); | |
process.send({ | |
type: "updateTaskStatus", | |
TaskID: TaskID, | |
TaskGroupID: TaskGroupID, | |
text: "API Misconfiguration (1). Restart Bot.", | |
color: "red", | |
}); | |
return; | |
} | |
if (!functionMain) { | |
process.send({ | |
type: "updateTaskStatus", | |
TaskID: TaskID, | |
TaskGroupID: TaskGroupID, | |
text: "API Misconfiguration (2). Restart Bot.", | |
color: "red", | |
}); | |
return; | |
} | |
helperVariables = setVariables(functionMain, TaskID); | |
helperFunctions = setHelperFunctions(functionMain); | |
taskInfo = { | |
TaskID: TaskID, | |
TaskGroupID: TaskGroupID, | |
Variables: helperVariables, | |
helperFunctions: helperFunctions, | |
Cookies: [], | |
Proxy: "", | |
requestHistory: {}, | |
CallStack: [], | |
har: [], | |
Stopped: false, | |
getTaskInfo: (taskId, taskObjects) => { | |
let taskGroupId = taskObjects[taskId].TaskGroupID; | |
let taskGroups = taskObjects.taskGroups; | |
let task_info = taskGroups | |
.find((group) => group.id === taskGroupId) | |
.tasks.find((task) => task.id === taskId); | |
return task_info; | |
}, | |
getProfile: (taskId, taskObjects) => { | |
let taskGroupId = taskObjects[taskId].TaskGroupID; | |
let taskGroups = taskObjects.taskGroups; | |
let profileGroups = taskObjects.profileGroups; | |
try { | |
let task_info = taskGroups | |
.find((group) => group.id === taskGroupId) | |
.tasks.find((task) => task.id === taskId); | |
let profile_id = task_info.task_profile_info.profile_id; | |
let profile_group_id = task_info.task_profile_info.profile_group_id; | |
let profile_info = profileGroups | |
.find((group) => group.id === profile_group_id) | |
.profiles.find((profile) => profile.id === profile_id); | |
return profile_info; | |
} catch (e) { | |
console.log(e); | |
return null; | |
} | |
}, | |
getAccount: (taskId, taskObjects) => { | |
let taskGroupId = taskObjects[taskId].TaskGroupID; | |
let taskGroups = taskObjects.taskGroups; | |
let accountGroups = taskObjects.accountGroups; | |
try { | |
let task_info = taskGroups | |
.find((group) => group.id === taskGroupId) | |
.tasks.find((task) => task.id === taskId); | |
let account_id = task_info.task_account_info.account_id; | |
let account_group_id = task_info.task_account_info.account_group_id; | |
let account_info = accountGroups | |
.find((group) => group.id === account_group_id) | |
.accounts.find((account) => account.id === account_id); | |
return account_info; | |
} catch { | |
return null; | |
} | |
}, | |
updateAccount: (taskId, taskObjects, newAccount) => { | |
let taskGroupId = taskObjects[taskId].TaskGroupID; | |
let taskGroups = taskObjects.taskGroups; | |
let task_info = taskGroups | |
.find((group) => group.id === taskGroupId) | |
.tasks.find((task) => task.id === taskId); | |
let account_id = task_info.task_account_info.account_id; | |
let account_group_id = task_info.task_account_info.account_group_id; | |
process.send({ | |
type: "saveAccountInfo", | |
groupID: account_group_id, | |
accountID: account_id, | |
account: newAccount, | |
}); | |
}, | |
getProxy: (taskId, taskObjects) => { | |
let taskGroupId = taskObjects[taskId].TaskGroupID; | |
let taskGroups = taskObjects.taskGroups; | |
let proxyGroups = taskObjects.proxyGroups; | |
let task_info = taskGroups | |
.find((group) => group.id === taskGroupId) | |
.tasks.find((task) => task.id === taskId); | |
let proxy_group_id = task_info.task_proxy_info.proxy_group_id; | |
if (task_info.task_proxy_info.localhost) { | |
return "localhost"; | |
} | |
let proxy_info = proxyGroups.find( | |
(group) => group.id === proxy_group_id | |
).proxies; | |
return proxy_info[ | |
Math.floor(Math.random() * Math.floor(proxy_info.length)) | |
]; | |
}, | |
setProxy: (taskId, taskObjects, customProxy) => { | |
try { | |
if (customProxy) { | |
let proxy = customProxy; | |
if (proxy === "localhost") { | |
taskObjects[taskId].Proxy = false; | |
return; | |
} else { | |
let splitProxy = proxy.split(":"); | |
proxy = `http://${splitProxy[2]}:${splitProxy[3]}@${splitProxy[0]}:${splitProxy[1]}`; | |
taskObjects[taskId].Proxy = | |
taskObjects[taskId].helperFunctions.HttpsProxyAgent(proxy); | |
return "Set Proxy: " + proxy; | |
} | |
} else { | |
let proxy = taskObjects[taskId].getProxy(taskId, taskObjects); | |
if (proxy === "localhost") { | |
taskObjects[taskId].Proxy = false; | |
return; | |
} | |
let splitProxy = proxy.split(":"); | |
proxy = `http://${splitProxy[2]}:${splitProxy[3]}@${splitProxy[0]}:${splitProxy[1]}`; | |
taskObjects[taskId].Proxy = | |
taskObjects[taskId].helperFunctions.HttpsProxyAgent(proxy); | |
return "Set Proxy: " + proxy; | |
} | |
} catch {} | |
}, | |
getCaptchaAPIKey: (captchaService) => { | |
if (captchaService === "Capmonster") { | |
return taskObjects.settings.captcha_autosolve.capmonster_api_key; | |
} else if (captchaService === "2CAP") { | |
return taskObjects.settings.captcha_autosolve.twocap_api_key; | |
} | |
}, | |
setCookie: (taskId, taskObjects, cookie) => { | |
const handleCookieJar = (cookieJar, cookies) => { | |
const grabCookies = (cookieArray) => { | |
return cookieArray.map((i) => { | |
let newCookie = i.split(";")[0] + ";"; | |
let newCookieName = newCookie.split("=")[0]; | |
for (let x = 0; x < cookieJar.length; x++) { | |
if (cookieJar[x].split("=")[0] == newCookieName) { | |
cookieJar[x] = newCookie; | |
return; | |
} | |
} | |
cookieJar.push(newCookie); | |
}); | |
}; | |
if (typeof cookies == "string") { | |
cookies = [cookies]; | |
} | |
grabCookies(cookies); | |
return cookieJar; | |
}; | |
taskObjects[TaskID].Cookies = handleCookieJar( | |
taskObjects[TaskID].Cookies, | |
cookie | |
); | |
}, | |
getRandomShapeCookie: (taskObjects) => { | |
return taskObjects.cookieData[ | |
getRandomInt(taskObjects.cookieData.length) | |
]; | |
}, | |
deleteShapeCookie: (id) => { | |
process.send({ | |
type: "deleteCookie", | |
id: id, | |
}); | |
}, | |
}; | |
taskObjects[TaskID] = taskInfo; | |
let site = taskObjects[TaskID].getTaskInfo(TaskID, taskObjects).product.site; | |
if (!taskObjects["monitors"]) { | |
taskObjects["monitors"] = {}; | |
} | |
if (!taskObjects["monitors"][site]) { | |
taskObjects["monitors"][site] = {}; | |
taskObjects["monitors"][site]["sku"] = { | |
available: true, | |
}; | |
} | |
taskObjects[TaskID].setProxy(TaskID, taskObjects); | |
console.log( | |
`[ ${TaskID} ] [ ` + | |
`Task Engine` + | |
` ] [ ${timestampSHORT()} ] ` + | |
`Starting Task` | |
); | |
taskObjects[TaskID].harLog = { | |
log: { | |
version: "1.2", | |
creator: { | |
name: "WebInspector", | |
version: "537.36", | |
}, | |
pages: [ | |
{ | |
startedDateTime: "2021-06-16T19:33:00.729Z", | |
id: "page_2", | |
title: "https://www.target.com/p/lex/-/A-81471773", | |
pageTimings: { | |
onContentLoad: 341.79400000721216, | |
onLoad: 2915.4930000077, | |
}, | |
}, | |
], | |
entries: [], | |
}, | |
}; | |
let entryPoint = moduleJSON[site][task_type][task_mode].entryPoint; | |
main(TaskID, moduleJSON[site][task_type][task_mode].functions[entryPoint]); | |
const lastTaskStatusUpdateChecker = setInterval(async () => { | |
if (taskObjects[TaskID].Stopped === true) { | |
clearInterval(lastTaskStatusUpdateChecker); | |
return; | |
} | |
if (taskObjects[TaskID].lastTaskStatusUpdate) { | |
let newTime = new Date(); | |
let timeDif = (newTime - taskObjects[TaskID].lastTaskStatusUpdate) / 1000; | |
if (timeDif >= 300) { | |
//restart task | |
process.send({ | |
type: "updateTaskStatus", | |
TaskID: TaskID, | |
TaskGroupID: TaskGroupID, | |
text: "Task Error. Restarting task...", | |
color: "yellow", | |
}); | |
await sleep(1000); | |
console.log("restarting task"); | |
start(TaskID, TaskGroupID); | |
clearInterval(lastTaskStatusUpdateChecker); | |
} | |
} | |
}, 100); | |
}; | |
//////////////// | |
process.on("message", (load) => { | |
switch (load.message) { | |
case "StartTask": | |
start(load.TaskID, load.TaskGroupID); | |
break; | |
case "BulkStartTask": | |
let tempStatusQueue = []; | |
let tempStatisticQueue = []; | |
load.TaskIDs.forEach((TaskID) => { | |
try { | |
if (taskObjects[TaskID]?.Stopped === false) { | |
return; | |
} | |
} catch {} | |
tempStatusQueue.push( | |
JSON.stringify({ | |
TaskID: TaskID, | |
TaskGroupID: load.TaskGroupID, | |
text: "Starting task...", | |
color: "blue", | |
}) | |
); | |
tempStatisticQueue.push( | |
JSON.stringify({ | |
TaskID: TaskID, | |
TaskGroupID: load.TaskGroupID, | |
statisticType: "taskCountActive", | |
action: "increment", | |
}) | |
); | |
start(TaskID, load.TaskGroupID); | |
}); | |
mainProcessSocket.send( | |
JSON.stringify({ | |
type: "BulkUpdateTaskStatus", | |
taskStatusQueue: tempStatusQueue, | |
taskStatisticQueue: tempStatisticQueue, | |
}) | |
); | |
break; | |
case "StopTask": | |
try { | |
delete taskObjects[load.TaskID]; | |
taskObjects[load.TaskID] = {}; | |
taskObjects[load.TaskID].Stopped = true; | |
taskStatusQueue = taskStatusQueue.filter((item) => { | |
return JSON.parse(item).TaskID !== load.TaskID; | |
}); | |
taskStatusQueue.push( | |
JSON.stringify({ | |
TaskID: load.TaskID, | |
TaskGroupID: load.TaskGroupID, | |
text: "Task Stopped", | |
color: "red", | |
}) | |
); | |
} catch {} | |
break; | |
case "BulkStopTask": | |
let tempStatusQueue2 = []; | |
let tempStatisticQueue2 = []; | |
load.TaskIDs.forEach((TaskID) => { | |
try { | |
try { | |
if (taskObjects[TaskID]?.Stopped === false) { | |
tempStatisticQueue2.push( | |
JSON.stringify({ | |
TaskID: TaskID, | |
TaskGroupID: load.TaskGroupID, | |
statisticType: "taskCountActive", | |
action: "decrement", | |
}) | |
); | |
} | |
} catch {} | |
delete taskObjects[TaskID]; | |
taskObjects[TaskID] = {}; | |
taskObjects[TaskID].Stopped = true; | |
taskStatusQueue = taskStatusQueue.filter((item) => { | |
return JSON.parse(item).TaskID !== TaskID; | |
}); | |
tempStatusQueue2.push( | |
JSON.stringify({ | |
TaskID: TaskID, | |
TaskGroupID: load.TaskGroupID, | |
text: "Stopped", | |
color: "red", | |
}) | |
); | |
} catch (e) { | |
console.log(e); | |
} | |
}); | |
mainProcessSocket.send( | |
JSON.stringify({ | |
type: "BulkUpdateTaskStatus", | |
taskStatusQueue: tempStatusQueue2, | |
taskStatisticQueue: tempStatisticQueue2, | |
}) | |
); | |
break; | |
case "ModuleUpdate": | |
try { | |
moduleData = lexdecrypt(load.encryptedModule); | |
moduleJSON[moduleData["site"]] = moduleData; | |
} catch (e) {} | |
break; | |
case "TaskInfoUpdate": | |
taskObjects.taskGroups = load.data.task_groups; | |
break; | |
case "ProfileInfoUpdate": | |
taskObjects.profileGroups = load.data.profile_groups; | |
break; | |
case "ProxyInfoUpdate": | |
taskObjects.proxyGroups = load.data.proxy_groups; | |
break; | |
case "AccountInfoUpdate": | |
taskObjects.accountGroups = load.data.account_groups; | |
break; | |
case "CookieInfoUpdate": | |
taskObjects.cookieData = load.data.cookies; | |
break; | |
case "SettingsUpdate": | |
taskObjects.settings = load.data; | |
break; | |
case "FetchResponse": | |
eventEmitter.emit(`promiseSolved${load.id}`, load.data); | |
break; | |
case "AmazonRestock": | |
taskObjects.amazonRestockArray.push(load.data); | |
break; | |
case "PING": | |
process.send({ | |
type: "PONG", | |
}); | |
break; | |
} | |
}); | |
process.on("uncaughtException", function (err) { | |
console.log(err); | |
}); | |
/// ///////////// | |
function timestampSHORT() { | |
function checkTime(i) { | |
if (i < 10) { | |
i = `0${i}`; | |
} | |
return i; | |
} | |
const today = new Date(); | |
const h = today.getHours(); | |
let m = today.getMinutes(); | |
let s = today.getSeconds(); | |
m = checkTime(m); | |
s = checkTime(s); | |
time_r = `${h}:${m}:${s}`; | |
return `${h}:${m}:${s}`; | |
} | |
function getRandomInt(max) { | |
return Math.floor(Math.random() * Math.floor(max)); | |
} | |
async function sleep(ms) { | |
return new Promise((resolve) => setTimeout(resolve, ms)); | |
} | |
//////////////////////////////////////////////////////// | |
// Lex Decryption | |
var ABC = { | |
toAscii: function (bin) { | |
return bin.replace(/\s*[01]{8}\s*/g, function (bin) { | |
return String.fromCharCode(parseInt(bin, 2)); | |
}); | |
}, | |
toBinary: function (str, spaceSeparatedOctets) { | |
return str.replace(/[\s\S]/g, function (str) { | |
str = ABC.zeroPad(str.charCodeAt().toString(2)); | |
return !1 == spaceSeparatedOctets ? str : str + " "; | |
}); | |
}, | |
zeroPad: function (num) { | |
return "00000000".slice(String(num).length) + num; | |
}, | |
}; | |
function reverseString(s) { | |
return s.split("").reverse().join(""); | |
} | |
const lexdecrypt = (text) => { | |
let key = | |
" l$Tv&b;^uqEQ:`4VU]\\)tCe=xMw1.?*'{cd-+z87O|PSXiN>,s2oyGWI0Kk_p(Af/95~Yg}!\"<B[LD3hjH%R#n6@aZFJmr"; | |
// newText = reverseString(text) | |
let finalText = ""; | |
let newText = JSON.parse(text); | |
newText = newText.split(","); | |
for (let i = 0; i < newText.length; i += 2) { | |
tempText = newText[i]; | |
text = key[tempText]; | |
if (text) { | |
finalText += text; | |
} | |
} | |
finalText = "{" + finalText; | |
return JSON.parse(finalText); | |
}; | |
////////////// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"site": "Target", | |
"task":{ | |
"Fast": { | |
"entryPoint": "submitShipping", | |
"variables": [ | |
"ItemInfo", | |
"ItemAvailability", | |
"cart_id", | |
"Access_Token", | |
"Visitor_ID", | |
"Refresh_Token" | |
], | |
"taskStatistics":{ | |
"addedToCart":"taskCartCount", | |
"addedToCart2":"taskCartCount", | |
"successfulCheckout": "taskCountCheckedOut", | |
"checkout2": "taskCountCheckedOut", | |
"PaymentDecline": "taskCountDeclined", | |
"Decline": "taskCountDeclined" | |
}, | |
"captchaHarvester": true, | |
"helperFunctions": { | |
"returnResubmitCVVUrl": { | |
"arguments": "taskObjects, TaskID", | |
"body": "response=taskObjects[TaskID]['requestHistory']['submitCheckout'];text=await response.text();instructions_id=text.split('Missing CVV or PIN code on payment instruction ')[1].split('\"')[0];console.log(instructions_id);return `https://carts.target.com/checkout_payments/v1/payment_instructions/${instructions_id}?key=feaf228eb2777fd3eee0fd5192ae7107d6224b39`" | |
}, | |
"setCookies": { | |
"arguments": "taskObjects, TaskID", | |
"body": "try{taskObjects[TaskID].Cookies=[];let account=taskObjects[TaskID].getAccount(TaskID,taskObjects);let cookies=account.cookies;let accessToken='accessToken='+cookies.accessToken;let visitorID='visitorID='+cookies.visitorID;taskObjects[TaskID].setCookie(TaskID,taskObjects,accessToken);taskObjects[TaskID].setCookie(TaskID,taskObjects,visitorID)}catch{}" | |
}, | |
"setRefreshCookies": { | |
"arguments": "taskObjects, TaskID", | |
"body": "try{let account=taskObjects[TaskID].getAccount(TaskID,taskObjects);let cookies=account.cookies;let Access_Token=cookies.accessToken;let Visitor_ID=cookies.visitorID;let Refresh_Token=taskObjects[TaskID]['helperFunctions']['jwt_decode'](Access_Token)['jti'];taskObjects[TaskID]['Variables']['Access_Token']=Access_Token;taskObjects[TaskID]['Variables']['Visitor_ID']=Visitor_ID;taskObjects[TaskID]['Variables']['Refresh_Token']=Refresh_Token;taskObjects[TaskID].Cookies=[];taskObjects[TaskID].Cookies.push('refreshToken='+Refresh_Token+';');taskObjects[TaskID].Cookies.push('visitorId='+Visitor_ID+';')}catch (e){console.log(e)}" | |
}, | |
"setLoginCookies": { | |
"arguments": "taskObjects, TaskID", | |
"body": "try{if(taskObjects[TaskID].Variables.CookieData){console.log('REMOVING COOKIE DATA');taskObjects[TaskID].deleteShapeCookie(taskObjects[TaskID].Variables.CookieData.id)};taskObjects[TaskID].Cookies=[];let cookieData=taskObjects[TaskID].getRandomShapeCookie(taskObjects);taskObjects[TaskID].Variables.CookieData=cookieData;let newCookies=cookieData.Cookies.split('; ');newCookies=newCookies.map((cookie)=>{return cookie+';'});taskObjects[TaskID].Cookies=newCookies}catch(e){console.log(e)}" | |
} | |
}, | |
"logStatusColors": { | |
"success": "magenta", | |
"addedToCart":"magenta", | |
"successfulCheckout":"green", | |
"checkout2":"green", | |
"OutOfStock": "cyan", | |
"OutOfStock2": "cyan", | |
"NoLoadedTCINs": "cyan", | |
"cartFull": "yellow", | |
"logCheckout": "green", | |
"PID_LOCKED": "yellow", | |
"processing": "yellow", | |
"error": "yellow", | |
"fail": "red", | |
"InStock": "cyan", | |
"shippingAlreadyPresent": "cyan" | |
}, | |
"functions": { | |
"SignIn": { | |
"name": "SignIn", | |
"type": "request", | |
"start": "setLoginCookies", | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://gsp.target.com/gsp/authentications/v1/credential_validations?client_id=ecom-web-1.0.0" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "gsp.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"customHeaders": { | |
"x-gyjwza5z-a": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-A'];" | |
}, | |
"x-gyjwza5z-b": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-B'];" | |
}, | |
"x-gyjwza5z-c": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-C'];" | |
}, | |
"x-gyjwza5z-d": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-D'];" | |
}, | |
"x-gyjwza5z-f": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-F'];" | |
}, | |
"x-gyjwza5z-z": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-Z'];" | |
}, | |
"user-agent": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['UserAgent'];" | |
} | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "let cookieData=taskObjects[TaskID].Variables.CookieData;let parsedData=JSON.stringify({'username':taskObjects[TaskID].getAccount(TaskID,taskObjects).username,'password':taskObjects[TaskID].getAccount(TaskID,taskObjects).password,'device_info':JSON.parse(cookieData.DeviceInfo),'keep_me_signed_in':true});return parsedData;" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": false, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"reLogin", | |
"_ERR_AUTH_DENIED", | |
"IPBanned", | |
"_ERR_USER_DOES_NOT_EXIST", | |
"success" | |
], | |
"success": { | |
"log": "Signed in...", | |
"status": 202, | |
"options": {} | |
}, | |
"_ERR_USER_DOES_NOT_EXIST": { | |
"log": "Account does not exist.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "_ERR_USER_DOES_NOT_EXIST" | |
} | |
}, | |
"_ERR_AUTH_DENIED": { | |
"log": "Authentication denied", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "_ERR_AUTH_DENIED" | |
} | |
}, | |
"IPBanned": { | |
"log": "IP Banned.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "accessDenied" | |
} | |
}, | |
"reLogin": { | |
"log": "Invalid Tokens. Signing in again...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Not Found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "authSignIn", | |
"_ERR_AUTH_DENIED":"SignIn", | |
"reLogin": "SignIn", | |
"IPBanned":"end", | |
"_ERR_USER_DOES_NOT_EXIST":"end", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"authSignIn": { | |
"name": "authSignIn", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 1000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://gsp.target.com/gsp/authentications/v1/auth_codes?client_id=ecom-web-1.0.0" | |
}, | |
"method": "GET", | |
"headers": { | |
"authority": "gsp.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": {} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"redirect":"false", | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success"], | |
"success": { | |
"log": "Authenticated", | |
"status": 302, | |
"options": {} | |
} | |
}, | |
"taskLogic": { | |
"success": "genTokens", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"genTokens": { | |
"name": "genTokens", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://gsp.target.com/gsp/oauth_tokens/v2/client_tokens" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "let cookieData=taskObjects[TaskID].Variables.CookieData;let code=taskObjects[TaskID].requestHistory['authSignIn'].headers.location.split('https://www.target.com/?code=')[1].split('&state=')[0];let parsedData=JSON.stringify({'grant_type':'authorization_code','client_credential':{'client_id':'ecom-web-1.0.0'},'code':code,'device_info':JSON.parse(cookieData.DeviceInfo)});return parsedData;return taskObjects[TaskID].Variables.CookieData['UserAgent'];" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": false, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"reLogin", | |
"IPBanned", | |
"success" | |
], | |
"success": { | |
"log": "Refreshed Tokens", | |
"status": 201, | |
"options": {} | |
}, | |
"IPBanned": { | |
"log": "IP Banned.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "accessDenied" | |
} | |
}, | |
"reLogin": { | |
"log": "Invalid Tokens. Signing in again...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Not Found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "parseRefreshToken", | |
"reLogin": "SignIn", | |
"IPBanned":"end", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"refreshTokens": { | |
"name": "refreshTokens", | |
"type": "request", | |
"start": "setRefreshCookies", | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://gsp.target.com/gsp/oauth_tokens/v2/client_tokens" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": "{\"grant_type\":\"refresh_token\",\"client_credential\":{\"client_id\":\"ecom-web-1.0.0\"}}", | |
"function": null | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": false, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"reLogin", | |
"IPBanned", | |
"success" | |
], | |
"success": { | |
"log": "Refreshed Tokens", | |
"status": 201, | |
"options": {} | |
}, | |
"IPBanned": { | |
"log": "IP Banned.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "accessDenied" | |
} | |
}, | |
"reLogin": { | |
"log": "Invalid Tokens. Signing in again...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Not Found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "parseRefreshToken", | |
"reLogin": "SignIn", | |
"IPBanned":"SignIn", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"parseRefreshToken": { | |
"name": "parseRefreshToken", | |
"type": "function", | |
"start": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "try{let account=taskObjects[TaskID].getAccount(TaskID,taskObjects);if(!account?.cookies){account.cookies={}};let response;if(taskObjects[TaskID].CallStack[taskObjects[TaskID].CallStack.length-2]==='genTokens'){response=JSON.parse(taskObjects[TaskID].requestHistory.genTokens.data);let cookieData=taskObjects[TaskID].Variables.CookieData;account.cookies.visitorID=JSON.parse(cookieData.DeviceInfo).visitor_id}else{response=JSON.parse(taskObjects[TaskID].requestHistory.refreshTokens.data)};let Access_Token=response.access_token;let id_token=response.id_token;account.cookies.idToken=id_token;account.cookies.accessToken=Access_Token;taskObjects[TaskID].updateAccount(TaskID,taskObjects,account);return'success'}catch(e){console.log(e);return'error'}" | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success", "noAccountCookies","error"], | |
"success": { | |
"log": "Parsed Tokens." | |
}, | |
"noAccountCookies": { | |
"log": "No Account Bin Found. Re-bin." | |
}, | |
"error": { | |
"log": "Error with account. Re-bin." | |
} | |
}, | |
"taskLogic": { | |
"success": "submitShipping", | |
"noAccountCookies":"SignIn", | |
"error": "SignIn", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"submitShipping": { | |
"name": "submitShipping", | |
"type": "request", | |
"start": "setCookies", | |
"delay": 0, | |
"retryDelay": 3001, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/cart_shipping_addresses?field_groups=ADDRESSES%2CCART%2CCART_ITEMS%2CPICKUP_INSTRUCTIONS%2CPROMOTION_CODES%2CSUMMARY&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "profile_info=taskObjects[TaskID].getProfile(TaskID, taskObjects);return JSON.stringify({'cart_type':'REGULAR','address':{'address_line1':profile_info['shipping_address']['address_line1'],'address_line2':profile_info['shipping_address']['address_line2'],'address_type':'SHIPPING','city':profile_info['shipping_address']['city'],'country':'US','first_name':profile_info['shipping_address']['first_name'],'last_name':profile_info['shipping_address']['last_name'],'mobile':profile_info['shipping_address']['phone'],'save_as_default':false,'state':profile_info['shipping_address']['state'],'zip_code':profile_info['shipping_address']['zip_code']},'selected':true,'save_to_profile':false,'skip_verification':true})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"success", | |
"shippingAlreadyPresent", | |
"accessTokenInvalid", | |
"CONSTRAINT_VALIDATION_FAILURE", | |
"INVALID_GUEST_STATUS", | |
"Unauthorized", | |
"Unauthorized2" | |
], | |
"success": { | |
"log": "Waiting for Monitor", | |
"status": 201, | |
"options": {} | |
}, | |
"shippingAlreadyPresent": { | |
"log": "Waiting for Monitor", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "ADDRESS_ALREADY_PRESENT" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"Unauthorized": { | |
"log": "Unauthorized", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Unauthorized" | |
} | |
}, | |
"Unauthorized2": { | |
"log": "Unauthorized", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "UNAUTHORIZED" | |
} | |
}, | |
"INVALID_GUEST_STATUS": { | |
"log": "Bad cookies. Re-bin account.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "INVALID_GUEST_STATUS" | |
} | |
}, | |
"CONSTRAINT_VALIDATION_FAILURE": { | |
"log": "Profile is missing Phone Number.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "address.mobile" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "Monitor", | |
"shippingAlreadyPresent": "Monitor", | |
"accessTokenInvalid": "refreshTokens", | |
"CONSTRAINT_VALIDATION_FAILURE": "end", | |
"INVALID_GUEST_STATUS": "SignIn", | |
"Unauthorized":"SignIn", | |
"Unauthorized2":"SignIn", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"Monitor": { | |
"name": "Monitor", | |
"type": "function", | |
"start": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "let monitorEventPromise=async(sku)=>{console.log('WaitingForSKU'+sku);return new Promise((resolve,reject)=>{let event=monitorEvent.on(sku,(message)=>{if(message.inStock){delete event;resolve(message)}})})};let result=await monitorEventPromise(taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.task_sku);taskObjects[TaskID]['Variables']['tcin']=result.SKU;return'InStock';" | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["InStock", "OutOfStock", "UnAvailable"], | |
"InStock": { | |
"log": "Item in Stock. Adding to cart." | |
}, | |
"OutOfStock": { | |
"log": "Monitoring..." | |
}, | |
"OutOfStock2": { | |
"log": "Monitoring..." | |
}, | |
"UnAvailable": { | |
"log": "Failed to get item. Monitoring..." | |
} | |
}, | |
"taskLogic": { | |
"InStock": "addToCart", | |
"OutOfStock": "Monitor", | |
"OutOfStock2": "Monitor", | |
"UnAvailable": "Monitor", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"addToCart": { | |
"name": "addToCart", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 1000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/cart_items?field_groups=CART%2CCART_ITEMS%2CSUMMARY&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return JSON.stringify({'cart_type':'REGULAR','channel_id':'10','shopping_context':'DIGITAL','cart_item':{'tcin':taskObjects[TaskID]['Variables']['tcin'],'quantity':taskObjects[TaskID].getTaskInfo(TaskID, taskObjects).product.item_quantity,'item_channel_id':'10'}})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["addedToCart", "cartFull", "accessTokenInvalid", "DEPENDENT_SERVICE_ERROR", "PID_LOCKED", "proxyBan"], | |
"addedToCart": { | |
"log": "Added To Cart", | |
"status": 201, | |
"options": {} | |
}, | |
"cartFull": { | |
"log": "MAX_PURCHASE_LIMIT_EXCEEDED", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "MAX_PURCHASE_LIMIT_EXCEEDED" | |
} | |
}, | |
"DEPENDENT_SERVICE_ERROR": { | |
"log": "Item OOS. Retrying atc...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "DEPENDENT_SERVICE_ERROR" | |
} | |
}, | |
"PID_LOCKED": { | |
"log": "Item PID Locked. Retrying atc...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Access Denied" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"proxyBan": { | |
"log": "Proxy Banned. Retrying...", | |
"status": 404, | |
"options": {} | |
} | |
}, | |
"taskLogic": { | |
"addedToCart": "submitBilling", | |
"cartFull": "harvestCartID", | |
"DEPENDENT_SERVICE_ERROR": "Monitor", | |
"accessTokenInvalid": "refreshTokens", | |
"PID_LOCKED": "Monitor", | |
"proxyBan":"Monitor", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"harvestCartID": { | |
"name": "harvestCartID", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/cart?field_groups=CART%2CCART_ITEMS%2CSUMMARY%2CPROMOTION_CODES%2CADDRESSES&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "PUT", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return JSON.stringify({'cart_type':'REGULAR'})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success", "cartFull", "accessTokenInvalid"], | |
"success": { | |
"log": "Got cart_id", | |
"status": 200, | |
"options": {} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "submitBilling", | |
"accessTokenInvalid": "refreshTokens", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"submitBilling": { | |
"name": "submitBilling", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/checkout_payments/v1/payment_instructions?key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "billing_info=taskObjects[TaskID].getProfile(TaskID,taskObjects);if(taskObjects[TaskID]['Variables']['cart_id']==null){cart_id=taskObjects[TaskID].getProfile(TaskID,taskObjects);response=taskObjects[TaskID]['requestHistory']['addToCart'];text=JSON.parse(await response.text());if(JSON.stringify(text).includes('cart_id')==false){response=taskObjects[TaskID]['requestHistory']['harvestCartID'];text=JSON.parse(await response.text())}cart_id=text['cart_id'];taskObjects[TaskID]['Variables']['cart_id']=cart_id}else{cart_id=taskObjects[TaskID]['Variables']['cart_id']};if(billing_info['billing_info']['card_details']['expiry_month'].includes('0')==false&&billing_info['billing_info']['card_details']['expiry_month'].length==1){var expiry_month='0'+billing_info['billing_info']['card_details']['expiry_month']}else{var expiry_month=billing_info['billing_info']['card_details']['expiry_month']};let expiry_year=profile_info['billing_info']['card_details']['expiry_year'];if(expiry_year.length==2){expiry_year='20'+expiry_year}return JSON.stringify({'cart_id':cart_id,'wallet_mode':'NONE','payment_type':'CARD','card_details':{'card_name':billing_info['billing_info']['card_details']['card_name'],'card_number':billing_info['billing_info']['card_details']['card_number'],'cvv':billing_info['billing_info']['card_details']['cvv'],'expiry_month':expiry_month,'expiry_year':expiry_year},'billing_address':{'address_line1':billing_info['billing_info']['billing_address']['address_line1'],'city':billing_info['billing_info']['billing_address']['city'],'first_name':billing_info['billing_info']['billing_address']['first_name'],'last_name':billing_info['billing_info']['billing_address']['last_name'],'phone':billing_info['billing_info']['billing_address']['phone'],'state':billing_info['billing_info']['billing_address']['state'],'zip_code':billing_info['billing_info']['billing_address']['zip_code'],'country':'US'}})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"success", | |
"serviceUnavailable", | |
"cardAlreadyPresent", | |
"CART_TOTAL_AMOUNT_ZERO", | |
"accessTokenInvalid", | |
"INVALID_PAYMENT_COMBINATION" | |
], | |
"success": { | |
"log": "Submitting Order", | |
"status": 201, | |
"options": {} | |
}, | |
"serviceUnavailable": { | |
"log": "Service Unavailable", | |
"status": 424, | |
"options": {} | |
}, | |
"CART_TOTAL_AMOUNT_ZERO": { | |
"log": "Cart is Empty. Check QTY.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CART_TOTAL_AMOUNT_ZERO" | |
} | |
}, | |
"cardAlreadyPresent": { | |
"log": "Submitting Order", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CARD_PAYMENT_EXIST" | |
} | |
}, | |
"INVALID_PAYMENT_COMBINATION": { | |
"log": "Submitting Order", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "INVALID_PAYMENT_COMBINATION" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "submitCheckout", | |
"CART_TOTAL_AMOUNT_ZERO":"Monitor", | |
"serviceUnavailable":"Monitor", | |
"cardAlreadyPresent": "submitCheckout", | |
"accessTokenInvalid": "refreshTokens", | |
"INVALID_PAYMENT_COMBINATION": "submitCheckout", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"resubmitCVV": { | |
"name": "resubmitCVV", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": null, | |
"urlFunction": { | |
"name": "returnResubmitCVVUrl", | |
"arguments": "taskObjects, TaskID" | |
} | |
}, | |
"method": "PUT", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "billing_info=taskObjects[TaskID].getProfile(TaskID, taskObjects);cart_id=taskObjects[TaskID]['Variables']['cart_id'];return JSON.stringify({'cart_id':cart_id,'wallet_mode':'NONE','payment_type':'CARD','card_details':{'cvv':billing_info['billing_info']['card_details']['cvv']}})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"success", | |
"cardAlreadyPresent", | |
"accessTokenInvalid" | |
], | |
"success": { | |
"log": "Resubmitted CVV", | |
"status": 200, | |
"options": {} | |
}, | |
"cardAlreadyPresent": { | |
"log": "Submitting Order", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CARD_PAYMENT_EXIST" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "submitCheckout", | |
"cardAlreadyPresent": "submitCheckout", | |
"accessTokenInvalid": "refreshTokens", | |
"end": "submitCheckout" | |
} | |
} | |
}, | |
"submitCheckout": { | |
"name": "submitCheckout", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/checkout?field_groups=ADDRESSES%2CCART%2CCART_ITEMS%2CDELIVERY_WINDOWS%2CPAYMENT_INSTRUCTIONS%2CPICKUP_INSTRUCTIONS%2CPROMOTION_CODES%2CSUMMARY&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": "{\"cart_type\":\"REGULAR\",\"channel_id\":10}", | |
"function": null | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"checkout2", | |
"PaymentDecline", | |
"RateLimited", | |
"MISSING_CREDIT_CARD_CVV", | |
"MISSING_OR_INVALID_PAYMENT_DETAILS", | |
"EMPTY_CART_FOR_ORDER_SUBMIT", | |
"accessTokenInvalid", | |
"CREDIT_CARD_COMPARE_REQUIRED" | |
], | |
"checkout2": { | |
"log": "Submitted Checkout.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "orders" | |
} | |
}, | |
"PaymentDecline": { | |
"log": "Payment Declined.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "PAYMENT_DECLINED_EXCEPTION" | |
} | |
}, | |
"RateLimited": { | |
"log": "Rate Limited. Retrying...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EC_PLATFORM_RATE_LIMITED" | |
} | |
}, | |
"MISSING_CREDIT_CARD_CVV": { | |
"log": "MISSING_CREDIT_CARD_CVV", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "MISSING_CREDIT_CARD_CVV" | |
} | |
}, | |
"MISSING_OR_INVALID_PAYMENT_DETAILS": { | |
"log": "MISSING_OR_INVALID_PAYMENT_DETAILS", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "MISSING_OR_INVALID_PAYMENT_DETAILS" | |
} | |
}, | |
"EMPTY_CART_FOR_ORDER_SUBMIT": { | |
"log": "Cart Empty", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EMPTY_CART_FOR_ORDER_SUBMIT" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token ", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"CREDIT_CARD_COMPARE_REQUIRED": { | |
"log": "CREDIT_CARD_COMPARE_REQUIRED", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CREDIT_CARD_COMPARE_REQUIRED" | |
} | |
} | |
}, | |
"taskLogic": { | |
"checkout2": "logCheckout", | |
"PaymentDecline": "Monitor", | |
"EMPTY_CART_FOR_ORDER_SUBMIT": "Monitor", | |
"MISSING_CREDIT_CARD_CVV": "resubmitCVV", | |
"itemNotAvailableYet": "Monitor", | |
"accessTokenInvalid": "refreshTokens", | |
"RateLimited":"Monitor", | |
"CREDIT_CARD_COMPARE_REQUIRED": "submitBilling", | |
"MISSING_OR_INVALID_PAYMENT_DETAILS": "submitBilling", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"logCheckout": { | |
"name": "logCheckout", | |
"type": "function", | |
"start": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "const response=taskObjects[TaskID].requestHistory.submitCheckout;const body_text=JSON.parse(await response.text());let item_info;const data=JSON.parse(taskObjects[TaskID].requestHistory.addToCart.data);let sku=taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.task_sku.split(':')[0];const cart_item=body_text.orders[0].cart_items.find((cart_item)=>{return cart_item.tcin===sku});try{item_info={Title:cart_item.item_attributes.description,Image:data.item_attributes.image_path,Price:cart_item.unit_price*taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.item_quantity,}}catch{item_info={Title:'N/A',Image:'',Price:'',}};let orderID;try{orderID=body_text.orders[0].order_id}catch{orderID='N/A'};let checkoutInfo={product_info:item_info,Task_Info:taskObjects[TaskID].getTaskInfo(TaskID,taskObjects)};const getProxyName=()=>{try{let taskGroupId=taskObjects[TaskID].TaskGroupID;let taskGroups=taskObjects.taskGroups;let proxyGroups=taskObjects.proxyGroups;let task_info=taskGroups.find((group)=>group.id===taskGroupId).tasks.find((task)=>task.id===TaskID);let proxy_group_id=task_info.task_proxy_info.proxy_group_id;if(task_info.task_proxy_info.localhost){return'localhost'};return proxyGroups.find((group)=>group.id===proxy_group_id).name}catch{return'N/A'}};let config={'content':null,'embeds':[{'title':'Successfully checked out!','description':checkoutInfo.product_info.Title,'color':3297740,'image':{'url':checkoutInfo.product_info.Image},'fields':[{'name':'Site','value':checkoutInfo.Task_Info.product.site,'inline':true},{'name':'SKU','value':checkoutInfo.Task_Info.product.task_sku,'inline':true},{'name':'Quantity','value':checkoutInfo.Task_Info.product.item_quantity,'inline':true},{'name':'Mode','value':checkoutInfo.Task_Info.task_settings.task_mode,'inline':true},{'name':'Profile','value':'||'+taskObjects[TaskID].getProfile(TaskID,taskObjects).profile_name+'||','inline':true},{'name':'Account Email','value':'||'+taskObjects[TaskID].getAccount(TaskID,taskObjects).username+'||','inline':true},{'name':'Account Password','value':'||'+taskObjects[TaskID].getAccount(TaskID,taskObjects).password+'||','inline':true},{'name':'Order #','value':'||'+orderID+'||','inline':true},{'name':'Proxy','value':'||'+getProxyName()+'||','inline':true}],'footer':{'text':'LexAIO v2 Success','icon_url':'https://avatars1.githubusercontent.com/u/76762917?s=40&v=4'},'timestamp':timestamp()}]};function timestamp(){const timeElapsed=Date.now();const today=new Date(timeElapsed);return today.toISOString()};checkoutInfo.config=config;process.send({'type':'SuccessfulCheckout','CheckoutInfo':checkoutInfo});if(taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).task_advanced_info.loopCheckout){taskObjects[TaskID]['Cookies']=[];taskObjects[TaskID]['Variables']['cart_id']=null;return'restart'}else{return'Checkout'}" | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success", "restart"], | |
"success": { | |
"log": "Submitted Checkout. " | |
}, | |
"restart": { | |
"log": "Restart Checkout." | |
}, | |
"Decline": { | |
"log": "Payment Declined. " | |
} | |
}, | |
"taskLogic": { | |
"Checkout": "end", | |
"restart": "submitShipping", | |
"Decline": "end", | |
"end": "end" | |
} | |
} | |
}, | |
"end": "exit" | |
} | |
}, | |
"Fast2": { | |
"entryPoint": "submitShipping", | |
"variables": [ | |
"ItemInfo", | |
"ItemAvailability", | |
"cart_id", | |
"Access_Token", | |
"Visitor_ID", | |
"Refresh_Token" | |
], | |
"taskStatistics":{ | |
"addedToCart":"taskCartCount", | |
"addedToCart2":"taskCartCount", | |
"successfulCheckout": "taskCountCheckedOut", | |
"checkout2": "taskCountCheckedOut", | |
"PaymentDecline": "taskCountDeclined", | |
"Decline": "taskCountDeclined" | |
}, | |
"captchaHarvester": true, | |
"helperFunctions": { | |
"returnResubmitCVVUrl": { | |
"arguments": "taskObjects, TaskID", | |
"body": "response=taskObjects[TaskID]['requestHistory']['submitCheckout'];text=await response.text();instructions_id=text.split('Missing CVV or PIN code on payment instruction ')[1].split('\"')[0];console.log(instructions_id);return `https://carts.target.com/checkout_payments/v1/payment_instructions/${instructions_id}?key=feaf228eb2777fd3eee0fd5192ae7107d6224b39`" | |
}, | |
"remnoveItemURL": { | |
"arguments": "taskObjects, TaskID", | |
"body": "let response=taskObjects[TaskID]['requestHistory']['preCart'];text=JSON.parse(await response.text());cart_item_id=text['cart_item_id'];return `https://carts.target.com/web_checkouts/v1/cart_items/${cart_item_id}?cart_type=REGULAR&field_groups=ADDRESSES%2CCART%2CCART_ITEMS%2CFINANCE_PROVIDERS%2CPROMOTION_CODES%2CSUMMARY&key=e59ce3b531b2c39afb2e2b8a71ff10113aac2a14`" | |
}, | |
"setCookies": { | |
"arguments": "taskObjects, TaskID", | |
"body": "try{taskObjects[TaskID].Cookies=[];let account=taskObjects[TaskID].getAccount(TaskID,taskObjects);let cookies=account.cookies;let accessToken='accessToken='+cookies.accessToken;let visitorID='visitorID='+cookies.visitorID;taskObjects[TaskID].setCookie(TaskID,taskObjects,accessToken);taskObjects[TaskID].setCookie(TaskID,taskObjects,visitorID)}catch{}" | |
}, | |
"setRefreshCookies": { | |
"arguments": "taskObjects, TaskID", | |
"body": "try{let account=taskObjects[TaskID].getAccount(TaskID,taskObjects);let cookies=account.cookies;let Access_Token=cookies.accessToken;let Visitor_ID=cookies.visitorID;let Refresh_Token=taskObjects[TaskID]['helperFunctions']['jwt_decode'](Access_Token)['jti'];taskObjects[TaskID]['Variables']['Access_Token']=Access_Token;taskObjects[TaskID]['Variables']['Visitor_ID']=Visitor_ID;taskObjects[TaskID]['Variables']['Refresh_Token']=Refresh_Token;taskObjects[TaskID].Cookies=[];taskObjects[TaskID].Cookies.push('refreshToken='+Refresh_Token+';');taskObjects[TaskID].Cookies.push('visitorId='+Visitor_ID+';')}catch (e){console.log(e)}" | |
}, | |
"setLoginCookies": { | |
"arguments": "taskObjects, TaskID", | |
"body": "try{if(taskObjects[TaskID].Variables.CookieData){console.log('REMOVING COOKIE DATA');taskObjects[TaskID].deleteShapeCookie(taskObjects[TaskID].Variables.CookieData.id)};taskObjects[TaskID].Cookies=[];let cookieData=taskObjects[TaskID].getRandomShapeCookie(taskObjects);taskObjects[TaskID].Variables.CookieData=cookieData;let newCookies=cookieData.Cookies.split('; ');newCookies=newCookies.map((cookie)=>{return cookie+';'});taskObjects[TaskID].Cookies=newCookies}catch(e){console.log(e)}" | |
} | |
}, | |
"logStatusColors": { | |
"success": "magenta", | |
"addedToCart":"magenta", | |
"successfulCheckout":"green", | |
"checkout2":"green", | |
"OutOfStock": "cyan", | |
"OutOfStock2": "cyan", | |
"NoLoadedTCINs": "cyan", | |
"cartFull": "yellow", | |
"logCheckout": "green", | |
"PID_LOCKED": "yellow", | |
"processing": "yellow", | |
"error": "yellow", | |
"fail": "red", | |
"InStock": "cyan", | |
"shippingAlreadyPresent": "cyan" | |
}, | |
"functions": { | |
"SignIn": { | |
"name": "SignIn", | |
"type": "request", | |
"start": "setLoginCookies", | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://gsp.target.com/gsp/authentications/v1/credential_validations?client_id=ecom-web-1.0.0" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "gsp.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"customHeaders": { | |
"x-gyjwza5z-a": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-A'];" | |
}, | |
"x-gyjwza5z-b": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-B'];" | |
}, | |
"x-gyjwza5z-c": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-C'];" | |
}, | |
"x-gyjwza5z-d": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-D'];" | |
}, | |
"x-gyjwza5z-f": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-F'];" | |
}, | |
"x-gyjwza5z-z": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-Z'];" | |
}, | |
"user-agent": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['UserAgent'];" | |
} | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "let cookieData=taskObjects[TaskID].Variables.CookieData;let parsedData=JSON.stringify({'username':taskObjects[TaskID].getAccount(TaskID,taskObjects).username,'password':taskObjects[TaskID].getAccount(TaskID,taskObjects).password,'device_info':JSON.parse(cookieData.DeviceInfo),'keep_me_signed_in':true});return parsedData;" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": false, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"reLogin", | |
"_ERR_AUTH_DENIED", | |
"IPBanned", | |
"_ERR_USER_DOES_NOT_EXIST", | |
"success" | |
], | |
"success": { | |
"log": "Signed in...", | |
"status": 202, | |
"options": {} | |
}, | |
"_ERR_USER_DOES_NOT_EXIST": { | |
"log": "Account does not exist.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "_ERR_USER_DOES_NOT_EXIST" | |
} | |
}, | |
"_ERR_AUTH_DENIED": { | |
"log": "Authentication denied", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "_ERR_AUTH_DENIED" | |
} | |
}, | |
"IPBanned": { | |
"log": "IP Banned.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "accessDenied" | |
} | |
}, | |
"reLogin": { | |
"log": "Invalid Tokens. Signing in again...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Not Found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "authSignIn", | |
"_ERR_AUTH_DENIED":"SignIn", | |
"reLogin": "SignIn", | |
"IPBanned":"end", | |
"_ERR_USER_DOES_NOT_EXIST":"end", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"authSignIn": { | |
"name": "authSignIn", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 1000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://gsp.target.com/gsp/authentications/v1/auth_codes?client_id=ecom-web-1.0.0" | |
}, | |
"method": "GET", | |
"headers": { | |
"authority": "gsp.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": {} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"redirect":"false", | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success"], | |
"success": { | |
"log": "Authenticated", | |
"status": 302, | |
"options": {} | |
} | |
}, | |
"taskLogic": { | |
"success": "genTokens", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"genTokens": { | |
"name": "genTokens", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://gsp.target.com/gsp/oauth_tokens/v2/client_tokens" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "let cookieData=taskObjects[TaskID].Variables.CookieData;let code=taskObjects[TaskID].requestHistory['authSignIn'].headers.location.split('https://www.target.com/?code=')[1].split('&state=')[0];let parsedData=JSON.stringify({'grant_type':'authorization_code','client_credential':{'client_id':'ecom-web-1.0.0'},'code':code,'device_info':JSON.parse(cookieData.DeviceInfo),'keep_me_signed_in':true});return parsedData;return taskObjects[TaskID].Variables.CookieData['UserAgent'];" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": false, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"reLogin", | |
"IPBanned", | |
"success" | |
], | |
"success": { | |
"log": "Refreshed Tokens", | |
"status": 201, | |
"options": {} | |
}, | |
"IPBanned": { | |
"log": "IP Banned.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "accessDenied" | |
} | |
}, | |
"reLogin": { | |
"log": "Invalid Tokens. Signing in again...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Not Found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "parseRefreshToken", | |
"reLogin": "SignIn", | |
"IPBanned":"end", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"refreshTokens": { | |
"name": "refreshTokens", | |
"type": "request", | |
"start": "setRefreshCookies", | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://gsp.target.com/gsp/oauth_tokens/v2/client_tokens" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": "{\"grant_type\":\"refresh_token\",\"client_credential\":{\"client_id\":\"ecom-web-1.0.0\"}}", | |
"function": null | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": false, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"reLogin", | |
"IPBanned", | |
"success" | |
], | |
"success": { | |
"log": "Refreshed Tokens", | |
"status": 201, | |
"options": {} | |
}, | |
"IPBanned": { | |
"log": "IP Banned.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "accessDenied" | |
} | |
}, | |
"reLogin": { | |
"log": "Invalid Tokens. Signing in again...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Not Found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "parseRefreshToken", | |
"reLogin": "SignIn", | |
"IPBanned":"SignIn", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"parseRefreshToken": { | |
"name": "parseRefreshToken", | |
"type": "function", | |
"start": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "try{let account=taskObjects[TaskID].getAccount(TaskID,taskObjects);if(!account?.cookies){account.cookies={}};let response;if(taskObjects[TaskID].CallStack[taskObjects[TaskID].CallStack.length-2]==='genTokens'){response=JSON.parse(taskObjects[TaskID].requestHistory.genTokens.data);let cookieData=taskObjects[TaskID].Variables.CookieData;account.cookies.visitorID=JSON.parse(cookieData.DeviceInfo).visitor_id}else{response=JSON.parse(taskObjects[TaskID].requestHistory.refreshTokens.data)};let Access_Token=response.access_token;let id_token=response.id_token;account.cookies.idToken=id_token;account.cookies.accessToken=Access_Token;taskObjects[TaskID].updateAccount(TaskID,taskObjects,account);return'success'}catch(e){console.log(e);return'error'}" | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success", "noAccountCookies","error"], | |
"success": { | |
"log": "Parsed Tokens." | |
}, | |
"noAccountCookies": { | |
"log": "No Account Bin Found. Re-bin." | |
}, | |
"error": { | |
"log": "Error with account. Re-bin." | |
} | |
}, | |
"taskLogic": { | |
"success": "submitShipping", | |
"noAccountCookies":"SignIn", | |
"error": "SignIn", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"submitShipping": { | |
"name": "submitShipping", | |
"type": "request", | |
"start": "setCookies", | |
"delay": 0, | |
"retryDelay": 3001, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/cart_shipping_addresses?field_groups=ADDRESSES%2CCART%2CCART_ITEMS%2CPICKUP_INSTRUCTIONS%2CPROMOTION_CODES%2CSUMMARY&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "profile_info=taskObjects[TaskID].getProfile(TaskID, taskObjects);return JSON.stringify({'cart_type':'REGULAR','address':{'address_line1':profile_info['shipping_address']['address_line1'],'address_line2':profile_info['shipping_address']['address_line2'],'address_type':'SHIPPING','city':profile_info['shipping_address']['city'],'country':'US','first_name':profile_info['shipping_address']['first_name'],'last_name':profile_info['shipping_address']['last_name'],'mobile':profile_info['shipping_address']['phone'],'save_as_default':false,'state':profile_info['shipping_address']['state'],'zip_code':profile_info['shipping_address']['zip_code']},'selected':true,'save_to_profile':false,'skip_verification':true})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"success", | |
"shippingAlreadyPresent", | |
"accessTokenInvalid", | |
"CONSTRAINT_VALIDATION_FAILURE", | |
"INVALID_GUEST_STATUS", | |
"Unauthorized", | |
"Unauthorized2" | |
], | |
"success": { | |
"log": "Waiting for Monitor", | |
"status": 201, | |
"options": {} | |
}, | |
"shippingAlreadyPresent": { | |
"log": "Waiting for Monitor", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "ADDRESS_ALREADY_PRESENT" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"Unauthorized": { | |
"log": "Unauthorized", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Unauthorized" | |
} | |
}, | |
"Unauthorized2": { | |
"log": "Unauthorized", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "UNAUTHORIZED" | |
} | |
}, | |
"INVALID_GUEST_STATUS": { | |
"log": "Bad cookies. Re-bin account.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "INVALID_GUEST_STATUS" | |
} | |
}, | |
"CONSTRAINT_VALIDATION_FAILURE": { | |
"log": "Profile is missing Phone Number.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "address.mobile" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "preCart", | |
"shippingAlreadyPresent": "preCart", | |
"accessTokenInvalid": "refreshTokens", | |
"CONSTRAINT_VALIDATION_FAILURE": "end", | |
"INVALID_GUEST_STATUS": "SignIn", | |
"Unauthorized":"SignIn", | |
"Unauthorized2":"SignIn", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"preCart": { | |
"name": "preCart", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 1000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/cart_items?field_groups=CART%2CCART_ITEMS%2CSUMMARY&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return JSON.stringify({'cart_type':'REGULAR','channel_id':'10','shopping_context':'DIGITAL','cart_item':{'tcin':'14046215','quantity':1,'item_channel_id':'10'}})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["addedToCart", "cartFull", "accessTokenInvalid", "DEPENDENT_SERVICE_ERROR", "PID_LOCKED", "proxyBan"], | |
"addedToCart": { | |
"log": "Added To Cart", | |
"status": 201, | |
"options": {} | |
}, | |
"cartFull": { | |
"log": "MAX_PURCHASE_LIMIT_EXCEEDED", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "MAX_PURCHASE_LIMIT_EXCEEDED" | |
} | |
}, | |
"DEPENDENT_SERVICE_ERROR": { | |
"log": "Item OOS. Retrying atc...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "DEPENDENT_SERVICE_ERROR" | |
} | |
}, | |
"PID_LOCKED": { | |
"log": "Item PID Locked. Retrying atc...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Access Denied" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"proxyBan": { | |
"log": "Proxy Banned. Retrying...", | |
"status": 404, | |
"options": {} | |
} | |
}, | |
"taskLogic": { | |
"addedToCart": "preSubmitBilling", | |
"cartFull": "harvestCartID", | |
"DEPENDENT_SERVICE_ERROR": "Monitor", | |
"accessTokenInvalid": "refreshTokens", | |
"PID_LOCKED": "Monitor", | |
"proxyBan":"Monitor", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"preSubmitBilling": { | |
"name": "preSubmitBilling", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/checkout_payments/v1/payment_instructions?key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "billing_info=taskObjects[TaskID].getProfile(TaskID,taskObjects);if(taskObjects[TaskID]['Variables']['cart_id']==null){cart_id=taskObjects[TaskID].getProfile(TaskID,taskObjects);response=taskObjects[TaskID]['requestHistory']['preCart'];text=JSON.parse(await response.text());if(JSON.stringify(text).includes('cart_id')==false){response=taskObjects[TaskID]['requestHistory']['harvestCartID'];text=JSON.parse(await response.text())}cart_id=text['cart_id'];taskObjects[TaskID]['Variables']['cart_id']=cart_id}else{cart_id=taskObjects[TaskID]['Variables']['cart_id']};if(billing_info['billing_info']['card_details']['expiry_month'].includes('0')==false&&billing_info['billing_info']['card_details']['expiry_month'].length==1){var expiry_month='0'+billing_info['billing_info']['card_details']['expiry_month']}else{var expiry_month=billing_info['billing_info']['card_details']['expiry_month']};let expiry_year=profile_info['billing_info']['card_details']['expiry_year'];if(expiry_year.length==2){expiry_year='20'+expiry_year}return JSON.stringify({'cart_id':cart_id,'wallet_mode':'NONE','payment_type':'CARD','card_details':{'card_name':billing_info['billing_info']['card_details']['card_name'],'card_number':billing_info['billing_info']['card_details']['card_number'],'cvv':billing_info['billing_info']['card_details']['cvv'],'expiry_month':expiry_month,'expiry_year':expiry_year},'billing_address':{'address_line1':billing_info['billing_info']['billing_address']['address_line1'],'city':billing_info['billing_info']['billing_address']['city'],'first_name':billing_info['billing_info']['billing_address']['first_name'],'last_name':billing_info['billing_info']['billing_address']['last_name'],'phone':billing_info['billing_info']['billing_address']['phone'],'state':billing_info['billing_info']['billing_address']['state'],'zip_code':billing_info['billing_info']['billing_address']['zip_code'],'country':'US'}})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"success", | |
"serviceUnavailable", | |
"cardAlreadyPresent", | |
"CART_TOTAL_AMOUNT_ZERO", | |
"accessTokenInvalid", | |
"INVALID_PAYMENT_COMBINATION" | |
], | |
"success": { | |
"log": "Waiting for Monitor...", | |
"status": 201, | |
"options": {} | |
}, | |
"serviceUnavailable": { | |
"log": "Service Unavailable", | |
"status": 424, | |
"options": {} | |
}, | |
"CART_TOTAL_AMOUNT_ZERO": { | |
"log": "Cart is Empty. Check QTY.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CART_TOTAL_AMOUNT_ZERO" | |
} | |
}, | |
"cardAlreadyPresent": { | |
"log": "Waiting for Monitor..", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CARD_PAYMENT_EXIST" | |
} | |
}, | |
"INVALID_PAYMENT_COMBINATION": { | |
"log": "Waiting for Monitor..", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "INVALID_PAYMENT_COMBINATION" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "Monitor", | |
"CART_TOTAL_AMOUNT_ZERO":"Monitor", | |
"serviceUnavailable":"Monitor", | |
"cardAlreadyPresent": "Monitor", | |
"accessTokenInvalid": "refreshTokens", | |
"INVALID_PAYMENT_COMBINATION": "Monitor", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"Monitor": { | |
"name": "Monitor", | |
"type": "function", | |
"start": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "let monitorEventPromise=async(sku)=>{console.log('WaitingForSKU'+sku);return new Promise((resolve,reject)=>{let event=monitorEvent.on(sku,(message)=>{if(message.inStock){delete event;resolve(message)}})})};let result=await monitorEventPromise(taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.task_sku);taskObjects[TaskID]['Variables']['tcin']=result.SKU;return'InStock';" | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["InStock", "OutOfStock", "UnAvailable"], | |
"InStock": { | |
"log": "Item in Stock. Adding to cart." | |
}, | |
"OutOfStock": { | |
"log": "Monitoring..." | |
}, | |
"OutOfStock2": { | |
"log": "Monitoring..." | |
}, | |
"UnAvailable": { | |
"log": "Failed to get item. Monitoring..." | |
} | |
}, | |
"taskLogic": { | |
"InStock": "addToCart", | |
"OutOfStock": "Monitor", | |
"OutOfStock2": "Monitor", | |
"UnAvailable": "Monitor", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"addToCart": { | |
"name": "addToCart", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 1000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/cart_items?field_groups=CART%2CCART_ITEMS%2CSUMMARY&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return JSON.stringify({'cart_type':'REGULAR','channel_id':'10','shopping_context':'DIGITAL','cart_item':{'tcin':taskObjects[TaskID]['Variables']['tcin'],'quantity':taskObjects[TaskID].getTaskInfo(TaskID, taskObjects).product.item_quantity,'item_channel_id':'10'}})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["addedToCart", "cartFull", "accessTokenInvalid", "DEPENDENT_SERVICE_ERROR", "PID_LOCKED", "proxyBan"], | |
"addedToCart": { | |
"log": "Submitting Checkout...", | |
"status": 201, | |
"options": {} | |
}, | |
"cartFull": { | |
"log": "MAX_PURCHASE_LIMIT_EXCEEDED", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "MAX_PURCHASE_LIMIT_EXCEEDED" | |
} | |
}, | |
"DEPENDENT_SERVICE_ERROR": { | |
"log": "Item OOS. Retrying atc...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "DEPENDENT_SERVICE_ERROR" | |
} | |
}, | |
"PID_LOCKED": { | |
"log": "Item PID Locked. Retrying atc...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Access Denied" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"proxyBan": { | |
"log": "Proxy Banned. Retrying...", | |
"status": 404, | |
"options": {} | |
} | |
}, | |
"taskLogic": { | |
"addedToCart": "removeItemFromCart", | |
"cartFull": "harvestCartID", | |
"DEPENDENT_SERVICE_ERROR": "Monitor", | |
"accessTokenInvalid": "refreshTokens", | |
"PID_LOCKED": "Monitor", | |
"proxyBan":"Monitor", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"removeItemFromCart": { | |
"name": "removeItemFromCart", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 1000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": null, | |
"urlFunction": { | |
"name": "remnoveItemURL", | |
"arguments": "taskObjects, TaskID" | |
} | |
}, | |
"method": "DELETE", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["removedFromCart"], | |
"removedFromCart": { | |
"log": "Submitting Checkout...", | |
"status": 200, | |
"options": {} | |
} | |
}, | |
"taskLogic": { | |
"removedFromCart": "submitCheckout", | |
"end": "submitCheckout" | |
} | |
} | |
}, | |
"harvestCartID": { | |
"name": "harvestCartID", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/cart?field_groups=CART%2CCART_ITEMS%2CSUMMARY%2CPROMOTION_CODES%2CADDRESSES&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "PUT", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return JSON.stringify({'cart_type':'REGULAR'})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success", "cartFull", "accessTokenInvalid"], | |
"success": { | |
"log": "Got cart_id", | |
"status": 200, | |
"options": {} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "submitBilling", | |
"accessTokenInvalid": "refreshTokens", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"submitBilling": { | |
"name": "submitBilling", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/checkout_payments/v1/payment_instructions?key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "billing_info=taskObjects[TaskID].getProfile(TaskID,taskObjects);if(taskObjects[TaskID]['Variables']['cart_id']==null){cart_id=taskObjects[TaskID].getProfile(TaskID,taskObjects);response=taskObjects[TaskID]['requestHistory']['addToCart'];text=JSON.parse(await response.text());if(JSON.stringify(text).includes('cart_id')==false){response=taskObjects[TaskID]['requestHistory']['harvestCartID'];text=JSON.parse(await response.text())}cart_id=text['cart_id'];taskObjects[TaskID]['Variables']['cart_id']=cart_id}else{cart_id=taskObjects[TaskID]['Variables']['cart_id']};if(billing_info['billing_info']['card_details']['expiry_month'].includes('0')==false&&billing_info['billing_info']['card_details']['expiry_month'].length==1){var expiry_month='0'+billing_info['billing_info']['card_details']['expiry_month']}else{var expiry_month=billing_info['billing_info']['card_details']['expiry_month']};let expiry_year=profile_info['billing_info']['card_details']['expiry_year'];if(expiry_year.length==2){expiry_year='20'+expiry_year}return JSON.stringify({'cart_id':cart_id,'wallet_mode':'NONE','payment_type':'CARD','card_details':{'card_name':billing_info['billing_info']['card_details']['card_name'],'card_number':billing_info['billing_info']['card_details']['card_number'],'cvv':billing_info['billing_info']['card_details']['cvv'],'expiry_month':expiry_month,'expiry_year':expiry_year},'billing_address':{'address_line1':billing_info['billing_info']['billing_address']['address_line1'],'city':billing_info['billing_info']['billing_address']['city'],'first_name':billing_info['billing_info']['billing_address']['first_name'],'last_name':billing_info['billing_info']['billing_address']['last_name'],'phone':billing_info['billing_info']['billing_address']['phone'],'state':billing_info['billing_info']['billing_address']['state'],'zip_code':billing_info['billing_info']['billing_address']['zip_code'],'country':'US'}})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"success", | |
"serviceUnavailable", | |
"cardAlreadyPresent", | |
"CART_TOTAL_AMOUNT_ZERO", | |
"accessTokenInvalid", | |
"INVALID_PAYMENT_COMBINATION" | |
], | |
"success": { | |
"log": "Submitting Order", | |
"status": 201, | |
"options": {} | |
}, | |
"serviceUnavailable": { | |
"log": "Service Unavailable", | |
"status": 424, | |
"options": {} | |
}, | |
"CART_TOTAL_AMOUNT_ZERO": { | |
"log": "Cart is Empty. Check QTY.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CART_TOTAL_AMOUNT_ZERO" | |
} | |
}, | |
"cardAlreadyPresent": { | |
"log": "Submitting Order", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CARD_PAYMENT_EXIST" | |
} | |
}, | |
"INVALID_PAYMENT_COMBINATION": { | |
"log": "Submitting Order", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "INVALID_PAYMENT_COMBINATION" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "submitCheckout", | |
"CART_TOTAL_AMOUNT_ZERO":"Monitor", | |
"serviceUnavailable":"Monitor", | |
"cardAlreadyPresent": "submitCheckout", | |
"accessTokenInvalid": "refreshTokens", | |
"INVALID_PAYMENT_COMBINATION": "submitCheckout", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"resubmitCVV": { | |
"name": "resubmitCVV", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": null, | |
"urlFunction": { | |
"name": "returnResubmitCVVUrl", | |
"arguments": "taskObjects, TaskID" | |
} | |
}, | |
"method": "PUT", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "billing_info=taskObjects[TaskID].getProfile(TaskID, taskObjects);cart_id=taskObjects[TaskID]['Variables']['cart_id'];return JSON.stringify({'cart_id':cart_id,'wallet_mode':'NONE','payment_type':'CARD','card_details':{'cvv':billing_info['billing_info']['card_details']['cvv']}})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"success", | |
"cardAlreadyPresent", | |
"accessTokenInvalid" | |
], | |
"success": { | |
"log": "Resubmitted CVV", | |
"status": 200, | |
"options": {} | |
}, | |
"cardAlreadyPresent": { | |
"log": "Submitting Order", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CARD_PAYMENT_EXIST" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "submitCheckout", | |
"cardAlreadyPresent": "submitCheckout", | |
"accessTokenInvalid": "refreshTokens", | |
"end": "submitCheckout" | |
} | |
} | |
}, | |
"submitCheckout": { | |
"name": "submitCheckout", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/checkout?field_groups=ADDRESSES%2CCART%2CCART_ITEMS%2CDELIVERY_WINDOWS%2CPAYMENT_INSTRUCTIONS%2CPICKUP_INSTRUCTIONS%2CPROMOTION_CODES%2CSUMMARY&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": "{\"cart_type\":\"REGULAR\",\"channel_id\":10}", | |
"function": null | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"checkout2", | |
"PaymentDecline", | |
"RateLimited", | |
"MISSING_CREDIT_CARD_CVV", | |
"MISSING_OR_INVALID_PAYMENT_DETAILS", | |
"EMPTY_CART_FOR_ORDER_SUBMIT", | |
"accessTokenInvalid", | |
"CREDIT_CARD_COMPARE_REQUIRED" | |
], | |
"checkout2": { | |
"log": "Submitted Checkout.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "orders" | |
} | |
}, | |
"PaymentDecline": { | |
"log": "Payment Declined.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "PAYMENT_DECLINED_EXCEPTION" | |
} | |
}, | |
"RateLimited": { | |
"log": "Rate Limited. Retrying...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EC_PLATFORM_RATE_LIMITED" | |
} | |
}, | |
"MISSING_CREDIT_CARD_CVV": { | |
"log": "MISSING_CREDIT_CARD_CVV", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "MISSING_CREDIT_CARD_CVV" | |
} | |
}, | |
"MISSING_OR_INVALID_PAYMENT_DETAILS": { | |
"log": "MISSING_OR_INVALID_PAYMENT_DETAILS", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "MISSING_OR_INVALID_PAYMENT_DETAILS" | |
} | |
}, | |
"EMPTY_CART_FOR_ORDER_SUBMIT": { | |
"log": "Cart Empty", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EMPTY_CART_FOR_ORDER_SUBMIT" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token ", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"CREDIT_CARD_COMPARE_REQUIRED": { | |
"log": "CREDIT_CARD_COMPARE_REQUIRED", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CREDIT_CARD_COMPARE_REQUIRED" | |
} | |
} | |
}, | |
"taskLogic": { | |
"checkout2": "logCheckout", | |
"PaymentDecline": "Monitor", | |
"EMPTY_CART_FOR_ORDER_SUBMIT": "Monitor", | |
"MISSING_CREDIT_CARD_CVV": "resubmitCVV", | |
"itemNotAvailableYet": "Monitor", | |
"accessTokenInvalid": "refreshTokens", | |
"RateLimited":"Monitor", | |
"CREDIT_CARD_COMPARE_REQUIRED": "submitBilling", | |
"MISSING_OR_INVALID_PAYMENT_DETAILS": "submitBilling", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"logCheckout": { | |
"name": "logCheckout", | |
"type": "function", | |
"start": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "const response=taskObjects[TaskID].requestHistory.submitCheckout;const body_text=JSON.parse(await response.text());let item_info;const data=JSON.parse(taskObjects[TaskID].requestHistory.addToCart.data);let sku=taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.task_sku.split(':')[0];const cart_item=body_text.orders[0].cart_items.find((cart_item)=>{return cart_item.tcin===sku});try{item_info={Title:cart_item.item_attributes.description,Image:data.item_attributes.image_path,Price:cart_item.unit_price*taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.item_quantity,}}catch{item_info={Title:'N/A',Image:'',Price:'',}};let orderID;try{orderID=body_text.orders[0].order_id}catch{orderID='N/A'};let checkoutInfo={product_info:item_info,Task_Info:taskObjects[TaskID].getTaskInfo(TaskID,taskObjects)};const getProxyName=()=>{try{let taskGroupId=taskObjects[TaskID].TaskGroupID;let taskGroups=taskObjects.taskGroups;let proxyGroups=taskObjects.proxyGroups;let task_info=taskGroups.find((group)=>group.id===taskGroupId).tasks.find((task)=>task.id===TaskID);let proxy_group_id=task_info.task_proxy_info.proxy_group_id;if(task_info.task_proxy_info.localhost){return'localhost'};return proxyGroups.find((group)=>group.id===proxy_group_id).name}catch{return'N/A'}};let config={'content':null,'embeds':[{'title':'Successfully checked out!','description':checkoutInfo.product_info.Title,'color':3297740,'image':{'url':checkoutInfo.product_info.Image},'fields':[{'name':'Site','value':checkoutInfo.Task_Info.product.site,'inline':true},{'name':'SKU','value':checkoutInfo.Task_Info.product.task_sku,'inline':true},{'name':'Quantity','value':checkoutInfo.Task_Info.product.item_quantity,'inline':true},{'name':'Mode','value':checkoutInfo.Task_Info.task_settings.task_mode,'inline':true},{'name':'Profile','value':'||'+taskObjects[TaskID].getProfile(TaskID,taskObjects).profile_name+'||','inline':true},{'name':'Account Email','value':'||'+taskObjects[TaskID].getAccount(TaskID,taskObjects).username+'||','inline':true},{'name':'Account Password','value':'||'+taskObjects[TaskID].getAccount(TaskID,taskObjects).password+'||','inline':true},{'name':'Order #','value':'||'+orderID+'||','inline':true},{'name':'Proxy','value':'||'+getProxyName()+'||','inline':true}],'footer':{'text':'LexAIO v2 Success','icon_url':'https://avatars1.githubusercontent.com/u/76762917?s=40&v=4'},'timestamp':timestamp()}]};function timestamp(){const timeElapsed=Date.now();const today=new Date(timeElapsed);return today.toISOString()};checkoutInfo.config=config;process.send({'type':'SuccessfulCheckout','CheckoutInfo':checkoutInfo});if(taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).task_advanced_info.loopCheckout){taskObjects[TaskID]['Cookies']=[];taskObjects[TaskID]['Variables']['cart_id']=null;return'restart'}else{return'Checkout'}" | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success", "restart"], | |
"success": { | |
"log": "Submitted Checkout. " | |
}, | |
"restart": { | |
"log": "Restart Checkout." | |
}, | |
"Decline": { | |
"log": "Payment Declined. " | |
} | |
}, | |
"taskLogic": { | |
"Checkout": "end", | |
"restart": "submitShipping", | |
"Decline": "end", | |
"end": "end" | |
} | |
} | |
}, | |
"end": "exit" | |
} | |
}, | |
"Safe": { | |
"entryPoint": "submitShipping", | |
"variables": [ | |
"ItemInfo", | |
"ItemAvailability", | |
"cart_id", | |
"Access_Token", | |
"Visitor_ID", | |
"Refresh_Token" | |
], | |
"taskStatistics":{ | |
"addedToCart":"taskCartCount", | |
"addedToCart2":"taskCartCount", | |
"successfulCheckout": "taskCountCheckedOut", | |
"checkout2": "taskCountCheckedOut", | |
"PaymentDecline": "taskCountDeclined", | |
"Decline": "taskCountDeclined" | |
}, | |
"captchaHarvester": true, | |
"helperFunctions": { | |
"returnResubmitCVVUrl": { | |
"arguments": "taskObjects, TaskID", | |
"body": "response=taskObjects[TaskID]['requestHistory']['submitCheckout'];text=await response.text();instructions_id=text.split('Missing CVV or PIN code on payment instruction ')[1].split('\"')[0];console.log(instructions_id);return `https://carts.target.com/checkout_payments/v1/payment_instructions/${instructions_id}?key=feaf228eb2777fd3eee0fd5192ae7107d6224b39`" | |
}, | |
"setCookies": { | |
"arguments": "taskObjects, TaskID", | |
"body": "try{taskObjects[TaskID].Cookies=[];let account=taskObjects[TaskID].getAccount(TaskID,taskObjects);let cookies=account.cookies;let accessToken='accessToken='+cookies.accessToken;let visitorID='visitorID='+cookies.visitorID;taskObjects[TaskID].setCookie(TaskID,taskObjects,accessToken);taskObjects[TaskID].setCookie(TaskID,taskObjects,visitorID)}catch{}" | |
}, | |
"setRefreshCookies": { | |
"arguments": "taskObjects, TaskID", | |
"body": "try{let account=taskObjects[TaskID].getAccount(TaskID,taskObjects);let cookies=account.cookies;let Access_Token=cookies.accessToken;let Visitor_ID=cookies.visitorID;let Refresh_Token=taskObjects[TaskID]['helperFunctions']['jwt_decode'](Access_Token)['jti'];taskObjects[TaskID]['Variables']['Access_Token']=Access_Token;taskObjects[TaskID]['Variables']['Visitor_ID']=Visitor_ID;taskObjects[TaskID]['Variables']['Refresh_Token']=Refresh_Token;taskObjects[TaskID].Cookies=[];taskObjects[TaskID].Cookies.push('refreshToken='+Refresh_Token+';');taskObjects[TaskID].Cookies.push('visitorId='+Visitor_ID+';')}catch (e){console.log(e)}" | |
}, | |
"setLoginCookies": { | |
"arguments": "taskObjects, TaskID", | |
"body": "try{if(taskObjects[TaskID].Variables.CookieData){console.log('REMOVING COOKIE DATA');taskObjects[TaskID].deleteShapeCookie(taskObjects[TaskID].Variables.CookieData.id)};taskObjects[TaskID].Cookies=[];let cookieData=taskObjects[TaskID].getRandomShapeCookie(taskObjects);taskObjects[TaskID].Variables.CookieData=cookieData;let newCookies=cookieData.Cookies.split('; ');newCookies=newCookies.map((cookie)=>{return cookie+';'});taskObjects[TaskID].Cookies=newCookies}catch(e){console.log(e)}" | |
} | |
}, | |
"logStatusColors": { | |
"success": "magenta", | |
"addedToCart":"magenta", | |
"successfulCheckout":"green", | |
"checkout2":"green", | |
"OutOfStock": "cyan", | |
"OutOfStock2": "cyan", | |
"NoLoadedTCINs": "cyan", | |
"cartFull": "yellow", | |
"logCheckout": "green", | |
"PID_LOCKED": "yellow", | |
"processing": "yellow", | |
"error": "yellow", | |
"fail": "red", | |
"InStock": "cyan", | |
"shippingAlreadyPresent": "cyan" | |
}, | |
"functions": { | |
"SignIn": { | |
"name": "SignIn", | |
"type": "request", | |
"start": "setLoginCookies", | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://gsp.target.com/gsp/authentications/v1/credential_validations?client_id=ecom-web-1.0.0" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "gsp.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"customHeaders": { | |
"x-gyjwza5z-a": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-A'];" | |
}, | |
"x-gyjwza5z-b": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-B'];" | |
}, | |
"x-gyjwza5z-c": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-C'];" | |
}, | |
"x-gyjwza5z-d": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-D'];" | |
}, | |
"x-gyjwza5z-f": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-F'];" | |
}, | |
"x-gyjwza5z-z": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-Z'];" | |
}, | |
"user-agent": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['UserAgent'];" | |
} | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "let cookieData=taskObjects[TaskID].Variables.CookieData;let parsedData=JSON.stringify({'username':taskObjects[TaskID].getAccount(TaskID,taskObjects).username,'password':taskObjects[TaskID].getAccount(TaskID,taskObjects).password,'device_info':JSON.parse(cookieData.DeviceInfo),'keep_me_signed_in':true});return parsedData;" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": false, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"reLogin", | |
"_ERR_AUTH_DENIED", | |
"IPBanned", | |
"_ERR_USER_DOES_NOT_EXIST", | |
"_ERR_PATTERN_EMAIL_ADDRESS", | |
"_ERR_INVALID_CREDENTIALS", | |
"success" | |
], | |
"success": { | |
"log": "Signed in...", | |
"status": 202, | |
"options": {} | |
}, | |
"_ERR_USER_DOES_NOT_EXIST": { | |
"log": "Account does not exist.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "_ERR_USER_DOES_NOT_EXIST" | |
} | |
}, | |
"_ERR_PATTERN_EMAIL_ADDRESS": { | |
"log": "Account does not exist.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "_ERR_PATTERN_EMAIL_ADDRESS" | |
} | |
}, | |
"_ERR_AUTH_DENIED": { | |
"log": "Authentication denied", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "_ERR_AUTH_DENIED" | |
} | |
}, | |
"_ERR_INVALID_CREDENTIALS": { | |
"log": "Authentication denied", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "_ERR_INVALID_CREDENTIALS" | |
} | |
}, | |
"IPBanned": { | |
"log": "IP Banned.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "accessDenied" | |
} | |
}, | |
"reLogin": { | |
"log": "Invalid Tokens. Signing in again...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Not Found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "authSignIn", | |
"_ERR_AUTH_DENIED":"SignIn", | |
"reLogin": "SignIn", | |
"IPBanned":"end", | |
"_ERR_USER_DOES_NOT_EXIST":"end", | |
"_ERR_PATTERN_EMAIL_ADDRESS":"end", | |
"_ERR_INVALID_CREDENTIALS":"end", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"authSignIn": { | |
"name": "authSignIn", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 1000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://gsp.target.com/gsp/authentications/v1/auth_codes?client_id=ecom-web-1.0.0" | |
}, | |
"method": "GET", | |
"headers": { | |
"authority": "gsp.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": {} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"redirect":"false", | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success"], | |
"success": { | |
"log": "Authenticated", | |
"status": 302, | |
"options": {} | |
} | |
}, | |
"taskLogic": { | |
"success": "genTokens", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"genTokens": { | |
"name": "genTokens", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://gsp.target.com/gsp/oauth_tokens/v2/client_tokens" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "let cookieData=taskObjects[TaskID].Variables.CookieData;let code=taskObjects[TaskID].requestHistory['authSignIn'].headers.location.split('https://www.target.com/?code=')[1].split('&state=')[0];let parsedData=JSON.stringify({'grant_type':'authorization_code','client_credential':{'client_id':'ecom-web-1.0.0'},'code':code,'device_info':JSON.parse(cookieData.DeviceInfo),'keep_me_signed_in':true});return parsedData;return taskObjects[TaskID].Variables.CookieData['UserAgent'];" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": false, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"reLogin", | |
"IPBanned", | |
"success" | |
], | |
"success": { | |
"log": "Refreshed Tokens", | |
"status": 201, | |
"options": {} | |
}, | |
"IPBanned": { | |
"log": "IP Banned.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "accessDenied" | |
} | |
}, | |
"reLogin": { | |
"log": "Invalid Tokens. Signing in again...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Not Found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "parseRefreshToken", | |
"reLogin": "SignIn", | |
"IPBanned":"end", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"refreshTokens": { | |
"name": "refreshTokens", | |
"type": "request", | |
"start": "setRefreshCookies", | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://gsp.target.com/gsp/oauth_tokens/v2/client_tokens" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": "{\"grant_type\":\"refresh_token\",\"client_credential\":{\"client_id\":\"ecom-web-1.0.0\"}}", | |
"function": null | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": false, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"reLogin", | |
"IPBanned", | |
"success" | |
], | |
"success": { | |
"log": "Refreshed Tokens", | |
"status": 201, | |
"options": {} | |
}, | |
"IPBanned": { | |
"log": "IP Banned.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "accessDenied" | |
} | |
}, | |
"reLogin": { | |
"log": "Invalid Tokens. Signing in again...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Not Found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "parseRefreshToken", | |
"reLogin": "SignIn", | |
"IPBanned":"SignIn", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"parseRefreshToken": { | |
"name": "parseRefreshToken", | |
"type": "function", | |
"start": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "try{let account=taskObjects[TaskID].getAccount(TaskID,taskObjects);if(!account?.cookies){account.cookies={}};let response;if(taskObjects[TaskID].CallStack[taskObjects[TaskID].CallStack.length-2]==='genTokens'){response=JSON.parse(taskObjects[TaskID].requestHistory.genTokens.data);let cookieData=taskObjects[TaskID].Variables.CookieData;account.cookies.visitorID=JSON.parse(cookieData.DeviceInfo).visitor_id}else{response=JSON.parse(taskObjects[TaskID].requestHistory.refreshTokens.data)};let Access_Token=response.access_token;let id_token=response.id_token;account.cookies.idToken=id_token;account.cookies.accessToken=Access_Token;taskObjects[TaskID].updateAccount(TaskID,taskObjects,account);return'success'}catch(e){console.log(e);return'error'}" | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success", "noAccountCookies","error"], | |
"success": { | |
"log": "Parsed Tokens." | |
}, | |
"noAccountCookies": { | |
"log": "No Account Bin Found. Re-bin." | |
}, | |
"error": { | |
"log": "Error with account. Re-bin." | |
} | |
}, | |
"taskLogic": { | |
"success": "submitShipping", | |
"noAccountCookies":"SignIn", | |
"error": "SignIn", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"submitShipping": { | |
"name": "submitShipping", | |
"type": "request", | |
"start": "setCookies", | |
"delay": 0, | |
"retryDelay": 3001, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/cart_shipping_addresses?field_groups=ADDRESSES%2CCART%2CCART_ITEMS%2CPICKUP_INSTRUCTIONS%2CPROMOTION_CODES%2CSUMMARY&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "profile_info=taskObjects[TaskID].getProfile(TaskID, taskObjects);return JSON.stringify({'cart_type':'REGULAR','address':{'address_line1':profile_info['shipping_address']['address_line1'],'address_line2':profile_info['shipping_address']['address_line2'],'address_type':'SHIPPING','city':profile_info['shipping_address']['city'],'country':'US','first_name':profile_info['shipping_address']['first_name'],'last_name':profile_info['shipping_address']['last_name'],'mobile':profile_info['shipping_address']['phone'],'save_as_default':false,'state':profile_info['shipping_address']['state'],'zip_code':profile_info['shipping_address']['zip_code']},'selected':true,'save_to_profile':false,'skip_verification':true})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"success", | |
"shippingAlreadyPresent", | |
"accessTokenInvalid", | |
"CONSTRAINT_VALIDATION_FAILURE", | |
"INVALID_GUEST_STATUS", | |
"Unauthorized", | |
"Unauthorized2" | |
], | |
"success": { | |
"log": "Waiting for Monitor", | |
"status": 201, | |
"options": {} | |
}, | |
"shippingAlreadyPresent": { | |
"log": "Waiting for Monitor", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "ADDRESS_ALREADY_PRESENT" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"Unauthorized": { | |
"log": "Unauthorized", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Unauthorized" | |
} | |
}, | |
"Unauthorized2": { | |
"log": "Unauthorized", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "UNAUTHORIZED" | |
} | |
}, | |
"INVALID_GUEST_STATUS": { | |
"log": "Bad cookies. Re-bin account.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "INVALID_GUEST_STATUS" | |
} | |
}, | |
"CONSTRAINT_VALIDATION_FAILURE": { | |
"log": "Profile is missing Phone Number.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "address.mobile" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "Monitor", | |
"shippingAlreadyPresent": "Monitor", | |
"accessTokenInvalid": "refreshTokens", | |
"CONSTRAINT_VALIDATION_FAILURE": "end", | |
"INVALID_GUEST_STATUS": "SignIn", | |
"Unauthorized":"SignIn", | |
"Unauthorized2":"SignIn", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"Monitor": { | |
"name": "Monitor", | |
"type": "function", | |
"start": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "taskObjects[TaskID].setProxy(TaskID, taskObjects);taskObjects[TaskID].Cookies = taskObjects[TaskID].Cookies.filter((cookie) => !cookie.includes('mitata'));let monitorEventPromise=async(sku)=>{console.log('WaitingForSKU'+sku);return new Promise((resolve,reject)=>{let event=monitorEvent.on(sku,(message)=>{if(message.inStock){delete event;resolve(message)}})})};let result=await monitorEventPromise(taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.task_sku);taskObjects[TaskID]['Variables']['tcin']=result.SKU;return'InStock';" | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["InStock", "OutOfStock", "UnAvailable"], | |
"InStock": { | |
"log": "Item in Stock. Adding to cart." | |
}, | |
"OutOfStock": { | |
"log": "Monitoring..." | |
}, | |
"OutOfStock2": { | |
"log": "Monitoring..." | |
}, | |
"UnAvailable": { | |
"log": "Failed to get item. Monitoring..." | |
} | |
}, | |
"taskLogic": { | |
"InStock": "addToCart", | |
"OutOfStock": "Monitor", | |
"OutOfStock2": "Monitor", | |
"UnAvailable": "Monitor", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"addToCart": { | |
"name": "addToCart", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 1000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/cart_items?field_groups=CART%2CCART_ITEMS%2CSUMMARY&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return JSON.stringify({'cart_type':'REGULAR','channel_id':'10','shopping_context':'DIGITAL','cart_item':{'tcin':taskObjects[TaskID]['Variables']['tcin'],'quantity':taskObjects[TaskID].getTaskInfo(TaskID, taskObjects).product.item_quantity,'item_channel_id':'10'}})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["addedToCart", "cartFull", "accessTokenInvalid", "DEPENDENT_SERVICE_ERROR", "PID_LOCKED", "proxyBan"], | |
"addedToCart": { | |
"log": "Added To Cart", | |
"status": 201, | |
"options": {} | |
}, | |
"cartFull": { | |
"log": "MAX_PURCHASE_LIMIT_EXCEEDED", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "MAX_PURCHASE_LIMIT_EXCEEDED" | |
} | |
}, | |
"DEPENDENT_SERVICE_ERROR": { | |
"log": "Item OOS. Retrying atc...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "DEPENDENT_SERVICE_ERROR" | |
} | |
}, | |
"PID_LOCKED": { | |
"log": "Item PID Locked. Retrying atc...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Access Denied" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"proxyBan": { | |
"log": "Proxy Banned. Retrying...", | |
"status": 404, | |
"options": {} | |
} | |
}, | |
"taskLogic": { | |
"addedToCart": "submitBilling", | |
"cartFull": "harvestCartID", | |
"DEPENDENT_SERVICE_ERROR": "Monitor", | |
"accessTokenInvalid": "refreshTokens", | |
"PID_LOCKED": "Monitor", | |
"proxyBan":"Monitor", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"harvestCartID": { | |
"name": "harvestCartID", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/cart?field_groups=CART%2CCART_ITEMS%2CSUMMARY%2CPROMOTION_CODES%2CADDRESSES&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "PUT", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return JSON.stringify({'cart_type':'REGULAR'})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success", "cartFull", "accessTokenInvalid"], | |
"success": { | |
"log": "Got cart_id", | |
"status": 200, | |
"options": {} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "submitBilling", | |
"accessTokenInvalid": "refreshTokens", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"submitBilling": { | |
"name": "submitBilling", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/checkout_payments/v1/payment_instructions?key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "billing_info=taskObjects[TaskID].getProfile(TaskID,taskObjects);if(taskObjects[TaskID]['Variables']['cart_id']==null){cart_id=taskObjects[TaskID].getProfile(TaskID,taskObjects);response=taskObjects[TaskID]['requestHistory']['addToCart'];text=JSON.parse(await response.text());if(JSON.stringify(text).includes('cart_id')==false){response=taskObjects[TaskID]['requestHistory']['harvestCartID'];text=JSON.parse(await response.text())}cart_id=text['cart_id'];taskObjects[TaskID]['Variables']['cart_id']=cart_id}else{cart_id=taskObjects[TaskID]['Variables']['cart_id']};if(billing_info['billing_info']['card_details']['expiry_month'].includes('0')==false&&billing_info['billing_info']['card_details']['expiry_month'].length==1){var expiry_month='0'+billing_info['billing_info']['card_details']['expiry_month']}else{var expiry_month=billing_info['billing_info']['card_details']['expiry_month']};let expiry_year=profile_info['billing_info']['card_details']['expiry_year'];if(expiry_year.length==2){expiry_year='20'+expiry_year}return JSON.stringify({'cart_id':cart_id,'wallet_mode':'NONE','payment_type':'CARD','card_details':{'card_name':billing_info['billing_info']['card_details']['card_name'],'card_number':billing_info['billing_info']['card_details']['card_number'],'cvv':billing_info['billing_info']['card_details']['cvv'],'expiry_month':expiry_month,'expiry_year':expiry_year},'billing_address':{'address_line1':billing_info['billing_info']['billing_address']['address_line1'],'city':billing_info['billing_info']['billing_address']['city'],'first_name':billing_info['billing_info']['billing_address']['first_name'],'last_name':billing_info['billing_info']['billing_address']['last_name'],'phone':billing_info['billing_info']['billing_address']['phone'],'state':billing_info['billing_info']['billing_address']['state'],'zip_code':billing_info['billing_info']['billing_address']['zip_code'],'country':'US'}})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"success", | |
"serviceUnavailable", | |
"CART_TOTAL_AMOUNT_ZERO", | |
"cardAlreadyPresent", | |
"accessTokenInvalid", | |
"INVALID_PAYMENT_COMBINATION" | |
], | |
"success": { | |
"log": "Submitting Order", | |
"status": 201, | |
"options": {} | |
}, | |
"serviceUnavailable": { | |
"log": "Service Unavailable", | |
"status": 424, | |
"options": {} | |
}, | |
"cardAlreadyPresent": { | |
"log": "Submitting Order", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CARD_PAYMENT_EXIST" | |
} | |
}, | |
"CART_TOTAL_AMOUNT_ZERO": { | |
"log": "Cart is Empty. Check QTY.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CART_TOTAL_AMOUNT_ZERO" | |
} | |
}, | |
"INVALID_PAYMENT_COMBINATION": { | |
"log": "Submitting Order", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "INVALID_PAYMENT_COMBINATION" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "harvestImg9", | |
"cardAlreadyPresent": "harvestImg9", | |
"serviceUnavailable":"submitBilling", | |
"CART_TOTAL_AMOUNT_ZERO":"Monitor", | |
"accessTokenInvalid": "refreshTokens", | |
"INVALID_PAYMENT_COMBINATION": "harvestImg9", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"resubmitCVV": { | |
"name": "resubmitCVV", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": null, | |
"urlFunction": { | |
"name": "returnResubmitCVVUrl", | |
"arguments": "taskObjects, TaskID" | |
} | |
}, | |
"method": "PUT", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "billing_info=taskObjects[TaskID].getProfile(TaskID, taskObjects);cart_id=taskObjects[TaskID]['Variables']['cart_id'];return JSON.stringify({'cart_id':cart_id,'wallet_mode':'NONE','payment_type':'CARD','card_details':{'cvv':billing_info['billing_info']['card_details']['cvv']}})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"success", | |
"cardAlreadyPresent", | |
"accessTokenInvalid" | |
], | |
"success": { | |
"log": "Resubmitted CVV", | |
"status": 200, | |
"options": {} | |
}, | |
"cardAlreadyPresent": { | |
"log": "Submitting Order", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CARD_PAYMENT_EXIST" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "submitCheckout", | |
"cardAlreadyPresent": "submitCheckout", | |
"accessTokenInvalid": "refreshTokens", | |
"end": "submitCheckout" | |
} | |
} | |
}, | |
"harvestImg9": { | |
"name": "harvestImg9", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "http://localhost:5634/img9-moment" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "let account=taskObjects[TaskID].getAccount(TaskID,taskObjects);let cookies=account.cookies;let Access_Token=cookies.accessToken;let idToken=cookies.idToken;return JSON.stringify({accessToken:Access_Token,idToken:idToken,})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": false, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"success", | |
"badRequest" | |
], | |
"success": { | |
"log": "Submitting Order", | |
"status": 200, | |
"options": {} | |
}, | |
"badRequest": { | |
"log": "Error with Img9", | |
"status": 400, | |
"options": {} | |
} | |
}, | |
"taskLogic": { | |
"success": "submitCheckout", | |
"badRequest": "harvestImg9", | |
"end": "submitCheckout" | |
} | |
} | |
}, | |
"submitCheckout": { | |
"name": "submitCheckout", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/checkout?field_groups=ADDRESSES%2CCART%2CCART_ITEMS%2CDELIVERY_WINDOWS%2CPAYMENT_INSTRUCTIONS%2CPICKUP_INSTRUCTIONS%2CPROMOTION_CODES%2CSUMMARY&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": "{\"cart_type\":\"REGULAR\",\"channel_id\":10}", | |
"function": null | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"successfulCheckout", | |
"PaymentDecline", | |
"RateLimited", | |
"MISSING_CREDIT_CARD_CVV", | |
"MISSING_OR_INVALID_PAYMENT_DETAILS", | |
"EMPTY_CART_FOR_ORDER_SUBMIT", | |
"accessTokenInvalid", | |
"CREDIT_CARD_COMPARE_REQUIRED" | |
], | |
"successfulCheckout": { | |
"log": "Submitted Checkout.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "orders" | |
} | |
}, | |
"PaymentDecline": { | |
"log": "Payment Declined.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "PAYMENT_DECLINED_EXCEPTION" | |
} | |
}, | |
"RateLimited": { | |
"log": "Rate Limited. Retrying...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EC_PLATFORM_RATE_LIMITED" | |
} | |
}, | |
"MISSING_CREDIT_CARD_CVV": { | |
"log": "MISSING_CREDIT_CARD_CVV", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "MISSING_CREDIT_CARD_CVV" | |
} | |
}, | |
"MISSING_OR_INVALID_PAYMENT_DETAILS": { | |
"log": "MISSING_OR_INVALID_PAYMENT_DETAILS", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "MISSING_OR_INVALID_PAYMENT_DETAILS" | |
} | |
}, | |
"EMPTY_CART_FOR_ORDER_SUBMIT": { | |
"log": "Cart Empty", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EMPTY_CART_FOR_ORDER_SUBMIT" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token ", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"CREDIT_CARD_COMPARE_REQUIRED": { | |
"log": "CREDIT_CARD_COMPARE_REQUIRED", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CREDIT_CARD_COMPARE_REQUIRED" | |
} | |
} | |
}, | |
"taskLogic": { | |
"checkout2": "logCheckout", | |
"PaymentDecline": "Monitor", | |
"EMPTY_CART_FOR_ORDER_SUBMIT": "Monitor", | |
"MISSING_CREDIT_CARD_CVV": "resubmitCVV", | |
"itemNotAvailableYet": "Monitor", | |
"accessTokenInvalid": "refreshTokens", | |
"RateLimited":"Monitor", | |
"CREDIT_CARD_COMPARE_REQUIRED": "submitBilling", | |
"MISSING_OR_INVALID_PAYMENT_DETAILS": "submitBilling", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"logCheckout": { | |
"name": "logCheckout", | |
"type": "function", | |
"start": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "const response=taskObjects[TaskID].requestHistory.submitCheckout;const body_text=JSON.parse(await response.text());let item_info;const data=JSON.parse(taskObjects[TaskID].requestHistory.addToCart.data);let sku=taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.task_sku.split(':')[0];const cart_item=body_text.orders[0].cart_items.find((cart_item)=>{return cart_item.tcin===sku});try{item_info={Title:cart_item.item_attributes.description,Image:data.item_attributes.image_path,Price:cart_item.unit_price*taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.item_quantity,}}catch{item_info={Title:'N/A',Image:'',Price:'',}};let orderID;try{orderID=body_text.orders[0].order_id}catch{orderID='N/A'};let checkoutInfo={product_info:item_info,Task_Info:taskObjects[TaskID].getTaskInfo(TaskID,taskObjects)};const getProxyName=()=>{try{let taskGroupId=taskObjects[TaskID].TaskGroupID;let taskGroups=taskObjects.taskGroups;let proxyGroups=taskObjects.proxyGroups;let task_info=taskGroups.find((group)=>group.id===taskGroupId).tasks.find((task)=>task.id===TaskID);let proxy_group_id=task_info.task_proxy_info.proxy_group_id;if(task_info.task_proxy_info.localhost){return'localhost'};return proxyGroups.find((group)=>group.id===proxy_group_id).name}catch{return'N/A'}};let config={'content':null,'embeds':[{'title':'Successfully checked out!','description':checkoutInfo.product_info.Title,'color':3297740,'image':{'url':checkoutInfo.product_info.Image},'fields':[{'name':'Site','value':checkoutInfo.Task_Info.product.site,'inline':true},{'name':'SKU','value':checkoutInfo.Task_Info.product.task_sku,'inline':true},{'name':'Quantity','value':checkoutInfo.Task_Info.product.item_quantity,'inline':true},{'name':'Mode','value':checkoutInfo.Task_Info.task_settings.task_mode,'inline':true},{'name':'Profile','value':'||'+taskObjects[TaskID].getProfile(TaskID,taskObjects).profile_name+'||','inline':true},{'name':'Account Email','value':'||'+taskObjects[TaskID].getAccount(TaskID,taskObjects).username+'||','inline':true},{'name':'Account Password','value':'||'+taskObjects[TaskID].getAccount(TaskID,taskObjects).password+'||','inline':true},{'name':'Order #','value':'||'+orderID+'||','inline':true},{'name':'Proxy','value':'||'+getProxyName()+'||','inline':true}],'footer':{'text':'LexAIO v2 Success','icon_url':'https://avatars1.githubusercontent.com/u/76762917?s=40&v=4'},'timestamp':timestamp()}]};function timestamp(){const timeElapsed=Date.now();const today=new Date(timeElapsed);return today.toISOString()};checkoutInfo.config=config;process.send({'type':'SuccessfulCheckout','CheckoutInfo':checkoutInfo});if(taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).task_advanced_info.loopCheckout){taskObjects[TaskID]['Cookies']=[];taskObjects[TaskID]['Variables']['cart_id']=null;return'restart'}else{return'Checkout'}" | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success", "restart"], | |
"success": { | |
"log": "Submitted Checkout. " | |
}, | |
"restart": { | |
"log": "Restart Checkout." | |
}, | |
"Decline": { | |
"log": "Payment Declined. " | |
} | |
}, | |
"taskLogic": { | |
"Checkout": "end", | |
"restart": "submitShipping", | |
"Decline": "end", | |
"end": "end" | |
} | |
} | |
}, | |
"end": "exit" | |
} | |
}, | |
"Pickup": { | |
"entryPoint": "submitShipping", | |
"variables": [ | |
"ItemInfo", | |
"ItemAvailability", | |
"cart_id", | |
"Access_Token", | |
"Visitor_ID", | |
"Refresh_Token", | |
"Store_Locations", | |
"pickup_id" | |
], | |
"captchaHarvester": false, | |
"helperFunctions": { | |
"getPickupID": { | |
"arguments": "taskObjects, TaskID", | |
"body": "let response = taskObjects[TaskID].requestHistory.harvestPickupID.data;console.log(response);taskObjects[TaskID].Variables.pickup_id = response.split('\"pickup_id\":\"')[1].split('\"')[0]" | |
}, | |
"returnPickupSubmissionEndpoint": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return `https://carts.target.com/web_checkouts/v1/cart_pickup_instructions/` + taskObjects[TaskID].Variables.pickup_id + `?field_groups=ADDRESSES%2CCART%2CCART_ITEMS%2CPICKUP_INSTRUCTIONS%2CPROMOTION_CODES%2CSUMMARY&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39`" | |
}, | |
"returnResubmitCVVUrl": { | |
"arguments": "taskObjects, TaskID", | |
"body": "response=taskObjects[TaskID]['requestHistory']['submitCheckout'];text=await response.text();instructions_id=text.split('Missing CVV or PIN code on payment instruction ')[1].split('\"')[0];console.log(instructions_id);return `https://carts.target.com/checkout_payments/v1/payment_instructions/${instructions_id}?key=feaf228eb2777fd3eee0fd5192ae7107d6224b39`" | |
}, | |
"setCookies": { | |
"arguments": "taskObjects, TaskID", | |
"body": "try{taskObjects[TaskID].Cookies=[];let account=taskObjects[TaskID].getAccount(TaskID,taskObjects);let cookies=account.cookies;let accessToken='accessToken='+cookies.accessToken;let visitorID='visitorID='+cookies.visitorID;taskObjects[TaskID].setCookie(TaskID,taskObjects,accessToken);taskObjects[TaskID].setCookie(TaskID,taskObjects,visitorID)}catch{}" | |
}, | |
"setRefreshCookies": { | |
"arguments": "taskObjects, TaskID", | |
"body": "try{let account=taskObjects[TaskID].getAccount(TaskID,taskObjects);let cookies=account.cookies;let Access_Token=cookies.accessToken;let Visitor_ID=cookies.visitorID;let Refresh_Token=taskObjects[TaskID]['helperFunctions']['jwt_decode'](Access_Token)['jti'];taskObjects[TaskID]['Variables']['Access_Token']=Access_Token;taskObjects[TaskID]['Variables']['Visitor_ID']=Visitor_ID;taskObjects[TaskID]['Variables']['Refresh_Token']=Refresh_Token;taskObjects[TaskID].Cookies=[];taskObjects[TaskID].Cookies.push('refreshToken='+Refresh_Token+';');taskObjects[TaskID].Cookies.push('visitorId='+Visitor_ID+';');}catch{}" | |
}, | |
"setLoginCookies": { | |
"arguments": "taskObjects, TaskID", | |
"body": "try{if(taskObjects[TaskID].Variables.CookieData){console.log('REMOVING COOKIE DATA');taskObjects[TaskID].deleteShapeCookie(taskObjects[TaskID].Variables.CookieData.id)};taskObjects[TaskID].Cookies=[];let cookieData=taskObjects[TaskID].getRandomShapeCookie(taskObjects);taskObjects[TaskID].Variables.CookieData=cookieData;let newCookies=cookieData.Cookies.split('; ');newCookies=newCookies.map((cookie)=>{return cookie+';'});taskObjects[TaskID].Cookies=newCookies}catch(e){console.log(e)}" | |
} | |
}, | |
"taskStatistics":{ | |
"addedToCart":"taskCartCount", | |
"addedToCart2":"taskCartCount", | |
"successfulCheckout": "taskCountCheckedOut", | |
"checkout2": "taskCountCheckedOut", | |
"PaymentDecline": "taskCountDeclined", | |
"Decline": "taskCountDeclined" | |
}, | |
"logStatusColors": { | |
"success": "magenta", | |
"addedToCart":"magenta", | |
"checkout2":"green", | |
"successfulCheckout":"green", | |
"OutOfStock": "cyan", | |
"OutOfStock2": "cyan", | |
"NoLoadedTCINs": "cyan", | |
"cartFull": "yellow", | |
"logCheckout": "green", | |
"PID_LOCKED": "yellow", | |
"processing": "yellow", | |
"error": "yellow", | |
"fail": "red", | |
"InStock": "cyan", | |
"shippingAlreadyPresent": "cyan" | |
}, | |
"functions": { | |
"SignIn": { | |
"name": "SignIn", | |
"type": "request", | |
"start": "setLoginCookies", | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://gsp.target.com/gsp/authentications/v1/credential_validations?client_id=ecom-web-1.0.0" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "gsp.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"customHeaders": { | |
"x-gyjwza5z-a": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-A'];" | |
}, | |
"x-gyjwza5z-b": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-B'];" | |
}, | |
"x-gyjwza5z-c": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-C'];" | |
}, | |
"x-gyjwza5z-d": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-D'];" | |
}, | |
"x-gyjwza5z-f": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-F'];" | |
}, | |
"x-gyjwza5z-z": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-Z'];" | |
}, | |
"user-agent": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['UserAgent'];" | |
} | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "let cookieData=taskObjects[TaskID].Variables.CookieData;let parsedData=JSON.stringify({'username':taskObjects[TaskID].getAccount(TaskID,taskObjects).username,'password':taskObjects[TaskID].getAccount(TaskID,taskObjects).password,'device_info':JSON.parse(cookieData.DeviceInfo),'keep_me_signed_in':true});return parsedData;" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": false, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"reLogin", | |
"_ERR_AUTH_DENIED", | |
"IPBanned", | |
"_ERR_USER_DOES_NOT_EXIST", | |
"_ERR_PATTERN_EMAIL_ADDRESS", | |
"_ERR_INVALID_CREDENTIALS", | |
"success" | |
], | |
"success": { | |
"log": "Signed in...", | |
"status": 202, | |
"options": {} | |
}, | |
"_ERR_USER_DOES_NOT_EXIST": { | |
"log": "Account does not exist.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "_ERR_USER_DOES_NOT_EXIST" | |
} | |
}, | |
"_ERR_PATTERN_EMAIL_ADDRESS": { | |
"log": "Account does not exist.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "_ERR_PATTERN_EMAIL_ADDRESS" | |
} | |
}, | |
"_ERR_AUTH_DENIED": { | |
"log": "Authentication denied", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "_ERR_AUTH_DENIED" | |
} | |
}, | |
"_ERR_INVALID_CREDENTIALS": { | |
"log": "Authentication denied", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "_ERR_INVALID_CREDENTIALS" | |
} | |
}, | |
"IPBanned": { | |
"log": "IP Banned.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "accessDenied" | |
} | |
}, | |
"reLogin": { | |
"log": "Invalid Tokens. Signing in again...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Not Found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "authSignIn", | |
"_ERR_AUTH_DENIED":"SignIn", | |
"reLogin": "SignIn", | |
"IPBanned":"end", | |
"_ERR_USER_DOES_NOT_EXIST":"end", | |
"_ERR_PATTERN_EMAIL_ADDRESS":"end", | |
"_ERR_INVALID_CREDENTIALS":"end", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"authSignIn": { | |
"name": "authSignIn", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 1000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://gsp.target.com/gsp/authentications/v1/auth_codes?client_id=ecom-web-1.0.0" | |
}, | |
"method": "GET", | |
"headers": { | |
"authority": "gsp.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": {} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"redirect":"false", | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success"], | |
"success": { | |
"log": "Authenticated", | |
"status": 302, | |
"options": {} | |
} | |
}, | |
"taskLogic": { | |
"success": "genTokens", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"genTokens": { | |
"name": "genTokens", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://gsp.target.com/gsp/oauth_tokens/v2/client_tokens" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "let cookieData=taskObjects[TaskID].Variables.CookieData;let code=taskObjects[TaskID].requestHistory['authSignIn'].headers.location.split('https://www.target.com/?code=')[1].split('&state=')[0];let parsedData=JSON.stringify({'grant_type':'authorization_code','client_credential':{'client_id':'ecom-web-1.0.0'},'code':code,'device_info':JSON.parse(cookieData.DeviceInfo),'keep_me_signed_in':true});return parsedData;return taskObjects[TaskID].Variables.CookieData['UserAgent'];" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": false, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"reLogin", | |
"IPBanned", | |
"success" | |
], | |
"success": { | |
"log": "Refreshed Tokens", | |
"status": 201, | |
"options": {} | |
}, | |
"IPBanned": { | |
"log": "IP Banned.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "accessDenied" | |
} | |
}, | |
"reLogin": { | |
"log": "Invalid Tokens. Signing in again...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Not Found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "parseRefreshToken", | |
"reLogin": "SignIn", | |
"IPBanned":"end", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"refreshTokens": { | |
"name": "refreshTokens", | |
"type": "request", | |
"start": "setRefreshCookies", | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://gsp.target.com/gsp/oauth_tokens/v2/client_tokens" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": "{\"grant_type\":\"refresh_token\",\"client_credential\":{\"client_id\":\"ecom-web-1.0.0\"}}", | |
"function": null | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": false, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"reLogin", | |
"IPBanned", | |
"success" | |
], | |
"success": { | |
"log": "Refreshed Tokens", | |
"status": 201, | |
"options": {} | |
}, | |
"IPBanned": { | |
"log": "IP Banned.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "accessDenied" | |
} | |
}, | |
"reLogin": { | |
"log": "Invalid Tokens. Signing in again...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Not Found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "parseRefreshToken", | |
"reLogin": "SignIn", | |
"IPBanned":"SignIn", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"parseRefreshToken": { | |
"name": "parseRefreshToken", | |
"type": "function", | |
"start": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "try{let account=taskObjects[TaskID].getAccount(TaskID,taskObjects);if(!account?.cookies){account.cookies={}};let response;if(taskObjects[TaskID].CallStack[taskObjects[TaskID].CallStack.length-2]==='genTokens'){response=JSON.parse(taskObjects[TaskID].requestHistory.genTokens.data);let cookieData=taskObjects[TaskID].Variables.CookieData;account.cookies.visitorID=JSON.parse(cookieData.DeviceInfo).visitor_id}else{response=JSON.parse(taskObjects[TaskID].requestHistory.refreshTokens.data)};let Access_Token=response.access_token;let id_token=response.id_token;account.cookies.idToken=id_token;account.cookies.accessToken=Access_Token;taskObjects[TaskID].updateAccount(TaskID,taskObjects,account);return'success'}catch(e){console.log(e);return'error'}" | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success", "noAccountCookies","error"], | |
"success": { | |
"log": "Parsed Tokens." | |
}, | |
"noAccountCookies": { | |
"log": "No Account Bin Found. Re-bin." | |
}, | |
"error": { | |
"log": "Error with account. Re-bin." | |
} | |
}, | |
"taskLogic": { | |
"success": "submitShipping", | |
"noAccountCookies":"SignIn", | |
"error": "SignIn", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"submitShipping": { | |
"name": "submitShipping", | |
"type": "request", | |
"start": "setCookies", | |
"delay": 0, | |
"retryDelay": 3001, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/cart_shipping_addresses?field_groups=ADDRESSES%2CCART%2CCART_ITEMS%2CPICKUP_INSTRUCTIONS%2CPROMOTION_CODES%2CSUMMARY&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "profile_info=taskObjects[TaskID].getProfile(TaskID, taskObjects);return JSON.stringify({'cart_type':'REGULAR','address':{'address_line1':profile_info['shipping_address']['address_line1'],'address_line2':profile_info['shipping_address']['address_line2'],'address_type':'SHIPPING','city':profile_info['shipping_address']['city'],'country':'US','first_name':profile_info['shipping_address']['first_name'],'last_name':profile_info['shipping_address']['last_name'],'mobile':profile_info['shipping_address']['phone'],'save_as_default':false,'state':profile_info['shipping_address']['state'],'zip_code':profile_info['shipping_address']['zip_code']},'selected':true,'save_to_profile':false,'skip_verification':true})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"success", | |
"shippingAlreadyPresent", | |
"accessTokenInvalid", | |
"CONSTRAINT_VALIDATION_FAILURE", | |
"INVALID_GUEST_STATUS", | |
"Unauthorized", | |
"Unauthorized2", | |
"RateLimited" | |
], | |
"success": { | |
"log": "Waiting for Monitor", | |
"status": 201, | |
"options": {} | |
}, | |
"shippingAlreadyPresent": { | |
"log": "Waiting for Monitor", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "ADDRESS_ALREADY_PRESENT" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"Unauthorized": { | |
"log": "Unauthorized", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Unauthorized" | |
} | |
}, | |
"Unauthorized2": { | |
"log": "Unauthorized", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "UNAUTHORIZED" | |
} | |
}, | |
"INVALID_GUEST_STATUS": { | |
"log": "Bad cookies. Re-bin account.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "INVALID_GUEST_STATUS" | |
} | |
}, | |
"CONSTRAINT_VALIDATION_FAILURE": { | |
"log": "Profile is missing Phone Number.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "address.mobile" | |
} | |
}, | |
"RateLimited": { | |
"log": "Rate Limited. Retrying...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EC_PLATFORM_RATE_LIMITED" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "Monitor", | |
"shippingAlreadyPresent": "Monitor", | |
"accessTokenInvalid": "refreshTokens", | |
"CONSTRAINT_VALIDATION_FAILURE": "end", | |
"INVALID_GUEST_STATUS": "SignIn", | |
"Unauthorized":"SignIn", | |
"Unauthorized2":"SignIn", | |
"RateLimited": "submitShipping", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"Monitor": { | |
"name": "Monitor", | |
"type": "function", | |
"start": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "taskObjects[TaskID].setProxy(TaskID, taskObjects);taskObjects[TaskID].Cookies = taskObjects[TaskID].Cookies.filter((cookie) => !cookie.includes('mitata'));taskObjects[TaskID].setProxy(TaskID, taskObjects);taskObjects[TaskID].Cookies = taskObjects[TaskID].Cookies.filter((cookie) => !cookie.includes('mitata'));let monitorEventPromise=async(sku)=>{console.log('WaitingForSKU'+sku);return new Promise((resolve,reject)=>{let event=monitorEvent.on(sku,(message)=>{if(message.inStock){delete event;resolve(message);return}})})};let result=await monitorEventPromise(taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.task_sku);taskObjects[TaskID]['Variables']['tcin']=result.SKU;taskObjects[TaskID]['Variables']['store_id']=result.store_id;return'InStock';" | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["InStock", "OutOfStock", "UnAvailable"], | |
"InStock": { | |
"log": "Item in Stock. Adding to cart." | |
}, | |
"OutOfStock": { | |
"log": "Monitoring..." | |
}, | |
"OutOfStock2": { | |
"log": "Monitoring..." | |
}, | |
"UnAvailable": { | |
"log": "Failed to get item. Monitoring..." | |
} | |
}, | |
"taskLogic": { | |
"InStock": "addToCart", | |
"OutOfStock": "Monitor", | |
"OutOfStock2": "Monitor", | |
"getStoreLocations": "Monitor", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"addToCart": { | |
"name": "addToCart", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 1000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/cart_items?field_groups=CART%2CCART_ITEMS%2CSUMMARY&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "console.log({'cart_type':'REGULAR','channel_id':'10','shopping_context':'DIGITAL','cart_item':{'tcin':taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.task_sku,'quantity':taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.item_quantity,'item_channel_id':'10'},'fulfillment':{'type':'PICKUP','location_id':taskObjects[TaskID].Variables.store_id,'ship_method':'STORE_PICKUP'}});return JSON.stringify({'cart_type':'REGULAR','channel_id':'10','shopping_context':'DIGITAL','cart_item':{'tcin':taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.task_sku,'quantity':taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.item_quantity,'item_channel_id':'10'},'fulfillment':{'type':'PICKUP','location_id':taskObjects[TaskID].Variables.store_id,'ship_method':'STORE_PICKUP'}})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["addedToCart", "cartFull", "accessTokenInvalid", "DEPENDENT_SERVICE_ERROR", "PID_LOCKED", "proxyBan", "RateLimited"], | |
"addedToCart": { | |
"log": "Added To Cart", | |
"status": 201, | |
"options": {} | |
}, | |
"cartFull": { | |
"log": "Cart Full. Skipping ATC...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "MAX_PURCHASE_LIMIT_EXCEEDED" | |
} | |
}, | |
"DEPENDENT_SERVICE_ERROR": { | |
"log": "Item OOS. Retrying atc...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "DEPENDENT_SERVICE_ERROR" | |
} | |
}, | |
"PID_LOCKED": { | |
"log": "Item PID Locked. Retrying atc...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Access Denied" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"proxyBan": { | |
"log": "Proxy Banned. Retrying...", | |
"status": 404, | |
"options": {} | |
}, | |
"RateLimited": { | |
"log": "Rate Limited. Retrying...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EC_PLATFORM_RATE_LIMITED" | |
} | |
} | |
}, | |
"taskLogic": { | |
"addedToCart": "harvestPickupID", | |
"cartFull": "harvestCartID", | |
"DEPENDENT_SERVICE_ERROR": "Monitor", | |
"accessTokenInvalid": "refreshTokens", | |
"PID_LOCKED": "Monitor", | |
"proxyBan":"Monitor", | |
"RateLimited":"addToCart", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"harvestPickupID": { | |
"name": "harvestPickupID", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/pre_checkout?field_groups=ADDRESSES%2CCART%2CCART_ITEMS%2CDELIVERY_WINDOWS%2CPAYMENT_INSTRUCTIONS%2CPICKUP_INSTRUCTIONS%2CPROMOTION_CODES%2CSUMMARY%2CFINANCE_PROVIDERS&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": "{\"cart_type\":\"REGULAR\"}", | |
"function": {} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success", "cartFull", "accessTokenInvalid", "RateLimited"], | |
"success": { | |
"log": "Got Pickup ID", | |
"status": 201, | |
"options": {} | |
}, | |
"cartFull": { | |
"log": "Cart Full. Skipping ATC...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "MAX_PURCHASE_LIMIT_EXCEEDED" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"RateLimited": { | |
"log": "Rate Limited. Retrying...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EC_PLATFORM_RATE_LIMITED" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "submitPickupPerson", | |
"cartFull": "harvestCartID", | |
"accessTokenInvalid": "refreshTokens", | |
"RateLimited": "harvestPickupID", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"harvestCartID": { | |
"name": "harvestCartID", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/cart?field_groups=CART%2CCART_ITEMS%2CSUMMARY%2CPROMOTION_CODES%2CADDRESSES&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "PUT", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return JSON.stringify({'cart_type':'REGULAR'})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success", "cartFull", "accessTokenInvalid", "RateLimited"], | |
"success": { | |
"log": "Got cart_id", | |
"status": 200, | |
"options": {} | |
}, | |
"cartFull": { | |
"log": "Cart Full. Skipping ATC...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "MAX_PURCHASE_LIMIT_EXCEEDED" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"RateLimited": { | |
"log": "Rate Limited. Retrying...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EC_PLATFORM_RATE_LIMITED" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "harvestPickupID", | |
"accessTokenInvalid": "refreshTokens", | |
"RateLimited": "harvestCartID", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"submitPickupPerson": { | |
"name": "submitPickupPerson", | |
"type": "request", | |
"start": "getPickupID", | |
"delay": 0, | |
"retryDelay": 3001, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": null, | |
"urlFunction": { | |
"name": "returnPickupSubmissionEndpoint", | |
"arguments": "taskObjects, TaskID" | |
} | |
}, | |
"method": "PUT", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "profile_info=taskObjects[TaskID].getProfile(TaskID,taskObjects);if(taskObjects[TaskID]['Variables']['cart_id']==null){response=taskObjects[TaskID]['requestHistory']['addToCart'];text=JSON.parse(await response.text());if(JSON.stringify(text).includes('cart_id')==false){response=taskObjects[TaskID]['requestHistory']['harvestCartID'];text=JSON.parse(await response.text())}cart_id=text['cart_id'];taskObjects[TaskID]['Variables']['cart_id']=cart_id}else{cart_id=taskObjects[TaskID]['Variables']['cart_id']};return JSON.stringify({'cart_id':cart_id,'cart_type':'REGULAR','guest_email_id':profile_info['email'],'pickup_instruction':{'first_name':profile_info['shipping_address']['first_name'],'last_name':profile_info['shipping_address']['last_name'],'email':profile_info['email'],'mobile':profile_info['shipping_address']['phone'],'nominee_first_name':'','nominee_last_name':'','nominee_email':''}});" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"success", | |
"accessTokenInvalid", | |
"RateLimited" | |
], | |
"success": { | |
"log": "Submitted Pickup Person", | |
"status": 200, | |
"options": {} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"RateLimited": { | |
"log": "Rate Limited. Retrying...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EC_PLATFORM_RATE_LIMITED" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "submitBilling", | |
"accessTokenInvalid": "refreshTokens", | |
"RateLimited": "RateLimited", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"submitBilling": { | |
"name": "submitBilling", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/checkout_payments/v1/payment_instructions?key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "billing_info=taskObjects[TaskID].getProfile(TaskID,taskObjects);if(taskObjects[TaskID]['Variables']['cart_id']==null){cart_id=taskObjects[TaskID].getProfile(TaskID,taskObjects);response=taskObjects[TaskID]['requestHistory']['addToCart'];text=JSON.parse(await response.text());if(JSON.stringify(text).includes('cart_id')==false){response=taskObjects[TaskID]['requestHistory']['harvestCartID'];text=JSON.parse(await response.text())}cart_id=text['cart_id'];taskObjects[TaskID]['Variables']['cart_id']=cart_id}else{cart_id=taskObjects[TaskID]['Variables']['cart_id']};if(billing_info['billing_info']['card_details']['expiry_month'].includes('0')==false&&billing_info['billing_info']['card_details']['expiry_month'].length==1){var expiry_month='0'+billing_info['billing_info']['card_details']['expiry_month']}else{var expiry_month=billing_info['billing_info']['card_details']['expiry_month']};let expiry_year=profile_info['billing_info']['card_details']['expiry_year'];if(expiry_year.length==2){expiry_year='20'+expiry_year}return JSON.stringify({'cart_id':cart_id,'wallet_mode':'NONE','payment_type':'CARD','card_details':{'card_name':billing_info['billing_info']['card_details']['card_name'],'card_number':billing_info['billing_info']['card_details']['card_number'],'cvv':billing_info['billing_info']['card_details']['cvv'],'expiry_month':expiry_month,'expiry_year':expiry_year},'billing_address':{'address_line1':billing_info['billing_info']['billing_address']['address_line1'],'city':billing_info['billing_info']['billing_address']['city'],'first_name':billing_info['billing_info']['billing_address']['first_name'],'last_name':billing_info['billing_info']['billing_address']['last_name'],'phone':billing_info['billing_info']['billing_address']['phone'],'state':billing_info['billing_info']['billing_address']['state'],'zip_code':billing_info['billing_info']['billing_address']['zip_code'],'country':'US'}})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"success", | |
"serviceUnavailable", | |
"CART_TOTAL_AMOUNT_ZERO", | |
"cardAlreadyPresent", | |
"accessTokenInvalid", | |
"INVALID_PAYMENT_COMBINATION", | |
"RateLimited" | |
], | |
"success": { | |
"log": "Submitting Order", | |
"status": 201, | |
"options": {} | |
}, | |
"serviceUnavailable": { | |
"log": "Service Unavailable", | |
"status": 424, | |
"options": {} | |
}, | |
"CART_TOTAL_AMOUNT_ZERO": { | |
"log": "Cart is Empty. Check QTY.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CART_TOTAL_AMOUNT_ZERO" | |
} | |
}, | |
"cardAlreadyPresent": { | |
"log": "Submitting Order", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CARD_PAYMENT_EXIST" | |
} | |
}, | |
"INVALID_PAYMENT_COMBINATION": { | |
"log": "Submitting Order", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "INVALID_PAYMENT_COMBINATION" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"RateLimited": { | |
"log": "Rate Limited. Retrying...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EC_PLATFORM_RATE_LIMITED" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "submitCheckout", | |
"CART_TOTAL_AMOUNT_ZERO":"Monitor", | |
"serviceUnavailable":"submitBilling", | |
"cardAlreadyPresent": "submitCheckout", | |
"accessTokenInvalid": "refreshTokens", | |
"INVALID_PAYMENT_COMBINATION": "submitCheckout", | |
"RateLimited": "submitBilling", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"resubmitCVV": { | |
"name": "resubmitCVV", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": null, | |
"urlFunction": { | |
"name": "returnResubmitCVVUrl", | |
"arguments": "taskObjects, TaskID" | |
} | |
}, | |
"method": "PUT", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "billing_info=taskObjects[TaskID].getProfile(TaskID, taskObjects);cart_id=taskObjects[TaskID]['Variables']['cart_id'];return JSON.stringify({'cart_id':cart_id,'wallet_mode':'NONE','payment_type':'CARD','card_details':{'cvv':billing_info['billing_info']['card_details']['cvv']}})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"success", | |
"cardAlreadyPresent", | |
"accessTokenInvalid", | |
"RateLimited" | |
], | |
"success": { | |
"log": "Resubmitted CVV", | |
"status": 200, | |
"options": {} | |
}, | |
"cardAlreadyPresent": { | |
"log": "Submitting Order", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CARD_PAYMENT_EXIST" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"RateLimited": { | |
"log": "Rate Limited. Retrying...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EC_PLATFORM_RATE_LIMITED" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "submitCheckout", | |
"cardAlreadyPresent": "submitCheckout", | |
"accessTokenInvalid": "refreshTokens", | |
"resubmitCVV": "resubmitCVV", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"submitCheckout": { | |
"name": "submitCheckout", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 2000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/checkout?field_groups=ADDRESSES%2CCART%2CCART_ITEMS%2CDELIVERY_WINDOWS%2CPAYMENT_INSTRUCTIONS%2CPICKUP_INSTRUCTIONS%2CPROMOTION_CODES%2CSUMMARY&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": "{\"cart_type\":\"REGULAR\",\"channel_id\":10}", | |
"function": null | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"checkout2", | |
"PaymentDecline", | |
"RateLimited", | |
"MISSING_CREDIT_CARD_CVV", | |
"MISSING_OR_INVALID_PAYMENT_DETAILS", | |
"accessTokenInvalid", | |
"CREDIT_CARD_COMPARE_REQUIRED", | |
"EMPTY_CART_FOR_ORDER_SUBMIT" | |
], | |
"checkout2": { | |
"log": "Submitted Checkout.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "orders" | |
} | |
}, | |
"PaymentDecline": { | |
"log": "Payment Declined.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "PAYMENT_DECLINED_EXCEPTION" | |
} | |
}, | |
"RateLimited": { | |
"log": "Rate Limited. Retrying...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EC_PLATFORM_RATE_LIMITED" | |
} | |
}, | |
"MISSING_CREDIT_CARD_CVV": { | |
"log": "MISSING_CREDIT_CARD_CVV", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "MISSING_CREDIT_CARD_CVV" | |
} | |
}, | |
"MISSING_OR_INVALID_PAYMENT_DETAILS": { | |
"log": "MISSING_OR_INVALID_PAYMENT_DETAILS", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "MISSING_OR_INVALID_PAYMENT_DETAILS" | |
} | |
}, | |
"CREDIT_CARD_COMPARE_REQUIRED": { | |
"log": "CREDIT_CARD_COMPARE_REQUIRED", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CREDIT_CARD_COMPARE_REQUIRED" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token ", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"EMPTY_CART_FOR_ORDER_SUBMIT": { | |
"log": "Cart Empty", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EMPTY_CART_FOR_ORDER_SUBMIT" | |
} | |
} | |
}, | |
"taskLogic": { | |
"checkout2": "logCheckout", | |
"PaymentDecline": "Monitor", | |
"MISSING_CREDIT_CARD_CVV": "resubmitCVV", | |
"EMPTY_CART_FOR_ORDER_SUBMIT": "Monitor", | |
"itemNotAvailableYet": "Monitor", | |
"CREDIT_CARD_COMPARE_REQUIRED": "submitBilling", | |
"accessTokenInvalid": "refreshTokens", | |
"RateLimited":"submitCheckout", | |
"MISSING_OR_INVALID_PAYMENT_DETAILS": "submitBilling", | |
"end": "submitCheckout" | |
} | |
} | |
}, | |
"logCheckout": { | |
"name": "logCheckout", | |
"type": "function", | |
"start": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "const response=taskObjects[TaskID].requestHistory.submitCheckout;const body_text=JSON.parse(await response.text());let item_info;const data=JSON.parse(taskObjects[TaskID].requestHistory.addToCart.data);let sku=taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.task_sku.split(':')[0];const cart_item=body_text.orders[0].cart_items.find((cart_item)=>{return cart_item.tcin===sku});try{item_info={Title:cart_item.item_attributes.description,Image:data.item_attributes.image_path,Price:cart_item.unit_price,}}catch{item_info={Title:'N/A',Image:'',Price:'',}};let orderID;try{orderID=body_text.orders[0].order_id}catch{orderID='N/A'};let checkoutInfo={product_info:item_info,Task_Info:taskObjects[TaskID].getTaskInfo(TaskID,taskObjects)};const getProxyName=()=>{try{let taskGroupId=taskObjects[TaskID].TaskGroupID;let taskGroups=taskObjects.taskGroups;let proxyGroups=taskObjects.proxyGroups;let task_info=taskGroups.find((group)=>group.id===taskGroupId).tasks.find((task)=>task.id===TaskID);let proxy_group_id=task_info.task_proxy_info.proxy_group_id;if(task_info.task_proxy_info.localhost){return'localhost'};return proxyGroups.find((group)=>group.id===proxy_group_id).name}catch{return'N/A'}};let config={'content':null,'embeds':[{'title':'Successfully checked out!','description':checkoutInfo.product_info.Title,'color':3297740,'image':{'url':checkoutInfo.product_info.Image},'fields':[{'name':'Site','value':checkoutInfo.Task_Info.product.site,'inline':true},{'name':'SKU','value':checkoutInfo.Task_Info.product.task_sku,'inline':true},{'name':'Quantity','value':checkoutInfo.Task_Info.product.item_quantity,'inline':true},{'name':'Mode','value':checkoutInfo.Task_Info.task_settings.task_mode,'inline':true},{'name':'Profile','value':'||'+taskObjects[TaskID].getProfile(TaskID,taskObjects).profile_name+'||','inline':true},{'name':'Account Email','value':'||'+taskObjects[TaskID].getAccount(TaskID,taskObjects).username+'||','inline':true},{'name':'Account Password','value':'||'+taskObjects[TaskID].getAccount(TaskID,taskObjects).password+'||','inline':true},{'name':'Order #','value':'||'+orderID+'||','inline':true},{'name':'Proxy','value':'||'+getProxyName()+'||','inline':true}],'footer':{'text':'LexAIO v2 Success','icon_url':'https://avatars1.githubusercontent.com/u/76762917?s=40&v=4'},'timestamp':timestamp()}]};function timestamp(){const timeElapsed=Date.now();const today=new Date(timeElapsed);return today.toISOString()};checkoutInfo.config=config;process.send({'type':'SuccessfulCheckout','CheckoutInfo':checkoutInfo});if(taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).task_advanced_info.loopCheckout){taskObjects[TaskID]['Cookies']=[];taskObjects[TaskID]['Variables']['cart_id']=null;return'restart'}else{return'Checkout'}" | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success", "restart"], | |
"success": { | |
"log": "Submitted Checkout. " | |
}, | |
"restart": { | |
"log": "Restart Checkout." | |
}, | |
"Decline": { | |
"log": "Payment Declined. " | |
} | |
}, | |
"taskLogic": { | |
"Checkout": "end", | |
"restart": "submitShipping", | |
"Decline": "end", | |
"end": "end" | |
} | |
} | |
}, | |
"end": "exit" | |
} | |
}, | |
"PickupSafe": { | |
"entryPoint": "submitShipping", | |
"variables": [ | |
"ItemInfo", | |
"ItemAvailability", | |
"cart_id", | |
"Access_Token", | |
"Visitor_ID", | |
"Refresh_Token", | |
"Store_Locations", | |
"pickup_id" | |
], | |
"captchaHarvester": false, | |
"helperFunctions": { | |
"getPickupID": { | |
"arguments": "taskObjects, TaskID", | |
"body": "let response = taskObjects[TaskID].requestHistory.harvestPickupID.data;console.log(response);taskObjects[TaskID].Variables.pickup_id = response.split('\"pickup_id\":\"')[1].split('\"')[0]" | |
}, | |
"returnPickupSubmissionEndpoint": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return `https://carts.target.com/web_checkouts/v1/cart_pickup_instructions/` + taskObjects[TaskID].Variables.pickup_id + `?field_groups=ADDRESSES%2CCART%2CCART_ITEMS%2CPICKUP_INSTRUCTIONS%2CPROMOTION_CODES%2CSUMMARY&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39`" | |
}, | |
"returnResubmitCVVUrl": { | |
"arguments": "taskObjects, TaskID", | |
"body": "response=taskObjects[TaskID]['requestHistory']['submitCheckout'];text=await response.text();instructions_id=text.split('Missing CVV or PIN code on payment instruction ')[1].split('\"')[0];console.log(instructions_id);return `https://carts.target.com/checkout_payments/v1/payment_instructions/${instructions_id}?key=feaf228eb2777fd3eee0fd5192ae7107d6224b39`" | |
}, | |
"setCookies": { | |
"arguments": "taskObjects, TaskID", | |
"body": "try{taskObjects[TaskID].Cookies=[];let account=taskObjects[TaskID].getAccount(TaskID,taskObjects);let cookies=account.cookies;let accessToken='accessToken='+cookies.accessToken;let visitorID='visitorID='+cookies.visitorID;taskObjects[TaskID].setCookie(TaskID,taskObjects,accessToken);taskObjects[TaskID].setCookie(TaskID,taskObjects,visitorID)}catch{}" | |
}, | |
"setRefreshCookies": { | |
"arguments": "taskObjects, TaskID", | |
"body": "try{let account=taskObjects[TaskID].getAccount(TaskID,taskObjects);let cookies=account.cookies;let Access_Token=cookies.accessToken;let Visitor_ID=cookies.visitorID;let Refresh_Token=taskObjects[TaskID]['helperFunctions']['jwt_decode'](Access_Token)['jti'];taskObjects[TaskID]['Variables']['Access_Token']=Access_Token;taskObjects[TaskID]['Variables']['Visitor_ID']=Visitor_ID;taskObjects[TaskID]['Variables']['Refresh_Token']=Refresh_Token;taskObjects[TaskID].Cookies=[];taskObjects[TaskID].Cookies.push('refreshToken='+Refresh_Token+';');taskObjects[TaskID].Cookies.push('visitorId='+Visitor_ID+';');}catch{}" | |
}, | |
"setLoginCookies": { | |
"arguments": "taskObjects, TaskID", | |
"body": "try{if(taskObjects[TaskID].Variables.CookieData){console.log('REMOVING COOKIE DATA');taskObjects[TaskID].deleteShapeCookie(taskObjects[TaskID].Variables.CookieData.id)};taskObjects[TaskID].Cookies=[];let cookieData=taskObjects[TaskID].getRandomShapeCookie(taskObjects);taskObjects[TaskID].Variables.CookieData=cookieData;let newCookies=cookieData.Cookies.split('; ');newCookies=newCookies.map((cookie)=>{return cookie+';'});taskObjects[TaskID].Cookies=newCookies}catch(e){console.log(e)}" | |
} | |
}, | |
"taskStatistics":{ | |
"addedToCart":"taskCartCount", | |
"addedToCart2":"taskCartCount", | |
"successfulCheckout": "taskCountCheckedOut", | |
"checkout2": "taskCountCheckedOut", | |
"PaymentDecline": "taskCountDeclined", | |
"Decline": "taskCountDeclined" | |
}, | |
"logStatusColors": { | |
"success": "magenta", | |
"addedToCart":"magenta", | |
"checkout2":"green", | |
"successfulCheckout":"green", | |
"OutOfStock": "cyan", | |
"OutOfStock2": "cyan", | |
"NoLoadedTCINs": "cyan", | |
"cartFull": "yellow", | |
"logCheckout": "green", | |
"PID_LOCKED": "yellow", | |
"processing": "yellow", | |
"error": "yellow", | |
"fail": "red", | |
"InStock": "cyan", | |
"shippingAlreadyPresent": "cyan" | |
}, | |
"functions": { | |
"SignIn": { | |
"name": "SignIn", | |
"type": "request", | |
"start": "setLoginCookies", | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://gsp.target.com/gsp/authentications/v1/credential_validations?client_id=ecom-web-1.0.0" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "gsp.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"customHeaders": { | |
"x-gyjwza5z-a": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-A'];" | |
}, | |
"x-gyjwza5z-b": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-B'];" | |
}, | |
"x-gyjwza5z-c": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-C'];" | |
}, | |
"x-gyjwza5z-d": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-D'];" | |
}, | |
"x-gyjwza5z-f": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-F'];" | |
}, | |
"x-gyjwza5z-z": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['ShapeH-Z'];" | |
}, | |
"user-agent": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return taskObjects[TaskID].Variables.CookieData['UserAgent'];" | |
} | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "let cookieData=taskObjects[TaskID].Variables.CookieData;let parsedData=JSON.stringify({'username':taskObjects[TaskID].getAccount(TaskID,taskObjects).username,'password':taskObjects[TaskID].getAccount(TaskID,taskObjects).password,'device_info':JSON.parse(cookieData.DeviceInfo),'keep_me_signed_in':true});return parsedData;" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": false, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"reLogin", | |
"_ERR_AUTH_DENIED", | |
"IPBanned", | |
"_ERR_USER_DOES_NOT_EXIST", | |
"_ERR_PATTERN_EMAIL_ADDRESS", | |
"_ERR_INVALID_CREDENTIALS", | |
"success" | |
], | |
"success": { | |
"log": "Signed in...", | |
"status": 202, | |
"options": {} | |
}, | |
"_ERR_USER_DOES_NOT_EXIST": { | |
"log": "Account does not exist.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "_ERR_USER_DOES_NOT_EXIST" | |
} | |
}, | |
"_ERR_PATTERN_EMAIL_ADDRESS": { | |
"log": "Account does not exist.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "_ERR_PATTERN_EMAIL_ADDRESS" | |
} | |
}, | |
"_ERR_AUTH_DENIED": { | |
"log": "Authentication denied", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "_ERR_AUTH_DENIED" | |
} | |
}, | |
"_ERR_INVALID_CREDENTIALS": { | |
"log": "Authentication denied", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "_ERR_INVALID_CREDENTIALS" | |
} | |
}, | |
"IPBanned": { | |
"log": "IP Banned.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "accessDenied" | |
} | |
}, | |
"reLogin": { | |
"log": "Invalid Tokens. Signing in again...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Not Found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "authSignIn", | |
"_ERR_AUTH_DENIED":"SignIn", | |
"reLogin": "SignIn", | |
"IPBanned":"end", | |
"_ERR_USER_DOES_NOT_EXIST":"end", | |
"_ERR_PATTERN_EMAIL_ADDRESS":"end", | |
"_ERR_INVALID_CREDENTIALS":"end", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"authSignIn": { | |
"name": "authSignIn", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 1000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://gsp.target.com/gsp/authentications/v1/auth_codes?client_id=ecom-web-1.0.0" | |
}, | |
"method": "GET", | |
"headers": { | |
"authority": "gsp.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": {} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"redirect":"false", | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success"], | |
"success": { | |
"log": "Authenticated", | |
"status": 302, | |
"options": {} | |
} | |
}, | |
"taskLogic": { | |
"success": "genTokens", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"genTokens": { | |
"name": "genTokens", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://gsp.target.com/gsp/oauth_tokens/v2/client_tokens" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "let cookieData=taskObjects[TaskID].Variables.CookieData;let code=taskObjects[TaskID].requestHistory['authSignIn'].headers.location.split('https://www.target.com/?code=')[1].split('&state=')[0];let parsedData=JSON.stringify({'grant_type':'authorization_code','client_credential':{'client_id':'ecom-web-1.0.0'},'code':code,'device_info':JSON.parse(cookieData.DeviceInfo),'keep_me_signed_in':true});return parsedData;return taskObjects[TaskID].Variables.CookieData['UserAgent'];" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": false, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"reLogin", | |
"IPBanned", | |
"success" | |
], | |
"success": { | |
"log": "Refreshed Tokens", | |
"status": 201, | |
"options": {} | |
}, | |
"IPBanned": { | |
"log": "IP Banned.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "accessDenied" | |
} | |
}, | |
"reLogin": { | |
"log": "Invalid Tokens. Signing in again...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Not Found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "parseRefreshToken", | |
"reLogin": "SignIn", | |
"IPBanned":"end", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"refreshTokens": { | |
"name": "refreshTokens", | |
"type": "request", | |
"start": "setRefreshCookies", | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://gsp.target.com/gsp/oauth_tokens/v2/client_tokens" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": "{\"grant_type\":\"refresh_token\",\"client_credential\":{\"client_id\":\"ecom-web-1.0.0\"}}", | |
"function": null | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": false, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"reLogin", | |
"IPBanned", | |
"success" | |
], | |
"success": { | |
"log": "Refreshed Tokens", | |
"status": 201, | |
"options": {} | |
}, | |
"IPBanned": { | |
"log": "IP Banned.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "accessDenied" | |
} | |
}, | |
"reLogin": { | |
"log": "Invalid Tokens. Signing in again...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Not Found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "parseRefreshToken", | |
"reLogin": "SignIn", | |
"IPBanned":"SignIn", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"parseRefreshToken": { | |
"name": "parseRefreshToken", | |
"type": "function", | |
"start": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "try{let account=taskObjects[TaskID].getAccount(TaskID,taskObjects);if(!account?.cookies){account.cookies={}};let response;if(taskObjects[TaskID].CallStack[taskObjects[TaskID].CallStack.length-2]==='genTokens'){response=JSON.parse(taskObjects[TaskID].requestHistory.genTokens.data);let cookieData=taskObjects[TaskID].Variables.CookieData;account.cookies.visitorID=JSON.parse(cookieData.DeviceInfo).visitor_id}else{response=JSON.parse(taskObjects[TaskID].requestHistory.refreshTokens.data)};let Access_Token=response.access_token;let id_token=response.id_token;account.cookies.idToken=id_token;account.cookies.accessToken=Access_Token;taskObjects[TaskID].updateAccount(TaskID,taskObjects,account);return'success'}catch(e){console.log(e);return'error'}" | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success", "noAccountCookies","error"], | |
"success": { | |
"log": "Parsed Tokens." | |
}, | |
"noAccountCookies": { | |
"log": "No Account Bin Found. Re-bin." | |
}, | |
"error": { | |
"log": "Error with account. Re-bin." | |
} | |
}, | |
"taskLogic": { | |
"success": "submitShipping", | |
"noAccountCookies":"SignIn", | |
"error": "SignIn", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"submitShipping": { | |
"name": "submitShipping", | |
"type": "request", | |
"start": "setCookies", | |
"delay": 0, | |
"retryDelay": 3001, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/cart_shipping_addresses?field_groups=ADDRESSES%2CCART%2CCART_ITEMS%2CPICKUP_INSTRUCTIONS%2CPROMOTION_CODES%2CSUMMARY&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "profile_info=taskObjects[TaskID].getProfile(TaskID, taskObjects);return JSON.stringify({'cart_type':'REGULAR','address':{'address_line1':profile_info['shipping_address']['address_line1'],'address_line2':profile_info['shipping_address']['address_line2'],'address_type':'SHIPPING','city':profile_info['shipping_address']['city'],'country':'US','first_name':profile_info['shipping_address']['first_name'],'last_name':profile_info['shipping_address']['last_name'],'mobile':profile_info['shipping_address']['phone'],'save_as_default':false,'state':profile_info['shipping_address']['state'],'zip_code':profile_info['shipping_address']['zip_code']},'selected':true,'save_to_profile':false,'skip_verification':true})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"success", | |
"shippingAlreadyPresent", | |
"accessTokenInvalid", | |
"CONSTRAINT_VALIDATION_FAILURE", | |
"INVALID_GUEST_STATUS", | |
"Unauthorized", | |
"Unauthorized2", | |
"RateLimited" | |
], | |
"success": { | |
"log": "Waiting for Monitor", | |
"status": 201, | |
"options": {} | |
}, | |
"shippingAlreadyPresent": { | |
"log": "Waiting for Monitor", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "ADDRESS_ALREADY_PRESENT" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"Unauthorized": { | |
"log": "Unauthorized", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Unauthorized" | |
} | |
}, | |
"Unauthorized2": { | |
"log": "Unauthorized", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "UNAUTHORIZED" | |
} | |
}, | |
"INVALID_GUEST_STATUS": { | |
"log": "Bad cookies. Re-bin account.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "INVALID_GUEST_STATUS" | |
} | |
}, | |
"CONSTRAINT_VALIDATION_FAILURE": { | |
"log": "Profile is missing Phone Number.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "address.mobile" | |
} | |
}, | |
"RateLimited": { | |
"log": "Rate Limited. Retrying...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EC_PLATFORM_RATE_LIMITED" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "Monitor", | |
"shippingAlreadyPresent": "Monitor", | |
"accessTokenInvalid": "refreshTokens", | |
"CONSTRAINT_VALIDATION_FAILURE": "end", | |
"INVALID_GUEST_STATUS": "SignIn", | |
"Unauthorized":"SignIn", | |
"Unauthorized2":"SignIn", | |
"RateLimited": "submitShipping", | |
"end": "SignIn" | |
} | |
} | |
}, | |
"Monitor": { | |
"name": "Monitor", | |
"type": "function", | |
"start": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "taskObjects[TaskID].setProxy(TaskID, taskObjects);taskObjects[TaskID].Cookies = taskObjects[TaskID].Cookies.filter((cookie) => !cookie.includes('mitata'));let monitorEventPromise=async(sku)=>{console.log('WaitingForSKU'+sku);return new Promise((resolve,reject)=>{let event=monitorEvent.on(sku,(message)=>{if(message.inStock){delete event;resolve(message);return}})})};let result=await monitorEventPromise(taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.task_sku);taskObjects[TaskID]['Variables']['tcin']=result.SKU;taskObjects[TaskID]['Variables']['store_id']=result.store_id;return'InStock';" | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["InStock", "OutOfStock", "UnAvailable"], | |
"InStock": { | |
"log": "Item in Stock. Adding to cart." | |
}, | |
"OutOfStock": { | |
"log": "Monitoring..." | |
}, | |
"OutOfStock2": { | |
"log": "Monitoring..." | |
}, | |
"UnAvailable": { | |
"log": "Failed to get item. Monitoring..." | |
} | |
}, | |
"taskLogic": { | |
"InStock": "addToCart", | |
"OutOfStock": "Monitor", | |
"OutOfStock2": "Monitor", | |
"getStoreLocations": "Monitor", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"addToCart": { | |
"name": "addToCart", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 1000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/cart_items?field_groups=CART%2CCART_ITEMS%2CSUMMARY&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return JSON.stringify({'cart_type':'REGULAR','channel_id':'10','shopping_context':'DIGITAL','cart_item':{'tcin':taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.task_sku,'quantity':taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.item_quantity,'item_channel_id':'10'},'fulfillment':{'type':'PICKUP','location_id':taskObjects[TaskID].Variables.store_id,'ship_method':'STORE_PICKUP'}})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["addedToCart", "cartFull", "accessTokenInvalid", "DEPENDENT_SERVICE_ERROR", "PID_LOCKED", "proxyBan", "RateLimited"], | |
"addedToCart": { | |
"log": "Added To Cart", | |
"status": 201, | |
"options": {} | |
}, | |
"cartFull": { | |
"log": "Cart Full. Skipping ATC...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "MAX_PURCHASE_LIMIT_EXCEEDED" | |
} | |
}, | |
"DEPENDENT_SERVICE_ERROR": { | |
"log": "Item OOS. Retrying atc...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "DEPENDENT_SERVICE_ERROR" | |
} | |
}, | |
"PID_LOCKED": { | |
"log": "Item PID Locked. Retrying atc...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "Access Denied" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"proxyBan": { | |
"log": "Proxy Banned. Retrying...", | |
"status": 404, | |
"options": {} | |
}, | |
"RateLimited": { | |
"log": "Rate Limited. Retrying...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EC_PLATFORM_RATE_LIMITED" | |
} | |
} | |
}, | |
"taskLogic": { | |
"addedToCart": "harvestPickupID", | |
"cartFull": "harvestCartID", | |
"DEPENDENT_SERVICE_ERROR": "Monitor", | |
"accessTokenInvalid": "refreshTokens", | |
"PID_LOCKED": "Monitor", | |
"proxyBan":"Monitor", | |
"RateLimited":"addToCart", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"harvestPickupID": { | |
"name": "harvestPickupID", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/pre_checkout?field_groups=ADDRESSES%2CCART%2CCART_ITEMS%2CDELIVERY_WINDOWS%2CPAYMENT_INSTRUCTIONS%2CPICKUP_INSTRUCTIONS%2CPROMOTION_CODES%2CSUMMARY%2CFINANCE_PROVIDERS&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": "{\"cart_type\":\"REGULAR\"}", | |
"function": {} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success", "cartFull", "accessTokenInvalid", "RateLimited"], | |
"success": { | |
"log": "Got Pickup ID", | |
"status": 201, | |
"options": {} | |
}, | |
"cartFull": { | |
"log": "Cart Full. Skipping ATC...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "MAX_PURCHASE_LIMIT_EXCEEDED" | |
} | |
}, | |
"RateLimited": { | |
"log": "Rate Limited. Retrying...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EC_PLATFORM_RATE_LIMITED" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "submitPickupPerson", | |
"cartFull": "harvestCartID", | |
"accessTokenInvalid": "refreshTokens", | |
"RateLimited": "harvestPickupID", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"harvestCartID": { | |
"name": "harvestCartID", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/cart?field_groups=CART%2CCART_ITEMS%2CSUMMARY%2CPROMOTION_CODES%2CADDRESSES&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "PUT", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return JSON.stringify({'cart_type':'REGULAR'})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success", "cartFull", "accessTokenInvalid", "RateLimited"], | |
"success": { | |
"log": "Got cart_id", | |
"status": 200, | |
"options": {} | |
}, | |
"cartFull": { | |
"log": "Cart Full. Skipping ATC...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "MAX_PURCHASE_LIMIT_EXCEEDED" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"RateLimited": { | |
"log": "Rate Limited. Retrying...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EC_PLATFORM_RATE_LIMITED" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "harvestPickupID", | |
"accessTokenInvalid": "refreshTokens", | |
"RateLimited": "harvestCartID", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"submitPickupPerson": { | |
"name": "submitPickupPerson", | |
"type": "request", | |
"start": "getPickupID", | |
"delay": 0, | |
"retryDelay": 3001, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": null, | |
"urlFunction": { | |
"name": "returnPickupSubmissionEndpoint", | |
"arguments": "taskObjects, TaskID" | |
} | |
}, | |
"method": "PUT", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "profile_info=taskObjects[TaskID].getProfile(TaskID,taskObjects);if(taskObjects[TaskID]['Variables']['cart_id']==null){response=taskObjects[TaskID]['requestHistory']['addToCart'];text=JSON.parse(await response.text());if(JSON.stringify(text).includes('cart_id')==false){response=taskObjects[TaskID]['requestHistory']['harvestCartID'];text=JSON.parse(await response.text())}cart_id=text['cart_id'];taskObjects[TaskID]['Variables']['cart_id']=cart_id}else{cart_id=taskObjects[TaskID]['Variables']['cart_id']};return JSON.stringify({'cart_id':cart_id,'cart_type':'REGULAR','guest_email_id':profile_info['email'],'pickup_instruction':{'first_name':profile_info['shipping_address']['first_name'],'last_name':profile_info['shipping_address']['last_name'],'email':profile_info['email'],'mobile':profile_info['shipping_address']['phone'],'nominee_first_name':'','nominee_last_name':'','nominee_email':''}});" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"success", | |
"accessTokenInvalid", | |
"RateLimited" | |
], | |
"success": { | |
"log": "Submitted Pickup Person", | |
"status": 200, | |
"options": {} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"RateLimited": { | |
"log": "Rate Limited. Retrying...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EC_PLATFORM_RATE_LIMITED" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "submitBilling", | |
"accessTokenInvalid": "refreshTokens", | |
"RateLimited":"submitPickupPerson", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"submitBilling": { | |
"name": "submitBilling", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/checkout_payments/v1/payment_instructions?key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "billing_info=taskObjects[TaskID].getProfile(TaskID,taskObjects);if(taskObjects[TaskID]['Variables']['cart_id']==null){cart_id=taskObjects[TaskID].getProfile(TaskID,taskObjects);response=taskObjects[TaskID]['requestHistory']['addToCart'];text=JSON.parse(await response.text());if(JSON.stringify(text).includes('cart_id')==false){response=taskObjects[TaskID]['requestHistory']['harvestCartID'];text=JSON.parse(await response.text())}cart_id=text['cart_id'];taskObjects[TaskID]['Variables']['cart_id']=cart_id}else{cart_id=taskObjects[TaskID]['Variables']['cart_id']};if(billing_info['billing_info']['card_details']['expiry_month'].includes('0')==false&&billing_info['billing_info']['card_details']['expiry_month'].length==1){var expiry_month='0'+billing_info['billing_info']['card_details']['expiry_month']}else{var expiry_month=billing_info['billing_info']['card_details']['expiry_month']};let expiry_year=profile_info['billing_info']['card_details']['expiry_year'];if(expiry_year.length==2){expiry_year='20'+expiry_year}return JSON.stringify({'cart_id':cart_id,'wallet_mode':'NONE','payment_type':'CARD','card_details':{'card_name':billing_info['billing_info']['card_details']['card_name'],'card_number':billing_info['billing_info']['card_details']['card_number'],'cvv':billing_info['billing_info']['card_details']['cvv'],'expiry_month':expiry_month,'expiry_year':expiry_year},'billing_address':{'address_line1':billing_info['billing_info']['billing_address']['address_line1'],'city':billing_info['billing_info']['billing_address']['city'],'first_name':billing_info['billing_info']['billing_address']['first_name'],'last_name':billing_info['billing_info']['billing_address']['last_name'],'phone':billing_info['billing_info']['billing_address']['phone'],'state':billing_info['billing_info']['billing_address']['state'],'zip_code':billing_info['billing_info']['billing_address']['zip_code'],'country':'US'}})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"success", | |
"cardAlreadyPresent", | |
"serviceUnavailable", | |
"accessTokenInvalid", | |
"CART_TOTAL_AMOUNT_ZERO", | |
"INVALID_PAYMENT_COMBINATION", | |
"RateLimited" | |
], | |
"success": { | |
"log": "Submitting Order", | |
"status": 201, | |
"options": {} | |
}, | |
"serviceUnavailable": { | |
"log": "Service Unavailable", | |
"status": 424, | |
"options": {} | |
}, | |
"CART_TOTAL_AMOUNT_ZERO": { | |
"log": "Cart is Empty. Check QTY.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CART_TOTAL_AMOUNT_ZERO" | |
} | |
}, | |
"cardAlreadyPresent": { | |
"log": "Submitting Order", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CARD_PAYMENT_EXIST" | |
} | |
}, | |
"INVALID_PAYMENT_COMBINATION": { | |
"log": "Submitting Order", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "INVALID_PAYMENT_COMBINATION" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"RateLimited": { | |
"log": "Rate Limited. Retrying...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EC_PLATFORM_RATE_LIMITED" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "harvestImg9", | |
"cardAlreadyPresent": "harvestImg9", | |
"CART_TOTAL_AMOUNT_ZERO":"Monitor", | |
"serviceUnavailable":"Monitor", | |
"accessTokenInvalid": "refreshTokens", | |
"INVALID_PAYMENT_COMBINATION": "harvestImg9", | |
"RateLimited":"submitBilling", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"resubmitCVV": { | |
"name": "resubmitCVV", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": null, | |
"urlFunction": { | |
"name": "returnResubmitCVVUrl", | |
"arguments": "taskObjects, TaskID" | |
} | |
}, | |
"method": "PUT", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "billing_info=taskObjects[TaskID].getProfile(TaskID, taskObjects);cart_id=taskObjects[TaskID]['Variables']['cart_id'];return JSON.stringify({'cart_id':cart_id,'wallet_mode':'NONE','payment_type':'CARD','card_details':{'cvv':billing_info['billing_info']['card_details']['cvv']}})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"success", | |
"cardAlreadyPresent", | |
"accessTokenInvalid", | |
"RateLimited" | |
], | |
"success": { | |
"log": "Resubmitted CVV", | |
"status": 200, | |
"options": {} | |
}, | |
"cardAlreadyPresent": { | |
"log": "Submitting Order", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CARD_PAYMENT_EXIST" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"RateLimited": { | |
"log": "Rate Limited. Retrying...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EC_PLATFORM_RATE_LIMITED" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "submitCheckout", | |
"cardAlreadyPresent": "submitCheckout", | |
"accessTokenInvalid": "refreshTokens", | |
"RateLimited":"resubmitCVV", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"harvestImg9": { | |
"name": "harvestImg9", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 3000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "http://localhost:5634/img9-moment" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "let account=taskObjects[TaskID].getAccount(TaskID,taskObjects);let cookies=account.cookies;let Access_Token=cookies.accessToken;let idToken=cookies.idToken;return JSON.stringify({accessToken:Access_Token,idToken:idToken,})" | |
} | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": false, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"success", | |
"badRequest" | |
], | |
"success": { | |
"log": "Submitting Order", | |
"status": 200, | |
"options": {} | |
}, | |
"badRequest": { | |
"log": "Error with Img9", | |
"status": 400, | |
"options": {} | |
} | |
}, | |
"taskLogic": { | |
"success": "submitCheckout", | |
"badRequest": "harvestImg9", | |
"end": "submitCheckout" | |
} | |
} | |
}, | |
"submitCheckout": { | |
"name": "submitCheckout", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 6000, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": "https://carts.target.com/web_checkouts/v1/checkout?field_groups=ADDRESSES%2CCART%2CCART_ITEMS%2CDELIVERY_WINDOWS%2CPAYMENT_INSTRUCTIONS%2CPICKUP_INSTRUCTIONS%2CPROMOTION_CODES%2CSUMMARY&key=feaf228eb2777fd3eee0fd5192ae7107d6224b39" | |
}, | |
"method": "POST", | |
"headers": { | |
"authority": "carts.target.com", | |
"sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"", | |
"accept": "application/json", | |
"x-application-name": "web", | |
"sec-ch-ua-mobile": "?0", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36", | |
"content-type": "application/json", | |
"origin": "https://www.target.com", | |
"sec-fetch-site": "same-site", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-dest": "empty", | |
"referer": "https://www.target.com/p/wahl-lithium-ion-pro-men-s-cordless-haircut-kit-with-finishing-trimmer-soft-storage-case-79600-3301/-/A-13794872", | |
"accept-language": "en-US,en;q=0.5" | |
}, | |
"body": { | |
"plainBody": "{\"cart_type\":\"REGULAR\",\"channel_id\":10}", | |
"function": null | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": true, | |
"useSessionCookies": true | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": [ | |
"checkout2", | |
"PaymentDecline", | |
"RateLimited", | |
"MISSING_CREDIT_CARD_CVV", | |
"MISSING_OR_INVALID_PAYMENT_DETAILS", | |
"accessTokenInvalid", | |
"CREDIT_CARD_COMPARE_REQUIRED", | |
"EMPTY_CART_FOR_ORDER_SUBMIT" | |
], | |
"checkout2": { | |
"log": "Submitted Checkout.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "orders" | |
} | |
}, | |
"PaymentDecline": { | |
"log": "Payment Declined.", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "PAYMENT_DECLINED_EXCEPTION" | |
} | |
}, | |
"RateLimited": { | |
"log": "Rate Limited. Retrying...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EC_PLATFORM_RATE_LIMITED" | |
} | |
}, | |
"MISSING_CREDIT_CARD_CVV": { | |
"log": "MISSING_CREDIT_CARD_CVV", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "MISSING_CREDIT_CARD_CVV" | |
} | |
}, | |
"MISSING_OR_INVALID_PAYMENT_DETAILS": { | |
"log": "MISSING_OR_INVALID_PAYMENT_DETAILS", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "MISSING_OR_INVALID_PAYMENT_DETAILS" | |
} | |
}, | |
"CREDIT_CARD_COMPARE_REQUIRED": { | |
"log": "CREDIT_CARD_COMPARE_REQUIRED", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "CREDIT_CARD_COMPARE_REQUIRED" | |
} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token ", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"EMPTY_CART_FOR_ORDER_SUBMIT": { | |
"log": "Cart Empty", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "EMPTY_CART_FOR_ORDER_SUBMIT" | |
} | |
} | |
}, | |
"taskLogic": { | |
"checkout2": "logCheckout", | |
"PaymentDecline": "Monitor", | |
"MISSING_CREDIT_CARD_CVV": "resubmitCVV", | |
"EMPTY_CART_FOR_ORDER_SUBMIT": "Monitor", | |
"itemNotAvailableYet": "Monitor", | |
"CREDIT_CARD_COMPARE_REQUIRED": "submitBilling", | |
"accessTokenInvalid": "Monitor", | |
"RateLimited":"submitCheckout", | |
"MISSING_OR_INVALID_PAYMENT_DETAILS": "submitBilling", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"logCheckout": { | |
"name": "logCheckout", | |
"type": "function", | |
"start": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "const response=taskObjects[TaskID].requestHistory.submitCheckout;const body_text=JSON.parse(await response.text());let item_info;const data=JSON.parse(taskObjects[TaskID].requestHistory.addToCart.data);let sku=taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.task_sku.split(':')[0];const cart_item=body_text.orders[0].cart_items.find((cart_item)=>{return cart_item.tcin===sku});try{item_info={Title:cart_item.item_attributes.description,Image:data.item_attributes.image_path,Price:cart_item.unit_price,}}catch{item_info={Title:'N/A',Image:'',Price:'',}};let orderID;try{orderID=body_text.orders[0].order_id}catch{orderID='N/A'};let checkoutInfo={product_info:item_info,Task_Info:taskObjects[TaskID].getTaskInfo(TaskID,taskObjects)};const getProxyName=()=>{try{let taskGroupId=taskObjects[TaskID].TaskGroupID;let taskGroups=taskObjects.taskGroups;let proxyGroups=taskObjects.proxyGroups;let task_info=taskGroups.find((group)=>group.id===taskGroupId).tasks.find((task)=>task.id===TaskID);let proxy_group_id=task_info.task_proxy_info.proxy_group_id;if(task_info.task_proxy_info.localhost){return'localhost'};return proxyGroups.find((group)=>group.id===proxy_group_id).name}catch{return'N/A'}};let config={'content':null,'embeds':[{'title':'Successfully checked out!','description':checkoutInfo.product_info.Title,'color':3297740,'image':{'url':checkoutInfo.product_info.Image},'fields':[{'name':'Site','value':checkoutInfo.Task_Info.product.site,'inline':true},{'name':'SKU','value':checkoutInfo.Task_Info.product.task_sku,'inline':true},{'name':'Quantity','value':checkoutInfo.Task_Info.product.item_quantity,'inline':true},{'name':'Mode','value':checkoutInfo.Task_Info.task_settings.task_mode,'inline':true},{'name':'Profile','value':'||'+taskObjects[TaskID].getProfile(TaskID,taskObjects).profile_name+'||','inline':true},{'name':'Account Email','value':'||'+taskObjects[TaskID].getAccount(TaskID,taskObjects).username+'||','inline':true},{'name':'Account Password','value':'||'+taskObjects[TaskID].getAccount(TaskID,taskObjects).password+'||','inline':true},{'name':'Order #','value':'||'+orderID+'||','inline':true},{'name':'Proxy','value':'||'+getProxyName()+'||','inline':true}],'footer':{'text':'LexAIO v2 Success','icon_url':'https://avatars1.githubusercontent.com/u/76762917?s=40&v=4'},'timestamp':timestamp()}]};function timestamp(){const timeElapsed=Date.now();const today=new Date(timeElapsed);return today.toISOString()};checkoutInfo.config=config;process.send({'type':'SuccessfulCheckout','CheckoutInfo':checkoutInfo});if(taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).task_advanced_info.loopCheckout){taskObjects[TaskID]['Cookies']=[];taskObjects[TaskID]['Variables']['cart_id']=null;return'restart'}else{return'Checkout'}" | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success", "restart"], | |
"success": { | |
"log": "Submitted Checkout. " | |
}, | |
"restart": { | |
"log": "Restart Checkout." | |
}, | |
"Decline": { | |
"log": "Payment Declined. " | |
} | |
}, | |
"taskLogic": { | |
"Checkout": "end", | |
"restart": "submitShipping", | |
"Decline": "end", | |
"end": "end" | |
} | |
} | |
}, | |
"end": "exit" | |
} | |
} | |
}, | |
"monitor":{ | |
"Shipping": { | |
"entryPoint": "getItemInfo", | |
"variables": [ | |
"ItemInfo", | |
"ItemAvailability" | |
], | |
"taskStatistics":{ | |
"addedToCart":"taskCartCount", | |
"addedToCart2":"taskCartCount", | |
"successfulCheckout": "taskCountCheckedOut", | |
"checkout2": "taskCountCheckedOut", | |
"PaymentDecline": "taskCountDeclined", | |
"Decline": "taskCountDeclined" | |
}, | |
"captchaHarvester": true, | |
"helperFunctions": { | |
"returnTaskTCIN2": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return `https://redsky.target.com/redsky_aggregations/v1/web/plp_fulfillment_v1?key=ff457966e64d5e877fdbad070f276d18ecec4a01&tcins=`+taskObjects[TaskID].getTaskInfo(TaskID, taskObjects).product.task_sku+`&store_id=1350&store_positions_store_id=1350&has_store_positions_store_id=true&zip=46037&state=IN&latitude=39.970&longitude=-85.920&scheduled_delivery_store_id=1350&pricing_store_id=1350&has_pricing_store_id=true`" | |
}, | |
"returnTaskTCIN": { | |
"arguments": "taskObjects, TaskID", | |
"body": "return `https://redsky.target.com/redsky_aggregations/v1/web/pdp_fulfillment_v1?key=ff457966e64d5e877fdbad070f276d18ecec4a01&tcin=`+taskObjects[TaskID].getTaskInfo(TaskID, taskObjects).product.task_sku+`&store_id=1350&store_positions_store_id=1350&has_store_positions_store_id=true&zip=11183&state=AM&latitude=31.970&longitude=35.900&pricing_store_id=1350&has_pricing_store_id=true&is_bot=false`" | |
}, | |
"parseItemInfo": { | |
"arguments": "taskObjects, TaskID", | |
"body": "let lastItem=taskObjects[TaskID]['CallStack'][taskObjects[TaskID]['CallStack'].length-2];let response=taskObjects[TaskID]['requestHistory'][lastItem];let responseText=response.data;if(responseText.includes('product_summaries')){try{let text=JSON.parse(responseText);for(let prod of text['data']['product_summaries']){var stat=prod['fulfillment']['shipping_options']['availability_status'];if(stat!='OUT_OF_STOCK'&&stat!='DISCONTINUED'&&stat!='PRE_ORDER_UNSELLABLE'){taskObjects[TaskID]['Variables']['ItemAvailability']=true;taskObjects[TaskID]['Variables']['tcin']=prod.tcin;return}}}catch(e){console.log(e);taskObjects[TaskID]['Variables']['ItemAvailability']=false;return};taskObjects[TaskID]['Variables']['ItemAvailability']=false}else{try{let text=JSON.parse(responseText);var stat=text['data']['product']['fulfillment']['shipping_options']['availability_status'];let stock_count=text['data']['product']['fulfillment']['shipping_options']['available_to_promise_quantity'];if(stat!='OUT_OF_STOCK'&&stat!='DISCONTINUED'&&stat!='PRE_ORDER_UNSELLABLE'){taskObjects[TaskID]['Variables']['ItemAvailability']=true;taskObjects[TaskID]['Variables']['tcin']=text.data.product.tcin;return}}catch(e){console.log(e);taskObjects[TaskID]['Variables']['ItemAvailability']=false;return};taskObjects[TaskID]['Variables']['ItemAvailability']=false}return;" | |
} | |
}, | |
"logStatusColors": { | |
"success": "magenta", | |
"addedToCart":"magenta", | |
"checkout2":"green", | |
"successfulCheckout":"green", | |
"OutOfStock": "cyan", | |
"OutOfStock2": "cyan", | |
"NoLoadedTCINs": "cyan", | |
"cartFull": "yellow", | |
"logCheckout": "green", | |
"PID_LOCKED": "yellow", | |
"processing": "yellow", | |
"error": "yellow", | |
"fail": "red", | |
"InStock": "cyan", | |
"shippingAlreadyPresent": "cyan" | |
}, | |
"functions": { | |
"getItemInfo": { | |
"name": "getItemInfo", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 55500, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": null, | |
"urlFunction": { | |
"name": "returnTaskTCIN", | |
"arguments": "taskObjects, TaskID" | |
} | |
}, | |
"method": "GET", | |
"headers": { | |
"accept": "application/json", | |
"accept-language": "en-US,en;q=0.9,ar-JO;q=0.8,ar;q=0.7", | |
"sec-ch-ua": "\"Chromium\";v=\"86\", \"\\\"Not\\\\A;Brand\";v=\"99\", \"Google Chrome\";v=\"86\"", | |
"sec-ch-ua-mobile": "?0", | |
"sec-fetch-dest": "empty", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-site": "same-site", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": null | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": false, | |
"useSessionCookies": false | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success", "BadTCIN","Throttle","fail", "accessTokenInvalid", "429", "InvalidTCIN"], | |
"success": { | |
"log": "Checking stock...", | |
"status": 200, | |
"options": {} | |
}, | |
"BadTCIN": { | |
"log": "TCIN Not Loaded. (400) Monitoring...", | |
"status": 400, | |
"options": {} | |
}, | |
"fail": { | |
"log": "Failed to get item", | |
"status": 444, | |
"options": {} | |
}, | |
"Throttle": { | |
"log": "Monitoring... (404)", | |
"status": 404, | |
"options": {} | |
}, | |
"429": { | |
"log": "SKU rate limited. Check SKU list. (Monitoring)", | |
"status": 429, | |
"options": {} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"InvalidTCIN": { | |
"log": "TCIN Not Loaded. Monitoring...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "No product found with tcin" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "Monitor", | |
"BadTCIN": "getItemInfo2", | |
"fail": "getItemInfo2", | |
"Throttle":"getItemInfo2", | |
"InvalidTCIN": "getItemInfo2", | |
"429": "getItemInfo2", | |
"end": "getItemInfo2" | |
} | |
} | |
}, | |
"getItemInfo2": { | |
"name": "getItemInfo2", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 500, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": null, | |
"urlFunction": { | |
"name": "returnTaskTCIN2", | |
"arguments": "taskObjects, TaskID" | |
} | |
}, | |
"method": "GET", | |
"headers": { | |
"accept": "application/json", | |
"accept-language": "en-US,en;q=0.9,ar-JO;q=0.8,ar;q=0.7", | |
"sec-ch-ua": "\"Chromium\";v=\"86\", \"\\\"Not\\\\A;Brand\";v=\"99\", \"Google Chrome\";v=\"86\"", | |
"sec-ch-ua-mobile": "?0", | |
"sec-fetch-dest": "empty", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-site": "same-site", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": null | |
} | |
}, | |
"requestOptions": { | |
"useTLS": true, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": false, | |
"useSessionCookies": false | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success", "NoLoadedTCINs", "BadTCIN", "fail", "accessTokenInvalid", "429", "InvalidTCIN"], | |
"success": { | |
"log": "Monitoring...", | |
"status": 200, | |
"options": {} | |
}, | |
"BadTCIN": { | |
"log": "TCIN Not Loaded. (400) Monitoring...", | |
"status": 400, | |
"options": {} | |
}, | |
"NoLoadedTCINs": { | |
"log": "Monitoring... (404)", | |
"status": 404, | |
"options": {} | |
}, | |
"fail": { | |
"log": "Failed to get item", | |
"status": 444, | |
"options": {} | |
}, | |
"429": { | |
"log": "SKU rate limited. Check SKU list. (Monitoring)", | |
"status": 429, | |
"options": {} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
}, | |
"InvalidTCIN": { | |
"log": "TCIN Not Loaded. Monitoring...", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "No product found with tcin" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "Monitor", | |
"BadTCIN": "getItemInfo2", | |
"fail": "getItemInfo2", | |
"InvalidTCIN": "getItemInfo2", | |
"429": "getItemInfo2", | |
"NoLoadedTCINs": "getItemInfo2", | |
"end": "getItemInfo2" | |
} | |
} | |
}, | |
"Monitor": { | |
"name": "Monitor", | |
"type": "function", | |
"start": "parseItemInfo", | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "taskObjects[TaskID].setProxy(TaskID, taskObjects);taskObjects[TaskID].Cookies = taskObjects[TaskID].Cookies.filter((cookie) => !cookie.includes('mitata'));taskObjects[TaskID].setProxy(TaskID, taskObjects);taskObjects[TaskID].Cookies = taskObjects[TaskID].Cookies.filter((cookie) => !cookie.includes('mitata'));monitorEvent.emit(taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.task_sku,{site:'Target',inStock:taskObjects[TaskID]['Variables']['ItemAvailability'],SKU:taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.task_sku});if(taskObjects[TaskID]['Variables']['ItemAvailability']==true){return'InStock'}else{return'OutOfStock'}" | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["InStock", "OutOfStock", "UnAvailable"], | |
"InStock": { | |
"log": "Item in Stock. Alerting Task..." | |
}, | |
"OutOfStock": { | |
"log": "Monitoring..." | |
}, | |
"OutOfStock2": { | |
"log": "Monitoring..." | |
}, | |
"UnAvailable": { | |
"log": "Failed to get item. Monitoring..." | |
} | |
}, | |
"taskLogic": { | |
"InStock": "getItemInfo", | |
"OutOfStock": "getItemInfo", | |
"OutOfStock2": "getItemInfo2", | |
"UnAvailable": "getItemInfo", | |
"end": "getItemInfo2" | |
} | |
} | |
}, | |
"end": "exit" | |
} | |
}, | |
"Pickup": { | |
"entryPoint": "CheckLocationStock2", | |
"variables": [ | |
"ItemInfo", | |
"ItemAvailability" | |
], | |
"taskStatistics":{ | |
"addedToCart":"taskCartCount", | |
"addedToCart2":"taskCartCount", | |
"successfulCheckout": "taskCountCheckedOut", | |
"checkout2": "taskCountCheckedOut", | |
"PaymentDecline": "taskCountDeclined", | |
"Decline": "taskCountDeclined" | |
}, | |
"captchaHarvester": true, | |
"helperFunctions": { | |
"returnLocationMonitorURL2": { | |
"arguments": "taskObjects, TaskID", | |
"body": "let mileRadius = 100;if (taskObjects[TaskID].getTaskInfo(TaskID, taskObjects).product.task_sku.includes(':') === true) {mileRadius = taskObjects[TaskID].getTaskInfo(TaskID, taskObjects).task_settings.mile_radius;};let zip_code = taskObjects[TaskID].getTaskInfo(TaskID, taskObjects).task_settings.zip_code;return `https://redsky.target.com/redsky_aggregations/v1/web_platform/fiats_v1?key=ff457966e64d5e877fdbad070f276d18ecec4a01&nearby=` + zip_code + `&limit=100&requested_quantity=1&radius=` + mileRadius + `&include_only_available_stores=true&tcin=` + taskObjects[TaskID].getTaskInfo(TaskID, taskObjects).product.task_sku;" | |
} | |
}, | |
"logStatusColors": { | |
"success": "magenta", | |
"addedToCart":"magenta", | |
"checkout2":"green", | |
"successfulCheckout":"green", | |
"OutOfStock": "cyan", | |
"OutOfStock2": "cyan", | |
"NoLoadedTCINs": "cyan", | |
"cartFull": "yellow", | |
"logCheckout": "green", | |
"PID_LOCKED": "yellow", | |
"processing": "yellow", | |
"error": "yellow", | |
"fail": "red", | |
"InStock": "cyan", | |
"shippingAlreadyPresent": "cyan" | |
}, | |
"functions": { | |
"CheckLocationStock2": { | |
"name": "CheckLocationStock2", | |
"type": "request", | |
"start": null, | |
"delay": 0, | |
"retryDelay": 500, | |
"request": { | |
"requestConfig": { | |
"url": { | |
"plainURL": null, | |
"urlFunction": { | |
"name": "returnLocationMonitorURL2", | |
"arguments": "taskObjects, TaskID" | |
} | |
}, | |
"method": "GET", | |
"headers": { | |
"accept": "application/json", | |
"accept-language": "en-US,en;q=0.9,ar-JO;q=0.8,ar;q=0.7", | |
"sec-ch-ua": "\"Chromium\";v=\"86\", \"\\\"Not\\\\A;Brand\";v=\"99\", \"Google Chrome\";v=\"86\"", | |
"sec-ch-ua-mobile": "?0", | |
"sec-fetch-dest": "empty", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-site": "same-site", | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36" | |
}, | |
"body": { | |
"plainBody": null, | |
"function": null | |
} | |
}, | |
"requestOptions": { | |
"useTLS": false, | |
"cookies": null, | |
"proxies": true, | |
"saveSessionCookies": false, | |
"useSessionCookies": false | |
} | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["success", "BadTCIN", "fail", "Throttle","accessTokenInvalid", "429"], | |
"success": { | |
"log": "Got Location Stock", | |
"status": 200, | |
"options": {} | |
}, | |
"BadTCIN": { | |
"log": "TCIN Not Loaded. (400) Monitoring...", | |
"status": 400, | |
"options": {} | |
}, | |
"Throttle": { | |
"log": "Failed to get Location Stock (404)", | |
"status": 404, | |
"options": {} | |
}, | |
"fail": { | |
"log": "Failed to get item", | |
"status": 444, | |
"options": {} | |
}, | |
"429": { | |
"log": "SKU rate limited. Check SKU list. (Monitoring)", | |
"status": 429, | |
"options": {} | |
}, | |
"accessTokenInvalid": { | |
"log": "Invalid Access Token", | |
"status": null, | |
"options": { | |
"type": "responseBodyIncludes", | |
"responseBodyIncludes": "no authorization header found" | |
} | |
} | |
}, | |
"taskLogic": { | |
"success": "Monitor", | |
"BadTCIN": "CheckLocationStock2", | |
"fail": "CheckLocationStock2", | |
"Throttle":"CheckLocationStock2", | |
"accessTokenInvalid": "CheckLocationStock2", | |
"429": "CheckLocationStock2", | |
"end": "Monitor" | |
} | |
} | |
}, | |
"Monitor": { | |
"name": "Monitor", | |
"type": "function", | |
"start": null, | |
"function": { | |
"arguments": "taskObjects, TaskID", | |
"body": "taskObjects[TaskID].setProxy(TaskID, taskObjects);taskObjects[TaskID].Cookies = taskObjects[TaskID].Cookies.filter((cookie) => !cookie.includes('mitata'));try{let response=JSON.parse(await taskObjects[TaskID].requestHistory.CheckLocationStock2.text());let locations=response.data.fulfillment_fiats.locations;if(locations.length>0){let store=locations.sort((a,b)=>(a.location_available_to_promise_quantity>b.location_available_to_promise_quantity)?1:((b.location_available_to_promise_quantity>a.location_available_to_promise_quantity)?-1:0));store.reverse();monitorEvent.emit(taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.task_sku,{site:'Target',inStock:true,SKU:taskObjects[TaskID].getTaskInfo(TaskID,taskObjects).product.task_sku,store_id:store[0].location_id});return'InStock'}else{return'OutOfStock'}}catch(e){console.log(e);return'OutOfStock'}" | |
}, | |
"logic": { | |
"functionLogic": { | |
"reqStatuses": ["InStock", "OutOfStock", "UnAvailable"], | |
"InStock": { | |
"log": "Item in Stock. Alerting Task..." | |
}, | |
"OutOfStock": { | |
"log": "Monitoring..." | |
}, | |
"OutOfStock2": { | |
"log": "Monitoring..." | |
}, | |
"UnAvailable": { | |
"log": "Failed to get item. Monitoring..." | |
} | |
}, | |
"taskLogic": { | |
"InStock": "CheckLocationStock2", | |
"OutOfStock": "CheckLocationStock2", | |
"OutOfStock2": "CheckLocationStock2", | |
"UnAvailable": "CheckLocationStock2", | |
"end": "CheckLocationStock2" | |
} | |
} | |
}, | |
"end": "exit" | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment