Skip to content

Commit

Permalink
Merge pull request #20 from suryavaddiraju/development
Browse files Browse the repository at this point in the history
v2.0.1
  • Loading branch information
suryavaddiraju authored May 4, 2024
2 parents d3d7ce8 + 7d8d9be commit 5c7c752
Show file tree
Hide file tree
Showing 14 changed files with 241 additions and 87 deletions.
1 change: 0 additions & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
github: [suryavaddiraju]
custom: [https://dev.vaddiraju.in/funding]
104 changes: 93 additions & 11 deletions .github/SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,103 @@
# Security Policy

This sections helps users how to report security issues privately.

## Supported Versions

Use this section to tell people about which versions of your project are
currently being supported with security updates.
versions of the project that are currently being supported with security updates.

| Version | Supported |
| ------- | ------------------ |
| 5.1.x | :white_check_mark: |
| 5.0.x | :x: |
| 4.0.x | :white_check_mark: |
| < 4.0 | :x: |
| 2.0.x | :white_check_mark: |
| 1.0.x | :x: |

## Vulnerability Disclosure

If you think you have found a potential security vulnerability in
requests, please email [Vaddiraju Surya Teja](mailto:[email protected])
and [Vaddiraju Rama Narasimha](mailto:[email protected]) directly.

**Do not file a public issue.**

Our PGP Key fingerprints are:
- ASAt 7xmp EQhK boIl zSb0 D9Fa n15c 1U9S wN4lb sVEVN HH3go ([suryavaddiraju](https://keybase.io/suryavaddiraju))

You can also contact us on [Keybase](https://keybase.io) with the
profiles above if desired.

If English is not your first language, please try to describe the
problem and its impact to the best of your ability. For greater detail,
please use your native language and we will try our best to translate it
using online services.

Please also include the code you used to find the problem and the
shortest amount of code necessary to reproduce it.

Please do not disclose this to anyone else. We will retrieve a CVE
identifier if necessary and give you full credit under whatever name or
alias you provide. We will only request an identifier when we have a fix
and can publish it in a release.

We will respect your privacy and will only publicize your involvement if
you grant us permission.

## Process

This following information discusses the process the requests project
follows in response to vulnerability disclosures. If you are disclosing
a vulnerability, this section of the documentation lets you know how we
will respond to your disclosure.

### Timeline

When you report an issue, one of the project members will respond to you
within two days *at the outside*. In most cases responses will be
faster, usually within 12 hours. This initial response will at the very
least confirm receipt of the report.

If we were able to rapidly reproduce the issue, the initial response
will also contain confirmation of the issue. If we are not, we will
often ask for more information about the reproduction scenario.

Our goal is to have a fix for any vulnerability released within two
weeks of the initial disclosure. This may potentially involve shipping
an interim release that simply disables function while a more mature fix
can be prepared, but will in the vast majority of cases mean shipping a
complete release as soon as possible.

Throughout the fix process we will keep you up to speed with how the fix
is progressing. Once the fix is prepared, we will notify you that we
believe we have a fix. Often we will ask you to confirm the fix resolves
the problem in your environment, especially if we are not confident of
our reproduction scenario.

At this point, we will prepare for the release. We will obtain a CVE
number if one is required, providing you with full credit for the
discovery. We will also decide on a planned release date, and let you
know when it is. This release date will *always* be on a weekday.

At this point we will reach out to our major downstream packagers to
notify them of an impending security-related patch so they can make
arrangements. In addition, these packagers will be provided with the
intended patch ahead of time, to ensure that they are able to promptly
release their downstream packages. Currently the list of people we
actively contact *ahead of a public release* is:

- Vaddiraju Surya Teja, Node (@suryavaddiraju)

We will notify these individuals at least a week ahead of our planned
release date to ensure that they have sufficient time to prepare. If you
believe you should be on this list, please let one of the maintainers
know at one of the email addresses at the top of this article.

## Reporting a Vulnerability
On release day, we will push the patch to our public repository, along
with an updated changelog that describes the issue and credits you. We
will then issue a PyPI release containing the patch.

Use this section to tell people how to report a vulnerability.
At this point, we will publicise the release. This will involve mails to
mailing lists, Tweets, and all other communication mechanisms available
to the core team.

Tell them where to go, how often they can expect to get an update on a
reported vulnerability, what to expect if the vulnerability is accepted or
declined, etc.
We will also explicitly mention which commits contain the fix to make it
easier for other distributors and users to easily patch their own
versions of requests if upgrading is not an option.
6 changes: 5 additions & 1 deletion api_reference.md → docs/api_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ console.log(response);
- Must be a String
- Preferred Coach for total ticket
- Must be related to the class of the ticket
- log
- Can be any one of the boolean values such as `true | false`
- Default value - `false`

The example input is as follows

Expand Down Expand Up @@ -148,7 +151,8 @@ The example input is as follows
"country":"Uk"
}
],
"coach":"D1"
"coach":"D1",
"log":true
};
```

Expand Down
File renamed without changes.
19 changes: 3 additions & 16 deletions examples/book_ticket.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,20 @@ 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": "XXXXXXX", // Secret User ID
"password": "XXXXXXXXXXX", // Secret Password
"passengers": [ // Passengers List - Max 4 members for Tatkal and 6 for General Quota
{
"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
"berth":"WS" // optional, Preferred Berth Code - LB | UB | SL | SU | MB | WS
},
{
"age": "21", // Age of Passenger
"food": "", // Food Preference - Leave as Empty string, if food is not required
"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{
const irctc = new IRCTC();
const response = await irctc.book(params);
console.log(response);
}
catch(e){
throw new Error(e);
}
};
await custom_command_name(params);
4 changes: 2 additions & 2 deletions examples/get_pnr_status.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {IRCTC} from "irctc-api";
const params = {
"userID": "username_here", // Secret User ID
"password": "someSecret_here", // Secret Password
"userID": "XXXXX", // Secret User ID
"password": "XXXXXXX", // Secret Password
"pnr":"457544545" // PNR Number
};
async function custom_command_name(params) {
Expand Down
4 changes: 2 additions & 2 deletions examples/last_txn_status.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {IRCTC} from "irctc-api";
const params = {
"userID": "username_here", // Secret User ID
"password": "someSecret_here", // Secret Password
"userID": "XXXXX", // Secret User ID
"password": "XXXXXXXXX", // Secret Password
};
async function custom_command_name(params) {
try{
Expand Down
4 changes: 4 additions & 0 deletions index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ class IRCTC extends main_class{
super();
}
async book(params){
if (!(params.hasOwnProperty("log") && typeof params["log"] === 'boolean')){
console.log("You have not set any valid log parameter. Setting log to false.\nIf you need to set up logging, please set log parameter to true.");
params.log = false;
}
return await super.book(params);
}
async last_transaction(params){
Expand Down
44 changes: 33 additions & 11 deletions lib/time_work.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import axios from "axios";
function sleep(ms){
return new Promise(resolve => setTimeout(resolve, ms));
}

async function get_current_time_api(){
const response = await axios.get(
"https://worldtimeapi.org/api/timezone/Etc/UTC",
);
return response.data.utc_datetime;
}

const psg_input_await = {
1:20000,
2:20000,
Expand All @@ -19,23 +27,29 @@ async function psg_input_wait(psg_count){

async function sleep_for_login(ticket_time){
if (ticket_time === 1){
const currentTime = new Date();
const date_time_string = await get_current_time_api();
const currentTime = new Date(date_time_string);
const targetTime = new Date(currentTime);
targetTime.setUTCHours(4, 28, 0, 0);
if (currentTime < targetTime) {
await sleep(targetTime - currentTime);
const balance_time = targetTime - currentTime;
console.log(`${balance_time} milliseconds left for login.\nSleeping for ${balance_time * 0.001} seconds to proceed for login.`);
await sleep(balance_time);
return "Proceeding to Login";
}
else{
return "No Sleep Required";
}
}
else if (ticket_time === 2){
const currentTime = new Date();
const date_time_string = await get_current_time_api();
const currentTime = new Date(date_time_string);
const targetTime = new Date(currentTime);
targetTime.setUTCHours(5, 28, 0, 0);
if (currentTime < targetTime) {
await sleep(targetTime - currentTime);
const balance_time = targetTime - currentTime;
console.log(`${balance_time} milliseconds left for login.\nSleeping for ${balance_time * 0.001} seconds to proceed for login.`);
await sleep(balance_time);
return "Proceeding to Login";
}
else{
Expand All @@ -49,23 +63,29 @@ async function sleep_for_login(ticket_time){

async function sleep_for_availability_check(ticket_time){
if (ticket_time === 1){
const currentTime = new Date();
const date_time_string = await get_current_time_api();
const currentTime = new Date(date_time_string);
const targetTime = new Date(currentTime);
targetTime.setUTCHours(4, 30, 1, 0);
if (currentTime < targetTime) {
await sleep(targetTime - currentTime);
const balance_time = targetTime - currentTime;
console.log(`${balance_time} milliseconds left for availability check.\nSleeping for ${balance_time * 0.001} seconds to proceed for availability check.`);
await sleep(balance_time);
return "Proceeding to Check Availability";
}
else{
return "No Sleep Required";
}
}
else if (ticket_time === 2){
const currentTime = new Date();
const date_time_string = await get_current_time_api();
const currentTime = new Date(date_time_string);
const targetTime = new Date(currentTime);
targetTime.setUTCHours(5, 30, 1, 0);
if (currentTime < targetTime) {
await sleep(targetTime - currentTime);
const balance_time = targetTime - currentTime;
console.log(`${balance_time} milliseconds left for availability check.\nSleeping for ${balance_time * 0.001} seconds to proceed for availability check.`);
await sleep(balance_time);
return "Proceeding to Check Availability";
}
else{
Expand All @@ -77,9 +97,10 @@ async function sleep_for_availability_check(ticket_time){
}
}

function start_before_3_minutes(ticket_time){
async function start_before_3_minutes(ticket_time){
if (ticket_time === 1) {
const currentTime = new Date();
const date_time_string = await get_current_time_api();
const currentTime = new Date(date_time_string);
const targetTime = new Date(currentTime);
targetTime.setUTCHours(4, 27, 0, 0);
if (currentTime < targetTime) {
Expand All @@ -90,7 +111,8 @@ function start_before_3_minutes(ticket_time){
}
}
else if (ticket_time === 2) {
const currentTime = new Date();
const date_time_string = await get_current_time_api();
const currentTime = new Date(date_time_string);
const targetTime = new Date(currentTime);
targetTime.setUTCHours(5, 27, 0, 0);
if (currentTime < targetTime) {
Expand Down
Loading

0 comments on commit 5c7c752

Please sign in to comment.