@@ -3,7 +3,7 @@ const v1BaseUrl = `${apiServerUrl}/v1/applications`
33const v2BaseUrl = `${ apiServerUrl } /v2/applications`
44const authUrl = `${ apiServerUrl } /v1/devices/authorize/`
55
6- const headers = new Headers ( {
6+ const headers : Headers = new Headers ( {
77 "Content-Type" : "application/json" ,
88 Accept : "application/json" ,
99 "Myket-Version" : "914" ,
@@ -14,33 +14,43 @@ const headers = new Headers({
1414 "Accept-Encoding" : "gzip" ,
1515} )
1616
17- const authBody = {
18- acId : "" ,
19- acKey : "" ,
20- adId : "82d8810f-e83c-46c0-8bf5-080a83d635c6" ,
21- andId : "82ee24cd7aad5173" ,
22- api : "29" ,
23- brand : "Nokia" ,
24- cpuAbis : [ "armeabi-v7a" , "armeabi" ] ,
25- dens : 2.625 ,
26- deviceModel : "Nokia 7 plus" ,
27- deviceName : "B2N_sprout" ,
28- deviceType : "normal" ,
29- dsize : "300" ,
30- hsh : "4e9118e410d75e2ef80aac45357493e397037940" ,
31- imei : "" ,
32- imsi : "" ,
33- manufacturer : "HMD Global" ,
34- product : "Onyx_00WW" ,
35- supportedAbis : [ "arm64-v8a" , "armeabi-v7a" , "armeabi" ] ,
36- uuid : "235f746f-3a40-44b7-97b4-01cac934df6d" ,
17+ function getAuthBody ( apiVersion : string ) {
18+ return {
19+ acId : "" ,
20+ acKey : "" ,
21+ adId : "82d8810f-e83c-46c0-8bf5-080a83d635c6" ,
22+ andId : "82ee24cd7aad5173" ,
23+ api : apiVersion ,
24+ brand : "Nokia" ,
25+ cpuAbis : [ "armeabi-v7a" , "armeabi" ] ,
26+ dens : 2.625 ,
27+ deviceModel : "Nokia 7 plus" ,
28+ deviceName : "B2N_sprout" ,
29+ deviceType : "normal" ,
30+ dsize : "300" ,
31+ hsh : "4e9118e410d75e2ef80aac45357493e397037940" ,
32+ imei : "" ,
33+ imsi : "" ,
34+ manufacturer : "HMD Global" ,
35+ product : "Onyx_00WW" ,
36+ supportedAbis : [ "arm64-v8a" , "armeabi-v7a" , "armeabi" ] ,
37+ uuid : "235f746f-3a40-44b7-97b4-01cac934df6d" ,
38+ }
3739}
3840
39- const postRequestInit : RequestInit = {
40- mode : "cors" ,
41- headers : headers ,
42- method : "POST" ,
43- body : JSON . stringify ( authBody ) ,
41+ async function getPostRequestInit ( ) : Promise < RequestInit > {
42+ return new Promise < RequestInit > ( resolve => {
43+ chrome . storage . local . get ( [ "apiVersion" ] , result => {
44+ const apiVersion =
45+ typeof result . apiVersion === "string" ? result . apiVersion : "29"
46+ resolve ( {
47+ mode : "cors" ,
48+ headers : headers ,
49+ method : "POST" ,
50+ body : JSON . stringify ( getAuthBody ( apiVersion ) ) ,
51+ } )
52+ } )
53+ } )
4454}
4555
4656const requestInit : RequestInit = {
@@ -49,4 +59,11 @@ const requestInit: RequestInit = {
4959 headers : headers ,
5060}
5161
52- export { v1BaseUrl , v2BaseUrl , authUrl , headers , requestInit , postRequestInit }
62+ export {
63+ v1BaseUrl ,
64+ v2BaseUrl ,
65+ authUrl ,
66+ headers ,
67+ requestInit ,
68+ getPostRequestInit ,
69+ }
0 commit comments