railkit 4.0.3 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -1
- package/index.d.ts +46 -1
- package/index.obfuscated.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# RailKit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/railkit)
|
|
4
4
|
[](https://www.npmjs.com/package/railkit)
|
|
5
5
|
[](https://github.com/RAJIV81205/railkit/blob/main/LICENSE)
|
|
6
6
|
|
|
@@ -20,6 +20,9 @@ A comprehensive Node.js SDK for Indian Railways. Get real-time PNR status, train
|
|
|
20
20
|
- 🔍 **Train Search** — Find all direct trains between two stations
|
|
21
21
|
- 💺 **Seat Availability** — Check availability and fare for any class and quota
|
|
22
22
|
- 💰 **Fare Lookup** — Full fare breakdown for any train, class, and quota
|
|
23
|
+
- 🚉 **Station Lookup** — Resolve station codes and search stations by name
|
|
24
|
+
- 🔎 **Train Lookup** — Resolve train numbers and search trains by name
|
|
25
|
+
- 🗓️ **Station Timetable** — Complete scheduled trains crossing a station
|
|
23
26
|
- ⚡ **Fast & Reliable** — Built-in timeout handling, input validation, and caching
|
|
24
27
|
|
|
25
28
|
---
|
|
@@ -72,6 +75,12 @@ import {
|
|
|
72
75
|
searchTrainBetweenStations,
|
|
73
76
|
getAvailability,
|
|
74
77
|
fareLookup,
|
|
78
|
+
cancelList,
|
|
79
|
+
stationByCode,
|
|
80
|
+
stationsByName,
|
|
81
|
+
trainByNumber,
|
|
82
|
+
trainsByName,
|
|
83
|
+
trainTimetableAtStation,
|
|
75
84
|
} from 'railkit';
|
|
76
85
|
|
|
77
86
|
// Configure once
|
|
@@ -97,6 +106,15 @@ const availResult = await getAvailability('12496', 'ASN', 'DDU', '27-12-2025', '
|
|
|
97
106
|
|
|
98
107
|
// Get fare for a journey
|
|
99
108
|
const fareResult = await fareLookup('12313', 'ASN', 'NDLS', '06-06-2026', '3A', 'GN');
|
|
109
|
+
|
|
110
|
+
// Look up stations and trains
|
|
111
|
+
const station = await stationByCode('NDLS');
|
|
112
|
+
const stationMatches = await stationsByName('delhi');
|
|
113
|
+
const train = await trainByNumber('12345');
|
|
114
|
+
const trainMatches = await trainsByName('rajdhani');
|
|
115
|
+
|
|
116
|
+
// Complete station timetable; omit date for all trains crossing the station
|
|
117
|
+
const timetable = await trainTimetableAtStation('ASN');
|
|
100
118
|
```
|
|
101
119
|
|
|
102
120
|
---
|
|
@@ -660,6 +678,63 @@ if (result.success) {
|
|
|
660
678
|
|
|
661
679
|
---
|
|
662
680
|
|
|
681
|
+
### 9. `cancelList()`
|
|
682
|
+
|
|
683
|
+
Get fully and partially cancelled trains.
|
|
684
|
+
|
|
685
|
+
```javascript
|
|
686
|
+
const result = await cancelList();
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
### 10. `stationByCode(stationCode)`
|
|
690
|
+
|
|
691
|
+
Resolve a station code to its name and coordinates.
|
|
692
|
+
|
|
693
|
+
```javascript
|
|
694
|
+
const result = await stationByCode('NDLS');
|
|
695
|
+
// result.data: { code, name, lat, lon }
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
### 11. `stationsByName(name)`
|
|
699
|
+
|
|
700
|
+
Find up to 10 stations matching a partial name.
|
|
701
|
+
|
|
702
|
+
```javascript
|
|
703
|
+
const result = await stationsByName('delhi');
|
|
704
|
+
// result.data.stations: [{ code, name, lat, lon }, ...]
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
### 12. `trainByNumber(trainNumber)`
|
|
708
|
+
|
|
709
|
+
Resolve an exact 5-digit numeric train number.
|
|
710
|
+
|
|
711
|
+
```javascript
|
|
712
|
+
const result = await trainByNumber('12345');
|
|
713
|
+
// result.data: { trainNo, trainName }
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
### 13. `trainsByName(name)`
|
|
717
|
+
|
|
718
|
+
Find up to 10 trains matching a partial name.
|
|
719
|
+
|
|
720
|
+
```javascript
|
|
721
|
+
const result = await trainsByName('rajdhani');
|
|
722
|
+
// result.data.trains: [{ trainNo, trainName }, ...]
|
|
723
|
+
```
|
|
724
|
+
|
|
725
|
+
### 14. `trainTimetableAtStation(stationCode, date?)`
|
|
726
|
+
|
|
727
|
+
Get the complete scheduled timetable for trains crossing a station. Omit the
|
|
728
|
+
date to return all trains and their running days. If supplied, date must be
|
|
729
|
+
today, yesterday, or tomorrow in `DD-MM-YYYY` format.
|
|
730
|
+
|
|
731
|
+
```javascript
|
|
732
|
+
const result = await trainTimetableAtStation('ASN');
|
|
733
|
+
// Or: await trainTimetableAtStation('ASN', '28-08-2026');
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
---
|
|
737
|
+
|
|
663
738
|
## ⚠️ Error Handling
|
|
664
739
|
|
|
665
740
|
All functions return a consistent response structure. Always check `success` before accessing `data`.
|
package/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Configure the SDK with your API key before using any other function.
|
|
3
3
|
* The backend URL is managed by the package - you only need your API key.
|
|
4
4
|
*
|
|
5
|
+
* @param apiKey - API key from the RailKit dashboard
|
|
5
6
|
* @example
|
|
6
7
|
* configure('your-api-key-here');
|
|
7
8
|
*/
|
|
@@ -10,6 +11,7 @@ export function configure(apiKey: string): void;
|
|
|
10
11
|
/**
|
|
11
12
|
* Check the PNR status for a given 10-digit PNR number.
|
|
12
13
|
*
|
|
14
|
+
* @param pnr - 10-digit PNR number
|
|
13
15
|
* @example
|
|
14
16
|
* const result = await checkPNRStatus('1234567890');
|
|
15
17
|
*
|
|
@@ -19,6 +21,7 @@ export function checkPNRStatus(pnr: string): Promise<any>;
|
|
|
19
21
|
/**
|
|
20
22
|
* Get detailed information and route for a given 5-digit train number.
|
|
21
23
|
*
|
|
24
|
+
* @param trainNumber - 5-digit train number
|
|
22
25
|
* @example
|
|
23
26
|
* const result = await getTrainInfo('12301');
|
|
24
27
|
*
|
|
@@ -27,6 +30,7 @@ export function getTrainInfo(trainNumber: string): Promise<any>;
|
|
|
27
30
|
|
|
28
31
|
/**
|
|
29
32
|
* Get the live running status of a train.
|
|
33
|
+
* @param trainNumber - 5-digit train number
|
|
30
34
|
* @param date - Journey date in DD-MM-YYYY format (optional, defaults to today)
|
|
31
35
|
*
|
|
32
36
|
* @example
|
|
@@ -51,7 +55,7 @@ export function getTrainHistory(trainNumber: string, journeyDate: string): Promi
|
|
|
51
55
|
|
|
52
56
|
/**
|
|
53
57
|
* Get the list of upcoming trains at a station.
|
|
54
|
-
* @param stationCode - Station
|
|
58
|
+
* @param stationCode - Station code (e.g., 'NDLS' for New Delhi)
|
|
55
59
|
* @param hours - Time window in hours: 2, 4, or 8 (default 2)
|
|
56
60
|
*
|
|
57
61
|
* @example
|
|
@@ -114,3 +118,44 @@ export function fareLookup(
|
|
|
114
118
|
travelClass: string,
|
|
115
119
|
quota: string
|
|
116
120
|
): Promise<any>;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Get all fully and partially cancelled trains.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* const result = await cancelList();
|
|
127
|
+
*/
|
|
128
|
+
export function cancelList(): Promise<any>;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Resolve a station code to its name and coordinates.
|
|
132
|
+
* @param stationCode - Station code of 1-5 letters or digits
|
|
133
|
+
*/
|
|
134
|
+
export function stationByCode(stationCode: string): Promise<any>;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Find up to 10 stations matching a partial name.
|
|
138
|
+
* @param name - Partial station name, at least 2 characters
|
|
139
|
+
*/
|
|
140
|
+
export function stationsByName(name: string): Promise<any>;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Resolve an exact 5-digit train number to its stored train name.
|
|
144
|
+
* @param trainNumber - Exactly 5 numeric digits
|
|
145
|
+
*/
|
|
146
|
+
export function trainByNumber(trainNumber: string): Promise<any>;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Find up to 10 trains matching a partial name.
|
|
150
|
+
* @param name - Partial train name, at least 2 characters
|
|
151
|
+
*/
|
|
152
|
+
export function trainsByName(name: string): Promise<any>;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Get the complete station timetable.
|
|
156
|
+
* Omit date for all trains; supplied date must be DD-MM-YYYY and today,
|
|
157
|
+
* yesterday, or tomorrow.
|
|
158
|
+
* @param stationCode - Station code of 1-5 letters or digits
|
|
159
|
+
* @param date - Optional date in DD-MM-YYYY format
|
|
160
|
+
*/
|
|
161
|
+
export function trainTimetableAtStation(stationCode: string, date?: string): Promise<any>;
|
package/index.obfuscated.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function a0_0x2ccd(){const _0x520c55=['yxbWBgLJyxrPB24VANnVBG','Agv4','l2fWAs9JAgvJA1bouLn0yxr1CY8','Dg9vChbLCKnHC2u','p2HYCZ0','sM91CM5LEsbKyxrLigLZihjLCxvPCMvKigfUzcbTDxn0igjLigLUierelu1nlvLzwvKGzM9YBwf0lG','BM93','nZGYmZiXB1vizufA','Ahr0Chm6lY9YywLSA2L0lwfWAs5YywPPDMr1yMv5lMrLDG','l2fWAs90CMfPBKHPC3rVCNKV','AxnbCNjHEq','mLnVzNf4Ba','C3rYAw5N','C3rHDhvZq29Kzq','qM90AcbMCM9TigfUzcb0BYbZDgf0Aw9UignVzgvZigfYzsbYzxf1AxjLzcbHBMqGBxvZDcbIzsbZDhjPBMDZlG','otDJntzLmdHImJDImtyXmti0zJG4ywnKngyYngqXyMq1mgy0oda3nwyXmwrJmJnIowvHnMmWyMm5yJjModC5na','r0vu','nJGXotjwBwvgDeC','ANnVBG','DgvZDa','B2jQzwn0','mty4nJq0n3fgzuXVBa','nJeZodyWmfLfwNblqW','sw52ywXPzcaNAg91CNmNihzHBhvLlIbbBgXVD2vKihzHBhvLCZOGmIWGncWGoc4','mJC5DfbACwvJ','ue5sig51BwjLCIbPCYbYzxf1AxjLzcbHBMqGBxvZDcbIzsbHihn0CMLUzY4','w3jHAwXRAxrDignVBMzPz3vYzsGPihjLCxvPCMvZigeGDMfSAwqGqvbjigTLEsbZDhjPBMCU','l2fWAs9SAxzLqxrtDgf0Aw9UlW','DxbKyxrL','Aw5JBhvKzxm','ue5sig51BwjLCIbTDxn0igjLigv4ywn0BhKGmtaGzgLNAxrZlG','C3rHDhvZ','l2fWAs9NzxruCMfPBKLUzM8V','sw52ywXPzcb0CMfPBIbUDw1IzxiUieL0ig11C3qGyMuGysa1lwnOyxjHy3rLCIbZDhjPBMCU','BgvUz3rO','p2rHDgu9','uMvXDwvZDcbMywLSzwq6ia','nMXpzwXJwG','l2fWAs9MyxjLtg9VA3vWlW','l2fWAs9NzxrbDMfPBgfIAwXPDhKV','CMvWBgfJzq','nde5mtu2mgv6q0X5sa','DhjPBq','CMfPBgTPDcbPCYbUB3qGy29UzMLNDxjLzc4Gq2fSBcbJB25MAwD1CMuOyxbPs2v5ksbMAxjZDc4','ndiXmtiZmK9Qrfz0Bq','l2fWAs90CMfJA1rYywLUlW','u3rHDgLVBIbJB2rLigLZihjLCxvPCMvKigfUzcbTDxn0igjLigeGC3rYAw5NlG','BwvZC2fNzq','l2fWAs9ZzwfYy2HuCMfPBKjLDhDLzw5tDgf0Aw9UCY8','C2HHmJu2','ntmXmte2nLL1t1fytq','sw5JB21WBgv0zsbKyxrHlIbqBgvHC2uGChjVDMLKzsbHBgWGCMvXDwLYzwqGzMLLBgrZlG'];a0_0x2ccd=function(){return _0x520c55;};return a0_0x2ccd();}const a0_0x4e53bf=a0_0x1090;(function(_0x128c9c,_0x3624f0){const _0x2f8ac8=a0_0x1090,_0x471ec5=_0x128c9c();while(!![]){try{const _0x3b2958=-parseInt(_0x2f8ac8(0x209))/0x1*(-parseInt(_0x2f8ac8(0x20d))/0x2)+parseInt(_0x2f8ac8(0x1e3))/0x3+-parseInt(_0x2f8ac8(0x1fa))/0x4+-parseInt(_0x2f8ac8(0x1f7))/0x5+parseInt(_0x2f8ac8(0x1f3))/0x6*(parseInt(_0x2f8ac8(0x200))/0x7)+parseInt(_0x2f8ac8(0x213))/0x8*(-parseInt(_0x2f8ac8(0x1e6))/0x9)+parseInt(_0x2f8ac8(0x1e4))/0xa;if(_0x3b2958===_0x3624f0)break;else _0x471ec5['push'](_0x471ec5['shift']());}catch(_0x117974){_0x471ec5['push'](_0x471ec5['shift']());}}}(a0_0x2ccd,0x89228));import{createHash,createHmac,randomBytes}from'node:crypto';const _baseUrl=a0_0x4e53bf(0x20a),_sdkVersion='1',_defaultSdkSigningSecret=a0_0x4e53bf(0x211);let _apiKey='',_sdkSigningSecret=_defaultSdkSigningSecret;function configure(_0x430fc2){const _0x3dea9=a0_0x4e53bf;if(!_0x430fc2||typeof _0x430fc2!==_0x3dea9(0x20e))throw new Error(_0x3dea9(0x1e8));_apiKey=_0x430fc2[_0x3dea9(0x1f8)]();}function a0_0x1090(_0x222767,_0x5186bf){_0x222767=_0x222767-0x1e0;const _0x2ccd33=a0_0x2ccd();let _0x109046=_0x2ccd33[_0x222767];if(a0_0x1090['zZESLq']===undefined){var _0x4a8580=function(_0x147805){const _0x5915e9='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x430fc2='',_0x133003='';for(let _0x6c4d38=0x0,_0x1e8445,_0x2d85fe,_0x52e5a2=0x0;_0x2d85fe=_0x147805['charAt'](_0x52e5a2++);~_0x2d85fe&&(_0x1e8445=_0x6c4d38%0x4?_0x1e8445*0x40+_0x2d85fe:_0x2d85fe,_0x6c4d38++%0x4)?_0x430fc2+=String['fromCharCode'](0xff&_0x1e8445>>(-0x2*_0x6c4d38&0x6)):0x0){_0x2d85fe=_0x5915e9['indexOf'](_0x2d85fe);}for(let _0x406f4d=0x0,_0x2200e5=_0x430fc2['length'];_0x406f4d<_0x2200e5;_0x406f4d++){_0x133003+='%'+('00'+_0x430fc2['charCodeAt'](_0x406f4d)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x133003);};a0_0x1090['jvuGeU']=_0x4a8580,a0_0x1090['mBYFOk']={},a0_0x1090['zZESLq']=!![];}const _0x43c083=_0x2ccd33[0x0],_0x3e6fe2=_0x222767+_0x43c083,_0x135e4d=a0_0x1090['mBYFOk'][_0x3e6fe2];return!_0x135e4d?(_0x109046=a0_0x1090['jvuGeU'](_0x109046),a0_0x1090['mBYFOk'][_0x3e6fe2]=_0x109046):_0x109046=_0x135e4d,_0x109046;}function _hashPayload(_0x133003){const _0x25f029=a0_0x4e53bf;return createHash(_0x25f029(0x1ff))[_0x25f029(0x1ea)](_0x133003)['digest'](_0x25f029(0x203));}function _buildSignature({method:_0x6c4d38,path:_0x1e8445,timestamp:_0x2d85fe,nonce:_0x52e5a2,payloadHash:_0x406f4d}){const _0x11379c=a0_0x4e53bf,_0x2200e5=[_0x6c4d38[_0x11379c(0x205)](),_0x1e8445,_0x2d85fe,_0x52e5a2,_0x406f4d,_apiKey]['join']('\x0a');return createHmac(_0x11379c(0x1ff),_sdkSigningSecret)[_0x11379c(0x1ea)](_0x2200e5)['digest'](_0x11379c(0x203));}function _getSdkSecurityHeaders(_0x43a077,_0x5ae2c4,_0xb0894=''){const _0x31d075=a0_0x4e53bf,_0x11cea9=String(Date[_0x31d075(0x208)]()),_0x5b4a3d=randomBytes(0x20)['toString']('hex'),_0x19451b=_hashPayload(_0xb0894),_0x2a887e=_buildSignature({'method':_0x43a077,'path':_0x5ae2c4,'timestamp':_0x11cea9,'nonce':_0x5b4a3d,'payloadHash':_0x19451b});return{'x-irctc-sdk-ts':_0x11cea9,'x-irctc-sdk-nonce':_0x5b4a3d,'x-irctc-sdk-payload-sha256':_0x19451b,'x-irctc-sdk-signature':_0x2a887e,'x-irctc-sdk-version':_sdkVersion};}async function _get(_0x515a0d){const _0x4fe55c=a0_0x4e53bf;if(!_apiKey)return{'success':![],'error':_0x4fe55c(0x1f9)};try{const _0x24efc8=_getSdkSecurityHeaders('GET',_0x515a0d,''),_0x3cc475=await fetch(''+_baseUrl+_0x515a0d,{'method':_0x4fe55c(0x212),'headers':{'x-api-key':_apiKey,'Accept':_0x4fe55c(0x202),..._0x24efc8}}),_0x37b1f8=await _0x3cc475[_0x4fe55c(0x1e0)]();return _0x37b1f8&&typeof _0x37b1f8===_0x4fe55c(0x1e2)&&!Array[_0x4fe55c(0x20c)](_0x37b1f8)&&Object['defineProperty'](_0x37b1f8,_0x4fe55c(0x20f),{'value':_0x3cc475[_0x4fe55c(0x1ed)],'enumerable':![]}),_0x37b1f8;}catch(_0x3d2be9){return{'success':![],'error':_0x4fe55c(0x1f2)+_0x3d2be9[_0x4fe55c(0x1fd)]};}}async function checkPNRStatus(_0x4e1e85){const _0x1ad7f0=a0_0x4e53bf;if(!_0x4e1e85||typeof _0x4e1e85!==_0x1ad7f0(0x20e))return{'success':![],'error':_0x1ad7f0(0x1e7)};const _0xfa283=_0x4e1e85[_0x1ad7f0(0x1f8)]()[_0x1ad7f0(0x1f6)](/\D/g,'');if(_0xfa283['length']!==0xa)return{'success':![],'error':_0x1ad7f0(0x1ec)};return _get(_0x1ad7f0(0x204)+_0xfa283);}async function getTrainInfo(_0x1774af){const _0x1c87f5=a0_0x4e53bf;if(!_0x1774af||typeof _0x1774af!==_0x1c87f5(0x20e)||_0x1774af[_0x1c87f5(0x1f8)]()[_0x1c87f5(0x1f0)]!==0x5)return{'success':![],'error':_0x1c87f5(0x1ef)};return _get(_0x1c87f5(0x1ee)+_0x1774af[_0x1c87f5(0x1f8)]());}async function trackTrain(_0x41f3d3,_0x4667d7){const _0x1101ce=a0_0x4e53bf;if(!_0x41f3d3||typeof _0x41f3d3!=='string'||_0x41f3d3[_0x1101ce(0x1f8)]()['length']!==0x5)return{'success':![],'error':_0x1101ce(0x1ef)};const _0x48b5a1=_0x4667d7?_0x1101ce(0x1fb)+_0x41f3d3[_0x1101ce(0x1f8)]()+'/'+encodeURIComponent(_0x4667d7[_0x1101ce(0x1f8)]()):'/api/trackTrain/'+_0x41f3d3[_0x1101ce(0x1f8)]()+'/today';return _get(_0x48b5a1);}async function getTrainHistory(_0x1c3848,_0x1d9528){const _0xa12d01=a0_0x4e53bf;if(!_0x1c3848||typeof _0x1c3848!==_0xa12d01(0x20e)||_0x1c3848[_0xa12d01(0x1f8)]()[_0xa12d01(0x1f0)]!==0x5)return{'success':![],'error':'Invalid\x20train\x20number.\x20It\x20must\x20be\x20a\x205-character\x20string.'};if(!_0x1d9528||typeof _0x1d9528!==_0xa12d01(0x20e)||!/^\d{2}-\d{2}-\d{4}$/[_0xa12d01(0x1e1)](_0x1d9528[_0xa12d01(0x1f8)]()))return{'success':![],'error':_0xa12d01(0x207)};return _get(_0xa12d01(0x20b)+_0x1c3848[_0xa12d01(0x1f8)]()+'/'+encodeURIComponent(_0x1d9528[_0xa12d01(0x1f8)]()));}async function liveAtStation(_0x2047f0,_0x59e4bd){const _0x4f2f92=a0_0x4e53bf;if(!_0x2047f0||typeof _0x2047f0!=='string')return{'success':![],'error':_0x4f2f92(0x1fc)};let _0x12e816='';if(_0x59e4bd!==undefined&&_0x59e4bd!==null){const _0x290be4=Number(_0x59e4bd);if(![0x2,0x4,0x8][_0x4f2f92(0x1eb)](_0x290be4))return{'success':![],'error':_0x4f2f92(0x1e5)};_0x12e816=_0x4f2f92(0x206)+_0x290be4;}return _get(_0x4f2f92(0x1e9)+_0x2047f0['trim']()[_0x4f2f92(0x205)]()+_0x12e816);}async function searchTrainBetweenStations(_0x4ee690,_0x4f75e9,_0x1831ad){const _0x1f7890=a0_0x4e53bf;if(!_0x4ee690||typeof _0x4ee690!=='string'||!_0x4f75e9||typeof _0x4f75e9!==_0x1f7890(0x20e)||_0x1831ad&&typeof _0x1831ad!=='string')return{'success':![],'error':_0x1f7890(0x210)};let _0x34500d=_0x1f7890(0x1fe)+_0x4ee690['trim']()[_0x1f7890(0x205)]()+'/'+_0x4f75e9[_0x1f7890(0x1f8)]()[_0x1f7890(0x205)]();return _0x1831ad&&(_0x34500d+=_0x1f7890(0x1f1)+encodeURIComponent(_0x1831ad['trim']())),_get(_0x34500d);}async function getAvailability(_0xa87837,_0x20594b,_0x57b964,_0x19d6b0,_0x9e0381,_0x1469da){const _0x5b8440=a0_0x4e53bf;if(!_0xa87837||!_0x20594b||!_0x57b964||!_0x19d6b0||!_0x9e0381||!_0x1469da)return{'success':![],'error':_0x5b8440(0x201)};const _0x4e3fa2=_0x20594b['trim']()[_0x5b8440(0x205)](),_0x1451e3=_0x57b964[_0x5b8440(0x1f8)]()[_0x5b8440(0x205)](),_0x44cde7=_0x9e0381[_0x5b8440(0x1f8)]()[_0x5b8440(0x205)](),_0x4d8914=_0x1469da['trim']()[_0x5b8440(0x205)](),_0x5257ce=_0xa87837[_0x5b8440(0x1f8)]();return _get(_0x5b8440(0x1f5)+_0x5257ce+'/'+_0x4e3fa2+'/'+_0x1451e3+'/'+encodeURIComponent(_0x19d6b0[_0x5b8440(0x1f8)]())+'/'+_0x44cde7+'/'+_0x4d8914);}async function fareLookup(_0x3aec91,_0x13acb8,_0x4613ae,_0x109711,_0x223e19,_0x351af0){const _0x3ab374=a0_0x4e53bf;if(!_0x3aec91||!_0x13acb8||!_0x4613ae||!_0x109711||!_0x223e19||!_0x351af0)return{'success':![],'error':'Incomplete\x20data.\x20Please\x20provide\x20all\x20required\x20fields.'};const _0x36809d=_0x13acb8[_0x3ab374(0x1f8)]()[_0x3ab374(0x205)](),_0x404327=_0x4613ae[_0x3ab374(0x1f8)]()[_0x3ab374(0x205)](),_0x47c7f0=_0x223e19[_0x3ab374(0x1f8)]()[_0x3ab374(0x205)](),_0xe89db6=_0x351af0[_0x3ab374(0x1f8)]()[_0x3ab374(0x205)](),_0x80402b=_0x3aec91[_0x3ab374(0x1f8)]();return _get(_0x3ab374(0x1f4)+_0x80402b+'/'+encodeURIComponent(_0x109711[_0x3ab374(0x1f8)]())+'/'+_0x36809d+'/'+_0x404327+'/'+_0x47c7f0+'/'+_0xe89db6);}export{configure,checkPNRStatus,getTrainInfo,trackTrain,getTrainHistory,liveAtStation,searchTrainBetweenStations,getAvailability,fareLookup};
|
|
1
|
+
const a0_0x2631c4=a0_0x71f0;(function(_0x2ce2c6,_0x544a57){const _0x37b4ee=a0_0x71f0,_0x5c47ec=_0x2ce2c6();while(!![]){try{const _0x558ce6=parseInt(_0x37b4ee(0x163))/0x1+-parseInt(_0x37b4ee(0x167))/0x2+-parseInt(_0x37b4ee(0x158))/0x3+-parseInt(_0x37b4ee(0x170))/0x4*(-parseInt(_0x37b4ee(0x17f))/0x5)+parseInt(_0x37b4ee(0x161))/0x6+parseInt(_0x37b4ee(0x160))/0x7+parseInt(_0x37b4ee(0x155))/0x8;if(_0x558ce6===_0x544a57)break;else _0x5c47ec['push'](_0x5c47ec['shift']());}catch(_0x4c4d49){_0x5c47ec['push'](_0x5c47ec['shift']());}}}(a0_0x1449,0xa8242));import{createHash,createHmac,randomBytes}from'node:crypto';const _baseUrl=a0_0x2631c4(0x16d),_sdkVersion='1',_defaultSdkSigningSecret=a0_0x2631c4(0x183);let _apiKey='',_sdkSigningSecret=_defaultSdkSigningSecret;function configure(_0x2d8da3){const _0x573901=a0_0x2631c4;if(!_0x2d8da3||typeof _0x2d8da3!==_0x573901(0x179))throw new Error('[railkit]\x20configure()\x20requires\x20a\x20valid\x20API\x20key\x20string.');_apiKey=_0x2d8da3[_0x573901(0x169)]();}function _hashPayload(_0x11eee6){const _0x39b94a=a0_0x2631c4;return createHash(_0x39b94a(0x175))[_0x39b94a(0x181)](_0x11eee6)[_0x39b94a(0x174)](_0x39b94a(0x15b));}function _buildSignature({method:_0xa87acc,path:_0x22cb60,timestamp:_0x1de83f,nonce:_0x5d615b,payloadHash:_0x36ede3}){const _0x5c958c=a0_0x2631c4,_0x4ec77c=[_0xa87acc[_0x5c958c(0x16f)](),_0x22cb60,_0x1de83f,_0x5d615b,_0x36ede3,_apiKey]['join']('\x0a');return createHmac(_0x5c958c(0x175),_sdkSigningSecret)[_0x5c958c(0x181)](_0x4ec77c)['digest'](_0x5c958c(0x15b));}function _getSdkSecurityHeaders(_0x1cedc9,_0x38efd8,_0x32854e=''){const _0x46967b=a0_0x2631c4,_0x494526=String(Date[_0x46967b(0x17d)]()),_0x46802c=randomBytes(0x20)[_0x46967b(0x16c)](_0x46967b(0x15b)),_0x341491=_hashPayload(_0x32854e),_0x22932=_buildSignature({'method':_0x1cedc9,'path':_0x38efd8,'timestamp':_0x494526,'nonce':_0x46802c,'payloadHash':_0x341491});return{'x-irctc-sdk-ts':_0x494526,'x-irctc-sdk-nonce':_0x46802c,'x-irctc-sdk-payload-sha256':_0x341491,'x-irctc-sdk-signature':_0x22932,'x-irctc-sdk-version':_sdkVersion};}async function _get(_0x2fbf36){const _0x1d78d9=a0_0x2631c4;if(!_apiKey)return{'success':![],'error':_0x1d78d9(0x15c)};try{const _0xa81f59=_getSdkSecurityHeaders(_0x1d78d9(0x185),_0x2fbf36,''),_0x4d9768=await fetch(''+_baseUrl+_0x2fbf36,{'method':'GET','headers':{'x-api-key':_apiKey,'Accept':_0x1d78d9(0x184),..._0xa81f59}}),_0x105368=await _0x4d9768['json']();return _0x105368&&typeof _0x105368===_0x1d78d9(0x171)&&!Array['isArray'](_0x105368)&&Object[_0x1d78d9(0x162)](_0x105368,_0x1d78d9(0x154),{'value':_0x4d9768['status'],'enumerable':![]}),_0x105368;}catch(_0x34494a){return{'success':![],'error':'Request\x20failed:\x20'+_0x34494a['message']};}}async function checkPNRStatus(_0x253651){const _0x388ea7=a0_0x2631c4;if(!_0x253651||typeof _0x253651!==_0x388ea7(0x179))return{'success':![],'error':_0x388ea7(0x17b)};const _0x333145=_0x253651['trim']()[_0x388ea7(0x177)](/\D/g,'');if(_0x333145[_0x388ea7(0x164)]!==0xa)return{'success':![],'error':_0x388ea7(0x15d)};return _get('/api/checkPNRStatus/'+_0x333145);}async function getTrainInfo(_0x3134d6){const _0x57ff9b=a0_0x2631c4;if(!_0x3134d6||typeof _0x3134d6!==_0x57ff9b(0x179)||_0x3134d6[_0x57ff9b(0x169)]()[_0x57ff9b(0x164)]!==0x5)return{'success':![],'error':_0x57ff9b(0x16a)};return _get(_0x57ff9b(0x176)+_0x3134d6[_0x57ff9b(0x169)]());}async function trackTrain(_0x1d3de3,_0x476a85){const _0x4c6c4b=a0_0x2631c4;if(!_0x1d3de3||typeof _0x1d3de3!==_0x4c6c4b(0x179)||_0x1d3de3[_0x4c6c4b(0x169)]()['length']!==0x5)return{'success':![],'error':_0x4c6c4b(0x16a)};const _0x3a5250=_0x476a85?'/api/trackTrain/'+_0x1d3de3[_0x4c6c4b(0x169)]()+'/'+encodeURIComponent(_0x476a85[_0x4c6c4b(0x169)]()):_0x4c6c4b(0x187)+_0x1d3de3[_0x4c6c4b(0x169)]()+_0x4c6c4b(0x180);return _get(_0x3a5250);}async function getTrainHistory(_0x254178,_0x208fa2){const _0x16d262=a0_0x2631c4;if(!_0x254178||typeof _0x254178!==_0x16d262(0x179)||_0x254178[_0x16d262(0x169)]()[_0x16d262(0x164)]!==0x5)return{'success':![],'error':_0x16d262(0x16a)};if(!_0x208fa2||typeof _0x208fa2!==_0x16d262(0x179)||!/^\d{2}-\d{2}-\d{4}$/[_0x16d262(0x15f)](_0x208fa2['trim']()))return{'success':![],'error':_0x16d262(0x168)};return _get(_0x16d262(0x166)+_0x254178[_0x16d262(0x169)]()+'/'+encodeURIComponent(_0x208fa2[_0x16d262(0x169)]()));}async function liveAtStation(_0x679978,_0x4ad254){const _0x6afaba=a0_0x2631c4;if(!_0x679978||typeof _0x679978!==_0x6afaba(0x179))return{'success':![],'error':_0x6afaba(0x172)};let _0x1d8ccf='';if(_0x4ad254!==undefined&&_0x4ad254!==null){const _0x5a77b2=Number(_0x4ad254);if(![0x2,0x4,0x8][_0x6afaba(0x159)](_0x5a77b2))return{'success':![],'error':_0x6afaba(0x186)};_0x1d8ccf=_0x6afaba(0x182)+_0x5a77b2;}return _get(_0x6afaba(0x16e)+_0x679978[_0x6afaba(0x169)]()[_0x6afaba(0x16f)]()+_0x1d8ccf);}async function searchTrainBetweenStations(_0x239d0f,_0x1f20f1,_0xd4cf2d){const _0x1345e1=a0_0x2631c4;if(!_0x239d0f||typeof _0x239d0f!==_0x1345e1(0x179)||!_0x1f20f1||typeof _0x1f20f1!==_0x1345e1(0x179)||_0xd4cf2d&&typeof _0xd4cf2d!=='string')return{'success':![],'error':_0x1345e1(0x17a)};let _0x4c81ae=_0x1345e1(0x157)+_0x239d0f[_0x1345e1(0x169)]()[_0x1345e1(0x16f)]()+'/'+_0x1f20f1['trim']()[_0x1345e1(0x16f)]();return _0xd4cf2d&&(_0x4c81ae+=_0x1345e1(0x156)+encodeURIComponent(_0xd4cf2d['trim']())),_get(_0x4c81ae);}async function getAvailability(_0x2c95a0,_0x40b024,_0x58d42a,_0xd52928,_0x3c1c35,_0xfa6763){const _0x375ffb=a0_0x2631c4;if(!_0x2c95a0||!_0x40b024||!_0x58d42a||!_0xd52928||!_0x3c1c35||!_0xfa6763)return{'success':![],'error':'Incomplete\x20data.\x20Please\x20provide\x20all\x20required\x20fields.'};const _0x321948=_0x40b024[_0x375ffb(0x169)]()[_0x375ffb(0x16f)](),_0x1b31a4=_0x58d42a['trim']()[_0x375ffb(0x16f)](),_0x49c03d=_0x3c1c35['trim']()[_0x375ffb(0x16f)](),_0xe3c355=_0xfa6763[_0x375ffb(0x169)]()[_0x375ffb(0x16f)](),_0x334cfb=_0x2c95a0[_0x375ffb(0x169)]();return _get('/api/getAvailability/'+_0x334cfb+'/'+_0x321948+'/'+_0x1b31a4+'/'+encodeURIComponent(_0xd52928['trim']())+'/'+_0x49c03d+'/'+_0xe3c355);}async function fareLookup(_0x11c3f7,_0x416e98,_0x1c2fef,_0x3786f7,_0x18343a,_0x11c364){const _0x33f2ba=a0_0x2631c4;if(!_0x11c3f7||!_0x416e98||!_0x1c2fef||!_0x3786f7||!_0x18343a||!_0x11c364)return{'success':![],'error':_0x33f2ba(0x173)};const _0x13318d=_0x416e98['trim']()[_0x33f2ba(0x16f)](),_0x18536d=_0x1c2fef[_0x33f2ba(0x169)]()[_0x33f2ba(0x16f)](),_0x124528=_0x18343a['trim']()['toUpperCase'](),_0x2073ff=_0x11c364[_0x33f2ba(0x169)]()[_0x33f2ba(0x16f)](),_0x25c7b6=_0x11c3f7['trim']();return _get(_0x33f2ba(0x178)+_0x25c7b6+'/'+encodeURIComponent(_0x3786f7[_0x33f2ba(0x169)]())+'/'+_0x13318d+'/'+_0x18536d+'/'+_0x124528+'/'+_0x2073ff);}async function cancelList(){return _get('/api/cancelled');}function a0_0x71f0(_0x216689,_0x63447a){_0x216689=_0x216689-0x154;const _0x14494a=a0_0x1449();let _0x71f07b=_0x14494a[_0x216689];if(a0_0x71f0['gbZJYF']===undefined){var _0x262760=function(_0x5d78e0){const _0x2c2905='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3e4499='',_0x2d8da3='';for(let _0x11eee6=0x0,_0xa87acc,_0x22cb60,_0x1de83f=0x0;_0x22cb60=_0x5d78e0['charAt'](_0x1de83f++);~_0x22cb60&&(_0xa87acc=_0x11eee6%0x4?_0xa87acc*0x40+_0x22cb60:_0x22cb60,_0x11eee6++%0x4)?_0x3e4499+=String['fromCharCode'](0xff&_0xa87acc>>(-0x2*_0x11eee6&0x6)):0x0){_0x22cb60=_0x2c2905['indexOf'](_0x22cb60);}for(let _0x5d615b=0x0,_0x36ede3=_0x3e4499['length'];_0x5d615b<_0x36ede3;_0x5d615b++){_0x2d8da3+='%'+('00'+_0x3e4499['charCodeAt'](_0x5d615b)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x2d8da3);};a0_0x71f0['GxRscx']=_0x262760,a0_0x71f0['LPTmbo']={},a0_0x71f0['gbZJYF']=!![];}const _0x3c4bea=_0x14494a[0x0];a0_0x71f0['CKjDOq']!==_0x3c4bea&&(a0_0x71f0['LPTmbo']={},a0_0x71f0['CKjDOq']=_0x3c4bea);const _0x58faeb=a0_0x71f0['LPTmbo'][_0x216689];return _0x58faeb===undefined?(_0x71f07b=a0_0x71f0['GxRscx'](_0x71f07b),a0_0x71f0['LPTmbo'][_0x216689]=_0x71f07b):_0x71f07b=_0x58faeb,_0x71f07b;}function a0_0x1449(){const _0x5f3ed1=['ue5sig51BwjLCIbTDxn0igjLigv4ywn0BhKGmtaGzgLNAxrZlG','l2fWAs90CMfPBNmVC2vHCMnOp25HBwu9','DgvZDa','mZi3mJG3mvbuBgfHsa','odG3odC0v0jPDuz2','zgvMAw5LuhjVCgvYDhK','mJGXnte5Eg91tfPR','BgvUz3rO','u3rHDgLVBIbJB2rLig11C3qGyMuGms01igXLDhrLCNmGB3iGzgLNAxrZlG','l2fWAs90CMfPBKHPC3rVCNKV','mJyYmty5ohbMExjAtG','sM91CM5LEsbKyxrLigLZihjLCxvPCMvKigfUzcbTDxn0igjLigLUierelu1nlvLzwvKGzM9YBwf0lG','DhjPBq','sw52ywXPzcb0CMfPBIbUDw1IzxiUieL0ig11C3qGyMuGysa1lwnOyxjHy3rLCIbZDhjPBMCU','rgf0zsbTDxn0igjLigLUierelu1nlvLzwvKGzM9YBwf0lG','Dg9tDhjPBMC','Ahr0Chm6lY9YywLSA2L0lwfWAs5YywPPDMr1yMv5lMrLDG','l2fWAs9SAxzLqxrtDgf0Aw9UlW','Dg9vChbLCKnHC2u','mJyYmdy0mhH5AxDwyq','B2jQzwn0','u3rHDgLVBIbJB2rLigLZihjLCxvPCMvKigfUzcbTDxn0igjLigeGC3rYAw5NlG','sw5JB21WBgv0zsbKyxrHlIbqBgvHC2uGChjVDMLKzsbHBgWGCMvXDwLYzwqGzMLLBgrZlG','zgLNzxn0','C2HHmJu2','l2fWAs9NzxruCMfPBKLUzM8V','CMvWBgfJzq','l2fWAs9MyxjLtg9VA3vWlW','C3rYAw5N','qM90AcbMCM9TigfUzcb0BYbZDgf0Aw9UignVzgvZigfYzsbYzxf1AxjLzcbHBMqGBxvZDcbIzsbZDhjPBMDZlG','ue5sig51BwjLCIbPCYbYzxf1AxjLzcbHBMqGBxvZDcbIzsbHihn0CMLUzY4','l2fWAs90CMfPBI8','BM93','l2fWAs9ZDgf0Aw9UlW','nwnRq0PTwa','l3rVzgf5','DxbKyxrL','p2HYCZ0','otDJntzLmdHImJDImtyXmti0zJG4ywnKngyYngqXyMq1mgy0oda3nwyXmwrJmJnIowvHnMmWyMm5yJjModC5na','yxbWBgLJyxrPB24VANnVBG','r0vu','sw52ywXPzcaNAg91CNmNihzHBhvLlIbbBgXVD2vKihzHBhvLCZOGmIWGncWGoc4','l2fWAs90CMfJA1rYywLUlW','C3rHDhvZq29Kzq','ntKYnJG4meHfExPfqq','p2rHDgu9','l2fWAs9ZzwfYy2HuCMfPBKjLDhDLzw5tDgf0Aw9UCY8','odGWntq4DxLcBMHW','Aw5JBhvKzxm','u3rHDgLVBIbUyw1Lig11C3qGy29UDgfPBIbHDcbSzwfZDcaYignOyxjHy3rLCNmU','Agv4','CMfPBgTPDcbPCYbUB3qGy29UzMLNDxjLzc4Gq2fSBcbJB25MAwD1CMuOyxbPs2v5ksbMAxjZDc4'];a0_0x1449=function(){return _0x5f3ed1;};return a0_0x1449();}async function stationByCode(_0x32f5cf){const _0x8a4043=a0_0x2631c4;if(!_0x32f5cf||typeof _0x32f5cf!=='string'||!/^[A-Za-z0-9]{1,5}$/[_0x8a4043(0x15f)](_0x32f5cf['trim']()))return{'success':![],'error':_0x8a4043(0x165)};return _get(_0x8a4043(0x17e)+_0x32f5cf[_0x8a4043(0x169)]()[_0x8a4043(0x16f)]());}async function stationsByName(_0x4b1c54){const _0x14154c=a0_0x2631c4;if(!_0x4b1c54||typeof _0x4b1c54!==_0x14154c(0x179)||_0x4b1c54[_0x14154c(0x169)]()[_0x14154c(0x164)]<0x2)return{'success':![],'error':_0x14154c(0x15a)};return _get('/api/stations/search?name='+encodeURIComponent(_0x4b1c54['trim']()));}async function trainByNumber(_0x3447e2){const _0x35352e=a0_0x2631c4;if(!_0x3447e2||typeof _0x3447e2!=='string'||!/^\d{5}$/[_0x35352e(0x15f)](_0x3447e2[_0x35352e(0x169)]()))return{'success':![],'error':'Train\x20number\x20must\x20be\x20exactly\x205\x20digits.'};return _get(_0x35352e(0x17c)+_0x3447e2[_0x35352e(0x169)]());}async function trainsByName(_0x11f378){const _0x26ba04=a0_0x2631c4;if(!_0x11f378||typeof _0x11f378!==_0x26ba04(0x179)||_0x11f378[_0x26ba04(0x169)]()[_0x26ba04(0x164)]<0x2)return{'success':![],'error':'Train\x20name\x20must\x20contain\x20at\x20least\x202\x20characters.'};return _get(_0x26ba04(0x15e)+encodeURIComponent(_0x11f378[_0x26ba04(0x169)]()));}async function trainTimetableAtStation(_0x53e732,_0x1fb4d0){const _0x583460=a0_0x2631c4;if(!_0x53e732||typeof _0x53e732!==_0x583460(0x179)||!/^[A-Za-z0-9]{1,5}$/[_0x583460(0x15f)](_0x53e732[_0x583460(0x169)]()))return{'success':![],'error':_0x583460(0x165)};if(_0x1fb4d0!==undefined&&_0x1fb4d0!==null&&(typeof _0x1fb4d0!=='string'||!/^\d{2}-\d{2}-\d{4}$/['test'](_0x1fb4d0['trim']())))return{'success':![],'error':_0x583460(0x16b)};const _0x12360a=_0x1fb4d0?'?date='+encodeURIComponent(_0x1fb4d0[_0x583460(0x169)]()):'';return _get(_0x583460(0x17e)+_0x53e732['trim']()[_0x583460(0x16f)]()+'/timetable'+_0x12360a);}export{configure,checkPNRStatus,getTrainInfo,trackTrain,getTrainHistory,liveAtStation,searchTrainBetweenStations,getAvailability,fareLookup,cancelList,stationByCode,stationsByName,trainByNumber,trainsByName,trainTimetableAtStation};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "railkit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "🚂 Complete Node.js SDK for Indian Railways - Check PNR status, train schedules, live running status, seat availability, station information and more. Promise-based API with TypeScript support.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"railkit",
|