@webex/calling 3.12.0-next.34 → 3.12.0-next.35
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/mobius-socket/errors.js +4 -11
- package/dist/mobius-socket/errors.js.map +1 -1
- package/dist/mobius-socket/errors.test.js +20 -0
- package/dist/mobius-socket/errors.test.js.map +1 -0
- package/dist/module/mobius-socket/errors.js +3 -9
- package/dist/types/mobius-socket/errors.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -9,7 +9,6 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
9
9
|
exports.UnknownResponse = exports.NotAuthorized = exports.Forbidden = exports.ConnectionError = exports.BadRequest = void 0;
|
|
10
10
|
exports.createTimeoutError = createTimeoutError;
|
|
11
11
|
exports.createWssResponseError = createWssResponseError;
|
|
12
|
-
var _defineProperties = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/define-properties"));
|
|
13
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
14
13
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
15
14
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/possibleConstructorReturn"));
|
|
@@ -25,13 +24,15 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
25
24
|
* Exception thrown when a websocket gets closed.
|
|
26
25
|
*/
|
|
27
26
|
var ConnectionError = exports.ConnectionError = /*#__PURE__*/function (_Exception) {
|
|
28
|
-
|
|
29
|
-
function ConnectionError(event) {
|
|
27
|
+
function ConnectionError() {
|
|
30
28
|
var _this;
|
|
29
|
+
var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
31
30
|
(0, _classCallCheck2.default)(this, ConnectionError);
|
|
32
31
|
_this = _callSuper(this, ConnectionError, [event]);
|
|
33
32
|
(0, _defineProperty2.default)(_this, "code", void 0);
|
|
34
33
|
(0, _defineProperty2.default)(_this, "reason", void 0);
|
|
34
|
+
_this.code = event.code;
|
|
35
|
+
_this.reason = event.reason;
|
|
35
36
|
return _this;
|
|
36
37
|
}
|
|
37
38
|
|
|
@@ -45,14 +46,6 @@ var ConnectionError = exports.ConnectionError = /*#__PURE__*/function (_Exceptio
|
|
|
45
46
|
key: "parse",
|
|
46
47
|
value: function parse() {
|
|
47
48
|
var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
48
|
-
(0, _defineProperties.default)(this, {
|
|
49
|
-
code: {
|
|
50
|
-
value: event.code
|
|
51
|
-
},
|
|
52
|
-
reason: {
|
|
53
|
-
value: event.reason
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
49
|
return event.reason;
|
|
57
50
|
}
|
|
58
51
|
}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_common","require","_callSuper","t","o","e","_getPrototypeOf2","default","_possibleConstructorReturn2","_isNativeReflectConstruct","_Reflect$construct","constructor","apply","Boolean","prototype","valueOf","call","ConnectionError","exports","_Exception","
|
|
1
|
+
{"version":3,"names":["_common","require","_callSuper","t","o","e","_getPrototypeOf2","default","_possibleConstructorReturn2","_isNativeReflectConstruct","_Reflect$construct","constructor","apply","Boolean","prototype","valueOf","call","ConnectionError","exports","_Exception","_this","event","arguments","length","undefined","_classCallCheck2","_defineProperty2","code","reason","_inherits2","_createClass2","key","value","parse","Exception","UnknownResponse","_ConnectionError2","BadRequest","_ConnectionError3","NotAuthorized","_ConnectionError4","Forbidden","_ConnectionError5","createWssResponseError","response","statusCode","statusMessage","error","Error","concat","name","trackingId","createTimeoutError","request","errorPayload","type","subtype"],"sources":["errors.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n// @ts-expect-error `@webex/common` is still JS-only and does not ship declarations.\nimport {Exception} from '@webex/common';\nimport type {SocketCloseEvent, SocketResponse} from './socket/types';\nimport {MobiusSocketResponseError} from './types';\n\n/**\n * Exception thrown when a websocket gets closed.\n */\nexport class ConnectionError extends Exception {\n static defaultMessage = 'Failed to connect to socket';\n\n code?: number;\n\n reason?: string;\n\n constructor(event: SocketCloseEvent = {}) {\n super(event);\n this.code = event.code;\n this.reason = event.reason;\n }\n\n /**\n * Parses a close event and sets the code and reason properties.\n * @param event - Socket close event to parse\n * @returns The reason string from the event\n */\n parse(event: SocketCloseEvent = {}) {\n return event.reason;\n }\n}\n\n/**\n * Thrown for CloseCode 1005.\n * UnknownResponse is produced by IE when we receive a 4XXX close code.\n * This should typically be treated like a NotFound error.\n */\nexport class UnknownResponse extends ConnectionError {\n static defaultMessage =\n 'UnknownResponse is produced by IE when we receive a 4XXX. You probably want to treat this like a NotFound';\n\n // eslint-disable-next-line no-useless-constructor\n constructor(event?: SocketCloseEvent) {\n super(event);\n }\n}\n\n/**\n * Thrown for CloseCode 4400.\n * BadRequest usually implies an attempt to use service account credentials.\n */\nexport class BadRequest extends ConnectionError {\n static defaultMessage =\n 'BadRequest usually implies an attempt to use service account credentials';\n\n // eslint-disable-next-line no-useless-constructor\n constructor(event?: SocketCloseEvent) {\n super(event);\n }\n}\n\n/**\n * Thrown for CloseCode 4401.\n * Indicates an authorization failure requiring a token refresh.\n */\nexport class NotAuthorized extends ConnectionError {\n static defaultMessage = 'Please refresh your access token';\n\n // eslint-disable-next-line no-useless-constructor\n constructor(event?: SocketCloseEvent) {\n super(event);\n }\n}\n\n/**\n * Thrown for CloseCode 4403.\n * Forbidden usually implies the credentials are not entitled for Webex.\n */\nexport class Forbidden extends ConnectionError {\n static defaultMessage = 'Forbidden usually implies these credentials are not entitled for Webex';\n\n // eslint-disable-next-line no-useless-constructor\n constructor(event?: SocketCloseEvent) {\n super(event);\n }\n}\n\n/**\n * Creates a MobiusSocketResponseError from a socket response.\n *\n * @param response - The socket response that triggered the error\n * @param statusCode - HTTP-style status code for the error\n * @param statusMessage - Human-readable status message\n * @returns A formatted error object with response details\n */\nexport function createWssResponseError(\n response: SocketResponse,\n statusCode?: number,\n statusMessage?: string\n): MobiusSocketResponseError {\n const error = new Error(\n statusMessage || `Mobius websocket request failed with status ${statusCode || 'unknown'}`\n ) as MobiusSocketResponseError;\n\n error.name = 'MobiusSocketResponseError';\n error.statusCode = statusCode;\n error.statusMessage = statusMessage;\n error.response = response;\n error.trackingId = response?.trackingId;\n\n return error;\n}\n\n/**\n * Creates a timeout error for a socket request that didn't receive a response.\n *\n * @param request - The socket request that timed out\n * @returns A timeout error with status code 408\n */\nexport function createTimeoutError(request: SocketResponse): MobiusSocketResponseError {\n const errorPayload = {\n type: 'response_event',\n subtype: request.type,\n trackingId: request.trackingId,\n };\n\n return createWssResponseError(errorPayload, 408, 'Mobius websocket response timed out');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAKA,IAAAA,OAAA,GAAAC,OAAA;AAAwC,SAAAC,WAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,WAAAD,CAAA,OAAAE,gBAAA,CAAAC,OAAA,EAAAH,CAAA,OAAAI,2BAAA,CAAAD,OAAA,EAAAJ,CAAA,EAAAM,yBAAA,KAAAC,kBAAA,CAAAN,CAAA,EAAAC,CAAA,YAAAC,gBAAA,CAAAC,OAAA,EAAAJ,CAAA,EAAAQ,WAAA,IAAAP,CAAA,CAAAQ,KAAA,CAAAT,CAAA,EAAAE,CAAA;AAAA,SAAAI,0BAAA,cAAAN,CAAA,IAAAU,OAAA,CAAAC,SAAA,CAAAC,OAAA,CAAAC,IAAA,CAAAN,kBAAA,CAAAG,OAAA,iCAAAV,CAAA,aAAAM,yBAAA,YAAAA,0BAAA,aAAAN,CAAA,UALxC;AACA;AACA,GAFA,CAIA;AAKA;AACA;AACA;AAFA,IAGac,eAAe,GAAAC,OAAA,CAAAD,eAAA,0BAAAE,UAAA;EAO1B,SAAAF,gBAAA,EAA0C;IAAA,IAAAG,KAAA;IAAA,IAA9BC,KAAuB,GAAAC,SAAA,CAAAC,MAAA,QAAA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eAAe;AAS9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPA,IAAAS,gBAAA,CAAAnB,OAAA,EATakC,SAAS,oBACI,wEAAwE;AAgB3F,SAASE,sBAAsBA,CACpCC,QAAwB,EACxBC,UAAmB,EACnBC,aAAsB,EACK;EAC3B,IAAMC,KAAK,GAAG,IAAIC,KAAK,CACrBF,aAAa,mDAAAG,MAAA,CAAmDJ,UAAU,IAAI,SAAS,CACzF,CAA8B;EAE9BE,KAAK,CAACG,IAAI,GAAG,2BAA2B;EACxCH,KAAK,CAACF,UAAU,GAAGA,UAAU;EAC7BE,KAAK,CAACD,aAAa,GAAGA,aAAa;EACnCC,KAAK,CAACH,QAAQ,GAAGA,QAAQ;EACzBG,KAAK,CAACI,UAAU,GAAGP,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEO,UAAU;EAEvC,OAAOJ,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,kBAAkBA,CAACC,OAAuB,EAA6B;EACrF,IAAMC,YAAY,GAAG;IACnBC,IAAI,EAAE,gBAAgB;IACtBC,OAAO,EAAEH,OAAO,CAACE,IAAI;IACrBJ,UAAU,EAAEE,OAAO,CAACF;EACtB,CAAC;EAED,OAAOR,sBAAsB,CAACW,YAAY,EAAE,GAAG,EAAE,qCAAqC,CAAC;AACzF","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _errors = require("./errors");
|
|
4
|
+
describe('Mobius socket errors', function () {
|
|
5
|
+
it('preserves close-event details assigned after super(event)', function () {
|
|
6
|
+
var error = new _errors.ConnectionError({
|
|
7
|
+
code: 3050,
|
|
8
|
+
reason: 'done (permanent)'
|
|
9
|
+
});
|
|
10
|
+
expect(error.code).toBe(3050);
|
|
11
|
+
expect(error.reason).toBe('done (permanent)');
|
|
12
|
+
expect(error.parse({
|
|
13
|
+
code: 3051,
|
|
14
|
+
reason: 'retry'
|
|
15
|
+
})).toBe('retry');
|
|
16
|
+
expect(error.code).toBe(3050);
|
|
17
|
+
expect(error.reason).toBe('done (permanent)');
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=errors.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_errors","require","describe","it","error","ConnectionError","code","reason","expect","toBe","parse"],"sources":["errors.test.ts"],"sourcesContent":["import {ConnectionError} from './errors';\n\ndescribe('Mobius socket errors', () => {\n it('preserves close-event details assigned after super(event)', () => {\n const error = new ConnectionError({code: 3050, reason: 'done (permanent)'});\n\n expect(error.code).toBe(3050);\n expect(error.reason).toBe('done (permanent)');\n expect(error.parse({code: 3051, reason: 'retry'})).toBe('retry');\n expect(error.code).toBe(3050);\n expect(error.reason).toBe('done (permanent)');\n });\n});\n"],"mappings":";;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEAC,QAAQ,CAAC,sBAAsB,EAAE,YAAM;EACrCC,EAAE,CAAC,2DAA2D,EAAE,YAAM;IACpE,IAAMC,KAAK,GAAG,IAAIC,uBAAe,CAAC;MAACC,IAAI,EAAE,IAAI;MAAEC,MAAM,EAAE;IAAkB,CAAC,CAAC;IAE3EC,MAAM,CAACJ,KAAK,CAACE,IAAI,CAAC,CAACG,IAAI,CAAC,IAAI,CAAC;IAC7BD,MAAM,CAACJ,KAAK,CAACG,MAAM,CAAC,CAACE,IAAI,CAAC,kBAAkB,CAAC;IAC7CD,MAAM,CAACJ,KAAK,CAACM,KAAK,CAAC;MAACJ,IAAI,EAAE,IAAI;MAAEC,MAAM,EAAE;IAAO,CAAC,CAAC,CAAC,CAACE,IAAI,CAAC,OAAO,CAAC;IAChED,MAAM,CAACJ,KAAK,CAACE,IAAI,CAAC,CAACG,IAAI,CAAC,IAAI,CAAC;IAC7BD,MAAM,CAACJ,KAAK,CAACG,MAAM,CAAC,CAACE,IAAI,CAAC,kBAAkB,CAAC;EAC/C,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -6,18 +6,12 @@ export class ConnectionError extends Exception {
|
|
|
6
6
|
static defaultMessage = 'Failed to connect to socket';
|
|
7
7
|
code;
|
|
8
8
|
reason;
|
|
9
|
-
constructor(event) {
|
|
9
|
+
constructor(event = {}) {
|
|
10
10
|
super(event);
|
|
11
|
+
this.code = event.code;
|
|
12
|
+
this.reason = event.reason;
|
|
11
13
|
}
|
|
12
14
|
parse(event = {}) {
|
|
13
|
-
Object.defineProperties(this, {
|
|
14
|
-
code: {
|
|
15
|
-
value: event.code,
|
|
16
|
-
},
|
|
17
|
-
reason: {
|
|
18
|
-
value: event.reason,
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
15
|
return event.reason;
|
|
22
16
|
}
|
|
23
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/mobius-socket/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAC,gBAAgB,EAAE,cAAc,EAAC,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAC,yBAAyB,EAAC,MAAM,SAAS,CAAC;AAKlD,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,MAAM,CAAC,cAAc,SAAiC;IAEtD,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,MAAM,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/mobius-socket/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAC,gBAAgB,EAAE,cAAc,EAAC,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAC,yBAAyB,EAAC,MAAM,SAAS,CAAC;AAKlD,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,MAAM,C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