abler-api 0.1.38 → 0.1.40
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/dist/cjs/pp-util.js +9 -8
- package/package.json +1 -1
package/dist/cjs/pp-util.js
CHANGED
|
@@ -84,7 +84,7 @@ class apiUtil$2 {
|
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
static signatureVerified(req) {
|
|
87
|
-
return req
|
|
87
|
+
return req?.signatureVerified;
|
|
88
88
|
} //#endregion
|
|
89
89
|
//#region ===== API服务相关工具
|
|
90
90
|
|
|
@@ -987,7 +987,7 @@ class apiUtil$2 {
|
|
|
987
987
|
// // 没有设置ip白名单的就不检查了
|
|
988
988
|
// if (whiteList == "" || ipMatched(tokenData.clientIp, whiteList + ",127.0.0.1,1"))
|
|
989
989
|
|
|
990
|
-
if (apiUtil$2.signatureVerified()) return companyInfo;
|
|
990
|
+
if (apiUtil$2.signatureVerified(req)) return companyInfo;
|
|
991
991
|
return apiUtil$2.verifyApiSignature(tokenData, req).then(x => {
|
|
992
992
|
return companyInfo;
|
|
993
993
|
}, e => {
|
|
@@ -1275,7 +1275,7 @@ class apiUtil$2 {
|
|
|
1275
1275
|
static $isMobile(req, res, next) {
|
|
1276
1276
|
req.isMobile = true;
|
|
1277
1277
|
|
|
1278
|
-
if (!
|
|
1278
|
+
if (!apiUtil$2.signatureVerified(req)) {
|
|
1279
1279
|
let params = apiUtil$2.extractParams(req);
|
|
1280
1280
|
moveProperty(params, req.headers, "access_token");
|
|
1281
1281
|
moveProperty(params, req.headers, "timestamp");
|
|
@@ -1297,8 +1297,8 @@ class apiUtil$2 {
|
|
|
1297
1297
|
|
|
1298
1298
|
static $checkApiKeyOld(req, res, next) {
|
|
1299
1299
|
//检查post的信息或者url查询参数或者头信息
|
|
1300
|
-
|
|
1301
|
-
|
|
1300
|
+
const tokenData = apiUtil$2.extractTokenData(req);
|
|
1301
|
+
const params = apiUtil$2.extractParams(req);
|
|
1302
1302
|
apiUtil$2.createApiCallRec(tokenData, req);
|
|
1303
1303
|
let errResponse = null;
|
|
1304
1304
|
|
|
@@ -1313,7 +1313,7 @@ class apiUtil$2 {
|
|
|
1313
1313
|
if (errResponse != null) {
|
|
1314
1314
|
apiUtil$2._saveApiCallRec(req.apiCallRec, errResponse);
|
|
1315
1315
|
|
|
1316
|
-
apiUtil$2.sendOrRedirect(req,
|
|
1316
|
+
apiUtil$2.sendOrRedirect(req, params.redirectUrl || params.callbackUrl, errResponse);
|
|
1317
1317
|
} else {
|
|
1318
1318
|
apiUtil$2.checkApiCallValid(tokenData, req).then(companyInfo => {
|
|
1319
1319
|
params.companyId = params.companyId || companyInfo.companyId;
|
|
@@ -1325,7 +1325,7 @@ class apiUtil$2 {
|
|
|
1325
1325
|
|
|
1326
1326
|
apiUtil$2._saveApiCallRec(req.apiCallRec, errResponse);
|
|
1327
1327
|
|
|
1328
|
-
apiUtil$2.sendOrRedirect(req,
|
|
1328
|
+
apiUtil$2.sendOrRedirect(req, params.redirectUrl || params.callbackUrl, errResponse);
|
|
1329
1329
|
});
|
|
1330
1330
|
}
|
|
1331
1331
|
}
|
|
@@ -1364,7 +1364,8 @@ class apiUtil$2 {
|
|
|
1364
1364
|
req.tokenData = p;
|
|
1365
1365
|
return apiUtil$2.$checkApiKeyOld(req, res, next);
|
|
1366
1366
|
}).catch(e => {
|
|
1367
|
-
|
|
1367
|
+
const params = apiUtil$2.extractParams(req);
|
|
1368
|
+
apiUtil$2.sendOrRedirect(req, params.redirectUrl || params.callbackUrl, apiUtil$2.spoApiFail(err$2.TOKEN_INVALID, req));
|
|
1368
1369
|
});
|
|
1369
1370
|
}
|
|
1370
1371
|
/**
|