diff --git a/.gitignore b/.gitignore index c6bba59..e99ad2a 100644 --- a/.gitignore +++ b/.gitignore @@ -128,3 +128,6 @@ dist .yarn/build-state.yml .yarn/install-state.gz .pnp.* + +# working directory files +captcha.jpg \ No newline at end of file diff --git a/.npmignore b/.npmignore index a19c46b..87bbfe8 100644 --- a/.npmignore +++ b/.npmignore @@ -4,4 +4,5 @@ test/ .gitignore api_reference.md contribution.md -_config.yml \ No newline at end of file +_config.yml +captcha.jpg \ No newline at end of file diff --git a/README.md b/README.md index 08196b2..8b28786 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ -# irctc-api A package built on top of IRCTC Website APIs to book train tickets, managing user profile faster and simpler. Currently this package only works on NodeJs environment and we were not recommending this to use on browser or any other Javascript environment. [![NPM Downloads](https://img.shields.io/npm/dw/irctc-api)](https://www.npmjs.com/package/irctc-api) -[![Node Current](https://img.shields.io/node/v/irctc-api)](https://www.npmjs.com/package/irctc-api) +[![Dynamic JSON Badge](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fsuryavaddiraju%2Firctc-api%2Fmain%2Fpackage.json&query=engines.node&label=node)](https://www.npmjs.com/package/irctc-api) [![Contributors](https://img.shields.io/github/contributors/suryavaddiraju/irctc-api.svg)](https://github.com/suryavaddiraju/irctc-api/graphs/contributors) [![GitHub License](https://img.shields.io/github/license/suryavaddiraju/irctc-api)](http://www.apache.org/licenses/LICENSE-2.0) -[![NPM Version](https://img.shields.io/npm/v/irctc-api)](https://www.npmjs.com/package/irctc-api) +[![Dynamic JSON Badge](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fsuryavaddiraju%2Firctc-api%2Fmain%2Fpackage.json&query=version&label=version)](https://www.npmjs.com/package/irctc-api) [![GitHub Issues or Pull Requests](https://img.shields.io/github/issues/suryavaddiraju/irctc-api)](https://github.com/suryavaddiraju/irctc-api/issues) [![GitHub last commit](https://img.shields.io/github/last-commit/suryavaddiraju/irctc-api)](https://github.com/suryavaddiraju/irctc-api) [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/suryavaddiraju/irctc-api/node.js.yml)](https://github.com/suryavaddiraju/irctc-api/actions/workflows/node.js.yml) @@ -78,9 +77,9 @@ To send a request, you: const client = new IRCTC(); const params = { - /** input parameters */ + // refer https://dev.vaddiraju.in/irctc-api/api_reference#book_input }; -const command = client.book(params); +const command = await client.book(params); ``` #### Async/await diff --git a/_config.yml b/_config.yml index 9700859..e42f909 100644 --- a/_config.yml +++ b/_config.yml @@ -1,4 +1,7 @@ google_analytics: G-L0BXR0ZGW7 +author: + name: Vaddiraju Surya Teja + email: "suryavaddiraju@proton.me" remote_theme: jekyll/minima plugins: - jekyll-remote-theme diff --git a/api_reference.md b/api_reference.md index 71b2df8..f1df4a8 100644 --- a/api_reference.md +++ b/api_reference.md @@ -1,11 +1,9 @@ --- layout: page -title: "API Reference | irctc-api | A Node Js Package to book tickets within system terminal" +title: "API Reference" permalink: /api_reference --- -# API Reference - To install the this package, simply type i or install irctc-api using the node package manager ```shell @@ -16,6 +14,224 @@ npm install irctc-api GitHub Logo npm Logo Documentation Logo +## book + +This is the heart of the package, where the whole intention for creation of this package is to book tickets in node js without use of any kind of drivers or browsers with simple input params and inbuilt payment completion capability. + +Currently Payment through UPI is only supported + +RoadMap to accept GST details is in process +[Example Usage](https://github.com/suryavaddiraju/irctc-api/blob/main/examples/book_ticket.js) + +```js +// some_fuction.mjs +import {IRCTC} from "irctc-api"; +const irctc = new IRCTC(); +const params = { + // refer book_input +}; +const response = await irctc.book(params); +console.log(response); +``` + +## book_input + +`book` function in IRCTC class takes input as a javascript object, where they are explained below + +`Mandatory Keys` + +- UPI + - Must be a string and have atleast three characters including `@` + - Must be a active UPI ID issued under NPCI UPI Guidlines + - It must be linked to atleast 1 bank account + - It must be capable of handling UPI collect requests +- class + - Must be a string and length must be between `2,3 or 4` + - short code name of Train Class that you are intending to travel by + - Can be anyone of the following `2A | 3A | SL | CC | 2S | FC | 1A | 3E` +- quota + - Must be a string and length must be 2 + - code of the quota that you want to book the tickets + - can be anyone of the following `GN | TQ | PT` +- train_number + - Must be a String and length must be 5 + - Defines the Identity of the train as code number given by indian railways +- from + - Must be a string and should match the with the list of existing station code names + - Must be short code of the station from where you are boarding + - The Train must pass by and have a stop at this station +- to + - Must be a string and should match the with the list of existing station code names + - Must be short code of the station to where you are travelling + - The Train must pass by and have a stop at this station +- journey_date + - Must be a String and in `YYYYMMDD` format + - The date on which you are boarding the train +- mobile_number + - Must be as string and length must be 10 + - Active Indian Mobile Number +- userID + - Must be a string + - Must be a valid user id given by IRCTC upon registering through their portal +- password + - Must be a string + - Must be linked to the userID + - Throws a error if its wrong + - Must not be expired + - You have to login atleast once using the password in the IRCTC website before using it here + - Must verify mobile number and email ID in the portal before using the credentials here +- coach + - Must be a String + - Preferred Coach for total ticket + - Must be related to the class of the ticket +- passengers + - Must be a List and Contains Javascript Object of Each Passenger details + - Passengers list must contain maximum of 6 passengers for General + - Passengers list must contain maximum of 4 passengers for tatkal and Premium Tatkal + - Each passenger details must be enclosed in an javascript object format and include them in passengers list main field + - Each Passenger Object Contains + - name + - Must be a string and Mandatory Field + - The Name of the passenger, who takes the journey + - Must match match with any one of their Nationally accepted ID Cards + - The Name is sliced to 16 characters if you give more than 16 characters + - age + - Must be string and Mandatory + - The age of the passenger + - Must be between 5 and 125 + - sex + - Must be a string and mandatory + - Gender of the passenger + - Acceptable genders `M or F` + - food + - Must be a string and Mandatory + - The Food choice need to be empty string if the train does not serves the food + - acceptable values `"V" | "N" | "D" | ""` + - berth + - Must be a string and Optional Parameter - Default to null + - This is the preferred berth that the passenger is opting and instructing IRCTC to book on the preferred berth + - However, IRCTC can not give guarantee on preferred berth opton + - Values can be any one of the items `LB | UB | SL | SU | MB | WS` + - country + - Must be a string and Optional Parameter - Defaults to IN + - ISO Country Code of the Passenger Nationality + +The example input is as follows + +```js +{ + "UPI": "9876543210@ybl", + "class": "2S", + "quota": "GN", + "train_number": "17201", + "from": "GNT", + "to": "PDKN", + "journey_date": "20240530", + "mobile_number": "9876543210", + "userID": "XXXXX", + "password": "XXXXXXX", + "passengers": [ + { + "age": "22", + "food": "", + "name": "Virat Kohli", + "sex": "M", + "berth":"WS" + }, + { + "age": "21", + "food": "", + "name": "Anushka Sharma", + "sex": "F", + "country":"Uk" + } + ], + "coach":"D1" +}; +``` + +## book_output + +The output is to be standardized and will be documented in future, currently Raw IRCTC data is sent as output + +## last_transaction + +The last transaction is the function which gives the status of last transaction initiated through the given userID + +[Example Usage](https://github.com/suryavaddiraju/irctc-api/blob/main/examples/last_txn_status.js) + +```js +import {IRCTC} from "irctc-api"; +const irctc = new IRCTC(); +const params = { + // refer last_transaction_input +}; +const response = await irctc.last_transaction(params); +console.log(response); +``` + +## last_transaction_input + +`last_transaction` function in IRCTC class takes input as a javascript object, where they are explained below + +`Mandatory Keys` + +- userID + - Must be a string + - Must be a valid user id given by IRCTC upon registering through their portal +- password + - Must be a string + - Must be linked to the userID + - Throws a error if its wrong + - Must not be expired + - You have to login atleast once using the password in the IRCTC website before using it here + - Must verify mobile number and email ID in the portal before using the credentials here + +## last_transaction_output + +The output is to be standardized and will be documented in future, currently Raw IRCTC data is sent as output + +## pnr_status + +The PNR Status is the function which gives the status of PNR of a transaction initiated through the given userID + +[Example Usage](https://github.com/suryavaddiraju/irctc-api/blob/main/examples/get_pnr_status.js) + +```js +import {IRCTC} from "irctc-api"; +const irctc = new IRCTC(); +const params = { + // refer pnr_status_input +}; +const response = await irctc.pnr_status(params); +console.log(response); +``` + +## pnr_status_input + +`pnr_status` function in IRCTC class takes input as a javascript object, where they are explained below + +`Mandatory Keys` + +- userID + - Must be a string + - Must be a valid user id given by IRCTC upon registering through their portal +- password + - Must be a string + - Must be linked to the userID + - Throws a error if its wrong + - Must not be expired + - You have to login atleast once using the password in the IRCTC website before using it here + - Must verify mobile number and email ID in the portal before using the credentials here +- pnr + - Must be a string + - Must have a length of 10 + - Must be linked to anytransaction of the USER + +## pnr_status_output + +The output is to be standardized and will be documented in future, currently Raw IRCTC data is sent as output + ## Copyright All Rights Reserved. © Vaddiraju Surya Teja, 2024 diff --git a/contribution.md b/contribution.md index dcf1836..5749886 100644 --- a/contribution.md +++ b/contribution.md @@ -1,11 +1,9 @@ --- layout: page -title: "Contribution | irctc-api | A Node Js Package to book tickets within system terminal" +title: "Contribution" permalink: /contribution --- -# Contribution - You need to fork the repository and then rasie a pull request and when the pull request is approved your changes will be applied to next scheduled release ## Useful Links diff --git a/examples/book_ticket.js b/examples/book_ticket.js index 399add9..1e76487 100644 --- a/examples/book_ticket.js +++ b/examples/book_ticket.js @@ -15,7 +15,8 @@ const params = { "age": "22", // Age of Passenger "food": "", // Food Preference - Leave as Empty string, if food is not required "name": "Virat Kohli", // Full Name of Passenger - "sex": "M" // Sex of Passenger - M | F + "sex": "M", // Sex of Passenger - M | F + "berth":"WS" // optional, Preferred Berth Code - LB | UB | SL | SU | MB | WS }, { "age": "21", // Age of Passenger @@ -23,7 +24,8 @@ const params = { "name": "Anushka Sharma", // Full Name of Passenger "sex": "F" // Sex of Passenger - M | F } - ] + ], + "coach":"D1", // Optional, Preferred Coach Code }; async function custom_command_name(params) { try{ diff --git a/lib/time_work.mjs b/lib/time_work.mjs index e91aa7f..1b7da45 100644 --- a/lib/time_work.mjs +++ b/lib/time_work.mjs @@ -2,32 +2,44 @@ function sleep(ms){ return new Promise(resolve => setTimeout(resolve, ms)); } +const psg_input_await = { + 1:20000, + 2:20000, + 3:25000, + 4:25000, + 5:30000, + 6:30000, +} + +async function psg_input_wait(psg_count){ + const sleep_time = psg_input_await[psg_count]; + console.log(`Sleeping for ${sleep_time * 0.001} seconds for passenger details input.`); + await sleep(sleep_time); +} + async function sleep_for_login(ticket_time){ - if (ticket_time === 1 || ticket_time === 2){ - if (ticket_time === 1){ - const currentTime = new Date(); - const targetTime = new Date(currentTime); - targetTime.setUTCHours(4, 28, 0, 0); - if (currentTime < targetTime) { - await sleep(targetTime - currentTime); - } - else{ - return "No Sleep Required"; - } + if (ticket_time === 1){ + const currentTime = new Date(); + const targetTime = new Date(currentTime); + targetTime.setUTCHours(4, 28, 0, 0); + if (currentTime < targetTime) { + await sleep(targetTime - currentTime); + return "Proceeding to Login"; + } + else{ + return "No Sleep Required"; } - else if (ticket_time === 2){ - const currentTime = new Date(); - const targetTime = new Date(currentTime); - targetTime.setUTCHours(5, 28, 0, 0); - if (currentTime < targetTime) { - await sleep(targetTime - currentTime); - } - else{ - return "No Sleep Required"; - } + } + else if (ticket_time === 2){ + const currentTime = new Date(); + const targetTime = new Date(currentTime); + targetTime.setUTCHours(5, 28, 0, 0); + if (currentTime < targetTime) { + await sleep(targetTime - currentTime); + return "Proceeding to Login"; } else{ - throw new Error("Invalid ticket_time parameter"); + return "No Sleep Required"; } } else{ @@ -36,31 +48,35 @@ async function sleep_for_login(ticket_time){ } async function sleep_for_availability_check(ticket_time){ - if (ticket_time === 1 || ticket_time === 2){ - if (ticket_time === 1){ - const currentTime = new Date(); - const targetTime = new Date(currentTime); - targetTime.setUTCHours(4, 30, 1, 0); - if (currentTime < targetTime) { - await sleep(targetTime - currentTime); - } + if (ticket_time === 1){ + const currentTime = new Date(); + const targetTime = new Date(currentTime); + targetTime.setUTCHours(4, 30, 1, 0); + if (currentTime < targetTime) { + await sleep(targetTime - currentTime); + return "Proceeding to Check Availability"; + } + else{ + return "No Sleep Required"; } - if (ticket_time === 2){ - const currentTime = new Date(); - const targetTime = new Date(currentTime); - targetTime.setUTCHours(5, 30, 1, 0); - if (currentTime < targetTime) { - await sleep(targetTime - currentTime); - } + } + else if (ticket_time === 2){ + const currentTime = new Date(); + const targetTime = new Date(currentTime); + targetTime.setUTCHours(5, 30, 1, 0); + if (currentTime < targetTime) { + await sleep(targetTime - currentTime); + return "Proceeding to Check Availability"; } else{ - throw new Error("Invalid ticket_time parameter"); + return "No Sleep Required"; } } else{ return "No Sleep Required"; } } + function start_before_3_minutes(ticket_time){ if (ticket_time === 1) { const currentTime = new Date(); @@ -88,4 +104,5 @@ function start_before_3_minutes(ticket_time){ return "Proceeding to Book Tickets"; } } -export {sleep, sleep_for_login, sleep_for_availability_check, start_before_3_minutes}; \ No newline at end of file + +export {sleep, psg_input_wait, sleep_for_login, sleep_for_availability_check, start_before_3_minutes}; \ No newline at end of file diff --git a/lib/utils.mjs b/lib/utils.mjs index 631f847..ea842fb 100644 --- a/lib/utils.mjs +++ b/lib/utils.mjs @@ -1,4 +1,3 @@ -import fs from 'fs'; import readline from 'readline'; import {start_before_3_minutes} from "./time_work.mjs"; import { stations_list } from './stations.mjs'; @@ -7,37 +6,37 @@ async function verify_booking_params(params) { if (!params.quota || !params.class || !params.train_number || !params.journey_date || !params.from || !params.to || !params.userID || !params.password || !params.passengers || !params.UPI || !params.mobile_number) { throw new Error("Missing parameters\nThe required parameters are quota, class, train_number, journey_date, from, to, userID, password, passengers, UPI, mobile_number"); } - else if (typeof params.quota !== "string" || params.quota.length !== 2 || !["GN","TQ","PT"].includes(params.quota)){ + if (typeof params.quota !== "string" || params.quota.length !== 2 || !["GN","TQ","PT"].includes(params.quota)){ throw new Error("Invalid quota parameter"); } - else if (typeof params.class !== "string" || params.class.length !== 2 || !["1A","2A","3A","3E","EC","CC","FC","SL","2S"].includes(params.class)){ + if (typeof params.class !== "string" || params.class.length !== 2 || !["1A","2A","3A","3E","EC","CC","FC","SL","2S"].includes(params.class)){ throw new Error("Invalid class parameter"); } - else if (typeof params.train_number !== "string" || params.train_number.length !== 5){ + if (typeof params.train_number !== "string" || params.train_number.length !== 5){ throw new Error("Invalid train_number parameter"); } - else if (typeof params.journey_date !== "string" || params.journey_date.length !== 8){ + if (typeof params.journey_date !== "string" || params.journey_date.length !== 8){ throw new Error("Invalid journey_date parameter"); } - else if (typeof params.from !== "string" || params.from.length < 2 || params.from.length > 4 || !stationsList.includes(params.from)){ + if (typeof params.from !== "string" || params.from.length < 2 || params.from.length > 4 || !stationsList.includes(params.from)){ throw new Error("Invalid from parameter"); } - else if (typeof params.to !== "string" || params.to.length < 2 || params.to.length > 4 || !stationsList.includes(params.to)){ + if (typeof params.to !== "string" || params.to.length < 2 || params.to.length > 4 || !stationsList.includes(params.to)){ throw new Error("Invalid to parameter"); } - else if (typeof params.userID !== "string" || params.userID.length === 0){ + if (typeof params.userID !== "string" || params.userID.length === 0){ throw new Error("Invalid userID parameter"); } - else if (typeof params.password !== "string" || params.password.length === 0){ + if (typeof params.password !== "string" || params.password.length === 0){ throw new Error("Invalid password parameter"); } - else if (!Array.isArray(params.passengers) || params.passengers.length === 0 || params.passengers.length > 6){ + if (!Array.isArray(params.passengers) || params.passengers.length === 0 || params.passengers.length > 6){ throw new Error("Invalid passengers parameter"); } - else if (typeof params.UPI !== "string" || params.UPI.length < 4 || !params.UPI.includes("@")){ + if (typeof params.UPI !== "string" || params.UPI.length < 4 || !params.UPI.includes("@")){ throw new Error("Invalid UPI parameter"); } - else if (typeof params.mobile_number !== "string" || params.mobile_number.length !== 10){ + if (typeof params.mobile_number !== "string" || params.mobile_number.length !== 10){ throw new Error("Invalid mobile_number parameter"); } for (let passenger of params.passengers) { @@ -53,6 +52,40 @@ async function verify_booking_params(params) { throw new Error("Invalid food parameter"); } } + if ("gst" in params) { + if (params.gst && typeof params.gst === "object"){ + if (params.gst.hasOwnProperty("gstin")){ + if (typeof params.gst.gstin === "string" && params.gst.gstin.length === 15){ + if (!gst_check(params.gst.gstin)){ + throw new Error("Invalid gstin"); + } + } + else{ + throw new Error("Invalid gstin parameter"); + } + } + else{ + throw new Error("gstin number is mandatory in gst object"); + } + if (params.gst.hasOwnProperty("pincode")){ + if (typeof params.gst.pincode === "string" && params.gst.pincode.length === 6){ + const posrtalCode = /^[1-9][0-9]{5}$/; + if (!posrtalCode.test(params.gst.pincode)){ + throw new Error("Invalid postal code"); + } + } + else{ + throw new Error("Invalid pincode parameter"); + } + } + else{ + throw new Error("pincode number is mandatory in gst object"); + } + } + else{ + throw new Error("Invalid gst parameter"); + } + } if (["TQ", "PT"].includes(params.quota) && ["2A","3A","EC","CC","3E"].includes(params.class)){ params.ticket_time = 1; } @@ -120,13 +153,19 @@ function generatePassenger(params) { if (passenger['food'] !== '') { passengerDetails['passengerFoodChoice'] = passenger['food']; } - + if (passenger['berth']) { + passengerDetails['passengerBerthChoice'] = passenger['berth']; + } + if (passenger["country"]){ + passengerDetails['passengerNationality'] = passenger["country"]; + } + food.push(passenger['food']); // Add the passenger details to the list passengers.push(passengerDetails); } - + params.psg_count = count; let foodList = [...new Set(food)]; if (foodList.includes('') && foodList.length > 1) { @@ -148,6 +187,9 @@ async function initialize_booking_variables(params){ params.quota_type = params.params.quota; params.upiid = params.params.UPI; params.mobile_number = params.params.mobile_number; + if (params.params.gst){ + params.gst = params.params.gst; + } } function input(prompt) { let rl = readline.createInterface({ @@ -166,23 +208,27 @@ function base64DecodeUnicode(e) { o[a] = "%" + ("00" + o[a].charCodeAt(0).toString(16)).slice(-2); return decodeURIComponent(o.join("")) } -async function verify_txn_params(params){ - if (!params.userID || !params.password) { - throw new Error("Missing parameters\nThe required parameters are quota, class, train_number, journey_date, from, to, userID, password, passengers, UPI, mobile_number"); - } - else if (typeof params.userID !== "string" || params.userID.length === 0){ - throw new Error("Invalid userID parameter"); - } - else if (typeof params.password !== "string" || params.password.length === 0){ - throw new Error("Invalid password parameter"); - } - else{ - return "done"; - } + +function gst_check(value) { + const regex = /^([0-2][0-9]|[3][0-7])[A-Z]{3}[ABCFGHLJPTK][A-Z]\d{4}[A-Z][A-Z0-9][Z][A-Z0-9]$/; + return regex.test(value) && gstChecksum(value); } -async function initialize_txn_variables(params){ - params.username = params.params.userID; - params.password = btoa(params.params.password); - return "Done"; +function gstChecksum(value) { + if (!/^[0-9A-Z]{15}$/.test(value)) { + return false; + } + const chars = [...'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ']; + const values = [...value]; + const lastChar = values.pop(); + const sum = values + .map((char, index) => { + const product = chars.indexOf(char) * (index % 2 !== 0 ? 2 : 1); + return Math.floor(product / chars.length) + (product % chars.length); + }) + .reduce((prev, current) => { + return prev + current; + }); + const checksum = (chars.length - (sum % chars.length)) % chars.length; + return chars[checksum] === lastChar; } -export {verify_booking_params, initialize_booking_variables, input, base64DecodeUnicode, verify_txn_params, initialize_txn_variables} \ No newline at end of file +export {verify_booking_params, initialize_booking_variables, input, base64DecodeUnicode} \ No newline at end of file diff --git a/lib/workings.mjs b/lib/workings.mjs index 75fc54d..48ab124 100644 --- a/lib/workings.mjs +++ b/lib/workings.mjs @@ -6,8 +6,8 @@ import * as cheerio from 'cheerio'; import querystring from 'querystring'; import { exec } from 'child_process'; import { URL } from 'url'; -import {verify_booking_params, initialize_booking_variables, input, base64DecodeUnicode,verify_txn_params, initialize_txn_variables} from './utils.mjs'; -import { sleep, sleep_for_login, sleep_for_availability_check} from "./time_work.mjs"; +import {verify_booking_params, initialize_booking_variables, input, base64DecodeUnicode} from './utils.mjs'; +import { psg_input_wait, sleep_for_login, sleep_for_availability_check} from "./time_work.mjs"; import {headers as main_headers} from './browser_headers.mjs'; class IRCTC{ constructor(){ @@ -303,6 +303,9 @@ class IRCTC{ "error": null } }; + if (this.params.coach){ + postdata.lapAvlRequestDTO[0].coachId = this.params.coach; + } const postdata_string = JSON.stringify(postdata); const headers = main_headers.headers_9; headers.greq = this.captcha_status; @@ -310,7 +313,7 @@ class IRCTC{ headers['spa-csrf-token'] = this.csrf_token; headers.bmiyek = this.user_hash; headers["Content-Length"] = postdata_string.length.toString(); - await sleep(21000); + await psg_input_wait(this.psg_count); const response = await this.axios_instance.post( "https://www.irctc.co.in/eticketing/protected/mapps1/allLapAvlFareEnq/Y", postdata_string, @@ -436,14 +439,7 @@ class IRCTC{ return "Gone to Paytm UPI Gateway Successfully"; } async paytm_pg_landing_page(){ - const $ = cheerio.load(this.paytm_params_d); - const script_tags = $('script').map((idx, el) => $(el).html()).toArray(); - let script_data = ""; - for (const script of script_tags) { - if (script.includes('pushAppData="')){ - script_data += script; - } - } + let script_data = this.paytm_params_d; const pushAppData = script_data.split('pushAppData="')[1].split('",encodeFlag=')[0]; const encodeFlag = script_data.split(',encodeFlag="')[1].split('";')[0]; let D = "true" == encodeFlag ? JSON.parse(base64DecodeUnicode(pushAppData)) : JSON.parse(pushAppData); diff --git a/package-lock.json b/package-lock.json index 624e136..c9f94d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,542 +1,425 @@ { - "name": "irctc-api", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "dependencies": { - "axios": "^1.6.5", - "axios-cookiejar-support": "^5.0.0", - "cheerio": "^1.0.0-rc.12", - "open": "^10.0.3", - "tough-cookie": "^4.1.3" - } - }, - "node_modules/agent-base": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz", - "integrity": "sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==", - "dependencies": { - "debug": "^4.3.4" - }, - "engines": { - "node": ">= 14" - } - }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" - }, - "node_modules/axios": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.5.tgz", - "integrity": "sha512-Ii012v05KEVuUoFWmMW/UQv9aRIc3ZwkWDcM+h5Il8izZCtRVpDUfwpoFf7eOtajT3QiGR4yDUx7lPqHJULgbg==", - "dependencies": { - "follow-redirects": "^1.15.4", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" - } - }, - "node_modules/axios-cookiejar-support": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/axios-cookiejar-support/-/axios-cookiejar-support-5.0.0.tgz", - "integrity": "sha512-4zdO95qgsKp0OX+LUwD0MRWdD0r5YsQBpTi3ULHLL87qU58QZl3O3UQF58fZTzcdGtxYPtcotyXT7sNWDE37ug==", - "dependencies": { - "http-cookie-agent": "^6.0.1" - }, - "engines": { - "node": ">=18.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/3846masa" - }, - "peerDependencies": { - "axios": ">=0.20.0", - "tough-cookie": ">=4.0.0" - } - }, - "node_modules/boolbase": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", - "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==" - }, - "node_modules/bundle-name": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-4.1.0.tgz", - "integrity": "sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q==", - "dependencies": { - "run-applescript": "^7.0.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/cheerio": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.12.tgz", - "integrity": "sha512-VqR8m68vM46BNnuZ5NtnGBKIE/DfN0cRIzg9n40EIq9NOv90ayxLBXA8fXC5gquFRGJSTRqBq25Jt2ECLR431Q==", - "dependencies": { - "cheerio-select": "^2.1.0", - "dom-serializer": "^2.0.0", - "domhandler": "^5.0.3", - "domutils": "^3.0.1", - "htmlparser2": "^8.0.1", - "parse5": "^7.0.0", - "parse5-htmlparser2-tree-adapter": "^7.0.0" - }, - "engines": { - "node": ">= 6" - }, - "funding": { - "url": "https://github.com/cheeriojs/cheerio?sponsor=1" - } - }, - "node_modules/cheerio-select": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-2.1.0.tgz", - "integrity": "sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==", - "dependencies": { - "boolbase": "^1.0.0", - "css-select": "^5.1.0", - "css-what": "^6.1.0", - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3", - "domutils": "^3.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/fb55" - } - }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/css-select": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz", - "integrity": "sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==", - "dependencies": { - "boolbase": "^1.0.0", - "css-what": "^6.1.0", - "domhandler": "^5.0.2", - "domutils": "^3.0.1", - "nth-check": "^2.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/fb55" - } - }, - "node_modules/css-what": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz", - "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==", - "engines": { - "node": ">= 6" - }, - "funding": { - "url": "https://github.com/sponsors/fb55" - } - }, - "node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/default-browser": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-5.2.1.tgz", - "integrity": "sha512-WY/3TUME0x3KPYdRRxEJJvXRHV4PyPoUsxtZa78lwItwRQRHhd2U9xOscaT/YTf8uCXIAjeJOFBVEh/7FtD8Xg==", - "dependencies": { - "bundle-name": "^4.1.0", - "default-browser-id": "^5.0.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/default-browser-id": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-5.0.0.tgz", - "integrity": "sha512-A6p/pu/6fyBcA1TRz/GqWYPViplrftcW2gZC9q79ngNCKAeR/X3gcEdXQHl4KNXV+3wgIJ1CPkJQ3IHM6lcsyA==", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/define-lazy-prop": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz", - "integrity": "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/dom-serializer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", - "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", - "dependencies": { - "domelementtype": "^2.3.0", - "domhandler": "^5.0.2", - "entities": "^4.2.0" - }, - "funding": { - "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" - } - }, - "node_modules/domelementtype": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", - "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/fb55" - } - ] - }, - "node_modules/domhandler": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", - "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", - "dependencies": { - "domelementtype": "^2.3.0" - }, - "engines": { - "node": ">= 4" - }, - "funding": { - "url": "https://github.com/fb55/domhandler?sponsor=1" - } - }, - "node_modules/domutils": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz", - "integrity": "sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==", - "dependencies": { - "dom-serializer": "^2.0.0", - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3" - }, - "funding": { - "url": "https://github.com/fb55/domutils?sponsor=1" - } - }, - "node_modules/entities": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", - "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, - "node_modules/follow-redirects": { - "version": "1.15.5", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", - "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, - "node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/htmlparser2": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.2.tgz", - "integrity": "sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==", - "funding": [ - "https://github.com/fb55/htmlparser2?sponsor=1", - { - "type": "github", - "url": "https://github.com/sponsors/fb55" - } - ], - "dependencies": { - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3", - "domutils": "^3.0.1", - "entities": "^4.4.0" - } - }, - "node_modules/http-cookie-agent": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/http-cookie-agent/-/http-cookie-agent-6.0.1.tgz", - "integrity": "sha512-AhPCqG7i3K8OVWORyuULoP7/Xv90wf14jBAKyLqjKpaJyGjutiwryYV+Lj1jqPYnQtbQFimwSaeY7NXw22TckQ==", - "dependencies": { - "agent-base": "^7.1.0" - }, - "engines": { - "node": ">=18.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/3846masa" - }, - "peerDependencies": { - "deasync": "^0.1.26", - "tough-cookie": "^4.0.0", - "undici": "^5.11.0 || ^6.0.0" - }, - "peerDependenciesMeta": { - "deasync": { - "optional": true - }, - "undici": { - "optional": true + "name": "irctc-api", + "version": "1.0.8", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "irctc-api", + "version": "1.0.8", + "license": "Apache-2.0", + "dependencies": { + "axios": "^1.6.8", + "axios-cookiejar-support": "^5.0.1", + "cheerio": "^1.0.0-rc.12", + "tough-cookie": "^4.1.3" + }, + "engines": { + "node": ">20.0.0", + "npm": ">10.0.0" + } + }, + "node_modules/agent-base": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz", + "integrity": "sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==", + "dependencies": { + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "node_modules/axios": { + "version": "1.6.8", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz", + "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/axios-cookiejar-support": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/axios-cookiejar-support/-/axios-cookiejar-support-5.0.1.tgz", + "integrity": "sha512-lwjyusKDJ1dLMRPnARWJCdcRXqmYvNITHnCQHRJGtIIL2QXj/lYPjMg04XZDp8QItzluu0KJqbjYlvI0+5X5Xw==", + "dependencies": { + "http-cookie-agent": "^6.0.3" + }, + "engines": { + "node": ">=18.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/3846masa" + }, + "peerDependencies": { + "axios": ">=0.20.0", + "tough-cookie": ">=4.0.0" + } + }, + "node_modules/boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==" + }, + "node_modules/cheerio": { + "version": "1.0.0-rc.12", + "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.12.tgz", + "integrity": "sha512-VqR8m68vM46BNnuZ5NtnGBKIE/DfN0cRIzg9n40EIq9NOv90ayxLBXA8fXC5gquFRGJSTRqBq25Jt2ECLR431Q==", + "dependencies": { + "cheerio-select": "^2.1.0", + "dom-serializer": "^2.0.0", + "domhandler": "^5.0.3", + "domutils": "^3.0.1", + "htmlparser2": "^8.0.1", + "parse5": "^7.0.0", + "parse5-htmlparser2-tree-adapter": "^7.0.0" + }, + "engines": { + "node": ">= 6" + }, + "funding": { + "url": "https://github.com/cheeriojs/cheerio?sponsor=1" + } + }, + "node_modules/cheerio-select": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-2.1.0.tgz", + "integrity": "sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==", + "dependencies": { + "boolbase": "^1.0.0", + "css-select": "^5.1.0", + "css-what": "^6.1.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/css-select": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz", + "integrity": "sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==", + "dependencies": { + "boolbase": "^1.0.0", + "css-what": "^6.1.0", + "domhandler": "^5.0.2", + "domutils": "^3.0.1", + "nth-check": "^2.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/css-what": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz", + "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==", + "engines": { + "node": ">= 6" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ] + }, + "node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/domutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz", + "integrity": "sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==", + "dependencies": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/htmlparser2": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.2.tgz", + "integrity": "sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==", + "funding": [ + "https://github.com/fb55/htmlparser2?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.0.1", + "entities": "^4.4.0" + } + }, + "node_modules/http-cookie-agent": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/http-cookie-agent/-/http-cookie-agent-6.0.3.tgz", + "integrity": "sha512-6JdymEgWgsg9VQ5VN9FGpRRcivyu4WdM0Ud3kW+Q0PB7knt0EFtlhNPU8wCuscXLfIEI5y6jEMdFTBODNsJR6g==", + "dependencies": { + "agent-base": "^7.1.1" + }, + "engines": { + "node": ">=18.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/3846masa" + }, + "peerDependencies": { + "deasync": "^0.1.26", + "tough-cookie": "^4.0.0", + "undici": "^5.11.0 || ^6.0.0" + }, + "peerDependenciesMeta": { + "deasync": { + "optional": true + }, + "undici": { + "optional": true + } + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/nth-check": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", + "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", + "dependencies": { + "boolbase": "^1.0.0" + }, + "funding": { + "url": "https://github.com/fb55/nth-check?sponsor=1" + } + }, + "node_modules/parse5": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz", + "integrity": "sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==", + "dependencies": { + "entities": "^4.4.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/parse5-htmlparser2-tree-adapter": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-7.0.0.tgz", + "integrity": "sha512-B77tOZrqqfUfnVcOrUvfdLbz4pu4RopLD/4vmu3HUPswwTA8OH0EMW9BlWR2B0RCoiZRAHEUu7IxeP1Pd1UU+g==", + "dependencies": { + "domhandler": "^5.0.2", + "parse5": "^7.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, + "node_modules/psl": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", + "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==" + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "engines": { + "node": ">=6" + } + }, + "node_modules/querystringify": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", + "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==" + }, + "node_modules/requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==" + }, + "node_modules/tough-cookie": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz", + "integrity": "sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==", + "dependencies": { + "psl": "^1.1.33", + "punycode": "^2.1.1", + "universalify": "^0.2.0", + "url-parse": "^1.5.3" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/universalify": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", + "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==", + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/url-parse": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", + "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", + "dependencies": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } } - } - }, - "node_modules/is-docker": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", - "integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==", - "bin": { - "is-docker": "cli.js" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-inside-container": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz", - "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==", - "dependencies": { - "is-docker": "^3.0.0" - }, - "bin": { - "is-inside-container": "cli.js" - }, - "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-wsl": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.0.tgz", - "integrity": "sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw==", - "dependencies": { - "is-inside-container": "^1.0.0" - }, - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "dependencies": { - "mime-db": "1.52.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, - "node_modules/nth-check": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", - "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", - "dependencies": { - "boolbase": "^1.0.0" - }, - "funding": { - "url": "https://github.com/fb55/nth-check?sponsor=1" - } - }, - "node_modules/open": { - "version": "10.0.3", - "resolved": "https://registry.npmjs.org/open/-/open-10.0.3.tgz", - "integrity": "sha512-dtbI5oW7987hwC9qjJTyABldTaa19SuyJse1QboWv3b0qCcrrLNVDqBx1XgELAjh9QTVQaP/C5b1nhQebd1H2A==", - "dependencies": { - "default-browser": "^5.2.1", - "define-lazy-prop": "^3.0.0", - "is-inside-container": "^1.0.0", - "is-wsl": "^3.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/parse5": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz", - "integrity": "sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==", - "dependencies": { - "entities": "^4.4.0" - }, - "funding": { - "url": "https://github.com/inikulin/parse5?sponsor=1" - } - }, - "node_modules/parse5-htmlparser2-tree-adapter": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-7.0.0.tgz", - "integrity": "sha512-B77tOZrqqfUfnVcOrUvfdLbz4pu4RopLD/4vmu3HUPswwTA8OH0EMW9BlWR2B0RCoiZRAHEUu7IxeP1Pd1UU+g==", - "dependencies": { - "domhandler": "^5.0.2", - "parse5": "^7.0.0" - }, - "funding": { - "url": "https://github.com/inikulin/parse5?sponsor=1" - } - }, - "node_modules/proxy-from-env": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" - }, - "node_modules/psl": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", - "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==" - }, - "node_modules/punycode": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", - "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", - "engines": { - "node": ">=6" - } - }, - "node_modules/querystringify": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", - "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==" - }, - "node_modules/requires-port": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==" - }, - "node_modules/run-applescript": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-7.0.0.tgz", - "integrity": "sha512-9by4Ij99JUr/MCFBUkDKLWK3G9HVXmabKz9U5MlIAIuvuzkiOicRYs8XJLxX+xahD+mLiiCYDqF9dKAgtzKP1A==", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/tough-cookie": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz", - "integrity": "sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==", - "dependencies": { - "psl": "^1.1.33", - "punycode": "^2.1.1", - "universalify": "^0.2.0", - "url-parse": "^1.5.3" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/universalify": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", - "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==", - "engines": { - "node": ">= 4.0.0" - } - }, - "node_modules/url-parse": { - "version": "1.5.10", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", - "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", - "dependencies": { - "querystringify": "^2.1.1", - "requires-port": "^1.0.0" - } } - } } diff --git a/package.json b/package.json index f4e91e7..b1651c8 100644 --- a/package.json +++ b/package.json @@ -1,45 +1,65 @@ { "name": "irctc-api", "description": "An exclusive NodeJs only package built on top of IRCTC Website APIs to book train tickets, managing user profile faster and simpler from anywhere in the world", - "version": "1.0.8", + "version": "2.0.0", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { - "type": "git", - "url": "https://github.com/suryavaddiraju/irctc-api.git" + "type": "git", + "url": "https://github.com/suryavaddiraju/irctc-api.git" }, "license": "Apache-2.0", - "keywords": ["irctc", "api", "irctc-api","indian railways","indian railway api","indian railway","indian railways api","tatkal","tatkal booking","tatkal booking api","tatkal booking irctc","pnr status","pnr","IR","IRCTC","train","ticket","booking","automate","software"], + "keywords": [ + "irctc", + "api", + "irctc-api", + "indian", + "railway", + "railways", + "tatkal", + "booking", + "pnr", + "status", + "IR", + "IRCTC", + "train", + "rail", + "ticket", + "automate", + "software", + "module", + "package", + "fast" + ], "author": { - "name": "Vaddiraju Surya Teja", - "email": "suryavaddiraju@proton.me", - "url": "http://github.com/suryavaddiraju" + "name": "Vaddiraju Surya Teja", + "email": "suryavaddiraju@proton.me", + "url": "http://github.com/suryavaddiraju" }, "bugs": { - "url": "https://github.com/suryavaddiraju/irctc-api/issues" + "url": "https://github.com/suryavaddiraju/irctc-api/issues" }, "homepage": "https://dev.vaddiraju.in/irctc-api", - "files":[ - "index.mjs", - "lib", - "LICENSE", - "README.md", - "package.json", - ".npmignore" + "files": [ + "index.mjs", + "lib", + "LICENSE", + "README.md", + "package.json", + ".npmignore" ], "dependencies": { - "axios": "^1.6.5", - "axios-cookiejar-support": "^5.0.0", + "axios": "^1.6.8", + "axios-cookiejar-support": "^5.0.1", "cheerio": "^1.0.0-rc.12", - "open": "^10.0.3", "tough-cookie": "^4.1.3" }, "engines": { - "node": ">=20.0.0", - "npm": ">=10.0.0" + "node": ">20.0.0", + "npm": ">10.0.0" }, - "main":"./index.mjs", + "main": "./index.mjs", "exports": "./index.mjs", "type": "module" -} \ No newline at end of file +} diff --git a/test/book_ticket.mjs b/test/book_ticket.mjs index 399add9..f2e4e91 100644 --- a/test/book_ticket.mjs +++ b/test/book_ticket.mjs @@ -8,8 +8,8 @@ const params = { "to": "PDKN", // Station code "journey_date": "20240530", // YYYYMMDD "mobile_number": "9876543210", // 10 Digit Mobile Number - "userID": "username_here", // Secret User ID - "password": "someSecret_here", // Secret Password + "userID": "XXXXX", // Secret User ID + "password": "XXXXXXX", // Secret Password "passengers": [ // Passengers List - Max 4 members for Tatkal and 6 for General Quota { "age": "22", // Age of Passenger @@ -26,13 +26,8 @@ const params = { ] }; async function custom_command_name(params) { - try{ const irctc = new IRCTC(); const response = await irctc.book(params); console.log(response); - } - catch(e){ - throw new Error(e); - } }; await custom_command_name(params); \ No newline at end of file