@webex/http-core 3.8.0 → 3.8.1-next.2

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.
@@ -22,6 +22,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_R
22
22
  * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
23
23
  */
24
24
  var LOCUS_REDIRECT_ERROR = 2000002;
25
+ var APPAPI_REDIRECT_ERROR = 404100;
25
26
 
26
27
  /**
27
28
  * @class
@@ -68,6 +69,10 @@ var HttpStatusInterceptor = exports.default = /*#__PURE__*/function (_Intercepto
68
69
  if (response.statusCode === 404 && response.body && response.body.errorCode === LOCUS_REDIRECT_ERROR) {
69
70
  return _promise.default.resolve(response);
70
71
  }
72
+ // to handle appapi redirects
73
+ if (response.statusCode === 404 && response.body && response.body.code === APPAPI_REDIRECT_ERROR) {
74
+ return _promise.default.resolve(response);
75
+ }
71
76
  }
72
77
 
73
78
  // Note: the extra parenthesis below are required to make sure `new` is
@@ -1 +1 @@
1
- {"version":3,"names":["_httpError","_interopRequireDefault","require","_interceptor","_createSuper","Derived","hasNativeReflectConstruct","_isNativeReflectConstruct","_createSuperInternal","Super","_getPrototypeOf2","default","result","NewTarget","constructor","_Reflect$construct","arguments","apply","_possibleConstructorReturn2","Reflect","sham","Proxy","Boolean","prototype","valueOf","call","e","LOCUS_REDIRECT_ERROR","HttpStatusInterceptor","exports","_Interceptor","_inherits2","_super","webex","options","_this","_classCallCheck2","ErrorConstructor","error","HttpError","_defineProperties","_assertThisInitialized2","value","_createClass2","key","onResponse","response","statusCode","_promise","resolve","body","errorCode","reject","select","create","Interceptor"],"sources":["http-status.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport HttpError from '../http-error';\nimport Interceptor from '../lib/interceptor';\n\nconst LOCUS_REDIRECT_ERROR = 2000002;\n\n/**\n * @class\n */\nexport default class HttpStatusInterceptor extends Interceptor {\n /**\n * @param {Object} webex\n * @param {Object} options\n * @returns {HttpStatusInterceptor}\n */\n constructor(webex, options) {\n super(webex);\n const ErrorConstructor = (options && (options.error || options.ErrorConstructor)) || HttpError;\n\n Object.defineProperties(this, {\n ErrorConstructor: {\n value: ErrorConstructor,\n },\n });\n }\n\n /**\n * @param {Object} options\n * @returns {HttpStatusInterceptor}\n */\n static create(options) {\n return new HttpStatusInterceptor(this, options);\n }\n\n /**\n * @param {Object} options\n * @param {HttpResponse} response\n * @returns {Promise}\n */\n onResponse(options, response) {\n if (response.statusCode) {\n if (response.statusCode < 400) {\n return Promise.resolve(response);\n }\n // to handle locus redirects\n if (\n response.statusCode === 404 &&\n response.body &&\n response.body.errorCode === LOCUS_REDIRECT_ERROR\n ) {\n return Promise.resolve(response);\n }\n }\n\n // Note: the extra parenthesis below are required to make sure `new` is\n // applied to the correct method (i.e., the result of `select()`, not\n // `select()` itself).\n return Promise.reject(new (this.ErrorConstructor.select(response.statusCode))(response));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAIA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA6C,SAAAE,aAAAC,OAAA,QAAAC,yBAAA,GAAAC,yBAAA,oBAAAC,qBAAA,QAAAC,KAAA,OAAAC,gBAAA,CAAAC,OAAA,EAAAN,OAAA,GAAAO,MAAA,MAAAN,yBAAA,QAAAO,SAAA,OAAAH,gBAAA,CAAAC,OAAA,QAAAG,WAAA,EAAAF,MAAA,GAAAG,kBAAA,CAAAN,KAAA,EAAAO,SAAA,EAAAH,SAAA,YAAAD,MAAA,GAAAH,KAAA,CAAAQ,KAAA,OAAAD,SAAA,gBAAAE,2BAAA,CAAAP,OAAA,QAAAC,MAAA;AAAA,SAAAL,0BAAA,eAAAY,OAAA,qBAAAJ,kBAAA,oBAAAA,kBAAA,CAAAK,IAAA,2BAAAC,KAAA,oCAAAC,OAAA,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CAACI,IAAI,CAACC,SAAS,KAAKxB,oBAAoB,EAChD;UACA,OAAOqB,QAAA,CAAArC,OAAA,CAAQsC,OAAO,CAACH,QAAQ,CAAC;QAClC;MACF;;MAEA;MACA;MACA;MACA,OAAOE,QAAA,CAAArC,OAAA,CAAQyC,MAAM,CAAC,KAAK,IAAI,CAACf,gBAAgB,CAACgB,MAAM,CAACP,QAAQ,CAACC,UAAU,CAAC,EAAED,QAAQ,CAAC,CAAC;IAC1F;EAAC;IAAAF,GAAA;IAAAF,KAAA,EA5BD,SAAAY,OAAcpB,OAAO,EAAE;MACrB,OAAO,IAAIN,qBAAqB,CAAC,IAAI,EAAEM,OAAO,CAAC;IACjD;EAAC;EAAA,OAAAN,qBAAA;AAAA,EAvBgD2B,oBAAW"}
1
+ {"version":3,"names":["_httpError","_interopRequireDefault","require","_interceptor","_createSuper","Derived","hasNativeReflectConstruct","_isNativeReflectConstruct","_createSuperInternal","Super","_getPrototypeOf2","default","result","NewTarget","constructor","_Reflect$construct","arguments","apply","_possibleConstructorReturn2","Reflect","sham","Proxy","Boolean","prototype","valueOf","call","e","LOCUS_REDIRECT_ERROR","APPAPI_REDIRECT_ERROR","HttpStatusInterceptor","exports","_Interceptor","_inherits2","_super","webex","options","_this","_classCallCheck2","ErrorConstructor","error","HttpError","_defineProperties","_assertThisInitialized2","value","_createClass2","key","onResponse","response","statusCode","_promise","resolve","body","errorCode","code","reject","select","create","Interceptor"],"sources":["http-status.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport HttpError from '../http-error';\nimport Interceptor from '../lib/interceptor';\n\nconst LOCUS_REDIRECT_ERROR = 2000002;\nconst APPAPI_REDIRECT_ERROR = 404100;\n\n/**\n * @class\n */\nexport default class HttpStatusInterceptor extends Interceptor {\n /**\n * @param {Object} webex\n * @param {Object} options\n * @returns {HttpStatusInterceptor}\n */\n constructor(webex, options) {\n super(webex);\n const ErrorConstructor = (options && (options.error || options.ErrorConstructor)) || HttpError;\n\n Object.defineProperties(this, {\n ErrorConstructor: {\n value: ErrorConstructor,\n },\n });\n }\n\n /**\n * @param {Object} options\n * @returns {HttpStatusInterceptor}\n */\n static create(options) {\n return new HttpStatusInterceptor(this, options);\n }\n\n /**\n * @param {Object} options\n * @param {HttpResponse} response\n * @returns {Promise}\n */\n onResponse(options, response) {\n if (response.statusCode) {\n if (response.statusCode < 400) {\n return Promise.resolve(response);\n }\n // to handle locus redirects\n if (\n response.statusCode === 404 &&\n response.body &&\n response.body.errorCode === LOCUS_REDIRECT_ERROR\n ) {\n return Promise.resolve(response);\n }\n // to handle appapi redirects\n if (\n response.statusCode === 404 &&\n response.body &&\n response.body.code === APPAPI_REDIRECT_ERROR\n ) {\n return Promise.resolve(response);\n }\n }\n\n // Note: the extra parenthesis below are required to make sure `new` is\n // applied to the correct method (i.e., the result of `select()`, not\n // `select()` itself).\n return Promise.reject(new (this.ErrorConstructor.select(response.statusCode))(response));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAIA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA6C,SAAAE,aAAAC,OAAA,QAAAC,yBAAA,GAAAC,yBAAA,oBAAAC,qBAAA,QAAAC,KAAA,OAAAC,gBAAA,CAAAC,OAAA,EAAAN,OAAA,GAAAO,MAAA,MAAAN,yBAAA,QAAAO,SAAA,OAAAH,gBAAA,CAAAC,OAAA,QAAAG,WAAA,EAAAF,MAAA,GAAAG,kBAAA,CAAAN,KAAA,EAAAO,SAAA,EAAAH,SAAA,YAAAD,MAAA,GAAAH,KAAA,CAAAQ,KAAA,OAAAD,SAAA,gBAAAE,2BAAA,CAAAP,OAAA,QAAAC,MAAA;AAAA,SAAAL,0BAAA,eAAAY,OAAA,qBAAAJ,kBAAA,oBAAAA,kBAAA,CAAAK,IAAA,2BAAAC,KAAA,oCAAAC,OAAA,CAAAC,SAAA,CAAA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,IACbJ,QAAQ,CAACI,IAAI,CAACC,SAAS,KAAKzB,oBAAoB,EAChD;UACA,OAAOsB,QAAA,CAAAtC,OAAA,CAAQuC,OAAO,CAACH,QAAQ,CAAC;QAClC;QACA;QACA,IACEA,QAAQ,CAACC,UAAU,KAAK,GAAG,IAC3BD,QAAQ,CAACI,IAAI,IACbJ,QAAQ,CAACI,IAAI,CAACE,IAAI,KAAKzB,qBAAqB,EAC5C;UACA,OAAOqB,QAAA,CAAAtC,OAAA,CAAQuC,OAAO,CAACH,QAAQ,CAAC;QAClC;MACF;;MAEA;MACA;MACA;MACA,OAAOE,QAAA,CAAAtC,OAAA,CAAQ2C,MAAM,CAAC,KAAK,IAAI,CAAChB,gBAAgB,CAACiB,MAAM,CAACR,QAAQ,CAACC,UAAU,CAAC,EAAED,QAAQ,CAAC,CAAC;IAC1F;EAAC;IAAAF,GAAA;IAAAF,KAAA,EApCD,SAAAa,OAAcrB,OAAO,EAAE;MACrB,OAAO,IAAIN,qBAAqB,CAAC,IAAI,EAAEM,OAAO,CAAC;IACjD;EAAC;EAAA,OAAAN,qBAAA;AAAA,EAvBgD4B,oBAAW"}
package/package.json CHANGED
@@ -28,21 +28,21 @@
28
28
  "@webex/eslint-config-legacy": "0.0.0",
29
29
  "@webex/jest-config-legacy": "0.0.0",
30
30
  "@webex/legacy-tools": "0.0.0",
31
- "@webex/test-helper-chai": "3.8.0",
32
- "@webex/test-helper-file": "3.8.0",
33
- "@webex/test-helper-make-local-url": "3.8.0",
34
- "@webex/test-helper-mocha": "3.8.0",
35
- "@webex/test-helper-mock-webex": "3.8.0",
36
- "@webex/test-helper-test-users": "3.8.0",
31
+ "@webex/test-helper-chai": "3.8.1-next.2",
32
+ "@webex/test-helper-file": "3.8.1-next.2",
33
+ "@webex/test-helper-make-local-url": "3.8.1-next.2",
34
+ "@webex/test-helper-mocha": "3.8.1-next.2",
35
+ "@webex/test-helper-mock-webex": "3.8.1-next.2",
36
+ "@webex/test-helper-test-users": "3.8.1-next.2",
37
37
  "eslint": "^8.24.0",
38
38
  "prettier": "^2.7.1",
39
39
  "sinon": "^9.2.4"
40
40
  },
41
41
  "dependencies": {
42
- "@webex/common": "3.8.0",
43
- "@webex/internal-plugin-device": "3.8.0",
44
- "@webex/test-helper-test-users": "3.8.0",
45
- "@webex/webex-core": "3.8.0",
42
+ "@webex/common": "3.8.1-next.2",
43
+ "@webex/internal-plugin-device": "3.8.1-next.2",
44
+ "@webex/test-helper-test-users": "3.8.1-next.2",
45
+ "@webex/webex-core": "3.8.1-next.2",
46
46
  "file-type": "^16.0.1",
47
47
  "global": "^4.4.0",
48
48
  "is-function": "^1.0.1",
@@ -63,5 +63,5 @@
63
63
  "test:style": "eslint ./src/**/*.*",
64
64
  "test:unit": "webex-legacy-tools test --unit --runner jest"
65
65
  },
66
- "version": "3.8.0"
66
+ "version": "3.8.1-next.2"
67
67
  }
