forked from BIT-BOBH/FakeLocation-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.js
207 lines (191 loc) · 6.24 KB
/
core.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/*
FakeLocation-Server
File: core.js
Description: Core code to simulate the server response.
Author: BobH
Time: 2022-5-11
A free and open source api server for app "Fake Location @ 1.3.0.2"
*/
const logger = require('./Logger');
const recommandedVersion = "1.3.0.2";
const fs = require('fs');
const path = require('path');
// enable this so that when there's a login request, the server will check users.json and verify the password
const UseVerification = false;
const sharedToken = "T_CrackedByBobH233"; //do not change this or you can't use FakeLocation!!
const sharedKey = "UsrTjEVxwRaQsvV5hD8I3Db8zrkjuavD/O8hJcVLUOkDimJc6ShgOQEzV5srpEPcOL63J2chFQA=";
const sharedUserId = "BobH233LoveLerist";
function Init(){
let usersConfigPath = "";
//TODO: support specific user to login
}
function login(reqBody, res){
let appVersion = reqBody['versionName'];
if(appVersion != recommandedVersion){
logger.LogWarn("Login request shows the version of the app is" + appVersion + ". However, version " + recommandedVersion + " is recommanded.");
}
let username = reqBody['loginName'];
let password = reqBody['loginPwd'];
logger.LogInfo("[ device: "+ reqBody.deviceModel + " ] Username = " + username + ", password = " + password + " login!");
if(!UseVerification || true){
//TODO: support specific user to login
let retPayload = {
"body": {
"regtime": Date.now() - 1000 * 60 * 60,
"proindate": Date.now() + 1000 * 60 * 60 * 24 * 365,
"createTime": Date.now() - 1000 * 60 * 60 - 1,
"loginType": "email",
"loginName": "BobH" + "Crack",
"updateTime": 0,
"type": 1,
"userId": sharedUserId,
"key": sharedKey,
"token": sharedToken
},
"code": 200,
"returnTime": Date.now(),
"success": true
};
res.send(JSON.stringify(retPayload));
}
}
function checkExist(reqBody, res){
logger.LogInfo("checkExist request.");
let retPayload = {
"body": true,
"code": 200,
"returnTime": Date.now(),
"success": true
};
res.send(JSON.stringify(retPayload));
}
function getNotices(reqBody, res){
logger.LogInfo("getNotices request.");
let retPayload = [
{
"content": "<p><strong>这是由BobH破解的FakeLocationApp的服务端发送的消息</strong></p>\r\n\r\n<p><strong>请勿将此软件用于非法用途,请勿用于出售或非法盈利</strong></p>\r\n\r\n",
"createTime": 0,
"flavor": "*",
"id": "00008",
"isAvailable": true,
"isNeedAgree": true,
"language": "*",
"needAgree": true,
"title": "破解说明",
"type": "text",
"weight": 100001
}
];
res.send(JSON.stringify(retPayload));
}
function getAds(reqBody, res){
logger.LogInfo("getAds request.");
let retPayload = [
{
"available": true,
"createTime": 0,
"intervalTime": 30000,
"isAvailable": true,
"isRandom": false,
"language": "*",
"provider": "BobH",
"random": false,
"texts": "此软件已经连接破解版服务器,无需再进行购买即可免费不限制使用",
"urls": "#",
"weight": 3
},
{
"available": true,
"createTime": 0,
"intervalTime": 16000,
"isAvailable": true,
"isRandom": false,
"language": "*",
"provider": "BobH",
"random": false,
"texts": "已经解锁了软件的全部应用模拟功能,不再有特定应用无法使用的问题",
"urls": "#",
"weight": 2
}
];
res.send(JSON.stringify(retPayload));
}
function getRenewalGoodsList(reqBody, res){
logger.LogInfo("getRenewalGoodsList request.");
let retPayload = {
"body": [
{
"createTime": 0,
"description": "",
"id": "0011",
"isAvailable": 1,
"locale": "*",
"name": "永久使用无限制",
"price": 0,
"priceUnit": "¥",
"recommend": "BobH",
"updateTime": 0,
"value": 30,
"weight": 4
}
],
"code": 200,
"returnTime": Date.now(),
"success": true
};
res.send(JSON.stringify(retPayload));
}
function getAppConfigs(reqBody, res){
logger.LogInfo("getAppConfigs request.");
// allow all apps to be simulated
let retPayload = {
"body": {
"createTime": Date.now(),
"disabledApps": [
],
"disabledFuncs": [
],
"disabledInfos": [
],
"isAllowRun": 1,
"isAvailable": 1,
"notice": "",
"updateTime": 0
},
"code": 200,
"returnTime": Date.now(),
"success": true
};
res.send(JSON.stringify(retPayload));
}
function checkApkUpdate(reqBody, res){
logger.LogInfo("checkApkUpdate request.");
let retPayload = {
"code": parseInt(reqBody.versionCode),
"message": "??????",
"returnTime": Date.now(),
"success": true
};
res.send(JSON.stringify(retPayload));
}
function userget(reqBody, res){
logger.LogInfo("userget request.");
let retPayload = {
"body": {
"regtime": Date.now() - 1000 * 60 * 60,
"proindate": Date.now() + 1000 * 60 * 60 * 24 * 365,
"createTime": Date.now() - 1000 * 60 * 60 - 1,
"loginType": "email",
"loginName": "BobH" + "Crack",
"updateTime": 0,
"type": 1,
"key": sharedKey,
"token": sharedToken
},
"code": 200,
"returnTime": Date.now(),
"success": true
}
res.send(JSON.stringify(retPayload));
}
module.exports = { login, Init, checkExist, getNotices, getAds, getRenewalGoodsList, getAppConfigs, checkApkUpdate, userget };