{"id":15062224,"url":"https://github.com/cawfree/sameorigin","last_synced_at":"2025-04-10T10:04:14.072Z","repository":{"id":132561756,"uuid":"611925691","full_name":"cawfree/sameorigin","owner":"cawfree","description":"🤖 🧪 Masquerade as if you were their own frontend.","archived":false,"fork":false,"pushed_at":"2023-09-26T12:30:49.000Z","size":91,"stargazers_count":27,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-31T05:31:56.972Z","etag":null,"topics":["axios","blur","bypass","cloudflare","cors","exploit","marketplace","nft","opensea","puppeteer"],"latest_commit_sha":null,"homepage":"https://twitter.com/cawfree","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cawfree.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":"2023-03-09T20:36:07.000Z","updated_at":"2025-01-02T11:27:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"c52f4f77-0f1f-497e-a6b1-7db44a817e0c","html_url":"https://github.com/cawfree/sameorigin","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"b486f2a4d5ddaac9da10c3368c31bd67ece8ee4a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cawfree%2Fsameorigin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cawfree%2Fsameorigin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cawfree%2Fsameorigin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cawfree%2Fsameorigin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cawfree","download_url":"https://codeload.github.com/cawfree/sameorigin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248198878,"owners_count":21063627,"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":["axios","blur","bypass","cloudflare","cors","exploit","marketplace","nft","opensea","puppeteer"],"created_at":"2024-09-24T23:32:25.311Z","updated_at":"2025-04-10T10:04:14.036Z","avatar_url":"https://github.com/cawfree.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## `@cawfree/sameorigin`\n🤖 🧪 Masquerade as if you were their own frontend.\n\n[`sameorigin`](https://github.com/cawfree/sameorigin) generalizes the process of [__Same-Origin-Resource-Crossing__](https://github.com/cawfree/opensea-submarine), which allows you to work around the domain-based restrictions centralized services use to protect their APIs from third parties.\n\n###  🚀 Getting Started\n\nYou can install [`sameorigin`](https://github.com/cawfree/sameorigin) via [`yarn`](https://yarnpkg.com):\n\n```shell\nyarn add @cawfree/sameorigin\n```\n\nNext, declare the domain you wish to squat on. In the following example, let's assume I want to bypass the [__CloudFlare__](https://www.cloudflare.com/) restrictions on the [__Blur Marketplace__](https://blur.io/):\n\n\n```typescript\nimport {sameorigin} from '@cawfree/sameorigin';\n\nconst [axios, {close}] = await sameorigin({\n  // Define the website url that has access permissions and generates some requests.\n  squatURL: 'https://blur.io/airdrop',\n});\n\nconst {data} = await axios({\n  // Important! You must declare the baseURL of the API you intend\n  // to target. This is because it is used to isolate requests you\n  // intend to hijack for your own purposes.\n  baseURL: 'https://core-api.prod.blur.io/v1',\n    \n  // GET https://core-api.prod.blur.io/v1/prices\n  url: '/prices',\n  method: 'get',\n});\n\n// Once finished, you'll need to close your client to prevent\n// memory leaks.\nawait close();\n```\n\n\u003e **Warning**\n\u003e \n\u003e Some interfaces defend against tools like `sameorigin` by making an analysis of the runtime window. If you find your requests are being rejected, please instantiate `sameorigin` using `headless: false` as a workaround.\n\n### 🤔 How does it work?\n\nWhen making a call to [`sameorigin`](https://github.com/cawfree/sameorigin), we allocate an instance of [`puppeteer`](https://github.com/puppeteer/puppeteer) in the background which is used to capture requests and serve as a trusted origin for API requests to originate from.\n\nWe make the page available via an [`express`](https://expressjs.com/) server which manages the life cycle of pages, captures requests which satisfy CloudFlare's protections and dynamically inject them with custom query data.\n\nThis process is masked behind the returned [`axios`](https://github.com/axios/axios) client. The underlying process of squatting on pages, hijacking requests and returning the data as if it were a conventional fetch request are abstracted away from the caller.\n\n### ✌️ License\n[__CC0-1.0__](./LICENSE)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcawfree%2Fsameorigin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcawfree%2Fsameorigin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcawfree%2Fsameorigin/lists"}