railkit 4.1.0 → 5.0.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # RailKit
2
2
 
3
- [![npm version](https://badge.fury.io/js/railkit.svg)](https://www.npmjs.com/package/railkit)
3
+ [![npm version](https://badge.fury.io/js/railkit.svg)](https://www.npmjs.com/package/railkit)
4
4
  [![Downloads](https://img.shields.io/npm/dm/railkit.svg)](https://www.npmjs.com/package/railkit)
5
5
  [![License](https://img.shields.io/npm/l/railkit.svg)](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 Code (e.g., 'NDLS' for New Delhi)
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
@@ -122,3 +126,36 @@ export function fareLookup(
122
126
  * const result = await cancelList();
123
127
  */
124
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>;
@@ -1 +1 @@
1
- const a0_0xf7c14=a0_0x3269;(function(_0x4334a9,_0x2797d0){const _0x87a19c=a0_0x3269,_0x56bb5a=_0x4334a9();while(!![]){try{const _0x4a1146=parseInt(_0x87a19c(0x9b))/0x1*(parseInt(_0x87a19c(0x94))/0x2)+parseInt(_0x87a19c(0x89))/0x3+-parseInt(_0x87a19c(0x9c))/0x4*(-parseInt(_0x87a19c(0x9d))/0x5)+parseInt(_0x87a19c(0xb4))/0x6*(-parseInt(_0x87a19c(0x9f))/0x7)+parseInt(_0x87a19c(0x8e))/0x8*(-parseInt(_0x87a19c(0xad))/0x9)+parseInt(_0x87a19c(0x97))/0xa+parseInt(_0x87a19c(0x91))/0xb;if(_0x4a1146===_0x2797d0)break;else _0x56bb5a['push'](_0x56bb5a['shift']());}catch(_0x26f69f){_0x56bb5a['push'](_0x56bb5a['shift']());}}}(a0_0x20dd,0xcfb26));import{createHash,createHmac,randomBytes}from'node:crypto';function a0_0x20dd(){const _0x2e81eb=['l2fWAs90CMfPBKHPC3rVCNKV','sw52ywXPzcaNAg91CNmNihzHBhvLlIbbBgXVD2vKihzHBhvLCZOGmIWGncWGoc4','l2fWAs9Jyw5JzwXSzwq','ANnVBG','nZu3odqYthv3DKPd','DgvZDa','l3rVzgf5','DxbKyxrL','C3rYAw5N','zgLNzxn0','Agv4','sM91CM5LEsbKyxrLigLZihjLCxvPCMvKigfUzcbTDxn0igjLigLUierelu1nlvLzwvKGzM9YBwf0lG','AxnbCNjHEq','mJK4nZi1nMfIvfbpEG','C3rHDhvZq29Kzq','l2fWAs90CMfJA1rYywLUlW','CMfPBgTPDcbPCYbUB3qGy29UzMLNDxjLzc4Gq2fSBcbJB25MAwD1CMuOyxbPs2v5ksbMAxjZDc4','BM93','ogDizuDqDq','DhjPBq','AM9PBG','odCZoti0n0L2EuXNtW','BwvZC2fNzq','sw5JB21WBgv0zsbKyxrHlIbqBgvHC2uGChjVDMLKzsbHBgWGCMvXDwLYzwqGzMLLBgrZlG','mKjJELDMtq','Dg9vChbLCKnHC2u','Dg9tDhjPBMC','mZG3mZaZme5xEuv1zW','r0vu','p2HYCZ0','C2HHmJu2','nJqZntG1AxnXrxP0','mti0vvLmy2ri','mJe4ntGWu2fcwLvg','Ahr0Chm6lY9YywLSA2L0lwfWAs5YywPPDMr1yMv5lMrLDG','otfvrfrnsee','yxbWBgLJyxrPB24VANnVBG','otDJntzLmdHImJDImtyXmti0zJG4ywnKngyYngqXyMq1mgy0oda3nwyXmwrJmJnIowvHnMmWyMm5yJjModC5na','w3jHAwXRAxrDignVBMzPz3vYzsGPihjLCxvPCMvZigeGDMfSAwqGqvbjigTLEsbZDhjPBMCU','l2fWAs9NzxrbDMfPBgfIAwXPDhKV','B2jQzwn0','sw52ywXPzcb0CMfPBIbUDw1IzxiUieL0ig11C3qGyMuGysa1lwnOyxjHy3rLCIbZDhjPBMCU','BgvUz3rO','zgvMAw5LuhjVCgvYDhK','l2fWAs9ZzwfYy2HuCMfPBKjLDhDLzw5tDgf0Aw9UCY8','ue5sig51BwjLCIbPCYbYzxf1AxjLzcbHBMqGBxvZDcbIzsbHihn0CMLUzY4','l2fWAs9NzxruCMfPBKLUzM8V','CMvWBgfJzq','l2fWAs9SAxzLqxrtDgf0Aw9UlW','mtuXntiZnJrZqwT2B00','Aw5JBhvKzxm','ue5sig51BwjLCIbTDxn0igjLigv4ywn0BhKGmtaGzgLNAxrZlG'];a0_0x20dd=function(){return _0x2e81eb;};return a0_0x20dd();}const _baseUrl=a0_0xf7c14(0x9e),_sdkVersion='1',_defaultSdkSigningSecret=a0_0xf7c14(0xa1);let _apiKey='',_sdkSigningSecret=_defaultSdkSigningSecret;function configure(_0x2ad275){const _0x3d51b5=a0_0xf7c14;if(!_0x2ad275||typeof _0x2ad275!=='string')throw new Error(_0x3d51b5(0xa2));_apiKey=_0x2ad275[_0x3d51b5(0x8f)]();}function a0_0x3269(_0x52887e,_0x510e78){_0x52887e=_0x52887e-0x89;const _0x20dd21=a0_0x20dd();let _0x32697e=_0x20dd21[_0x52887e];if(a0_0x3269['WuOdeO']===undefined){var _0x342ce7=function(_0x2ebeb6){const _0x231039='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x2ad275='',_0x1fe5aa='';for(let _0x408043=0x0,_0x5175ff,_0x2e1d95,_0x4128a2=0x0;_0x2e1d95=_0x2ebeb6['charAt'](_0x4128a2++);~_0x2e1d95&&(_0x5175ff=_0x408043%0x4?_0x5175ff*0x40+_0x2e1d95:_0x2e1d95,_0x408043++%0x4)?_0x2ad275+=String['fromCharCode'](0xff&_0x5175ff>>(-0x2*_0x408043&0x6)):0x0){_0x2e1d95=_0x231039['indexOf'](_0x2e1d95);}for(let _0x171826=0x0,_0xf0d80c=_0x2ad275['length'];_0x171826<_0xf0d80c;_0x171826++){_0x1fe5aa+='%'+('00'+_0x2ad275['charCodeAt'](_0x171826)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x1fe5aa);};a0_0x3269['wSBjKo']=_0x342ce7,a0_0x3269['SieHEL']={},a0_0x3269['WuOdeO']=!![];}const _0xbbcd55=_0x20dd21[0x0],_0x159f68=_0x52887e+_0xbbcd55,_0x274778=a0_0x3269['SieHEL'][_0x159f68];return!_0x274778?(_0x32697e=a0_0x3269['wSBjKo'](_0x32697e),a0_0x3269['SieHEL'][_0x159f68]=_0x32697e):_0x32697e=_0x274778,_0x32697e;}function _hashPayload(_0x1fe5aa){const _0x59aee7=a0_0xf7c14;return createHash(_0x59aee7(0x9a))['update'](_0x1fe5aa)[_0x59aee7(0xb9)](_0x59aee7(0xba));}function _buildSignature({method:_0x408043,path:_0x5175ff,timestamp:_0x2e1d95,nonce:_0x4128a2,payloadHash:_0x171826}){const _0x2faa27=a0_0xf7c14,_0xf0d80c=[_0x408043['toUpperCase'](),_0x5175ff,_0x2e1d95,_0x4128a2,_0x171826,_apiKey][_0x2faa27(0x90)]('\x0a');return createHmac(_0x2faa27(0x9a),_sdkSigningSecret)[_0x2faa27(0xb7)](_0xf0d80c)[_0x2faa27(0xb9)](_0x2faa27(0xba));}function _getSdkSecurityHeaders(_0x4475c1,_0x12bf87,_0x2274d3=''){const _0x24549a=a0_0xf7c14,_0x1ed60f=String(Date[_0x24549a(0x8d)]()),_0x423511=randomBytes(0x20)[_0x24549a(0x96)](_0x24549a(0xba)),_0x15c4fd=_hashPayload(_0x2274d3),_0x231c1c=_buildSignature({'method':_0x4475c1,'path':_0x12bf87,'timestamp':_0x1ed60f,'nonce':_0x423511,'payloadHash':_0x15c4fd});return{'x-irctc-sdk-ts':_0x1ed60f,'x-irctc-sdk-nonce':_0x423511,'x-irctc-sdk-payload-sha256':_0x15c4fd,'x-irctc-sdk-signature':_0x231c1c,'x-irctc-sdk-version':_sdkVersion};}async function _get(_0x4651b0){const _0x34f146=a0_0xf7c14;if(!_apiKey)return{'success':![],'error':_0x34f146(0x8c)};try{const _0x4e8d12=_getSdkSecurityHeaders(_0x34f146(0x98),_0x4651b0,''),_0x2053cd=await fetch(''+_baseUrl+_0x4651b0,{'method':_0x34f146(0x98),'headers':{'x-api-key':_apiKey,'Accept':_0x34f146(0xa0),..._0x4e8d12}}),_0x23d25c=await _0x2053cd[_0x34f146(0xb3)]();return _0x23d25c&&typeof _0x23d25c===_0x34f146(0xa4)&&!Array[_0x34f146(0xbc)](_0x23d25c)&&Object[_0x34f146(0xa7)](_0x23d25c,_0x34f146(0x8a),{'value':_0x2053cd['status'],'enumerable':![]}),_0x23d25c;}catch(_0x4fd11d){return{'success':![],'error':'Request\x20failed:\x20'+_0x4fd11d[_0x34f146(0x92)]};}}async function checkPNRStatus(_0x24a673){const _0x4156c1=a0_0xf7c14;if(!_0x24a673||typeof _0x24a673!==_0x4156c1(0xb8))return{'success':![],'error':_0x4156c1(0xa9)};const _0x4c0c43=_0x24a673[_0x4156c1(0x8f)]()[_0x4156c1(0xab)](/\D/g,'');if(_0x4c0c43[_0x4156c1(0xa6)]!==0xa)return{'success':![],'error':_0x4156c1(0xaf)};return _get('/api/checkPNRStatus/'+_0x4c0c43);}async function getTrainInfo(_0x575d82){const _0x4a543e=a0_0xf7c14;if(!_0x575d82||typeof _0x575d82!==_0x4a543e(0xb8)||_0x575d82[_0x4a543e(0x8f)]()[_0x4a543e(0xa6)]!==0x5)return{'success':![],'error':_0x4a543e(0xa5)};return _get(_0x4a543e(0xaa)+_0x575d82[_0x4a543e(0x8f)]());}async function trackTrain(_0x252368,_0xea23f8){const _0x4ca83d=a0_0xf7c14;if(!_0x252368||typeof _0x252368!==_0x4ca83d(0xb8)||_0x252368[_0x4ca83d(0x8f)]()['length']!==0x5)return{'success':![],'error':_0x4ca83d(0xa5)};const _0x44fbeb=_0xea23f8?_0x4ca83d(0x8b)+_0x252368[_0x4ca83d(0x8f)]()+'/'+encodeURIComponent(_0xea23f8[_0x4ca83d(0x8f)]()):'/api/trackTrain/'+_0x252368['trim']()+_0x4ca83d(0xb6);return _get(_0x44fbeb);}async function getTrainHistory(_0x3a6af5,_0x96935b){const _0x582afa=a0_0xf7c14;if(!_0x3a6af5||typeof _0x3a6af5!==_0x582afa(0xb8)||_0x3a6af5[_0x582afa(0x8f)]()['length']!==0x5)return{'success':![],'error':'Invalid\x20train\x20number.\x20It\x20must\x20be\x20a\x205-character\x20string.'};if(!_0x96935b||typeof _0x96935b!==_0x582afa(0xb8)||!/^\d{2}-\d{2}-\d{4}$/[_0x582afa(0xb5)](_0x96935b[_0x582afa(0x8f)]()))return{'success':![],'error':_0x582afa(0xbb)};return _get(_0x582afa(0xb0)+_0x3a6af5[_0x582afa(0x8f)]()+'/'+encodeURIComponent(_0x96935b['trim']()));}async function liveAtStation(_0x2a8898,_0xf8fdc9){const _0x5e05e1=a0_0xf7c14;if(!_0x2a8898||typeof _0x2a8898!==_0x5e05e1(0xb8))return{'success':![],'error':'Station\x20code\x20is\x20required\x20and\x20must\x20be\x20a\x20string.'};let _0x8603bc='';if(_0xf8fdc9!==undefined&&_0xf8fdc9!==null){const _0x4d00cb=Number(_0xf8fdc9);if(![0x2,0x4,0x8][_0x5e05e1(0xae)](_0x4d00cb))return{'success':![],'error':_0x5e05e1(0xb1)};_0x8603bc=_0x5e05e1(0x99)+_0x4d00cb;}return _get(_0x5e05e1(0xac)+_0x2a8898[_0x5e05e1(0x8f)]()[_0x5e05e1(0x95)]()+_0x8603bc);}async function searchTrainBetweenStations(_0x461051,_0x51e788,_0x1fca76){const _0x5ebd63=a0_0xf7c14;if(!_0x461051||typeof _0x461051!==_0x5ebd63(0xb8)||!_0x51e788||typeof _0x51e788!==_0x5ebd63(0xb8)||_0x1fca76&&typeof _0x1fca76!==_0x5ebd63(0xb8))return{'success':![],'error':'Both\x20from\x20and\x20to\x20station\x20codes\x20are\x20required\x20and\x20must\x20be\x20strings.'};let _0x12793f=_0x5ebd63(0xa8)+_0x461051[_0x5ebd63(0x8f)]()[_0x5ebd63(0x95)]()+'/'+_0x51e788[_0x5ebd63(0x8f)]()['toUpperCase']();return _0x1fca76&&(_0x12793f+='?date='+encodeURIComponent(_0x1fca76[_0x5ebd63(0x8f)]())),_get(_0x12793f);}async function getAvailability(_0x47d64f,_0x53e183,_0x4ea6e5,_0x332390,_0x389cb5,_0x111332){const _0x3a0efd=a0_0xf7c14;if(!_0x47d64f||!_0x53e183||!_0x4ea6e5||!_0x332390||!_0x389cb5||!_0x111332)return{'success':![],'error':'Incomplete\x20data.\x20Please\x20provide\x20all\x20required\x20fields.'};const _0x344191=_0x53e183[_0x3a0efd(0x8f)]()['toUpperCase'](),_0xa2f89d=_0x4ea6e5[_0x3a0efd(0x8f)]()[_0x3a0efd(0x95)](),_0x2b0f49=_0x389cb5['trim']()[_0x3a0efd(0x95)](),_0x3a804c=_0x111332['trim']()[_0x3a0efd(0x95)](),_0x1e0dc4=_0x47d64f[_0x3a0efd(0x8f)]();return _get(_0x3a0efd(0xa3)+_0x1e0dc4+'/'+_0x344191+'/'+_0xa2f89d+'/'+encodeURIComponent(_0x332390[_0x3a0efd(0x8f)]())+'/'+_0x2b0f49+'/'+_0x3a804c);}async function fareLookup(_0x979b0,_0xb77872,_0x2cb595,_0x14a0ee,_0x219a26,_0x2e2e2b){const _0x4e3da1=a0_0xf7c14;if(!_0x979b0||!_0xb77872||!_0x2cb595||!_0x14a0ee||!_0x219a26||!_0x2e2e2b)return{'success':![],'error':_0x4e3da1(0x93)};const _0x21147a=_0xb77872[_0x4e3da1(0x8f)]()[_0x4e3da1(0x95)](),_0x42f52d=_0x2cb595['trim']()[_0x4e3da1(0x95)](),_0x1d8f93=_0x219a26[_0x4e3da1(0x8f)]()['toUpperCase'](),_0x3bc870=_0x2e2e2b[_0x4e3da1(0x8f)]()['toUpperCase'](),_0x160792=_0x979b0['trim']();return _get('/api/fareLookup/'+_0x160792+'/'+encodeURIComponent(_0x14a0ee['trim']())+'/'+_0x21147a+'/'+_0x42f52d+'/'+_0x1d8f93+'/'+_0x3bc870);}async function cancelList(){const _0x41fd9c=a0_0xf7c14;return _get(_0x41fd9c(0xb2));}export{configure,checkPNRStatus,getTrainInfo,trackTrain,getTrainHistory,liveAtStation,searchTrainBetweenStations,getAvailability,fareLookup,cancelList};
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": "4.1.0",
3
+ "version": "5.0.1",
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",
@@ -1,143 +0,0 @@
1
- > ## ⚠️ DEPRECATION NOTICE
2
- >
3
- > **`irctc-connect` has been renamed to [`railkit`](https://www.npmjs.com/package/railkit).**
4
- >
5
- > This package will continue to work for now, but it will **not** receive new features, bug fixes, or security updates. Please migrate to `railkit` as soon as possible.
6
- >
7
- > ### 🔄 Migrate in 3 steps
8
- >
9
- > ```bash
10
- > # 1. Remove the old package
11
- > npm uninstall irctc-connect
12
- >
13
- > # 2. Install the new package
14
- > npm install railkit
15
- > ```
16
- >
17
- > ```diff
18
- > - import { configure, checkPNRStatus } from "irctc-connect";
19
- > + import { configure, checkPNRStatus } from "railkit";
20
- > ```
21
- >
22
- > 📖 **New documentation:** [https://railkit.rajivdubey.dev](https://railkit.rajivdubey.dev)
23
- > 📦 **New repository:** [github.com/RAJIV81205/RailKit](https://github.com/RAJIV81205/RailKit)
24
- > 🚀 **npm page:** [npmjs.com/package/railkit](https://www.npmjs.com/package/railkit)
25
- >
26
- > ---
27
-
28
- # IRCTC Connect (DEPRECATED)
29
-
30
- [![npm version](https://badge.fury.io/js/irctc-connect.svg)](https://www.npmjs.com/package/irctc-connect)
31
- [![Downloads](https://img.shields.io/npm/dm/irctc-connect.svg)](https://www.npmjs.com/package/irctc-connect)
32
- [![License: ISC](https://img.shields.io/npm/l/irctc-connect.svg)](https://github.com/RAJIV81205/RailKit/blob/main/LICENSE)
33
- [![Status: Deprecated](https://img.shields.io/badge/status-deprecated-red.svg)](#-deprecation-notice)
34
-
35
- <img width="1536" height="657" alt="IRCTC Connect Banner" src="https://github.com/user-attachments/assets/39c770a2-639c-443c-93b6-4e78889e78b0" />
36
-
37
- > **Heads up:** This is the **legacy** `irctc-connect` package. It still works, but the actively maintained successor is **[`railkit`](https://www.npmjs.com/package/railkit)**. New users should install `railkit` directly.
38
-
39
- A comprehensive Node.js SDK for Indian Railways. Get real-time PNR status, train information, live tracking, station updates, train search, and seat availability — all through a single, clean API.
40
-
41
- ---
42
-
43
- ## ✨ Features
44
-
45
- - 🎫 **PNR Status** — Real-time PNR status with full passenger details
46
- - 🚂 **Train Information** — Complete train details with station-by-station route
47
- - 📍 **Live Train Tracking** — Real-time position and delay info for any train
48
- - 🚉 **Live Station Board** — Upcoming trains at any station right now
49
- - 🔍 **Train Search** — Find all direct trains between two stations
50
- - 💺 **Seat Availability** — Check availability and fare for any class and quota
51
- - 💰 **Fare Lookup** — Full fare breakdown for any train, class, and quota
52
- - ⚡ **Fast & Reliable** — Built-in timeout handling, input validation, and caching
53
-
54
- ---
55
-
56
- ## 📦 Installation (NEW package — recommended)
57
-
58
- ```bash
59
- npm install railkit
60
- ```
61
-
62
- ### Legacy installation (this package)
63
-
64
- If you specifically need the legacy `irctc-connect` package — for example to keep an existing project running while you migrate — you can still install it, but a deprecation warning will be shown on every install/update:
65
-
66
- ```bash
67
- npm install irctc-connect@^3.3.1
68
- ```
69
-
70
- ---
71
-
72
- ## 🔑 Getting an API Key
73
-
74
- 1. Visit **[railkit.rajivdubey.dev](https://railkit.rajivdubey.dev)**
75
- 2. Sign up and navigate to your Dashboard
76
- 3. Generate an API key from the **API Keys** section
77
- 4. Copy the key — you'll use it in the next step
78
-
79
- ---
80
-
81
- ## 🚀 Quick Start
82
-
83
- ### Step 1 — Add your API key to `.env`
84
-
85
- ```bash
86
- # .env
87
- IRCTC_API_KEY=your_api_key_here
88
- ```
89
-
90
- ### Step 2 — Use the SDK
91
-
92
- **With the new `railkit` package (recommended):**
93
-
94
- ```js
95
- import { configure, checkPNRStatus } from "railkit";
96
-
97
- configure(process.env.IRCTC_API_KEY);
98
-
99
- const result = await checkPNRStatus("1234567890");
100
- console.log(result);
101
- ```
102
-
103
- **With the legacy `irctc-connect` package (still works):**
104
-
105
- ```js
106
- import { configure, checkPNRStatus } from "irctc-connect";
107
-
108
- configure(process.env.IRCTC_API_KEY);
109
-
110
- const result = await checkPNRStatus("1234567890");
111
- console.log(result);
112
- ```
113
-
114
- The API surface is identical — once you've swapped the import, you're done.
115
-
116
- ---
117
-
118
- ## 🧭 Migration Checklist
119
-
120
- - [ ] Run `npm uninstall irctc-connect`
121
- - [ ] Run `npm install railkit`
122
- - [ ] Replace every `from "irctc-connect"` with `from "railkit"`
123
- - [ ] Re-test your application
124
- - [ ] Deploy 🚀
125
-
126
- The `configure(apiKey)` call and all function names/signatures remain the same, so no other code changes are required.
127
-
128
- ---
129
-
130
- ## 📚 Documentation
131
-
132
- | Resource | Link |
133
- | ----------------- | ------------------------------------------------------------------------------------- |
134
- | New docs site | <https://railkit.rajivdubey.dev> |
135
- | npm (new package) | <https://www.npmjs.com/package/railkit> |
136
- | GitHub repository | <https://github.com/RAJIV81205/RailKit> |
137
- | Issues | <https://github.com/RAJIV81205/RailKit/issues> |
138
-
139
- ---
140
-
141
- ## 📜 License
142
-
143
- ISC © [Rajiv81205](https://github.com/RAJIV81205)
@@ -1,116 +0,0 @@
1
- /**
2
- * Configure the SDK with your API key before using any other function.
3
- * The backend URL is managed by the package - you only need your API key.
4
- *
5
- * @example
6
- * configure('your-api-key-here');
7
- */
8
- export function configure(apiKey: string): void;
9
-
10
- /**
11
- * Check the PNR status for a given 10-digit PNR number.
12
- *
13
- * @example
14
- * const result = await checkPNRStatus('1234567890');
15
- *
16
- */
17
- export function checkPNRStatus(pnr: string): Promise<any>;
18
-
19
- /**
20
- * Get detailed information and route for a given 5-digit train number.
21
- *
22
- * @example
23
- * const result = await getTrainInfo('12301');
24
- *
25
- */
26
- export function getTrainInfo(trainNumber: string): Promise<any>;
27
-
28
- /**
29
- * Get the live running status of a train.
30
- * @param date - Journey date in DD-MM-YYYY format (optional, defaults to today)
31
- *
32
- * @example
33
- * const result = await trackTrain('12301', '15-04-2025');
34
- *
35
- */
36
- export function trackTrain(trainNumber: string, date?: string): Promise<any>;
37
-
38
- /**
39
- * Get the completed journey history of a train for a specific journey date.
40
- * Returns the persisted TrainHistory record once the train has reached its
41
- * destination, including the full station-by-station timeline, per-stop delays,
42
- * and the final coach position.
43
- *
44
- * @param trainNumber - 5-digit train number
45
- * @param journeyDate - Journey date in DD-MM-YYYY format
46
- *
47
- * @example
48
- * const result = await getTrainHistory('12301', '15-04-2025');
49
- */
50
- export function getTrainHistory(trainNumber: string, journeyDate: string): Promise<any>;
51
-
52
- /**
53
- * Get the list of upcoming trains at a station.
54
- * @param stationCode - Station Code (e.g., 'NDLS' for New Delhi)
55
- * @param hours - Time window in hours: 2, 4, or 8 (default 2)
56
- *
57
- * @example
58
- * const result = await liveAtStation('NDLS', 2);
59
- */
60
- export function liveAtStation(stationCode: string, hours?: 2 | 4 | 8): Promise<any>;
61
-
62
- /**
63
- * Search for all direct trains between two stations.
64
- * @param fromStnCode - Source station code
65
- * @param toStnCode - Destination station code
66
- * @param date - Journey date in DD-MM-YYYY format (optional)
67
- *
68
- * @example
69
- * const result = await searchTrainBetweenStations('NDLS', 'BCT', '15-04-2025');
70
- */
71
- export function searchTrainBetweenStations(fromStnCode: string, toStnCode: string, date?: string): Promise<any>;
72
-
73
- /**
74
- * Check seat availability for a specific train, class, and date.
75
- * @param trainNo - 5-digit train number
76
- * @param fromStnCode - Source station code
77
- * @param toStnCode - Destination station code
78
- * @param date - Journey date in DD-MM-YYYY format
79
- * @param coach - '2S' | 'SL' | '3A' | '3E' | '2A' | '1A' | 'CC' | 'EC'
80
- * @param quota - 'GN' | 'LD' | 'SS' | 'TQ'
81
- *
82
- * @example
83
- * const result = await getAvailability('12301', 'NDLS', 'HWH', '15-04-2025', '3A', 'GN');
84
- *
85
- */
86
- export function getAvailability(
87
- trainNo: string,
88
- fromStnCode: string,
89
- toStnCode: string,
90
- date: string,
91
- coach: string,
92
- quota: string
93
- ): Promise<any>;
94
-
95
- /**
96
- * Get the fare breakdown for a train journey.
97
- * Returns baseFare, reservation, superfast, catering, GST, dynamicFare and totalFare.
98
- *
99
- * @param trainNo - 5-digit train number
100
- * @param fromStnCode - Source station code
101
- * @param toStnCode - Destination station code
102
- * @param date - Journey date in DD-MM-YYYY format
103
- * @param travelClass - '1A' | '2A' | '3A' | '3E' | 'CC' | 'EC' | 'EA' | 'FC' | 'SL' | '2S' | 'VS' | 'CH' | 'HS' | 'VC' | 'VA'
104
- * @param quota - 'GN' | 'TQ' | 'LD' | 'DF' | 'FT' | 'LB' | 'PT' | 'YU' | 'DP' | 'HP' | 'PH' | 'SS'
105
- *
106
- * @example
107
- * const result = await fareLookup('12313', 'ASN', 'NDLS', '06-06-2026', '3A', 'GN');
108
- */
109
- export function fareLookup(
110
- trainNo: string,
111
- fromStnCode: string,
112
- toStnCode: string,
113
- date: string,
114
- travelClass: string,
115
- quota: string
116
- ): Promise<any>;
@@ -1 +0,0 @@
1
- function a0_0x4b5b(){const _0x49030c=['l2fWAs9NzxrbDMfPBgfIAwXPDhKV','C3rYAw5N','ndu1ndr0BLnPweG','zgLNzxn0','w2LYy3rJlwnVBM5Ly3rDignVBMzPz3vYzsGPihjLCxvPCMvZigeGDMfSAwqGqvbjigTLEsbZDhjPBMCU','u3rHDgLVBIbJB2rLigLZihjLCxvPCMvKigfUzcbTDxn0igjLigeGC3rYAw5NlG','l2fWAs9MyxjLtg9VA3vWlW','yxbWBgLJyxrPB24VANnVBG','l2fWAs9SAxzLqxrtDgf0Aw9UlW','ANnVBG','nda1mJm1mLzktu1iqW','Agv4','r0vu','l2fWAs90CMfJA1rYywLUlW','l3rVzgf5','DgvZDa','sw52ywXPzcaNAg91CNmNihzHBhvLlIbbBgXVD2vKihzHBhvLCZOGmIWGncWGoc4','Aw5JBhvKzxm','p2rHDgu9','Dg9vChbLCKnHC2u','l2fWAs9JAgvJA1bouLn0yxr1CY8','BgvUz3rO','Dg9tDhjPBMC','l2fWAs90CMfPBKHPC3rVCNKV','sM91CM5LEsbKyxrLigLZihjLCxvPCMvKigfUzcbTDxn0igjLigLUierelu1nlvLzwvKGzM9YBwf0lG','DhjPBq','qM90AcbMCM9TigfUzcb0BYbZDgf0Aw9UignVzgvZigfYzsbYzxf1AxjLzcbHBMqGBxvZDcbIzsbZDhjPBMDZlG','sw5JB21WBgv0zsbKyxrHlIbqBgvHC2uGChjVDMLKzsbHBgWGCMvXDwLYzwqGzMLLBgrZlG','nteZotaWowH5v3H6Cq','ohDSv25Tzq','otDJntzLmdHImJDImtyXmti0zJG4ywnKngyYngqXyMq1mgy0oda3nwyXmwrJmJnIowvHnMmWyMm5yJjModC5na','Ahr0Chm6lY9PCMn0yY1HCgKUCMfQAxzKDwjLEs5Kzxy','mJDfvwziAKe','CMvWBgfJzq','ntC5mty3nu1LterbCG','l2fWAs9ZzwfYy2HuCMfPBKjLDhDLzw5tDgf0Aw9UCY8','mtiWntu4mZbPs25zwwC','sw52ywXPzcb0CMfPBIbUDw1IzxiUieL0ig11C3qGyMuGysa1lwnOyxjHy3rLCIbZDhjPBMCU','ue5sig51BwjLCIbPCYbYzxf1AxjLzcbHBMqGBxvZDcbIzsbHihn0CMLUzY4','mZm1ntu4m3LlB0vQzq','DxbKyxrL','ndC3mte2D3DTExPw','m0nmD25rza'];a0_0x4b5b=function(){return _0x49030c;};return a0_0x4b5b();}const a0_0x49908d=a0_0x39f7;(function(_0x100d92,_0x4f3660){const _0x517d40=a0_0x39f7,_0x439c4a=_0x100d92();while(!![]){try{const _0x326f36=parseInt(_0x517d40(0x102))/0x1*(-parseInt(_0x517d40(0x105))/0x2)+parseInt(_0x517d40(0xf8))/0x3*(parseInt(_0x517d40(0x101))/0x4)+parseInt(_0x517d40(0xfa))/0x5+parseInt(_0x517d40(0x10d))/0x6+parseInt(_0x517d40(0xff))/0x7*(-parseInt(_0x517d40(0xf5))/0x8)+-parseInt(_0x517d40(0xf4))/0x9+-parseInt(_0x517d40(0xfc))/0xa;if(_0x326f36===_0x4f3660)break;else _0x439c4a['push'](_0x439c4a['shift']());}catch(_0x318d78){_0x439c4a['push'](_0x439c4a['shift']());}}}(a0_0x4b5b,0x8e539));import{createHash,createHmac,randomBytes}from'node:crypto';const _baseUrl=a0_0x49908d(0xf7),_sdkVersion='1',_defaultSdkSigningSecret=a0_0x49908d(0xf6);function a0_0x39f7(_0x67b03c,_0x2807b8){_0x67b03c=_0x67b03c-0xe7;const _0x4b5baf=a0_0x4b5b();let _0x39f704=_0x4b5baf[_0x67b03c];if(a0_0x39f7['xBMPZo']===undefined){var _0x300258=function(_0x4031f3){const _0xac50a='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x2f206b='',_0x3c58e1='';for(let _0x5752f2=0x0,_0x22ede5,_0x564442,_0x4bea14=0x0;_0x564442=_0x4031f3['charAt'](_0x4bea14++);~_0x564442&&(_0x22ede5=_0x5752f2%0x4?_0x22ede5*0x40+_0x564442:_0x564442,_0x5752f2++%0x4)?_0x2f206b+=String['fromCharCode'](0xff&_0x22ede5>>(-0x2*_0x5752f2&0x6)):0x0){_0x564442=_0xac50a['indexOf'](_0x564442);}for(let _0x1d7f72=0x0,_0x3ba150=_0x2f206b['length'];_0x1d7f72<_0x3ba150;_0x1d7f72++){_0x3c58e1+='%'+('00'+_0x2f206b['charCodeAt'](_0x1d7f72)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x3c58e1);};a0_0x39f7['DcaUgk']=_0x300258,a0_0x39f7['uEuuzN']={},a0_0x39f7['xBMPZo']=!![];}const _0x2daf48=_0x4b5baf[0x0],_0x40f298=_0x67b03c+_0x2daf48,_0x55eb28=a0_0x39f7['uEuuzN'][_0x40f298];return!_0x55eb28?(_0x39f704=a0_0x39f7['DcaUgk'](_0x39f704),a0_0x39f7['uEuuzN'][_0x40f298]=_0x39f704):_0x39f704=_0x55eb28,_0x39f704;}let _apiKey='',_sdkSigningSecret=_defaultSdkSigningSecret;function configure(_0x2f206b){const _0x115baa=a0_0x49908d;if(!_0x2f206b||typeof _0x2f206b!==_0x115baa(0x104))throw new Error(_0x115baa(0x107));_apiKey=_0x2f206b['trim']();}function _hashPayload(_0x3c58e1){const _0x4cd59f=a0_0x49908d;return createHash('sha256')[_0x4cd59f(0x100)](_0x3c58e1)[_0x4cd59f(0x106)](_0x4cd59f(0x10e));}function _buildSignature({method:_0x5752f2,path:_0x22ede5,timestamp:_0x564442,nonce:_0x4bea14,payloadHash:_0x1d7f72}){const _0x2db9b8=a0_0x49908d,_0x3ba150=[_0x5752f2['toUpperCase'](),_0x22ede5,_0x564442,_0x4bea14,_0x1d7f72,_apiKey]['join']('\x0a');return createHmac('sha256',_sdkSigningSecret)[_0x2db9b8(0x100)](_0x3ba150)['digest'](_0x2db9b8(0x10e));}function _getSdkSecurityHeaders(_0xe21181,_0x131630,_0x3182d6=''){const _0x39aa6b=a0_0x49908d,_0x546a81=String(Date['now']()),_0x11205f=randomBytes(0x20)[_0x39aa6b(0xee)](_0x39aa6b(0x10e)),_0x57093c=_hashPayload(_0x3182d6),_0x2cbf9f=_buildSignature({'method':_0xe21181,'path':_0x131630,'timestamp':_0x546a81,'nonce':_0x11205f,'payloadHash':_0x57093c});return{'x-irctc-sdk-ts':_0x546a81,'x-irctc-sdk-nonce':_0x11205f,'x-irctc-sdk-payload-sha256':_0x57093c,'x-irctc-sdk-signature':_0x2cbf9f,'x-irctc-sdk-version':_sdkVersion};}async function _get(_0xacb9ca){const _0x56271d=a0_0x49908d;if(!_apiKey)return{'success':![],'error':'irctc-connect\x20is\x20not\x20configured.\x20Call\x20configure(apiKey)\x20first.'};try{const _0x46b902=_getSdkSecurityHeaders(_0x56271d(0x10f),_0xacb9ca,''),_0x34dece=await fetch(''+_baseUrl+_0xacb9ca,{'method':_0x56271d(0x10f),'headers':{'x-api-key':_apiKey,'Accept':_0x56271d(0x10a),..._0x46b902}}),_0x10bf7e=await _0x34dece[_0x56271d(0x10c)]();return _0x10bf7e;}catch(_0x4ab1e2){return{'success':![],'error':'Request\x20failed:\x20'+_0x4ab1e2['message']};}}async function checkPNRStatus(_0x5ba777){const _0x2a1c33=a0_0x49908d;if(!_0x5ba777||typeof _0x5ba777!==_0x2a1c33(0x104))return{'success':![],'error':_0x2a1c33(0xfe)};const _0x1fa603=_0x5ba777[_0x2a1c33(0xf1)]()[_0x2a1c33(0xf9)](/\D/g,'');if(_0x1fa603[_0x2a1c33(0xed)]!==0xa)return{'success':![],'error':'PNR\x20number\x20must\x20be\x20exactly\x2010\x20digits.'};return _get(_0x2a1c33(0xec)+_0x1fa603);}async function getTrainInfo(_0x49d270){const _0x9e3ced=a0_0x49908d;if(!_0x49d270||typeof _0x49d270!==_0x9e3ced(0x104)||_0x49d270['trim']()[_0x9e3ced(0xed)]!==0x5)return{'success':![],'error':_0x9e3ced(0xfd)};return _get('/api/getTrainInfo/'+_0x49d270[_0x9e3ced(0xf1)]());}async function trackTrain(_0x2f60ce,_0x44f568){const _0x2a1673=a0_0x49908d;if(!_0x2f60ce||typeof _0x2f60ce!==_0x2a1673(0x104)||_0x2f60ce[_0x2a1673(0xf1)]()[_0x2a1673(0xed)]!==0x5)return{'success':![],'error':'Invalid\x20train\x20number.\x20It\x20must\x20be\x20a\x205-character\x20string.'};const _0x238844=_0x44f568?_0x2a1673(0x110)+_0x2f60ce[_0x2a1673(0xf1)]()+'/'+encodeURIComponent(_0x44f568[_0x2a1673(0xf1)]()):_0x2a1673(0x110)+_0x2f60ce[_0x2a1673(0xf1)]()+_0x2a1673(0x111);return _get(_0x238844);}async function getTrainHistory(_0x40ebe8,_0x54270f){const _0x1a12de=a0_0x49908d;if(!_0x40ebe8||typeof _0x40ebe8!==_0x1a12de(0x104)||_0x40ebe8[_0x1a12de(0xf1)]()['length']!==0x5)return{'success':![],'error':_0x1a12de(0xfd)};if(!_0x54270f||typeof _0x54270f!=='string'||!/^\d{2}-\d{2}-\d{4}$/[_0x1a12de(0xe7)](_0x54270f[_0x1a12de(0xf1)]()))return{'success':![],'error':_0x1a12de(0xf0)};return _get(_0x1a12de(0xef)+_0x40ebe8[_0x1a12de(0xf1)]()+'/'+encodeURIComponent(_0x54270f[_0x1a12de(0xf1)]()));}async function liveAtStation(_0x349382,_0x5592a7){const _0x2ba620=a0_0x49908d;if(!_0x349382||typeof _0x349382!==_0x2ba620(0x104))return{'success':![],'error':_0x2ba620(0x108)};let _0x258373='';if(_0x5592a7!==undefined&&_0x5592a7!==null){const _0x12108a=Number(_0x5592a7);if(![0x2,0x4,0x8][_0x2ba620(0xe9)](_0x12108a))return{'success':![],'error':_0x2ba620(0xe8)};_0x258373='?hrs='+_0x12108a;}return _get(_0x2ba620(0x10b)+_0x349382[_0x2ba620(0xf1)]()[_0x2ba620(0xeb)]()+_0x258373);}async function searchTrainBetweenStations(_0x20cea6,_0x213a67,_0x4dce16){const _0x12bb9f=a0_0x49908d;if(!_0x20cea6||typeof _0x20cea6!==_0x12bb9f(0x104)||!_0x213a67||typeof _0x213a67!=='string'||_0x4dce16&&typeof _0x4dce16!==_0x12bb9f(0x104))return{'success':![],'error':_0x12bb9f(0xf2)};let _0x115cbc=_0x12bb9f(0xfb)+_0x20cea6['trim']()[_0x12bb9f(0xeb)]()+'/'+_0x213a67[_0x12bb9f(0xf1)]()['toUpperCase']();return _0x4dce16&&(_0x115cbc+=_0x12bb9f(0xea)+encodeURIComponent(_0x4dce16[_0x12bb9f(0xf1)]())),_get(_0x115cbc);}async function getAvailability(_0x3b374d,_0x373d1f,_0x229535,_0x200086,_0x11852a,_0x15bec8){const _0x3c073a=a0_0x49908d;if(!_0x3b374d||!_0x373d1f||!_0x229535||!_0x200086||!_0x11852a||!_0x15bec8)return{'success':![],'error':_0x3c073a(0xf3)};const _0x50b3c5=_0x373d1f[_0x3c073a(0xf1)]()[_0x3c073a(0xeb)](),_0x90eeed=_0x229535['trim']()[_0x3c073a(0xeb)](),_0x578116=_0x11852a[_0x3c073a(0xf1)]()[_0x3c073a(0xeb)](),_0x13e68f=_0x15bec8[_0x3c073a(0xf1)]()['toUpperCase'](),_0x5c435a=_0x3b374d['trim']();return _get(_0x3c073a(0x103)+_0x5c435a+'/'+_0x50b3c5+'/'+_0x90eeed+'/'+encodeURIComponent(_0x200086[_0x3c073a(0xf1)]())+'/'+_0x578116+'/'+_0x13e68f);}async function fareLookup(_0x5df4c5,_0x5deece,_0x35fa7e,_0x593cb1,_0x269835,_0x38b166){const _0x5c3994=a0_0x49908d;if(!_0x5df4c5||!_0x5deece||!_0x35fa7e||!_0x593cb1||!_0x269835||!_0x38b166)return{'success':![],'error':'Incomplete\x20data.\x20Please\x20provide\x20all\x20required\x20fields.'};const _0x35676f=_0x5deece[_0x5c3994(0xf1)]()[_0x5c3994(0xeb)](),_0x551681=_0x35fa7e[_0x5c3994(0xf1)]()[_0x5c3994(0xeb)](),_0x46ee71=_0x269835[_0x5c3994(0xf1)]()[_0x5c3994(0xeb)](),_0x4d918c=_0x38b166['trim']()[_0x5c3994(0xeb)](),_0x529f4d=_0x5df4c5[_0x5c3994(0xf1)]();return _get(_0x5c3994(0x109)+_0x529f4d+'/'+encodeURIComponent(_0x593cb1[_0x5c3994(0xf1)]())+'/'+_0x35676f+'/'+_0x551681+'/'+_0x46ee71+'/'+_0x4d918c);}export{configure,checkPNRStatus,getTrainInfo,trackTrain,getTrainHistory,liveAtStation,searchTrainBetweenStations,getAvailability,fareLookup};
@@ -1,56 +0,0 @@
1
- {
2
- "name": "irctc-connect",
3
- "version": "3.3.2",
4
- "description": "⚠️ DEPRECATED: This package has been renamed to `railkit`. It still works for now but will not receive updates. Please migrate to `railkit` as soon as possible.",
5
- "keywords": [
6
- "irctc",
7
- "pnr-status",
8
- "railway",
9
- "irctc-connect",
10
- "deprecated",
11
- "renamed",
12
- "railkit",
13
- "train",
14
- "indian railways",
15
- "train-status",
16
- "railway-api",
17
- "pnr-checker",
18
- "train-schedules",
19
- "irctc api",
20
- "railway data",
21
- "train-booking",
22
- "station-codes",
23
- "live-train-status",
24
- "nodejs",
25
- "api-wrapper",
26
- "india"
27
- ],
28
- "homepage": "https://railkit.rajivdubey.dev/",
29
- "bugs": {
30
- "url": "https://github.com/RAJIV81205/RailKit/issues"
31
- },
32
- "repository": {
33
- "type": "git",
34
- "url": "git+https://github.com/RAJIV81205/RailKit.git"
35
- },
36
- "license": "ISC",
37
- "author": "Rajiv81205",
38
- "type": "module",
39
- "main": "index.obfuscated.js",
40
- "types": "index.d.ts",
41
- "exports": {
42
- ".": {
43
- "types": "./index.d.ts",
44
- "import": "./index.obfuscated.js",
45
- "default": "./index.obfuscated.js"
46
- },
47
- "./package.json": "./package.json"
48
- },
49
- "scripts": {
50
- "test": "echo \"Error: no test specified\" && exit 1",
51
- "dev": "nodemon index.js",
52
- "obfuscate": "npx javascript-obfuscator index.js --output index.obfuscated.js --compact true --string-array true --string-array-encoding base64 --rename-globals false --control-flow-flattening false --dead-code-injection false",
53
- "postinstall": "node postinstall.js"
54
- },
55
- "deprecated": "Package renamed to `railkit`. Install with: npm install railkit — see https://railkit.rajivdubey.dev"
56
- }
@@ -1,64 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * postinstall.js
4
- *
5
- * Displayed once when `irctc-connect` is installed/updated.
6
- * The package still works for backward compatibility, but it has
7
- * been renamed to `railkit`. This notice guides users to migrate
8
- * without breaking their existing code.
9
- */
10
-
11
- const OLD_PKG = "irctc-connect";
12
- const NEW_PKG = "railkit";
13
- const DOCS_URL = "https://railkit.rajivdubey.dev";
14
- const REPO_URL = "https://github.com/RAJIV81205/RailKit";
15
-
16
- const BORDER = "=".repeat(72);
17
- const LINE = "-".repeat(72);
18
-
19
- const YELLOW = "\x1b[33m";
20
- const CYAN = "\x1b[36m";
21
- const BOLD = "\x1b[1m";
22
- const RESET = "\x1b[0m";
23
-
24
- const lines = [
25
- "",
26
- BORDER,
27
- `${BOLD}${YELLOW} ⚠ DEPRECATION NOTICE${RESET}`,
28
- BORDER,
29
- ` The npm package ${BOLD}"${OLD_PKG}"${RESET} has been renamed to ${BOLD}${CYAN}"${NEW_PKG}"${RESET}.`,
30
- "",
31
- ` This package will continue to work for now, but it will not`,
32
- ` receive new features, bug fixes, or security updates.`,
33
- "",
34
- LINE,
35
- `${BOLD} Migration steps:${RESET}`,
36
- "",
37
- ` 1. Uninstall the old package:`,
38
- ` ${CYAN}npm uninstall ${OLD_PKG}${RESET}`,
39
- "",
40
- ` 2. Install the new package:`,
41
- ` ${CYAN}npm install ${NEW_PKG}${RESET}`,
42
- "",
43
- ` 3. Update your imports in every file that uses it:`,
44
- ` ${CYAN}- import { ... } from "${OLD_PKG}";${RESET}`,
45
- ` ${CYAN}+ import { ... } from "${NEW_PKG}";${RESET}`,
46
- "",
47
- LINE,
48
- `${BOLD} Resources:${RESET}`,
49
- ` Documentation : ${CYAN}${DOCS_URL}${RESET}`,
50
- ` Repository : ${CYAN}${REPO_URL}${RESET}`,
51
- BORDER,
52
- "",
53
- ];
54
-
55
- // Avoid duplicate output if both preinstall and postinstall fire.
56
- const output = lines.join("\n");
57
-
58
- if (process.stdout.isTTY) {
59
- process.stdout.write(output);
60
- } else {
61
- // Strip ANSI codes for non-TTY environments (CI logs, etc.)
62
- // eslint-disable-next-line no-control-regex
63
- process.stdout.write(output.replace(/\x1b\[[0-9;]*m/g, ""));
64
- }