{"id":23046432,"url":"https://github.com/globaltechinfo/web-pair-qr","last_synced_at":"2025-08-15T00:33:16.483Z","repository":{"id":264631265,"uuid":"893143971","full_name":"GlobalTechInfo/WEB-PAIR-QR","owner":"GlobalTechInfo","description":"Session Id Generator For Whatsapp Bots Using Mega","archived":false,"fork":false,"pushed_at":"2025-06-09T17:15:32.000Z","size":183,"stargazers_count":6,"open_issues_count":0,"forks_count":72,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-09T18:24:51.227Z","etag":null,"topics":["baileys","baileys-bot","baileys-md","bot","express-pairing","express-session","pair","pair-code","pairing","qr-code","qrcode","qrcode-generator","qrcode-scanner","session","whatsapp","whatsapp-api","whatsapp-automation","whatsapp-bot","whatsapp-web","whatsappbot"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GlobalTechInfo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2024-11-23T16:45:23.000Z","updated_at":"2025-06-09T17:15:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"67887dc6-3237-4b39-89e1-3842edb4a462","html_url":"https://github.com/GlobalTechInfo/WEB-PAIR-QR","commit_stats":null,"previous_names":["globaltechinfo/web-pair-qr"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/GlobalTechInfo/WEB-PAIR-QR","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GlobalTechInfo%2FWEB-PAIR-QR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GlobalTechInfo%2FWEB-PAIR-QR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GlobalTechInfo%2FWEB-PAIR-QR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GlobalTechInfo%2FWEB-PAIR-QR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GlobalTechInfo","download_url":"https://codeload.github.com/GlobalTechInfo/WEB-PAIR-QR/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GlobalTechInfo%2FWEB-PAIR-QR/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270505601,"owners_count":24596501,"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","status":"online","status_checked_at":"2025-08-14T02:00:10.309Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["baileys","baileys-bot","baileys-md","bot","express-pairing","express-session","pair","pair-code","pairing","qr-code","qrcode","qrcode-generator","qrcode-scanner","session","whatsapp","whatsapp-api","whatsapp-automation","whatsapp-bot","whatsapp-web","whatsappbot"],"created_at":"2024-12-15T22:24:29.869Z","updated_at":"2025-08-15T00:33:16.473Z","avatar_url":"https://github.com/GlobalTechInfo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Session Id Generator For WhatsApp Bots Using Mega\n\n**It Will Uploads Your Creds To Mega And Will Sends You Id Of That File.**\n\n\n**How Session Id Will Works?**\n\u003cdetails\u003e\n  \u003csummary\u003eClick Here To View?\u003c/summary\u003e\n  \u003cp\u003e\n\n  ```js\nimport { fileURLToPath } from 'url'; \n\nimport path from 'path'; \n\nimport { writeFileSync } from 'fs'; \n\nimport * as mega from 'megajs'; \n// This imports everything from the `megajs` module (which is a JavaScript library to interact with Mega.nz) as an object `mega`.\n// This module allows interacting with files stored on the Mega cloud storage.\n\nasync function SaveCreds(txt) { \n  // Declares an asynchronous function named `SaveCreds` that takes `txt` as an argument. The function will save credentials ( in JSON format) to a local file.\n\n  const __filename = fileURLToPath(import.meta.url); \n  // `import.meta.url` gives the URL of the current module. The `fileURLToPath` function converts that URL to a file path for the current file.\n\n  const __dirname = path.dirname(__filename); \n  // `path.dirname` extracts the directory name from the `__filename` path, so it provides the path to the directory containing the current file.\n\n  const megaCode = txt.replace('', ''); \n  //if you did used some prefix before the session id\n\n  const megaUrl = `https://mega.nz/file/${megaCode}`; \n  // Creates a Mega URL using the `file id` . It constructs the full URL to access the file stored on Mega.\n\n  console.log(megaUrl); \n  // Logs the generated Mega URL to the console for debugging or confirmation purposes.\n\n  const file = mega.File.fromURL(megaUrl); \n  // Uses the `mega.File.fromURL` method from `megajs` to create a `file` object from the Mega URL. This object represents the file to be downloaded.\n\n  try {\n\n    const stream = file.download(); \n    // Downloads the file from Mega as a stream. This returns a readable stream of the file's data.\n\n    let data = ''; \n    // Initializes an empty string `data` to accumulate the chunks of data downloaded from the stream.\n\n    for await (const chunk of stream) { \n      // Iterates over each chunk in the stream asynchronously (i.e., handles the data as it is downloaded).\n      \n      data += chunk.toString(); \n      // Converts each chunk (which may be a Buffer) to a string and appends it to the `data` variable.\n    }\n\n    const credsPath = path.join(__dirname, '..', 'session', 'creds.json'); \n    // Joins several path segments to form the path to save the credentials file (it goes up one directory level and then to `session/creds.json`).\n\n    writeFileSync(credsPath, data); \n    // Writes the `data` (credentials) to the `creds.json` file synchronously at the specified `credsPath`.\n\n    console.log('Saved credentials to', credsPath); \n    // Logs a message to the console indicating that the credentials were successfully saved to the specified path.\n\n  } catch (error) { \n    // If an error occurs during the download or file writing process, this block catches it.\n\n    console.error('Error downloading or saving credentials:', error); \n    // Logs the error message to the console, providing feedback if something goes wrong.\n  }\n}\n\nexport default SaveCreds; \n// Exports the `SaveCreds` function as the default export of this module, making it available for use in main file.\n\n\n//Now Import Function In Main File\ndotenv.config()\nimport SaveCreds from './some-file.js'\n\nasync function main() {\n  const txt = process.env.SESSION_ID\n\n  if (!txt) {\n    console.error('Environment variable not found.')\n    return\n  }\n\n  try {\n    await SaveCreds(txt)\n    console.log('process SaveCreds completed.')\n  } catch (error) {\n    console.error('Error:', error)\n  }\n}\n\nmain()\n// Now Use Further code \n```\n\u003c/p\u003e\n\u003c/details\u003e\n\n\nCRAFTED USING TEMPLATES OF SUHAILTECHINFO ( QR )  AND PRABATH ( PAIR )\n\nBOTH PAIR CODE AND QR CODE WORKING\n\nYOU CAN DEPLOY IT ON ANY CLOUD PLATFORM e.g `HEROKU` `RENDER` `KOYEB` etc.\n\n**⭐ THE REPO IF YOU ARE GOING TO COPY OR FORK**\n\nNote: Make Sure Add Your Email And Password ( Required In mega.js ) Before Running/Deploying The API.\n\n## OTHER PROJECTS:\n\n- [PASTE SESSION](https://github.com/GlobalTechInfo/PAIRING-WEB)\n- [WHATSAPP BOT](https://github.com/GlobalTechInfo/MEGA-AI)\n- [TELEGRAM BOT](https://github.com/GlobalTechInfo/TELEGRAM-AI#readme)\n\n\n\n| [![Qasim Ali](https://github.com/GlobalTechInfo.png?size=100)](https://github.com/GlobalTechInfo) |\n| --- |\n| [Qasim Ali](https://github.com/GlobalTechInfo) |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglobaltechinfo%2Fweb-pair-qr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglobaltechinfo%2Fweb-pair-qr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglobaltechinfo%2Fweb-pair-qr/lists"}