{"id":13481755,"url":"https://github.com/Danny-Dasilva/CycleTLS","last_synced_at":"2025-03-27T12:31:23.839Z","repository":{"id":36968320,"uuid":"346116221","full_name":"Danny-Dasilva/CycleTLS","owner":"Danny-Dasilva","description":"Spoof TLS/JA3 fingerprints in GO and Javascript ","archived":false,"fork":false,"pushed_at":"2024-08-10T23:06:20.000Z","size":39501,"stargazers_count":910,"open_issues_count":75,"forks_count":171,"subscribers_count":27,"default_branch":"main","last_synced_at":"2024-10-22T23:43:00.959Z","etag":null,"topics":["bypass","fingerprint","fingerprinting","go","golang","http","http2","https","ja3","javascript","js","tls","typescript"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Danny-Dasilva.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-09T19:11:50.000Z","updated_at":"2024-10-22T13:05:11.000Z","dependencies_parsed_at":"2023-02-17T04:01:18.351Z","dependency_job_id":"ad6e93a7-8516-4221-8894-54c0c6b25e7e","html_url":"https://github.com/Danny-Dasilva/CycleTLS","commit_stats":{"total_commits":122,"total_committers":7,"mean_commits":"17.428571428571427","dds":"0.21311475409836067","last_synced_commit":"7af4329e67e9809bad4b6cc18fb9312065f48742"},"previous_names":["danny-dasilva/go-tls"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danny-Dasilva%2FCycleTLS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danny-Dasilva%2FCycleTLS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danny-Dasilva%2FCycleTLS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Danny-Dasilva%2FCycleTLS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Danny-Dasilva","download_url":"https://codeload.github.com/Danny-Dasilva/CycleTLS/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245844907,"owners_count":20681801,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bypass","fingerprint","fingerprinting","go","golang","http","http2","https","ja3","javascript","js","tls","typescript"],"created_at":"2024-07-31T17:00:55.216Z","updated_at":"2025-03-27T12:31:23.824Z","avatar_url":"https://github.com/Danny-Dasilva.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# CycleTLS\n\n\n\n\u003cdiv align=\"center\"\u003e\n\t\u003cimg src=\"docs/media/Banner.png\" alt=\"CycleTLS\"/\u003e\n\t\u003cbr\u003e\n\t\nAccepting Community Support and PR's\n\n\t\n\t\n\n![build](https://github.com/Danny-Dasilva/CycleTLS/actions/workflows/test_golang.yml/badge.svg)\n[![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg)](http://godoc.org/github.com/Danny-Dasilva/CycleTLS/cycletls) \n[![license](https://img.shields.io/github/license/Danny-Dasilva/CycleTLS.svg)](https://github.com/Danny-Dasilva/CycleTLS/blob/main/LICENSE)\n[![Go Report Card](https://goreportcard.com/badge/github.com/Danny-Dasilva/CycleTLS/cycletls)](https://goreportcard.com/report/github.com/Danny-Dasilva/CycleTLS/cycletls)\n[![npm version](https://img.shields.io/npm/v/cycletls.svg)](https://www.npmjs.org/package/cycletls)\n \u003ca href=\"https://discord.gg/gsmxMHrwhu\"\u003e\n  \u003cimg src=\"https://img.shields.io/discord/1100945880888115200?logo=discord\"\n      alt=\"chat on Discord\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\nIf you have a API change or feature request feel free to open an [Issue](https://github.com/Danny-Dasilva/CycleTLS/issues/new/choose)\n\n\n\n# 🚀 Features\n\n- [High-performance](#-performance) Built-in goroutine pool used for handling asynchronous requests\n- Custom header ordering via [fhttp](https://github.com/useflyent/fhttp)\n- Proxy support | Socks4, Socks5, Socks5h\n- Ja3 Token configuration\n\n\nTable of contents\n=================\n\n\n* [Table of contents](#table-of-contents)\n* [Installation](#installation)\n* [Usage](#usage)\n\t* [QuickStart JS](#example-cycletls-request-for-typescript-and-javascript)\n\t* [Quickstart Golang](#example-cycletls-request-for-golang)\n\t* [Initializing CycleTLS](#creating-an-instance)\n\t* [API/Methods](#cycletls-alias-methods)\n\t* [Request Config](#cycletls-request-config)\n\t* [Response Schema](#cycletls-response-schema)\n\t* [Multiple Requests Example](#multiple-requests-example-for-typescript-and-javascript)\n* [Local Setup](#dev-setup)\n* [QA](#questions)\n* [LICENSE](#license)\n\n## Dependencies\n\n```\nnode ^v18.0\ngolang ^v1.21x\n```\n\n## Installation\n\nNode Js\n\n```bash\n$ npm install cycletls\n```\n\nGolang\n\n```bash\n$ go get github.com/Danny-Dasilva/CycleTLS/cycletls \n```\n\n# Usage \n\n## Example CycleTLS Request for Typescript and Javascript\n\nYou can run this test in `tests/simple.test.ts`\n\n```js\n\nconst initCycleTLS = require('cycletls');\n// Typescript: import initCycleTLS from 'cycletls';\n\n(async () =\u003e {\n  // Initiate CycleTLS\n  const cycleTLS = await initCycleTLS();\n\n  // Send request\n  const response = await cycleTLS('https://ja3er.com/json', {\n    body: '',\n    ja3: '771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-51-57-47-53-10,0-23-65281-10-11-35-16-5-51-43-13-45-28-21,29-23-24-25-256-257,0',\n    userAgent: 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0',\n    proxy: 'http://username:password@hostname.com:443', \n  }, 'get');\n\n  console.log(response);\n\n  // Cleanly exit CycleTLS\n  cycleTLS.exit();\n\n})();\n\n```\n\n## Example CycleTLS Request for Golang\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"github.com/Danny-Dasilva/CycleTLS/cycletls\"\n)\n\nfunc main() {\n\n\tclient := cycletls.Init()\n\n\tresponse, err := client.Do(\"https://ja3er.com/json\", cycletls.Options{\n\t\tBody : \"\",\n\t\tJa3: \"771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-51-57-47-53-10,0-23-65281-10-11-35-16-5-51-43-13-45-28-21,29-23-24-25-256-257,0\",\n\t\tUserAgent: \"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0\",\n\t  }, \"GET\");\n\tif err != nil {\n\t\tlog.Print(\"Request Failed: \" + err.Error())\n\t}\n\tlog.Println(response)\n}\n\n```\n#### Example using your own custom http.Client\n\n\u003cdetails\u003e\n\n```go\nimport (\n\t\"github.com/Danny-Dasilva/CycleTLS/cycletls\"\n\thttp \"github.com/Danny-Dasilva/fhttp\" // note this is a drop-in replacement for net/http\n)\n\nfunc main() {\n\tja3 := \"771,52393-52392-52244-52243-49195-49199-49196-49200-49171-49172-156-157-47-53-10,65281-0-23-35-13-5-18-16-30032-11-10,29-23-24,0\"\n\tua := \"Chrome Version 57.0.2987.110 (64-bit) Linux\"\n\n \t cycleClient := \u0026http.Client{\n \t\tTransport:     cycletls.NewTransport(ja3, ua),\n \t }\n\n\tresp, err := cycleClient.Get(\"https://tls.peet.ws/\")\n\t...\n}\n```\n\u003c/details\u003e\n\n## Creating an instance\n\nIn order to create a `cycleTLS` instance, you can run the following:\n\n#### JavaScript\n\n```js\n// The initCycleTLS function spawns a Golang process that handles all requests concurrently via goroutine loops. \nconst initCycleTLS = require('cycletls');\n// import initCycleTLS from 'cycletls';\n\n// Async/Await method\nconst cycleTLS = await initCycleTLS();\n// .then method\ninitCycleTLS().then((cycleTLS) =\u003e {});\n\n```\n#### Golang\n\n```go\nimport (\n\t\"github.com/Danny-Dasilva/CycleTLS/cycletls\"\n)\n\n//The `Init` function initializes golang channels to process requests. \nclient := cycletls.Init()\n```\n\n\n## CycleTLS Alias Methods\n\nThe following methods exist in CycleTLS\n\n**cycleTLS(url, [config])**\n\n**cycleTLS.get(url, [config])**\n\n**cycleTLS.delete(url, [config])**\n\n**cycleTLS.head(url, [config])**\n\n**cycleTLS.options(url, [config])**\n\n**cycleTLS.post(url, [config])**\n\n**cycleTLS.put(url, config)**\n\n**cycleTLS.patch(url, [config])**\n\nUrl is not optional, config is optional\n\n## CycleTLS Request Config\n\n```js\n{\n  // URL for the request (required if not specified as an argument)\n  url: \"https://example.com\"\n  // Method for the request (\"head\" | \"get\" | \"post\" | \"put\" | \"delete\" | \"trace\" | \"options\" | \"connect\" | \"patch\")\n  method: \"get\" // Default method\n  // Custom headers to send\n  headers: { \"Authorization\": \"Bearer someexampletoken\" }\n  // Custom cookies to send\n  Cookies: [{\n    \"name\": \"key\",\n    \"value\": \"val\",\n    \"path\":  \"/docs\",\n    \"domain\":  \"google.com\",\n                \"expires\": \"Mon, 02-Jan-2022 15:04:05 EST\"\n    \"maxAge\": 90,\n    \"secure\": false,\n    \"httpOnly\": true,\n    \"sameSite\": \"Lax\"\t\t\n  }],\n  // Body to send with request (must be a string - cannot pass an object)\n  body: '',\n  // JA3 token to send with request\n  ja3: '771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-51-57-47-53-10,0-23-65281-10-11-35-16-5-51-43-13-45-28-21,29-23-24-25-256-257,0',\n  // User agent for request\n  userAgent: 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0',\n  // Proxy to send request through (must be in the same format)\n  proxy: 'http://username:password@hostname.com:443',\n  // Amount of seconds before request timeout (default: 7)\n  timeout: 2,\n  // Toggle if CycleTLS should follow redirects\n  disableRedirect: true,\n  // Custom header order to send with request (This value will overwrite default header order)\n  headerOrder: [\"cache-control\", \"connection\", \"host\"],\n  // Toggle if CycleTLS should skip verify certificate (If InsecureSkipVerify is true, TLS accepts any certificate presented by the server and any host name in that certificate.)\n  insecureSkipVerify: false\t\n  // Forces CycleTLS to do a http1 handshake\n  forceHTTP1: false\t\n}\n\n```\n\n## CycleTLS Response Schema\n\n```js\n{\n  // Status code returned from server (Number)\n  status: 200,\n  // Body returned from the server (String)\n  body: \"\",\n  // Headers returned from the server (Object)\n  headers: {\n    \"some\": \"header\",\n    ...\n  },\n  // FinalUrl returned from the server (String). This field is useful when redirection is active.\n  finalUrl: \"https://final.url/\"\t\n}\n\n```\n\n\n\n## Multiple Requests Example for Typescript and Javascript\n\nIf CycleTLS is being used by in a JavaScript environment, CycleTLS will spawn a Golang process to handle requests. This Golang process handles requests `concurrently` in a worker pool. Due to this, CycleTLS returns response objects as soon as they are made available \n(in other terms, CycleTLS processes requests as they are received, but responses are returned asynchronously so they will NOT be returned in the order requested)\n\nIf you are using CycleTLS in JavaScript, it is necessary to exit out of the instance to prevent zombie processes. The example below shows one way to approach cleanly exiting CycleTLS if you need to process multiple requests (note: keep in mind that calling the `exit()` function will kill any requests in progress). If your workflow requires requests running the entire time the process runs, modules such as [exit-hook](https://www.npmjs.com/package/exit-hook) could serve as an alternative solution to cleanly exiting CycleTLS.\n\n```js\nconst initCycleTLS = require(\"cycletls\");\n// Typescript: import initCycleTLS from 'cycletls';\n\n// Defining custom JA3 token and user agenton multiple requests,\n  \"https://httpbin.org/user-agent\": {\n    ja3: ja3,\n    userAgent: userAgent,\n  },\n  \"http://httpbin.org/post\": {\n    body: '{\"field\":\"POST-VAL\"}',\n    method: \"POST\",\n  },\n  \"http://httpbin.org/cookies\": {\n    cookies: [\n      {\n        name: \"example1\",\n        value: \"aaaaaaa\",\n        expires: \"Mon, 02-Jan-2022 15:04:05 EST\",\n      },\n    ],\n  },\n};\n\n// Promises array of requests\nconst promises = [];\n\n// Anonymous async function\n(async () =\u003e {\n  // Initiate CycleTLS\n  const cycleTLS = await initCycleTLS();\n\n  // Loop through requestDict (Object) defined above\n  for (const url in requestDict) {\n    // Fetch configs from requestDict (Object)\n    const params = requestDict[url];\n\n    // Send request (note: no waiting)\n    const response = cycleTLS(\n      url, {\n        body: params.body ?? \"\", //?? is just setting defaults in this case\n        ja3: params.ja3 ?? ja3,\n        userAgent: params.userAgent ?? userAgent,\n        headers: params.headers,\n        cookies: params.cookies,\n      }, params.method ?? \"GET\");\n\n    // console.log the response object\n    response.then((out) =\u003e {\n      console.log(url, out);\n    });\n\n    // Push request to promise array\n    promises.push(response);\n  }\n\n  // Wait for all requests to execute successfully\n  Promise.all(promises).then(() =\u003e {\n    // Cleanly exit CycleTLS one all requests have been received\n    cycleTLS.exit();\n  });\n})();\n```\n\n## Multiple Requests Example for Golang\n\nThe general expectation for golang packages is to expect the user to implement a worker pool or any other form of goroutine/asynchronous processing. This package includes a built in Queue method that leverages a worker pool/channels for long running asynchronous requests against a set of urls.\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\n\tcycletls \"github.com/Danny-Dasilva/CycleTLS/cycletls\"\n)\n\n// Static variables\nvar (\n\tja3       = \"771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513,29-23-24,0\"\n\tuserAgent = \"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36\"\n)\n\n// RequestConfig holds the configuration for each request.\ntype RequestConfig struct {\n\tURL     string\n\tMethod  string\n\tOptions cycletls.Options\n}\n\nfunc main() {\n\tclient := cycletls.Init(true) // Initialize with worker pool\n\n\t// Define the requests\n\trequests := []RequestConfig{\n\t\t{\n\t\t\tURL:    \"http://httpbin.org/delay/4\",\n\t\t\tMethod: \"GET\",\n\t\t\tOptions: cycletls.Options{\n\t\t\t\tJa3:       ja3,\n\t\t\t\tUserAgent: userAgent,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tURL:    \"http://httpbin.org/post\",\n\t\t\tMethod: \"POST\",\n\t\t\tOptions: cycletls.Options{\n\t\t\t\tBody:      `{\"field\":\"POST-VAL\"}`,\n\t\t\t\tJa3:       ja3,\n\t\t\t\tUserAgent: userAgent,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tURL:    \"http://httpbin.org/cookies\",\n\t\t\tMethod: \"GET\",\n\t\t\tOptions: cycletls.Options{\n\t\t\t\tJa3:       ja3,\n\t\t\t\tUserAgent: userAgent,\n\t\t\t\tCookies: []cycletls.Cookie{\n\t\t\t\t\t{\n\t\t\t\t\t\tName:  \"example1\",\n\t\t\t\t\t\tValue: \"aaaaaaa\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\t// Queue the requests\n\tfor _, req := range requests {\n\t\tclient.Queue(req.URL, req.Options, req.Method)\n\t}\n\n\t// Asynchronously read responses as soon as they are available\n\t// They will return as soon as they are processed\n\t// e.g. Delay 3 will be returned last\n\tfor i := 0; i \u003c len(requests); i++ {\n\t\tresponse := \u003c-client.RespChan\n\t\tlog.Println(\"Response:\", response)\n\t}\n\n\t// Close the client\n\tclient.Close()\n}\n\n```\n\n# Dev Setup\n\nIf you would like to compile CycleTLS on your own, use the following commands:\n\nSet module-aware mode\n`go env -w  GO111MODULE=off`\n\nInstall golang dependencies\n`go get github.com/Danny-Dasilva/CycleTLS/cycletls`\n\ninstall npm packages (this command handles the above)\n\n`npm install`\n\n### To recompile index.ts in the src folder\n\n`npm run build`\n\n### To recompile Golang files in the golang folder\n\nAll\n\n`npm run build:go`\n\nWindows\n\n`npm run build:go:windows:amd64`\n\nLinux\n\n`npm run build:go:linux:amd64`\n\nMac\n\n`npm run build:go:mac:arm64`\n\n\nYou can view the available compile options within the `package.json`\n\n## Questions\n\n### How do I set Cookies\n\u003cdetails\u003e\n\nThere are two simple ways to interface with cookies \n### Javascript Simple Cookie Configuration\n\n```js\nconst initCycleTLS = require(\"cycletls\");\n(async () =\u003e {\n  // Initiate cycleTLS\n  const cycleTLS = await initCycleTLS();\n  const response = await cycleTLS(\"https://httpbin.org/cookies\", {\n    cookies: {\n      cookie1: \"value1\",\n      cookie2: \"value2\",\n    },\n  });\n  console.log(response.body);\n  /* Expected\n  {\n    \"cookies\": {\n      \"cookie1\": \"value1\",\n      \"cookie2\": \"value2\"\n    }\n  }\n  */\n  cycleTLS.exit();\n})();\n```\n\nIn this simple example you can set the cookie `name` and `value` within an object\n\n\n### Javascript Complex Cookie Configuration\n\nIf you wish to have more fine grained control over cookie parameters you have access to the full underlying Go struct\n\nhere are the following values you can set\n\n```ts\nexport interface Cookie {\n  name: string;\n  value: string;\n  path?: string;\n  domain?: string;\n  expires?: string;\n  rawExpires?: string;\n  maxAge?: number;\n  secure?: boolean;\n  httpOnly?: boolean;\n  sameSite?: string;\n  unparsed?: string;\n}\n```\n\nyou can use them in a request as follows\n\n```js\nconst initCycleTLS = require(\"cycletls\");\n(async () =\u003e {\n  // Initiate cycleTLS\n  const cycleTLS = await initCycleTLS();\n  const complexCookies = [\n    {\n      name: \"cookie1\",\n      value: \"value1\",\n      domain: \"httpbin.org\",\n    },\n    {\n      name: \"cookie2\",\n      value: \"value2\",\n      domain: \"httpbin.org\",\n    },\n  ];\n\n  const response = await cycleTLS(\"https://httpbin.org/cookies\", {\n    cookies: complexCookies,\n  });\n\n  console.log(response.body);\n  /* Expected\n  {\n    \"cookies\": {\n      \"cookie1\": \"value1\",\n      \"cookie2\": \"value2\"\n    }\n  }\n  */\n  cycleTLS.exit();\n})();\n```\n\n\n### Golang Configure Cookies\n```golang\npackage main\n\nimport (\n    \"github.com/Danny-Dasilva/CycleTLS/cycletls\"\n)\n\nfunc main() {\n    resp, err := client.Do(\"https://httpbin.org/cookies\", cycletls.Options{\n\t\tBody:      \"\",\n\t\tJa3:       \"771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-51-57-47-53-10,0-23-65281-10-11-35-16-5-51-43-13-45-28-21,29-23-24-25-256-257,0\",\n\t\tUserAgent: \"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0\",\n\t\tCookies: []cycletls.Cookie{{Name: \"cookie1\", Value: \"value1\"},\n\t\t\t{Name: \"cookie2\", Value: \"value2\"}},\n    }, \"GET\")\n    if err != nil {\n      log.Print(\"Request Failed: \" + err.Error())\n    }\n    log.Println(resp.Body)\n    /* Expected\n    {\n      \"cookies\": {\n        \"cookie1\": \"value1\", \n        \"cookie2\": \"value2\"\n      }\n      }\n    */\n    \n    //Altenatively if you want access to values within a map\n    log.Println(resp.JSONBody())\n    /* Expected\n    map[cookies:map[cookie1:value1 cookie2:value2]]\n    */\n}\n\n```\n\n\nFeel free to open an [Issue](https://github.com/Danny-Dasilva/CycleTLS/issues/new/choose) with a feature request for specific file type support. \n\u003c/details\u003e\n\n\n### How do I use CookieJar in CycleTLS?\n\n\u003cdetails\u003e\n\n\n### CookieJar in JS\n\n```js\nconst initCycleTLS = require(\"cycletls\");\n\nconst tough = require(\"tough-cookie\");\nconst Cookie = tough.Cookie;\n\n(async () =\u003e {\n  // Initiate cycleTLS and CookieJar\n  const cycleTLS = await initCycleTLS();\n  const cookieJar = new tough.CookieJar();\n\n  // Capture a set cookie\n  const firstResponse = await cycleTLS.get(\n    \"https://httpbin.org/cookies/set?freeform=test\",\n    {\n      disableRedirect: true,\n    }\n  );\n  \n  // Now use the processCookies function to add the cookies from the response headers to the cookie jar\n  await processCookies(\n    firstResponse,\n    \"https://httpbin.org/cookies/set?freeform=test\",\n    cookieJar\n  );\n  // Now send a second to verify we have our cookies\n  const secondResponse = await cycleTLS.get(\"https://httpbin.org/cookies\", {\n    headers: {\n      cookie: await cookieJar.getCookieString(\"https://httpbin.org/cookies\"),\n    },\n  });\n  \n  //verify cookies were set\n  console.log(secondResponse.body)\n  /* Expected\n  {\n    \"cookies\": {\n      \"freeform\": \"test\"\n    }\n  }\n  */\n  cycleTLS.exit();\n})();\n\nasync function processCookies(response, url, cookieJar) {\n  if (response.headers[\"Set-Cookie\"] instanceof Array) {\n    response.headers[\"Set-Cookie\"].map(\n      async (cookieString) =\u003e await cookieJar.setCookie(cookieString, url)\n    );\n  } else {\n    await cookieJar.setCookie(response.headers[\"Set-Cookie\"], url);\n  }\n}\n```\n\n\n### CookieJar in Golang\n\n```go\npackage main\n\nimport (\n\t\"github.com/Danny-Dasilva/CycleTLS/cycletls\"\n\t\"log\"\n\t\"net/http/cookiejar\"\n\t\"net/url\"\n\t\"strings\"\n)\n\nfunc main() {\n\tclient := cycletls.Init()\n\tjar, err := cookiejar.New(nil)\n  if err != nil {\n      log.Fatal(err)\n  }\n\t// First request to set cookie\n\tfirstResponse, err := client.Do(\"https://httpbin.org/cookies/set?a=1\u0026b=2\u0026c=3\", cycletls.Options{\n\t\tBody: \"\",\n\t\tJa3:       \"771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513,29-23-24,0\",\n\t\tUserAgent: \"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36\",\n\t\tDisableRedirect: true,\n\t},\n\t\t \"GET\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfirstURL, _ := url.Parse(firstResponse.FinalUrl)\n  jar.SetCookies( firstURL, firstResponse.Cookies)\n\n\n\t// Second request to verify cookies, including the cookies from the first response\n\tsecondResponse, err := client.Do(\"https://httpbin.org/cookies\", cycletls.Options{\n    Body: \"\",\n    Ja3:       \"771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513,29-23-24,0\",\n    UserAgent: \"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36\",\n    Headers: map[string]string{\n        \"Cookie\": getHeadersFromJar(jar, firstURL),\n    },\n\t}, \"GET\")\n\tif err != nil {\n\t    log.Fatal(err)\n\t}\n\n\tlog.Println(\"Second Response body:\", secondResponse.Body)\n}\n\n\nfunc getHeadersFromJar(jar *cookiejar.Jar, url *url.URL) string {\n    cookies := jar.Cookies(url)\n    var cookieStrs []string\n    for _, cookie := range cookies {\n        cookieStrs = append(cookieStrs, cookie.Name+\"=\"+cookie.Value)\n    }\n    return strings.Join(cookieStrs, \"; \")\n}\n\n```\n\n\u003c/details\u003e\n\n### How do I send multipart/form-data in CycleTLS\n\n\u003cdetails\u003e\n\n### Javascript Text form-data\n```js\nconst initCycleTLS = require(\"cycletls\");\nconst FormData = require('form-data');\n\n(async () =\u003e {\n  const cycleTLS = await initCycleTLS();\n\n  const formData = new FormData();\n  formData.append(\"key1\", \"value1\");\n  formData.append(\"key2\", \"value2\");\n  \n  const response = await cycleTLS('http://httpbin.org/post', {\n      body: formData,\n      headers: {\n          'Content-Type': 'multipart/form-data',\n      },\n  }, 'post');\n\n  console.log(response);\n\n  cycleTLS.exit();\n})();\n\n```\n\n\n### Javascript File form-data\n```js\nconst initCycleTLS = require(\"cycletls\");\nconst FormData = require('form-data');\nconst fs = require('fs');\n\n(async () =\u003e {\n  const cycleTLS = await initCycleTLS();\n\n  const formData = new FormData();\n  const fileStream = fs.createReadStream(\"../go.mod\");\n  formData.append('file', fileStream);\n\n  \n  const response = await cycleTLS('http://httpbin.org/post', {\n      body: formData,\n      headers: {\n          'Content-Type': 'multipart/form-data',\n      },\n  }, 'post');\n\n  console.log(response);\n\n  cycleTLS.exit();\n})();\n\n```\n\n### Golang Text form-data\n```golang\npackage main\n\nimport (\n\t\"bytes\"\n\t\"github.com/Danny-Dasilva/CycleTLS/cycletls\"\n\t\"log\"\n\t\"mime/multipart\"\n)\n\nfunc main() {\n\tclient := cycletls.Init()\n\n\t// Prepare a buffer to write our multipart form\n\tvar requestBody bytes.Buffer\n\tmultipartWriter := multipart.NewWriter(\u0026requestBody)\n\n\t// Add form fields\n\tmultipartWriter.WriteField(\"key1\", \"value1\")\n\tmultipartWriter.WriteField(\"key2\", \"value2\")\n\n\tcontentType := multipartWriter.FormDataContentType()\n\t// Close the writer before making the request\n\tmultipartWriter.Close()\n\n\tresponse, err := client.Do(\"http://httpbin.org/post\", cycletls.Options{\n\t\tBody: requestBody.String(),\n\t\tHeaders: map[string]string{\n\t\t\t\"Content-Type\": contentType,\n\t\t},\n\t}, \"POST\")\n\n\tif err != nil {\n\t\tlog.Print(\"Request Failed: \" + err.Error())\n\t}\n\n\tlog.Println(response.Body)\n}\n```\n\n\n### Golang file upload form-data\n```golang\npackage main\n\nimport (\n\t\"github.com/Danny-Dasilva/CycleTLS/cycletls\"\n\t\"bytes\"\n\t\"io\"\n\t\"log\"\n\t\"mime/multipart\"\n\t\"os\"\n)\n\nfunc main() {\n  client := cycletls.Init()\n\n  // Prepare a buffer to write our multipart form\n  var requestBody bytes.Buffer\n  multipartWriter := multipart.NewWriter(\u0026requestBody)\n\n  // Add a file\n  fileWriter, err := multipartWriter.CreateFormFile(\"fieldname\", \"filename\")\n  if err != nil {\n      log.Fatal(\"CreateFormFile Error: \", err)\n  }\n\n  // Open the file that you want to upload\n  file, err := os.Open(\"path/to/your/file\")\n  if err != nil {\n      log.Fatal(\"File Open Error: \", err)\n  }\n  defer file.Close()\n\n  // Copy the file to the multipart writer\n  _, err = io.Copy(fileWriter, file)\n  if err != nil {\n      log.Fatal(\"File Copy Error: \", err)\n  }\n\n  // Close the writer before making the request\n  contentType := multipartWriter.FormDataContentType()\n  multipartWriter.Close()\n\n  response, err := client.Do(\"http://httpbin.org/post\", cycletls.Options{\n      Body: requestBody.String(),\n      Headers: map[string]string{\n          \"Content-Type\": contentType,\n      },\n  }, \"POST\")\n\n  if err != nil {\n      log.Print(\"Request Failed: \" + err.Error())\n  }\n\n  log.Println(response.Body)\n}\n```\n\n\nIf requested encoding helpers can be added to the repo for golang \n\u003c/details\u003e\n\n### How do I send a application/x-www-form-urlencoded Post request\n\n\u003cdetails\u003e\n\n### Javascript application/x-www-form-urlencoded form\n```js\nconst initCycleTLS = require(\"cycletls\");\n(async () =\u003e {\n  const cycleTLS = await initCycleTLS();\n\n  const urlEncodedData = new URLSearchParams();\n  urlEncodedData.append('key1', 'value1');\n  urlEncodedData.append('key2', 'value2');\n\n  const response = await cycleTLS('http://httpbin.org/post', {\n      body: urlEncodedData,\n      headers: {\n          'Content-Type': 'application/x-www-form-urlencoded',\n      },\n  }, 'post');\n\n  console.log(response);\n\n  cycleTLS.exit();\n})();\n\n```\n### Golang application/x-www-form-urlencoded form\n```golang\npackage main\n\nimport (\n    \"log\"\n\t  \"net/url\"\n    \"github.com/Danny-Dasilva/CycleTLS/cycletls\"\n)\n\nfunc main() {\n\n\tclient := cycletls.Init()\n\n\t// Prepare form data\n\tform := url.Values{}\n\tform.Add(\"key1\", \"value1\")\n\tform.Add(\"key2\", \"value2\")\n\n\tresponse, err := client.Do(\"http://httpbin.org/post\", cycletls.Options{\n\t\tBody: form.Encode(),\n\t\tHeaders: map[string]string{\n\t\t\t\"Content-Type\": \"application/x-www-form-urlencoded\",\n\t\t},\n\t}, \"POST\")\n\tif err != nil {\n\t\tlog.Print(\"Request Failed: \" + err.Error())\n\t}\n\tlog.Println(response.Body)\n}\n\n```\n\u003c/details\u003e\n\n### How do I download images?\n\n\u003cdetails\u003e\n\nImages with a `Content-Type` header of the following types are base 64 encoded. \n\n**Supported Image Types**\n* `image/svg+xml`\n* `image/webp`\n* `image/jpeg`\n* `image/png`\n* `application/pdf`\n\nTo write them to a file you can use the below methods\n\n### Javascript Image Write to File\n```js\nconst initCycleTLS = require(\"cycletls\");\nvar fs = require(\"fs\");\n\n//Function to write image to a file\nconst writeImage = (filename, data) =\u003e {\n  let writeStream = fs.createWriteStream(filename);\n\n  // write some data with a base64 encoding\n  writeStream.write(data, \"base64\");\n  writeStream.on(\"finish\", () =\u003e {\n    console.log(`wrote to file ${filename}`);\n  });\n  \n  // close the stream\n  writeStream.end();\n};\n\n(async () =\u003e {\n  const cycleTLS = await initCycleTLS();\n  // try {\n\n  const jpegImage = await cycleTLS(\"http://httpbin.org/image/jpeg\", {\n    ja3: \"771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-51-57-47-53-10,0-23-65281-10-11-35-16-5-51-43-13-45-28-21,29-23-24-25-256-257,0\",\n    userAgent:\n      \"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0\",\n  });\n  //Write Image\n  writeImage(\"test.jpeg\", jpegImage.body);\n\n  cycleTLS.exit();\n})();\n\n```\n### Golang Image Write to File\n```golang\npackage main\n\nimport (\n    \"encoding/base64\"\n    \"os\"\n    \"github.com/Danny-Dasilva/CycleTLS/cycletls\"\n)\n\nfunc main() {\n\n    client := cycletls.Init()\n    response, err := client.Do(\"http://httpbin.org/image/jpeg\", cycletls.Options{\n      Body:      \"\",\n      Ja3:       \"771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-21,29-23-24,0\",\n      UserAgent: \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36\",\n    }, \"GET\")\n    // Decode Base64\n    dec, err := base64.StdEncoding.DecodeString(response.Body)\n    if err != nil {\n        panic(err)\n    }\n    //create file to write\n    f, err := os.Create(\"test.jpeg\")\n    if err != nil {\n        panic(err)\n    }\n    defer f.Close()\n    //write b64 to file\n    if _, err := f.Write(dec); err != nil {\n        panic(err)\n    }\n    if err := f.Sync(); err != nil {\n        panic(err)\n    }\n}\n\n```\n\n\nAdditional file type support is planned.\n\nFeel free to open an [Issue](https://github.com/Danny-Dasilva/CycleTLS/issues/new/choose) with a feature request for specific file type support. \n\u003c/details\u003e\n\n\n### How do I set/force HTTP1\n\n\u003cdetails\u003e\n\nIn golang set `ForceHTTP1` in Options\n\n```go\npackage main\n\nimport (\n\t\"github.com/Danny-Dasilva/CycleTLS/cycletls\"\n\t\"log\"\n)\n\nfunc main() {\n\tclient := cycletls.Init()\n\tresponse, err := client.Do(\"https://tls.peet.ws/api/all\", cycletls.Options{\n\t\tForceHTTP1: true,\n\t}, \"GET\")\n\tif err != nil {\n\t\tlog.Print(\"Request Failed: \" + err.Error())\n\t}\n\tlog.Println(response.Body,) //You can verify the HTTP_Version in the response\n\n}\n\n```\n\n\nIn JS/TS set `forceHTTP1` in Options\n\n```js\nconst initCycleTLS = require('cycletls');\n// Typescript: import initCycleTLS from 'cycletls';\n\n(async () =\u003e {\n  const cycleTLS = await initCycleTLS();\n\n  const response = await cycleTLS('https://ja3er.com/json', {\n     body: '',\n    ja3: '771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-51-57-47-53-10,0-23-65281-10-11-35-16-5-51-43-13-45-28-21,29-23-24-25-256-257,0',\n    userAgent:\n      'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0',\n    forceHTTP1: false, //Set this field\n  });\n\n  console.log(response);\n  //You can verify the HTTP_Version in the response\n  cycleTLS.exit();\n\n})();\n\n```\n\n\u003c/details\u003e\n\n### Cross Compiling for other platforms\n\u003cdetails\u003e\n\nNatively the 3 Operating System types `linux`, `darwin` , `windows`  should cover most use cases.\n\t\nYou can use the built in Golang cross compiling commands `go build` to compile for another operating system. \n\nAs an example for linux arm you need to pass in the `GOOS` and `GOARCH` arguments\n\n```bash\n$ GOOS=linux GOARCH=arm go build -o ./dist/index ./golang \u0026\u0026 chmod +x ./dist/index\n```\n\nWith the above command you can simply run `./index` and CycleTLS should function as intended.\n\nUse this [gist](https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63) for different Operating Systems that support cross-compilation and feel free to open an [Issue](https://github.com/Danny-Dasilva/CycleTLS/issues/new/choose) with a feature request for your specific operating system use case. \n\n\u003c/details\u003e\n\n## LICENSE\n### GPL3 LICENSE SYNOPSIS\n\n**_TL;DR_*** Here's what the GPL3 license entails:\n\n```markdown\n1. Anyone can copy, modify and distribute this software.\n2. You have to include the license and copyright notice with each and every distribution.\n3. You can use this software privately.\n4. You can use this software for commercial purposes.\n5. Source code MUST be made available when the software is distributed.\n6. Any modifications of this code base MUST be distributed with the same license, GPLv3.\n7. This software is provided without warranty.\n8. The software author or license can not be held liable for any damages inflicted by the software.\n```\n\nMore information on about the [LICENSE can be found here](http://choosealicense.com/licenses/gpl-3.0/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDanny-Dasilva%2FCycleTLS","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDanny-Dasilva%2FCycleTLS","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDanny-Dasilva%2FCycleTLS/lists"}