@gjzq/sdk 1.6.0-beta.4 → 1.6.0-beta.6

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.
@@ -5338,6 +5338,54 @@ http.interceptors.request.use(function (config) {
5338
5338
  http.interceptors.response.use(authMiddleware);
5339
5339
  http.interceptors.response.use(parseResponseMiddleware);
5340
5340
 
5341
+ // 封装支持跨域cookie共享的http函数
5342
+ // hybrid环境下不支持域名共享(安卓兼容性问题白屏) 需要区分
5343
+ var isHybrid = location.origin.indexOf('http') != 0 && window.envConfig;
5344
+ // 获取请求配置,只有在非hybrid环境下才添加withCredentials
5345
+ var getRequestOptions = function getRequestOptions(additionalOptions) {
5346
+ if (additionalOptions === void 0) {
5347
+ additionalOptions = {};
5348
+ }
5349
+ if (!isHybrid) {
5350
+ return _assign(_assign({}, additionalOptions), {
5351
+ withCredentials: true
5352
+ });
5353
+ }
5354
+ return additionalOptions;
5355
+ };
5356
+ var httpWithCred = {
5357
+ get: function get(url, params) {
5358
+ var requestOptions = getRequestOptions(params);
5359
+ return Object.keys(requestOptions).length > 0 ? http.get(url, _assign({}, requestOptions)) : http.get(url);
5360
+ },
5361
+ post: function post(url, data) {
5362
+ var requestOptions = getRequestOptions({
5363
+ withCredentials: true
5364
+ });
5365
+ return http.post(url, data, requestOptions);
5366
+ },
5367
+ put: function put(url, data) {
5368
+ var requestOptions = getRequestOptions();
5369
+ return http.put(url, data, requestOptions);
5370
+ },
5371
+ delete: function _delete(url, params) {
5372
+ var requestOptions = getRequestOptions(params);
5373
+ return Object.keys(requestOptions).length > 0 ? http.delete(url, _assign({}, requestOptions)) : http.delete(url);
5374
+ },
5375
+ patch: function patch(url, data) {
5376
+ var requestOptions = getRequestOptions();
5377
+ return http.patch(url, data, requestOptions);
5378
+ },
5379
+ head: function head(url, params) {
5380
+ var requestOptions = getRequestOptions(params);
5381
+ return Object.keys(requestOptions).length > 0 ? http.head(url, _assign({}, requestOptions)) : http.head(url);
5382
+ },
5383
+ options: function options(url, params) {
5384
+ var requestOptions = getRequestOptions(params);
5385
+ return Object.keys(requestOptions).length > 0 ? http.options(url, _assign({}, requestOptions)) : http.options(url);
5386
+ }
5387
+ };
5388
+
5341
5389
  /**
5342
5390
  * yjb3.0-user登录-phpsession状态同步
5343
5391
  * @function userLogin
@@ -5345,7 +5393,7 @@ http.interceptors.response.use(parseResponseMiddleware);
5345
5393
  * @returns {Promise<HttpResponse>}
5346
5394
  */
5347
5395
  function userLoginForWeb(param) {
5348
- return http.post("".concat(API_URL, "/login/user"), param);
5396
+ return httpWithCred.post("".concat(API_URL, "/login/user"), param);
5349
5397
  }
5350
5398
 
5351
5399
  /**
@@ -5355,7 +5403,7 @@ function userLoginForWeb(param) {
5355
5403
  * @returns {Promise<HttpResponse>}
5356
5404
  */
5357
5405
  function pidLogin(param) {
5358
- return http.post("".concat(API_URL, "/login/passport"), param);
5406
+ return httpWithCred.post("".concat(API_URL, "/login/passport"), param);
5359
5407
  }
5360
5408
 
5361
5409
  function readHybridNoSystemParam$1() {
@@ -5371,7 +5419,7 @@ function readHybridNoSystemParam$1() {
5371
5419
  });
5372
5420
  }
5373
5421
  function checkFundAccountLoginFromServer() {
5374
- return http.get(API_URL + '/login/fundAccount');
5422
+ return httpWithCred.get(API_URL + '/login/fundAccount');
5375
5423
  }
5376
5424
  //委托客户端请求yjbapi
5377
5425
  function fetchYJBAPI(param_1) {
@@ -5584,7 +5632,7 @@ function getUserTokenForHybrid() {
5584
5632
  * multiLogin 功能组件
5585
5633
  */
5586
5634
  function multiLogin(param) {
5587
- return http.post("".concat(API_URL, "/login/multi"), param);
5635
+ return httpWithCred.post("".concat(API_URL, "/login/multi"), param);
5588
5636
  }
5589
5637
 
5590
5638
  /* eslint-disable @typescript-eslint/no-unused-vars */
@@ -5709,9 +5757,9 @@ function readHybridSystemParamIgnoreError(keys) {
5709
5757
  */
5710
5758
  function logoutForWeb(loginType) {
5711
5759
  if (loginType) {
5712
- return http.post("".concat(API_URL, "/logout/").concat(loginType));
5760
+ return httpWithCred.post("".concat(API_URL, "/logout/").concat(loginType));
5713
5761
  }
5714
- return http.post("".concat(API_URL, "/logout"), {});
5762
+ return httpWithCred.post("".concat(API_URL, "/logout"), {});
5715
5763
  }
5716
5764
 
5717
5765
  /**
@@ -5763,7 +5811,7 @@ function checkFundAccountLogin() {
5763
5811
  });
5764
5812
  });
5765
5813
  }
5766
- return http.get("".concat(API_URL, "/login/fundAccount"));
5814
+ return httpWithCred.get("".concat(API_URL, "/login/fundAccount"));
5767
5815
  }
5768
5816
 
5769
5817
  /**
@@ -5772,7 +5820,7 @@ function checkFundAccountLogin() {
5772
5820
  * @returns {Promise<HttpResponse>}
5773
5821
  */
5774
5822
  function checkMarginAccountLogin() {
5775
- return http.get("".concat(API_URL, "/login/marginAccount"));
5823
+ return httpWithCred.get("".concat(API_URL, "/login/marginAccount"));
5776
5824
  }
5777
5825
 
5778
5826
  /**
@@ -5781,7 +5829,7 @@ function checkMarginAccountLogin() {
5781
5829
  * @returns {Promise<HttpResponse>}
5782
5830
  */
5783
5831
  function checkUserLogin() {
5784
- return http.get("".concat(API_URL, "/login/user"));
5832
+ return httpWithCred.get("".concat(API_URL, "/login/user"));
5785
5833
  }
5786
5834
 
5787
5835
  /**
@@ -5849,7 +5897,7 @@ function bindInfo(data) {
5849
5897
  * @returns {Promise<HttpResponse> }
5850
5898
  */
5851
5899
  function marginAccountLogin(param) {
5852
- return http.post("".concat(API_URL, "/login/marginAccount"), param);
5900
+ return httpWithCred.post("".concat(API_URL, "/login/marginAccount"), param);
5853
5901
  }
5854
5902
 
5855
5903
  /**
@@ -5859,7 +5907,7 @@ function marginAccountLogin(param) {
5859
5907
  * @returns {Promise<HttpResponse>}
5860
5908
  */
5861
5909
  function fundAccountLogin(param) {
5862
- return http.post("".concat(API_URL, "/login/fundAccount"), param);
5910
+ return httpWithCred.post("".concat(API_URL, "/login/fundAccount"), param);
5863
5911
  }
5864
5912
 
5865
5913
  /**
@@ -7424,7 +7472,7 @@ function getWechatUserInfoService(params) {
7424
7472
  * @returns
7425
7473
  */
7426
7474
  function getShortLinkFunc(data) {
7427
- return http.post(API_URL, _assign({
7475
+ return httpWithCred.post(API_URL, _assign({
7428
7476
  UniqueKey: 'serviceName.shortlink.create.remainParam'
7429
7477
  }, data));
7430
7478
  }
@@ -8990,7 +9038,7 @@ var pageInitWithSession = function pageInitWithSession(loginType, URL, needClose
8990
9038
  * @returns {Promise<HttpResponse>}
8991
9039
  */
8992
9040
  function qqStockLogin(param) {
8993
- return http.post("".concat(API_URL, "/login/qqstock"), param);
9041
+ return httpWithCred.post("".concat(API_URL, "/login/qqstock"), param);
8994
9042
  }
8995
9043
 
8996
9044
  function readFile(param) {
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-5FZwaohR.js');
3
+ var index = require('./index-Bhwz_1He.js');
4
4
  require('ts-md5');
5
5
  require('weixin-js-sdk');
6
6
  require('clipboard');
package/dist/pure.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-5FZwaohR.js');
3
+ var index = require('./index-Bhwz_1He.js');
4
4
  require('ts-md5');
5
5
  require('weixin-js-sdk');
6
6
  require('clipboard');
@@ -1,7 +1,7 @@
1
1
  import { __awaiter, __generator } from '../node_modules/tslib/tslib.es6.mjs';
2
2
  import { useHybridLogin, LoginType, LOGOUT_TYPE } from '../utils/const.mjs';
3
3
  import { API_URL } from '../utils/urls.mjs';
4
- import { http } from '../http/index.mjs';
4
+ import httpWithCred from '../http/httpWithCred.mjs';
5
5
  import { syncLoginStatusBetweenNativeAndServer } from '../syncLoginStatusBetweenNativeAndServer/index.mjs';
6
6
  import { checkFundAccountLoginFromServer } from '../utils/loginFuncs.mjs';
7
7
  import { decrypt } from '../utils/funcs.mjs';
@@ -57,7 +57,7 @@ function checkFundAccountLogin() {
57
57
  });
58
58
  });
59
59
  }
60
- return http.get("".concat(API_URL, "/login/fundAccount"));
60
+ return httpWithCred.get("".concat(API_URL, "/login/fundAccount"));
61
61
  }
62
62
 
63
63
  export { checkFundAccountLogin };
@@ -1,5 +1,5 @@
1
1
  import { API_URL } from '../utils/urls.mjs';
2
- import { http } from '../http/index.mjs';
2
+ import httpWithCred from '../http/httpWithCred.mjs';
3
3
 
4
4
  /**
5
5
  * marginAccount登录状态检查
@@ -7,7 +7,7 @@ import { http } from '../http/index.mjs';
7
7
  * @returns {Promise<HttpResponse>}
8
8
  */
9
9
  function checkMarginAccountLogin() {
10
- return http.get("".concat(API_URL, "/login/marginAccount"));
10
+ return httpWithCred.get("".concat(API_URL, "/login/marginAccount"));
11
11
  }
12
12
 
13
13
  export { checkMarginAccountLogin };
@@ -1,5 +1,5 @@
1
1
  import { API_URL } from '../utils/urls.mjs';
2
- import { http } from '../http/index.mjs';
2
+ import httpWithCred from '../http/httpWithCred.mjs';
3
3
 
4
4
  /**
5
5
  * user登录状态检查
@@ -7,7 +7,7 @@ import { http } from '../http/index.mjs';
7
7
  * @returns {Promise<HttpResponse>}
8
8
  */
9
9
  function checkUserLogin() {
10
- return http.get("".concat(API_URL, "/login/user"));
10
+ return httpWithCred.get("".concat(API_URL, "/login/user"));
11
11
  }
12
12
 
13
13
  export { checkUserLogin };
@@ -1,5 +1,5 @@
1
1
  import { API_URL } from '../utils/urls.mjs';
2
- import { http } from '../http/index.mjs';
2
+ import httpWithCred from '../http/httpWithCred.mjs';
3
3
 
4
4
  /**
5
5
  * fundaccount登录
@@ -8,7 +8,7 @@ import { http } from '../http/index.mjs';
8
8
  * @returns {Promise<HttpResponse>}
9
9
  */
10
10
  function fundAccountLogin(param) {
11
- return http.post("".concat(API_URL, "/login/fundAccount"), param);
11
+ return httpWithCred.post("".concat(API_URL, "/login/fundAccount"), param);
12
12
  }
13
13
 
14
14
  export { fundAccountLogin };
@@ -0,0 +1,52 @@
1
+ import { __assign as _assign } from '../node_modules/tslib/tslib.es6.mjs';
2
+ import { http } from './index.mjs';
3
+
4
+ // 封装支持跨域cookie共享的http函数
5
+ // hybrid环境下不支持域名共享(安卓兼容性问题白屏) 需要区分
6
+ var isHybrid = location.origin.indexOf('http') != 0 && window.envConfig;
7
+ // 获取请求配置,只有在非hybrid环境下才添加withCredentials
8
+ var getRequestOptions = function getRequestOptions(additionalOptions) {
9
+ if (additionalOptions === void 0) {
10
+ additionalOptions = {};
11
+ }
12
+ if (!isHybrid) {
13
+ return _assign(_assign({}, additionalOptions), {
14
+ withCredentials: true
15
+ });
16
+ }
17
+ return additionalOptions;
18
+ };
19
+ var httpWithCred = {
20
+ get: function get(url, params) {
21
+ var requestOptions = getRequestOptions(params);
22
+ return Object.keys(requestOptions).length > 0 ? http.get(url, _assign({}, requestOptions)) : http.get(url);
23
+ },
24
+ post: function post(url, data) {
25
+ var requestOptions = getRequestOptions({
26
+ withCredentials: true
27
+ });
28
+ return http.post(url, data, requestOptions);
29
+ },
30
+ put: function put(url, data) {
31
+ var requestOptions = getRequestOptions();
32
+ return http.put(url, data, requestOptions);
33
+ },
34
+ delete: function _delete(url, params) {
35
+ var requestOptions = getRequestOptions(params);
36
+ return Object.keys(requestOptions).length > 0 ? http.delete(url, _assign({}, requestOptions)) : http.delete(url);
37
+ },
38
+ patch: function patch(url, data) {
39
+ var requestOptions = getRequestOptions();
40
+ return http.patch(url, data, requestOptions);
41
+ },
42
+ head: function head(url, params) {
43
+ var requestOptions = getRequestOptions(params);
44
+ return Object.keys(requestOptions).length > 0 ? http.head(url, _assign({}, requestOptions)) : http.head(url);
45
+ },
46
+ options: function options(url, params) {
47
+ var requestOptions = getRequestOptions(params);
48
+ return Object.keys(requestOptions).length > 0 ? http.options(url, _assign({}, requestOptions)) : http.options(url);
49
+ }
50
+ };
51
+
52
+ export { httpWithCred as default };
@@ -1,5 +1,5 @@
1
1
  import { API_URL } from '../utils/urls.mjs';
2
- import { http } from '../http/index.mjs';
2
+ import httpWithCred from '../http/httpWithCred.mjs';
3
3
 
4
4
  /**
5
5
  * 登出
@@ -9,9 +9,9 @@ import { http } from '../http/index.mjs';
9
9
  */
10
10
  function logoutForWeb(loginType) {
11
11
  if (loginType) {
12
- return http.post("".concat(API_URL, "/logout/").concat(loginType));
12
+ return httpWithCred.post("".concat(API_URL, "/logout/").concat(loginType));
13
13
  }
14
- return http.post("".concat(API_URL, "/logout"), {});
14
+ return httpWithCred.post("".concat(API_URL, "/logout"), {});
15
15
  }
16
16
 
17
17
  export { logoutForWeb };
@@ -1,5 +1,5 @@
1
1
  import { API_URL } from '../utils/urls.mjs';
2
- import { http } from '../http/index.mjs';
2
+ import httpWithCred from '../http/httpWithCred.mjs';
3
3
 
4
4
  /**
5
5
  * marginAccount登录
@@ -8,7 +8,7 @@ import { http } from '../http/index.mjs';
8
8
  * @returns {Promise<HttpResponse> }
9
9
  */
10
10
  function marginAccountLogin(param) {
11
- return http.post("".concat(API_URL, "/login/marginAccount"), param);
11
+ return httpWithCred.post("".concat(API_URL, "/login/marginAccount"), param);
12
12
  }
13
13
 
14
14
  export { marginAccountLogin };
@@ -1,11 +1,11 @@
1
1
  import { API_URL } from '../utils/urls.mjs';
2
- import { http } from '../http/index.mjs';
2
+ import httpWithCred from '../http/httpWithCred.mjs';
3
3
 
4
4
  /**
5
5
  * multiLogin 功能组件
6
6
  */
7
7
  function multiLogin(param) {
8
- return http.post("".concat(API_URL, "/login/multi"), param);
8
+ return httpWithCred.post("".concat(API_URL, "/login/multi"), param);
9
9
  }
10
10
 
11
11
  export { multiLogin };
@@ -1,5 +1,5 @@
1
1
  import { API_URL } from '../utils/urls.mjs';
2
- import { http } from '../http/index.mjs';
2
+ import httpWithCred from '../http/httpWithCred.mjs';
3
3
 
4
4
  /**
5
5
  * yjb3.0-passportId登录-phpsession状态同步
@@ -8,7 +8,7 @@ import { http } from '../http/index.mjs';
8
8
  * @returns {Promise<HttpResponse>}
9
9
  */
10
10
  function pidLogin(param) {
11
- return http.post("".concat(API_URL, "/login/passport"), param);
11
+ return httpWithCred.post("".concat(API_URL, "/login/passport"), param);
12
12
  }
13
13
 
14
14
  export { pidLogin };
@@ -1,5 +1,5 @@
1
1
  import { API_URL } from '../utils/urls.mjs';
2
- import { http } from '../http/index.mjs';
2
+ import httpWithCred from '../http/httpWithCred.mjs';
3
3
 
4
4
  /**
5
5
  * 腾讯自选股渠道,session_id登录
@@ -8,7 +8,7 @@ import { http } from '../http/index.mjs';
8
8
  * @returns {Promise<HttpResponse>}
9
9
  */
10
10
  function qqStockLogin(param) {
11
- return http.post("".concat(API_URL, "/login/qqstock"), param);
11
+ return httpWithCred.post("".concat(API_URL, "/login/qqstock"), param);
12
12
  }
13
13
 
14
14
  export { qqStockLogin };
@@ -1,5 +1,5 @@
1
1
  import { API_URL } from '../utils/urls.mjs';
2
- import { http } from '../http/index.mjs';
2
+ import httpWithCred from '../http/httpWithCred.mjs';
3
3
 
4
4
  /**
5
5
  * yjb3.0-user登录-phpsession状态同步
@@ -8,7 +8,7 @@ import { http } from '../http/index.mjs';
8
8
  * @returns {Promise<HttpResponse>}
9
9
  */
10
10
  function userLoginForWeb(param) {
11
- return http.post("".concat(API_URL, "/login/user"), param);
11
+ return httpWithCred.post("".concat(API_URL, "/login/user"), param);
12
12
  }
13
13
 
14
14
  export { userLoginForWeb };
@@ -1,5 +1,6 @@
1
1
  import { __awaiter, __generator, __assign as _assign } from '../node_modules/tslib/tslib.es6.mjs';
2
2
  import { http } from '../http/index.mjs';
3
+ import httpWithCred from '../http/httpWithCred.mjs';
3
4
  import { wechatUserInfoDomain, wechatAuthDomain, API_URL } from './urls.mjs';
4
5
 
5
6
  function getWechatAuthUrl(params) {
@@ -23,7 +24,7 @@ function getWechatUserInfoService(params) {
23
24
  * @returns
24
25
  */
25
26
  function getShortLinkFunc(data) {
26
- return http.post(API_URL, _assign({
27
+ return httpWithCred.post(API_URL, _assign({
27
28
  UniqueKey: 'serviceName.shortlink.create.remainParam'
28
29
  }, data));
29
30
  }
@@ -1,5 +1,5 @@
1
1
  import { __awaiter, __generator, __assign as _assign } from '../node_modules/tslib/tslib.es6.mjs';
2
- import { http } from '../http/index.mjs';
2
+ import httpWithCred from '../http/httpWithCred.mjs';
3
3
  import { API_URL } from './urls.mjs';
4
4
  import { LoginType, NO_TOKEN, MESSAGE, CHANNELID, ALL_NO_SYSTEM_PARAM_KEYS, DEFAULT_RESPONSE } from './const.mjs';
5
5
  import { getUserUKeysByChannelId } from '../getUserUKeysByChannelId/index.mjs';
@@ -18,7 +18,7 @@ function readHybridNoSystemParam$1() {
18
18
  });
19
19
  }
20
20
  function checkFundAccountLoginFromServer() {
21
- return http.get(API_URL + '/login/fundAccount');
21
+ return httpWithCred.get(API_URL + '/login/fundAccount');
22
22
  }
23
23
  //委托客户端请求yjbapi
24
24
  function fetchYJBAPI(param_1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjzq/sdk",
3
- "version": "1.6.0-beta.4",
3
+ "version": "1.6.0-beta.6",
4
4
  "main": "dist/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "types": "./dist/index.d.ts",