@@ -6,6 +6,7 @@ import HttpError from '../http-error';
6
6
  import Interceptor from '../lib/interceptor';
7
7
 
8
8
  const LOCUS_REDIRECT_ERROR = 2000002;
9
+ const APPAPI_REDIRECT_ERROR = 404100;
9
10
 
10
11
  /**
11
12
  * @class
@@ -53,6 +54,14 @@ export default class HttpStatusInterceptor extends Interceptor {
53
54
  ) {
54
55
  return Promise.resolve(response);
55
56
  }
57
+ // to handle appapi redirects
58
+ if (
59
+ response.statusCode === 404 &&
60
+ response.body &&
61
+ response.body.code === APPAPI_REDIRECT_ERROR
62
+ ) {
63
+ return Promise.resolve(response);
64
+ }
56
65
  }
57
66
 
58
67
  // Note: the extra parenthesis below are required to make sure `new` is
@@ -41,6 +41,28 @@ describe('http-core', () => {
41
41
  },
42
42
  };
43
43
 
44
+ assert.isRejected(interceptor.onResponse({}, response));
45
+ });
46
+ it('resolves on appapi redirect error', () => {
47
+ const response = {
48
+ statusCode: 404,
49
+ body: {
50
+ code: 404100,
51
+ },
52
+ };
53
+
54
+ return interceptor.onResponse({}, response).then((result) => {
55
+ assert.equal(result, response);
56
+ });
57
+ });
58
+ it('rejects when appapi redirect is not intended', () => {
59
+ const response = {
60
+ statusCode: 404,
61
+ body: {
62
+ errorCode: 404101,
63
+ },
64
+ };
65
+
44
66
  assert.isRejected(interceptor.onResponse({}, response));
45
67
  });
46
68
  });