@alicloud/alfa-core 1.5.6-alpha.0 → 1.5.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.
@@ -118,7 +118,9 @@ export var getConfigV2 = /*#__PURE__*/function () {
118
118
  case 8:
119
119
  _context2.prev = 8;
120
120
  _context2.next = 11;
121
- return request.get("https://".concat(config.env !== 'prod' ? 'pre-' : '', "fecs.console.").concat(parseEnv().MAIN_DOMAIN, "/api/alfa/console/config?appId=").concat(relatedConsoleAppId));
121
+ return request.get("https://".concat(config.env !== 'prod' ? 'pre-' : '', "fecs.console.").concat(parseEnv().MAIN_DOMAIN, "/api/alfa/console/config?appId=").concat(relatedConsoleAppId), {
122
+ withCredentials: true
123
+ });
122
124
  case 11:
123
125
  res = _context2.sent;
124
126
  return _context2.abrupt("return", {
@@ -1,9 +1,12 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
+ var _window$ALIYUN_CONSOL;
2
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
- var whiteList = ['alicdn.com', 'idptcloud01cdn.com'];
4
+ // 支持的主权云 CDN Host
5
+ // @ts-ignore
6
+ var whiteList = ['idptcloud01cdn.com', ((_window$ALIYUN_CONSOL = window.ALIYUN_CONSOLE_CONFIG) === null || _window$ALIYUN_CONSOL === void 0 ? void 0 : _window$ALIYUN_CONSOL.MAIN_RESOURCE_CDN) || 'alicdn.com'];
4
7
  var win = window;
5
8
 
6
- // 兼容非公有云环境
9
+ // 兼容非公有云环境,用于替换请求的 hostname
7
10
  var getCurrentCdnHost = function getCurrentCdnHost() {
8
11
  try {
9
12
  var _document$currentScri;
@@ -11,7 +14,11 @@ var getCurrentCdnHost = function getCurrentCdnHost() {
11
14
  if (win.__alfa_cdn_host__) {
12
15
  return win.__alfa_cdn_host__;
13
16
  }
14
- var scriptUrl = ((_document$currentScri = document.currentScript) === null || _document$currentScri === void 0 ? void 0 : _document$currentScri.src) || import.meta.url;
17
+ var scriptUrl = (_document$currentScri = document.currentScript) === null || _document$currentScri === void 0 ? void 0 : _document$currentScri.src;
18
+ if (!scriptUrl) {
19
+ var _Error$stack, _Error$stack$toString;
20
+ scriptUrl = (_Error$stack = new Error('').stack) === null || _Error$stack === void 0 ? void 0 : (_Error$stack$toString = _Error$stack.toString().match(/(https?:\/\/[^\s]+)/)) === null || _Error$stack$toString === void 0 ? void 0 : _Error$stack$toString[1];
21
+ }
15
22
 
16
23
  // document.currentScript 可能为 null
17
24
  var _URL = new URL(scriptUrl),
@@ -28,6 +35,9 @@ var getCurrentCdnHost = function getCurrentCdnHost() {
28
35
  };
29
36
  var currentCdnHost = getCurrentCdnHost();
30
37
 
38
+ // 如果 host 被 o2 插件替换,则可以被用来判断是否需要替换 cdnHost
39
+ var gCdnHost = '//g.alicdn.com/';
40
+
31
41
  // 根据不同环境替换 cdn 的域名
32
42
  export default function requestInterceptor(_x) {
33
43
  return _requestInterceptor.apply(this, arguments);
@@ -37,7 +47,7 @@ function _requestInterceptor() {
37
47
  return _regeneratorRuntime.wrap(function _callee$(_context) {
38
48
  while (1) switch (_context.prev = _context.next) {
39
49
  case 0:
40
- if (currentCdnHost && currentCdnHost !== 'alicdn.com' && whiteList.includes(currentCdnHost)) {
50
+ if (currentCdnHost && currentCdnHost !== 'alicdn.com' && (whiteList.includes(currentCdnHost) || gCdnHost.includes(currentCdnHost))) {
41
51
  // if cdn is not alicdn, replace it
42
52
  if (config.url) {
43
53
  config.url = config.url.replace(new RegExp('.alicdn.com'), ".".concat(currentCdnHost)).replace('cws2.', 'cws.') // 非公有云下无 cws2
@@ -125,7 +125,9 @@ var getConfigV2 = exports.getConfigV2 = /*#__PURE__*/function () {
125
125
  case 8:
126
126
  _context2.prev = 8;
127
127
  _context2.next = 11;
128
- return _request.default.get("https://".concat(config.env !== 'prod' ? 'pre-' : '', "fecs.console.").concat((0, _consoleBaseConfParseEnv.default)().MAIN_DOMAIN, "/api/alfa/console/config?appId=").concat(relatedConsoleAppId));
128
+ return _request.default.get("https://".concat(config.env !== 'prod' ? 'pre-' : '', "fecs.console.").concat((0, _consoleBaseConfParseEnv.default)().MAIN_DOMAIN, "/api/alfa/console/config?appId=").concat(relatedConsoleAppId), {
129
+ withCredentials: true
130
+ });
129
131
  case 11:
130
132
  res = _context2.sent;
131
133
  return _context2.abrupt("return", {
@@ -7,10 +7,13 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = requestInterceptor;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
- var whiteList = ['alicdn.com', 'idptcloud01cdn.com'];
10
+ var _window$ALIYUN_CONSOL;
11
+ // 支持的主权云 CDN Host
12
+ // @ts-ignore
13
+ var whiteList = ['idptcloud01cdn.com', ((_window$ALIYUN_CONSOL = window.ALIYUN_CONSOLE_CONFIG) === null || _window$ALIYUN_CONSOL === void 0 ? void 0 : _window$ALIYUN_CONSOL.MAIN_RESOURCE_CDN) || 'alicdn.com'];
11
14
  var win = window;
12
15
 
13
- // 兼容非公有云环境
16
+ // 兼容非公有云环境,用于替换请求的 hostname
14
17
  var getCurrentCdnHost = function getCurrentCdnHost() {
15
18
  try {
16
19
  var _document$currentScri;
@@ -18,7 +21,11 @@ var getCurrentCdnHost = function getCurrentCdnHost() {
18
21
  if (win.__alfa_cdn_host__) {
19
22
  return win.__alfa_cdn_host__;
20
23
  }
21
- var scriptUrl = ((_document$currentScri = document.currentScript) === null || _document$currentScri === void 0 ? void 0 : _document$currentScri.src) || import.meta.url;
24
+ var scriptUrl = (_document$currentScri = document.currentScript) === null || _document$currentScri === void 0 ? void 0 : _document$currentScri.src;
25
+ if (!scriptUrl) {
26
+ var _Error$stack, _Error$stack$toString;
27
+ scriptUrl = (_Error$stack = new Error('').stack) === null || _Error$stack === void 0 ? void 0 : (_Error$stack$toString = _Error$stack.toString().match(/(https?:\/\/[^\s]+)/)) === null || _Error$stack$toString === void 0 ? void 0 : _Error$stack$toString[1];
28
+ }
22
29
 
23
30
  // document.currentScript 可能为 null
24
31
  var _URL = new URL(scriptUrl),
@@ -35,6 +42,9 @@ var getCurrentCdnHost = function getCurrentCdnHost() {
35
42
  };
36
43
  var currentCdnHost = getCurrentCdnHost();
37
44
 
45
+ // 如果 host 被 o2 插件替换,则可以被用来判断是否需要替换 cdnHost
46
+ var gCdnHost = '//g.alicdn.com/';
47
+
38
48
  // 根据不同环境替换 cdn 的域名
39
49
  function requestInterceptor(_x) {
40
50
  return _requestInterceptor.apply(this, arguments);
@@ -44,7 +54,7 @@ function _requestInterceptor() {
44
54
  return _regenerator.default.wrap(function _callee$(_context) {
45
55
  while (1) switch (_context.prev = _context.next) {
46
56
  case 0:
47
- if (currentCdnHost && currentCdnHost !== 'alicdn.com' && whiteList.includes(currentCdnHost)) {
57
+ if (currentCdnHost && currentCdnHost !== 'alicdn.com' && (whiteList.includes(currentCdnHost) || gCdnHost.includes(currentCdnHost))) {
48
58
  // if cdn is not alicdn, replace it
49
59
  if (config.url) {
50
60
  config.url = config.url.replace(new RegExp('.alicdn.com'), ".".concat(currentCdnHost)).replace('cws2.', 'cws.') // 非公有云下无 cws2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alicloud/alfa-core",
3
- "version": "1.5.6-alpha.0",
3
+ "version": "1.5.6",
4
4
  "description": "MicroFront End SDK for alicloud",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",