@tmsfe/tms-core 0.0.91 → 0.0.94
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/package.json
CHANGED
package/src/index-proxy.js
CHANGED
|
@@ -65,7 +65,7 @@ const asyncFuncNames = [
|
|
|
65
65
|
// 这行是tms-ui的
|
|
66
66
|
'showDrawer', 'hideDrawer', 'showModal', 'hideModal',
|
|
67
67
|
// 这行是runtime的
|
|
68
|
-
'getPhone', 'login', 'getLoginInfo', 'getOpenId', 'getMycarPubOpenId', 'getSinanPubOpenId',
|
|
68
|
+
'getPhone', 'registerPhone', 'login', 'getLoginInfo', 'getOpenId', 'getMycarPubOpenId', 'getSinanPubOpenId',
|
|
69
69
|
// tms-core
|
|
70
70
|
'setAuthInfo', 'getConfig', 'navigateToWebview', 'callCloudFunc', 'getEncryptUserInfo',
|
|
71
71
|
'setUserLocation', 'getUserLocation', 'getMpOpenId', 'getOuterOpenId',
|
package/src/report/clone.ts
CHANGED
|
@@ -6,10 +6,15 @@ const maxArrLen = 10;
|
|
|
6
6
|
const maxStrLen = 200;
|
|
7
7
|
const maxFieldLen = 20;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// 字符串字段白名单,白名单内的字段不截断
|
|
10
|
+
const fieldWhiteList = [
|
|
11
|
+
'tmapExtra', // 手图跳过来时附加的加密数据,用于分析用户操作路径,奉刚要求字段不能截断
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
function isBasicsType(obj: any, isConstraintLen = true): { isBasics: boolean, value: any } {
|
|
10
15
|
const type = typeof obj;
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
const arr1 = ['number', 'boolean', 'bigint'];
|
|
17
|
+
if (obj === null || obj === undefined || arr1.includes(type)) {
|
|
13
18
|
return { isBasics: true, value: obj };
|
|
14
19
|
}
|
|
15
20
|
if (type === 'string') {
|
|
@@ -19,7 +24,7 @@ function isBasicsType(obj: any): { isBasics: boolean, value: any } {
|
|
|
19
24
|
return { isBasics: true, value: '' };
|
|
20
25
|
}
|
|
21
26
|
|
|
22
|
-
const value = obj.substring(0, maxStrLen);
|
|
27
|
+
const value = isConstraintLen ? obj.substring(0, maxStrLen) : obj;
|
|
23
28
|
return { isBasics: true, value };
|
|
24
29
|
}
|
|
25
30
|
if (type === 'function' || type === 'symbol') {
|
|
@@ -61,7 +66,8 @@ function deepClone(obj: any, depth = 0, maxDepth = 5): any {
|
|
|
61
66
|
continue;
|
|
62
67
|
}
|
|
63
68
|
const value = obj[name];
|
|
64
|
-
const
|
|
69
|
+
const isConstraintLen = !fieldWhiteList.includes(name);
|
|
70
|
+
const res1 = isBasicsType(value, isConstraintLen);
|
|
65
71
|
if (res1.isBasics) {
|
|
66
72
|
// @ts-ignore
|
|
67
73
|
newObj[name] = res1.value;
|
package/src/report/proxy/app.ts
CHANGED
|
@@ -18,8 +18,11 @@ function proxyNavigateApi(api: string): void {
|
|
|
18
18
|
const { url = '' } = args[0] || {};
|
|
19
19
|
const [path, params = ''] = url.split('?');
|
|
20
20
|
const data = {};
|
|
21
|
-
params.split('&').
|
|
22
|
-
|
|
21
|
+
params.split('&').forEach((str: string) => {
|
|
22
|
+
const [key, val] = str.split('=');
|
|
23
|
+
let value = val || '';
|
|
24
|
+
// 简单判断是否encodeURIComponent字段,如果时的话则抛弃掉
|
|
25
|
+
// 因为在后端会被decode导致反序列化时语法错误
|
|
23
26
|
if (value.indexOf('%') !== -1) {
|
|
24
27
|
value = '';
|
|
25
28
|
}
|
package/src/runtime/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import Login from './login';
|
|
|
9
9
|
import Car from './car';
|
|
10
10
|
import getOpenAppTrafficData from './getopenapptrafficdata';
|
|
11
11
|
|
|
12
|
-
const { loginFn, getOpenId, getMycarPubOpenId, getSinanPubOpenId, getPhone } = Login;
|
|
12
|
+
const { loginFn, getOpenId, getMycarPubOpenId, getSinanPubOpenId, getPhone, registerPhone } = Login;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* __resolver__ 用于维护 app.tms.fn 中数据的填充
|
|
@@ -205,6 +205,7 @@ async function queryServicePermissions(param = {}) {
|
|
|
205
205
|
|
|
206
206
|
const api = {
|
|
207
207
|
getPhone,
|
|
208
|
+
registerPhone,
|
|
208
209
|
login,
|
|
209
210
|
getLoginInfo,
|
|
210
211
|
getOpenId,
|
|
@@ -18,6 +18,12 @@
|
|
|
18
18
|
|
|
19
19
|
import getOpenAppTrafficData from './getopenapptrafficdata';
|
|
20
20
|
|
|
21
|
+
interface PhoneRegisterResult {
|
|
22
|
+
success: boolean,
|
|
23
|
+
phone: string,
|
|
24
|
+
errMsg: string,
|
|
25
|
+
}
|
|
26
|
+
|
|
21
27
|
/**
|
|
22
28
|
* 调用wx.login获取登录code
|
|
23
29
|
* @private
|
|
@@ -93,6 +99,7 @@ const getOpenId = async () => {
|
|
|
93
99
|
return getOpenIdProm;
|
|
94
100
|
}
|
|
95
101
|
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
96
103
|
getOpenIdProm = new Promise(async (resolve, reject) => {
|
|
97
104
|
getApp().tms.callCloudFunc('user', { $url: 'user/getOpenId' })
|
|
98
105
|
.then((res) => {
|
|
@@ -192,15 +199,42 @@ const getSinanPubOpenId = () => {
|
|
|
192
199
|
const getPhone = () => getApp().tms.createRequest({ withAuth: true }).post('user/phone/fetch')
|
|
193
200
|
.then((res) => {
|
|
194
201
|
if (res && res.errCode === 0) {
|
|
195
|
-
return (res.resData
|
|
202
|
+
return (res.resData?.phoneno) || '';
|
|
196
203
|
}
|
|
197
204
|
return Promise.reject(res);
|
|
198
205
|
});
|
|
199
206
|
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* 绑定手机号
|
|
210
|
+
*/
|
|
211
|
+
async function registerPhone({ encryptedData, iv }: {encryptedData: string, iv: string}): Promise<PhoneRegisterResult> {
|
|
212
|
+
try {
|
|
213
|
+
const result = await getApp().tms.createRequest().post('user/phone/regist', {
|
|
214
|
+
iv,
|
|
215
|
+
isCipher: 1,
|
|
216
|
+
phoneno: encryptedData,
|
|
217
|
+
});
|
|
218
|
+
return {
|
|
219
|
+
success: result.errCode === 0,
|
|
220
|
+
phone: result.errCode === 0 ? result.resData.phoneno : '',
|
|
221
|
+
errMsg: result.errMsg,
|
|
222
|
+
};
|
|
223
|
+
} catch (error: any) {
|
|
224
|
+
console.error(error);
|
|
225
|
+
return {
|
|
226
|
+
success: false,
|
|
227
|
+
phone: '',
|
|
228
|
+
errMsg: '绑定失败',
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
200
233
|
const runtimeObj = {
|
|
201
234
|
loginFn,
|
|
202
235
|
getOpenId,
|
|
203
236
|
getPhone,
|
|
237
|
+
registerPhone,
|
|
204
238
|
getMycarPubOpenId,
|
|
205
239
|
getSinanPubOpenId,
|
|
206
240
|
};
|