@@ -6,7 +6,7 @@ import { LogMessage, LogType } from '@common/types';
6
6
import jwtDecode , { InvalidTokenError } from 'jwt-decode' ;
7
7
import { getTimeLeft , timeout } from '@common/utils' ;
8
8
import { BotError , FatalBotError , NotImplementedError } from '@/utils/errorUtils' ;
9
- import { getLatestExtraID } from '@/utils/reverser' ;
9
+ import { ExtraProperties , getLatestExtraProperties } from '@/utils/reverser' ;
10
10
import {
11
11
Variant ,
12
12
ReservationsPostResponse ,
@@ -40,7 +40,10 @@ interface BotOptions {
40
40
}
41
41
42
42
export class KideAppBot {
43
- protected extraId = LATEST_EXTRA_ID ;
43
+ protected extraProperties : ExtraProperties = {
44
+ extraId : LATEST_EXTRA_ID ,
45
+ xRequestedTokenKey : 'X-Requested-Token-a02'
46
+ } ;
44
47
protected _botIsActive = false ;
45
48
protected silentLog = false ;
46
49
protected startTime : number | null = null ;
@@ -88,12 +91,16 @@ export class KideAppBot {
88
91
icon : '🆔' ,
89
92
title : 'Fetching extra ID...'
90
93
} ) ;
91
- const latestExtraId = await getLatestExtraID ( this . options . extraIdApiUrl ) ;
92
- this . extraId = latestExtraId ;
94
+ this . extraProperties = await getLatestExtraProperties ( this . options . extraIdApiUrl ) ;
95
+ this . fullLog ( {
96
+ icon : '✅' ,
97
+ title : 'Received extra header key' ,
98
+ content : this . extraProperties . xRequestedTokenKey
99
+ } ) ;
93
100
this . fullLog ( {
94
101
icon : '✅' ,
95
102
title : 'Received extra ID' ,
96
- content : latestExtraId
103
+ content : this . extraProperties . extraId
97
104
} ) ;
98
105
} catch ( e ) {
99
106
console . error ( e ) ;
@@ -104,8 +111,6 @@ export class KideAppBot {
104
111
content : e . message ,
105
112
force : true
106
113
} ) ;
107
- // As a backup return latest known extraID
108
- this . extraId = LATEST_EXTRA_ID ;
109
114
}
110
115
}
111
116
}
@@ -126,7 +131,10 @@ export class KideAppBot {
126
131
'Content-Type' : 'application/json;charset=UTF-8' ,
127
132
accept : 'application/json, text/plain, */*' ,
128
133
authorization : 'Bearer ' + token ,
129
- 'X-Requested-Token-c69' : calculateXRequestedId ( inventoryId , this . extraId )
134
+ [ this . extraProperties . xRequestedTokenKey ] : calculateXRequestedId (
135
+ inventoryId ,
136
+ this . extraProperties . extraId
137
+ )
130
138
} ;
131
139
132
140
return await axios . post < ReservationsPostResponse > ( API_RESERVATION_ENDPOINT , body , { headers } ) ;
0 commit comments