@webex/http-core 3.0.0-beta.14 → 3.0.0-beta.15
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/README.md +0 -1
- package/dist/http-error-subtypes.js.map +1 -1
- package/dist/http-error.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/interceptors/http-status.js.map +1 -1
- package/dist/lib/detect.js.map +1 -1
- package/dist/lib/interceptor.js.map +1 -1
- package/dist/lib/xhr.js +27 -27
- package/dist/lib/xhr.js.map +1 -1
- package/dist/progress-event.js.map +1 -1
- package/dist/request/request.js.map +1 -1
- package/dist/request/request.shim.js.map +1 -1
- package/package.json +10 -10
- package/src/http-error-subtypes.js +1 -1
- package/src/http-error.js +15 -23
- package/src/index.js +4 -9
- package/src/interceptors/http-status.js +7 -5
- package/src/lib/detect.js +0 -1
- package/src/lib/interceptor.js +2 -4
- package/src/lib/xhr.js +197 -194
- package/src/progress-event.js +10 -5
- package/src/request/request.js +16 -14
- package/src/request/request.shim.js +47 -38
- package/test/integration/spec/http-error.js +11 -11
- package/test/integration/spec/interceptor.js +20 -13
- package/test/integration/spec/progress-event.js +8 -8
- package/test/integration/spec/request.js +135 -127
- package/test/unit/spec/interceptors/http-status.js +14 -11
package/README.md
CHANGED
|
@@ -51,7 +51,6 @@ Curried version of `request()` that produces an http client with overridden defa
|
|
|
51
51
|
|
|
52
52
|
Child of `Error` (by way of `Exception` from `@webex/common`). Has subclassed errors for each [official HTTP status code](https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html) (and 429 Too Man Requests).
|
|
53
53
|
|
|
54
|
-
|
|
55
54
|
## Maintainers
|
|
56
55
|
|
|
57
56
|
This package is maintained by [Cisco Webex for Developers](https://developer.webex.com/).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["makeSubTypes","Base","NetworkOrCORSError","BadRequest","Unauthorized","PaymentRequired","Forbidden","NotFound","MethodNotAllowed","NotAcceptable","ProxyAuthenticationRequired","RequestTimeout","Conflict","Gone","LengthRequired","PreconditionFailed","RequestEntityTooLarge","RequestUriTooLong","UnsupportedMediaType","RequestRangeNotSatisfiable","ExpectationFailed","TooManyRequests","InternalServerError","NotImplemented","BadGateway","ServiceUnavailable","GatewayTimeout","HttpVersionNotSupported","select","statusCode","E","toString","split","shift"],"sources":["http-error-subtypes.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/**\n * @param {Error} Base\n * @returns {undefined}\n */\nexport default function makeSubTypes(Base) {\n /**\n * NetworkOrCORSError\n */\n class NetworkOrCORSError extends Base {}\n /**\n * BadRequest\n */\n class BadRequest extends Base {}\n /**\n * Unauthorized\n */\n class Unauthorized extends BadRequest {}\n /**\n * PaymentRequired\n */\n class PaymentRequired extends BadRequest {}\n /**\n * Forbidden\n */\n class Forbidden extends BadRequest {}\n /**\n * NotFound\n */\n class NotFound extends BadRequest {}\n /**\n * MethodNotAllowed\n */\n class MethodNotAllowed extends BadRequest {}\n /**\n * NotAcceptable\n */\n class NotAcceptable extends BadRequest {}\n /**\n * ProxyAuthenticationRequired\n */\n class ProxyAuthenticationRequired extends BadRequest {}\n /**\n * RequestTimeout\n */\n class RequestTimeout extends BadRequest {}\n /**\n * Conflict\n */\n class Conflict extends BadRequest {}\n /**\n * Gone\n */\n class Gone extends BadRequest {}\n /**\n * LengthRequired\n */\n class LengthRequired extends BadRequest {}\n /**\n * PreconditionFailed\n */\n class PreconditionFailed extends BadRequest {}\n /**\n * RequestEntityTooLarge\n */\n class RequestEntityTooLarge extends BadRequest {}\n /**\n * RequestUriTooLong\n */\n class RequestUriTooLong extends BadRequest {}\n /**\n * UnsupportedMediaType\n */\n class UnsupportedMediaType extends BadRequest {}\n /**\n * RequestRangeNotSatisfiable\n */\n class RequestRangeNotSatisfiable extends BadRequest {}\n /**\n * ExpectationFailed\n */\n class ExpectationFailed extends BadRequest {}\n /**\n * TooManyRequests\n */\n class TooManyRequests extends BadRequest {}\n /**\n * InternalServerError\n */\n class InternalServerError extends Base {}\n /**\n * NotImplemented\n */\n class NotImplemented extends InternalServerError {}\n /**\n * BadGateway\n */\n class BadGateway extends InternalServerError {}\n /**\n * ServiceUnavailable\n */\n class ServiceUnavailable extends InternalServerError {}\n /**\n * GatewayTimeout\n */\n class GatewayTimeout extends InternalServerError {}\n /**\n * HttpVersionNotSupported\n */\n class HttpVersionNotSupported extends InternalServerError {}\n\n Object.assign(Base, {\n 0: NetworkOrCORSError,\n NetworkOrCORSError,\n 400: BadRequest,\n BadRequest,\n 401: Unauthorized,\n Unauthorized,\n 402: PaymentRequired,\n PaymentRequired,\n 403: Forbidden,\n Forbidden,\n 404: NotFound,\n NotFound,\n 405: MethodNotAllowed,\n MethodNotAllowed,\n 406: NotAcceptable,\n NotAcceptable,\n 407: ProxyAuthenticationRequired,\n ProxyAuthenticationRequired,\n 408: RequestTimeout,\n RequestTimeout,\n 409: Conflict,\n Conflict,\n 410: Gone,\n Gone,\n 411: LengthRequired,\n LengthRequired,\n 412: PreconditionFailed,\n PreconditionFailed,\n 413: RequestEntityTooLarge,\n RequestEntityTooLarge,\n 414: RequestUriTooLong,\n RequestUriTooLong,\n 415: UnsupportedMediaType,\n UnsupportedMediaType,\n 416: RequestRangeNotSatisfiable,\n RequestRangeNotSatisfiable,\n 417: ExpectationFailed,\n ExpectationFailed,\n 429: TooManyRequests,\n TooManyRequests,\n 500: InternalServerError,\n InternalServerError,\n 501: NotImplemented,\n NotImplemented,\n 502: BadGateway,\n BadGateway,\n 503: ServiceUnavailable,\n ServiceUnavailable,\n 504: GatewayTimeout,\n GatewayTimeout,\n 505: HttpVersionNotSupported,\n HttpVersionNotSupported,\n select(statusCode) {\n if (typeof statusCode === 'undefined' || statusCode === null) {\n return Base;\n }\n\n statusCode = statusCode.statusCode || statusCode;\n const E = Base[statusCode];\n\n if (E) {\n return E;\n }\n\n // Fallback to the default for the category (e.g. BadRequest for 429)\n statusCode = `${statusCode.toString().split('').shift()}00`;\n statusCode = parseInt(statusCode, 10);\n\n return Base[statusCode] || Base;\n }
|
|
1
|
+
{"version":3,"names":["makeSubTypes","Base","NetworkOrCORSError","BadRequest","Unauthorized","PaymentRequired","Forbidden","NotFound","MethodNotAllowed","NotAcceptable","ProxyAuthenticationRequired","RequestTimeout","Conflict","Gone","LengthRequired","PreconditionFailed","RequestEntityTooLarge","RequestUriTooLong","UnsupportedMediaType","RequestRangeNotSatisfiable","ExpectationFailed","TooManyRequests","InternalServerError","NotImplemented","BadGateway","ServiceUnavailable","GatewayTimeout","HttpVersionNotSupported","select","statusCode","E","toString","split","shift"],"sources":["http-error-subtypes.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/**\n * @param {Error} Base\n * @returns {undefined}\n */\nexport default function makeSubTypes(Base) {\n /**\n * NetworkOrCORSError\n */\n class NetworkOrCORSError extends Base {}\n /**\n * BadRequest\n */\n class BadRequest extends Base {}\n /**\n * Unauthorized\n */\n class Unauthorized extends BadRequest {}\n /**\n * PaymentRequired\n */\n class PaymentRequired extends BadRequest {}\n /**\n * Forbidden\n */\n class Forbidden extends BadRequest {}\n /**\n * NotFound\n */\n class NotFound extends BadRequest {}\n /**\n * MethodNotAllowed\n */\n class MethodNotAllowed extends BadRequest {}\n /**\n * NotAcceptable\n */\n class NotAcceptable extends BadRequest {}\n /**\n * ProxyAuthenticationRequired\n */\n class ProxyAuthenticationRequired extends BadRequest {}\n /**\n * RequestTimeout\n */\n class RequestTimeout extends BadRequest {}\n /**\n * Conflict\n */\n class Conflict extends BadRequest {}\n /**\n * Gone\n */\n class Gone extends BadRequest {}\n /**\n * LengthRequired\n */\n class LengthRequired extends BadRequest {}\n /**\n * PreconditionFailed\n */\n class PreconditionFailed extends BadRequest {}\n /**\n * RequestEntityTooLarge\n */\n class RequestEntityTooLarge extends BadRequest {}\n /**\n * RequestUriTooLong\n */\n class RequestUriTooLong extends BadRequest {}\n /**\n * UnsupportedMediaType\n */\n class UnsupportedMediaType extends BadRequest {}\n /**\n * RequestRangeNotSatisfiable\n */\n class RequestRangeNotSatisfiable extends BadRequest {}\n /**\n * ExpectationFailed\n */\n class ExpectationFailed extends BadRequest {}\n /**\n * TooManyRequests\n */\n class TooManyRequests extends BadRequest {}\n /**\n * InternalServerError\n */\n class InternalServerError extends Base {}\n /**\n * NotImplemented\n */\n class NotImplemented extends InternalServerError {}\n /**\n * BadGateway\n */\n class BadGateway extends InternalServerError {}\n /**\n * ServiceUnavailable\n */\n class ServiceUnavailable extends InternalServerError {}\n /**\n * GatewayTimeout\n */\n class GatewayTimeout extends InternalServerError {}\n /**\n * HttpVersionNotSupported\n */\n class HttpVersionNotSupported extends InternalServerError {}\n\n Object.assign(Base, {\n 0: NetworkOrCORSError,\n NetworkOrCORSError,\n 400: BadRequest,\n BadRequest,\n 401: Unauthorized,\n Unauthorized,\n 402: PaymentRequired,\n PaymentRequired,\n 403: Forbidden,\n Forbidden,\n 404: NotFound,\n NotFound,\n 405: MethodNotAllowed,\n MethodNotAllowed,\n 406: NotAcceptable,\n NotAcceptable,\n 407: ProxyAuthenticationRequired,\n ProxyAuthenticationRequired,\n 408: RequestTimeout,\n RequestTimeout,\n 409: Conflict,\n Conflict,\n 410: Gone,\n Gone,\n 411: LengthRequired,\n LengthRequired,\n 412: PreconditionFailed,\n PreconditionFailed,\n 413: RequestEntityTooLarge,\n RequestEntityTooLarge,\n 414: RequestUriTooLong,\n RequestUriTooLong,\n 415: UnsupportedMediaType,\n UnsupportedMediaType,\n 416: RequestRangeNotSatisfiable,\n RequestRangeNotSatisfiable,\n 417: ExpectationFailed,\n ExpectationFailed,\n 429: TooManyRequests,\n TooManyRequests,\n 500: InternalServerError,\n InternalServerError,\n 501: NotImplemented,\n NotImplemented,\n 502: BadGateway,\n BadGateway,\n 503: ServiceUnavailable,\n ServiceUnavailable,\n 504: GatewayTimeout,\n GatewayTimeout,\n 505: HttpVersionNotSupported,\n HttpVersionNotSupported,\n select(statusCode) {\n if (typeof statusCode === 'undefined' || statusCode === null) {\n return Base;\n }\n\n statusCode = statusCode.statusCode || statusCode;\n const E = Base[statusCode];\n\n if (E) {\n return E;\n }\n\n // Fallback to the default for the category (e.g. BadRequest for 429)\n statusCode = `${statusCode.toString().split('').shift()}00`;\n statusCode = parseInt(statusCode, 10);\n\n return Base[statusCode] || Base;\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACe,SAASA,YAAT,CAAsBC,IAAtB,EAA4B;EACzC;AACF;AACA;EAH2C,IAInCC,kBAJmC;IAAA;;IAAA;;IAAA;MAAA;MAAA;IAAA;;IAAA;EAAA,EAIRD,IAJQ;EAKzC;AACF;AACA;;;EAP2C,IAQnCE,UARmC;IAAA;;IAAA;;IAAA;MAAA;MAAA;IAAA;;IAAA;EAAA,EAQhBF,IARgB;EASzC;AACF;AACA;;;EAX2C,IAYnCG,YAZmC;IAAA;;IAAA;;IAAA;MAAA;MAAA;IAAA;;IAAA;EAAA,EAYdD,UAZc;EAazC;AACF;AACA;;;EAf2C,IAgBnCE,eAhBmC;IAAA;;IAAA;;IAAA;MAAA;MAAA;IAAA;;IAAA;EAAA,EAgBXF,UAhBW;EAiBzC;AACF;AACA;;;EAnB2C,IAoBnCG,SApBmC;IAAA;;IAAA;;IAAA;MAAA;MAAA;IAAA;;IAAA;EAAA,EAoBjBH,UApBiB;EAqBzC;AACF;AACA;;;EAvB2C,IAwBnCI,QAxBmC;IAAA;;IAAA;;IAAA;MAAA;MAAA;IAAA;;IAAA;EAAA,EAwBlBJ,UAxBkB;EAyBzC;AACF;AACA;;;EA3B2C,IA4BnCK,gBA5BmC;IAAA;;IAAA;;IAAA;MAAA;MAAA;IAAA;;IAAA;EAAA,EA4BVL,UA5BU;EA6BzC;AACF;AACA;;;EA/B2C,IAgCnCM,aAhCmC;IAAA;;IAAA;;IAAA;MAAA;MAAA;IAAA;;IA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;;MAED4B,UAAU,GAAGA,UAAU,CAACA,UAAX,IAAyBA,UAAtC;MACA,IAAMC,CAAC,GAAG7B,IAAI,CAAC4B,UAAD,CAAd;;MAEA,IAAIC,CAAJ,EAAO;QACL,OAAOA,CAAP;MACD,CAVgB,CAYjB;;;MACAD,UAAU,aAAMA,UAAU,CAACE,QAAX,GAAsBC,KAAtB,CAA4B,EAA5B,EAAgCC,KAAhC,EAAN,OAAV;MACAJ,UAAU,GAAG,wBAASA,UAAT,EAAqB,EAArB,CAAb;MAEA,OAAO5B,IAAI,CAAC4B,UAAD,CAAJ,IAAoB5B,IAA3B;IACD;EAtEiB,CAApB;AAwED"}
|
package/dist/http-error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HttpError","res","body","message","JSON","parse","parseObject","err","defaultMessage","enumerable","value","httpVersion","headers","rawHeaders","trailers","rawTrailers","method","url","statusCode","statusMessage","socket","_res","messages","errorKeys","length","Exception","makeSubTypes"],"sources":["http-error.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {pick} from 'lodash';\nimport {Exception} from '@webex/common';\n\nimport makeSubTypes from './http-error-subtypes';\n\n/**\n * Base HttpError class. Unlikely to be thrown directly, but handy for general\n * type comparison.\n */\nexport default class HttpError extends Exception {\n /**\n * @example Extend via\n * MyError extends HttpError {\n * static errorKeys = HttpError.errorKeys.concat([\n * `key1`,\n * `key2`\n * ])\n * }\n *\n * @type {Array}\n */\n static errorKeys = [
|
|
1
|
+
{"version":3,"names":["HttpError","res","body","message","JSON","parse","parseObject","err","defaultMessage","enumerable","value","httpVersion","headers","rawHeaders","trailers","rawTrailers","method","url","statusCode","statusMessage","socket","_res","messages","errorKeys","length","Exception","makeSubTypes"],"sources":["http-error.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {pick} from 'lodash';\nimport {Exception} from '@webex/common';\n\nimport makeSubTypes from './http-error-subtypes';\n\n/**\n * Base HttpError class. Unlikely to be thrown directly, but handy for general\n * type comparison.\n */\nexport default class HttpError extends Exception {\n /**\n * @example Extend via\n * MyError extends HttpError {\n * static errorKeys = HttpError.errorKeys.concat([\n * `key1`,\n * `key2`\n * ])\n * }\n *\n * @type {Array}\n */\n static errorKeys = ['error', 'errorString', 'response', 'errorResponse', 'message', 'msg'];\n\n /**\n * Default error string if no error can be extracted from the http response\n * @type {string}\n */\n static defaultMessage = 'An error was received while trying to fulfill the request';\n\n /**\n * Parses HttpResponse objects for useful information (status, headers, etc)\n * as well as attempting to extract a useful error message.\n * @param {HttpResponse} res\n * @returns {string}\n */\n parse(res) {\n // complexity is high here because of all the default values below.\n /* eslint complexity: [0] */\n let {body} = res;\n let message;\n\n switch (typeof body) {\n case 'string':\n try {\n body = JSON.parse(body);\n message = this.parseObject(body);\n } catch (err) {\n message = body;\n }\n break;\n case 'object':\n message = this.parseObject(body);\n break;\n default:\n }\n\n if (!message) {\n message = this.defaultMessage;\n }\n\n Object.defineProperties(this, {\n body: {\n enumerable: false,\n value: body,\n },\n httpVersion: {\n enumerable: false,\n value: res.httpVersion,\n },\n headers: {\n enumerable: false,\n value: res.headers || {},\n },\n rawHeaders: {\n enumerable: false,\n value: res.rawHeaders || [],\n },\n trailers: {\n enumerable: false,\n value: res.trailers || {},\n },\n rawTrailers: {\n enumerable: false,\n value: res.rawTrailers || [],\n },\n method: {\n enumerable: false,\n value: res.method,\n },\n url: {\n enumerable: false,\n value: res.url,\n },\n statusCode: {\n enumerable: false,\n value: res.statusCode,\n },\n statusMessage: {\n enumerable: false,\n value: res.statusMessage,\n },\n socket: {\n enumerable: false,\n value: res.socket,\n },\n _res: {\n enumerable: false,\n value: res,\n },\n });\n\n return message;\n }\n\n /**\n * Recursively parses an error body looking for a likely error candidate\n * @param {object} body\n * @returns {string}\n */\n parseObject(body) {\n // Search body for common names of error strings\n const messages = Object.values(pick(body, HttpError.errorKeys));\n\n // If no error candidate was found, stringify the entire body\n if (messages.length === 0) {\n return JSON.stringify(body, null, 2);\n }\n\n // Assume the first key found was the error explanation\n const message = messages[0];\n\n // If the explanation is an object, recurse and try again\n if (typeof message === 'object') {\n return this.parseObject(message);\n }\n\n // Return the first key\n return message;\n }\n}\n\nmakeSubTypes(HttpError);\nHttpError.makeSubTypes = makeSubTypes;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA;;AAEA;;;;;;AAEA;AACA;AACA;AACA;IACqBA,S;;;;;;;;;;;;;IACnB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;IAGE;AACF;AACA;AACA;;IAGE;AACF;AACA;AACA;AACA;AACA;IACE,eAAMC,GAAN,EAAW;MACT;;MACA;MACA,IAAKC,IAAL,GAAaD,GAAb,CAAKC,IAAL;MACA,IAAIC,OAAJ;;MAEA,8BAAeD,IAAf;QACE,KAAK,QAAL;UACE,IAAI;YACFA,IAAI,GAAGE,IAAI,CAACC,KAAL,CAAWH,IAAX,CAAP;YACAC,OAAO,GAAG,KAAKG,WAAL,CAAiBJ,IAAjB,CAAV;UACD,CAHD,CAGE,OAAOK,GAAP,EAAY;YACZJ,OAAO,GAAGD,IAAV;UACD;;UACD;;QACF,KAAK,QAAL;UACEC,OAAO,GAAG,KAAKG,WAAL,CAAiBJ,IAAjB,CAAV;UACA;;QACF;MAZF;;MAeA,IAAI,CAACC,OAAL,EAAc;QACZA,OAAO,GAAG,KAAKK,cAAf;MACD;;MAED,+BAAwB,IAAxB,EAA8B;QAC5BN,IAAI,EAAE;UACJO,UAAU,EAAE,KADR;UAEJC,KAAK,EAAER;QAFH,CADsB;QAK5BS,WAAW,EAAE;UACXF,UAAU,EAAE,KADD;UAEXC,KAAK,EAAET,GAAG,CAACU;QAFA,CALe;QAS5BC,OAAO,EAAE;UACPH,UAAU,EAAE,KADL;UAEPC,KAAK,EAAET,GAAG,CAACW,OAAJ,IAAe;QAFf,CATmB;Q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AYhB;;MACA,IAAI,sBAAOnB,OAAP,MAAmB,QAAvB,EAAiC;QAC/B,OAAO,KAAKG,WAAL,CAAiBH,OAAjB,CAAP;MACD,CAfe,CAiBhB;;;MACA,OAAOA,OAAP;IACD;;;EAjIoCsB,iB;;;8BAAlBzB,S,eAYA,CAAC,OAAD,EAAU,aAAV,EAAyB,UAAzB,EAAqC,eAArC,EAAsD,SAAtD,EAAiE,KAAjE,C;8BAZAA,S,oBAkBK,2D;AAkH1B,IAAA0B,0BAAA,EAAa1B,SAAb;AACAA,SAAS,CAAC0B,YAAV,GAAyBA,0BAAzB"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["protorequest","defaultOptions","options","uri","arguments","forEach","prop","descriptor","enumerable","writable","json","logger","console","_request","interceptors","HttpStatusInterceptor","create","defaults","request"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {assign, curry, defaults as lodashDefaults, isString} from 'lodash';\n\nimport HttpStatusInterceptor from './interceptors/http-status';\nimport _request from './request';\n\n// Curry protorequest so we generate a function with default options built in.\nconst protorequest = curry(function protorequest(defaultOptions, options) {\n // allow for options to be a string (and therefore expect options in the third\n // position) to match request's api.\n if (isString(options)) {\n const uri = options;\n\n /* eslint prefer-rest-params: [0] */\n options = arguments[2] || {};\n options.uri = uri;\n }\n\n // Hide useless elements from logs\n [
|
|
1
|
+
{"version":3,"names":["protorequest","defaultOptions","options","uri","arguments","forEach","prop","descriptor","enumerable","writable","json","logger","console","_request","interceptors","HttpStatusInterceptor","create","defaults","request"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {assign, curry, defaults as lodashDefaults, isString} from 'lodash';\n\nimport HttpStatusInterceptor from './interceptors/http-status';\nimport _request from './request';\n\n// Curry protorequest so we generate a function with default options built in.\nconst protorequest = curry(function protorequest(defaultOptions, options) {\n // allow for options to be a string (and therefore expect options in the third\n // position) to match request's api.\n if (isString(options)) {\n const uri = options;\n\n /* eslint prefer-rest-params: [0] */\n options = arguments[2] || {};\n options.uri = uri;\n }\n\n // Hide useless elements from logs\n ['download', 'interceptors', 'logger', 'upload'].forEach((prop) => {\n let descriptor = Reflect.getOwnPropertyDescriptor(options, prop);\n\n descriptor = assign({}, descriptor, {\n enumerable: false,\n writable: true,\n });\n Reflect.defineProperty(options, prop, descriptor);\n });\n\n lodashDefaults(options, defaultOptions);\n\n if (!options.json && options.json !== false) {\n Reflect.deleteProperty(options, 'json');\n }\n\n options.logger = options.logger || this.logger || console;\n\n return _request(options);\n});\n\nconst defaultOptions = {\n json: true,\n interceptors: [\n // Reminder: this is supposed to be an instantiated interceptor.\n HttpStatusInterceptor.create(),\n ],\n};\n\nexport const defaults = protorequest;\nexport const request = protorequest(defaultOptions);\nexport {default as ProgressEvent} from './progress-event';\nexport {default as Interceptor} from './lib/interceptor';\nexport {default as HttpError} from './http-error';\nexport {default as HttpStatusInterceptor} from './interceptors/http-status';\nexport {default as detect} from './lib/detect';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;AACA;;AA8CA;;AACA;;AACA;;AAEA;;AAhDA;AACA,IAAMA,YAAY,GAAG,qBAAM,SAASA,YAAT,CAAsBC,cAAtB,EAAsCC,OAAtC,EAA+C;EACxE;EACA;EACA,IAAI,wBAASA,OAAT,CAAJ,EAAuB;IACrB,IAAMC,GAAG,GAAGD,OAAZ;IAEA;;IACAA,OAAO,GAAGE,SAAS,CAAC,CAAD,CAAT,IAAgB,EAA1B;IACAF,OAAO,CAACC,GAAR,GAAcA,GAAd;EACD,CATuE,CAWxE;;;EACA,CAAC,UAAD,EAAa,cAAb,EAA6B,QAA7B,EAAuC,QAAvC,EAAiDE,OAAjD,CAAyD,UAACC,IAAD,EAAU;IACjE,IAAIC,UAAU,GAAG,uCAAiCL,OAAjC,EAA0CI,IAA1C,CAAjB;IAEAC,UAAU,GAAG,sBAAO,EAAP,EAAWA,UAAX,EAAuB;MAClCC,UAAU,EAAE,KADsB;MAElCC,QAAQ,EAAE;IAFwB,CAAvB,CAAb;IAIA,6BAAuBP,OAAvB,EAAgCI,IAAhC,EAAsCC,UAAtC;EACD,CARD;EAUA,wBAAeL,OAAf,EAAwBD,cAAxB;;EAEA,IAAI,CAACC,OAAO,CAACQ,IAAT,IAAiBR,OAAO,CAACQ,IAAR,KAAiB,KAAtC,EAA6C;IAC3C,6BAAuBR,OAAvB,EAAgC,MAAhC;EACD;;EAEDA,OAAO,CAACS,MAAR,GAAiBT,OAAO,CAACS,MAAR,IAAkB,KAAKA,MAAvB,IAAiCC,OAAlD;EAEA,OAAO,IAAAC,iBAAA,EAASX,OAAT,CAAP;AACD,CA/BoB,CAArB;AAiCA,IAAMD,cAAc,GAAG;EACrBS,IAAI,EAAE,IADe;EAErBI,YAAY,EAAE,CACZ;EACAC,mBAAA,CAAsBC,MAAtB,EAFY;AAFO,CAAvB;AAQO,IAAMC,QAAQ,GAAGjB,YAAjB;;AACA,IAAMkB,OAAO,GAAGlB,YAAY,CAACC,cAAD,CAA5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LOCUS_REDIRECT_ERROR","HttpStatusInterceptor","webex","options","ErrorConstructor","error","HttpError","value","response","statusCode","resolve","body","errorCode","reject","select","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
|
|
1
|
+
{"version":3,"names":["LOCUS_REDIRECT_ERROR","HttpStatusInterceptor","webex","options","ErrorConstructor","error","HttpError","value","response","statusCode","resolve","body","errorCode","reject","select","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;;AACA;;;;;;AAEA,IAAMA,oBAAoB,GAAG,OAA7B;AAEA;AACA;AACA;;IACqBC,qB;;;;;EACnB;AACF;AACA;AACA;AACA;EACE,+BAAYC,KAAZ,EAAmBC,OAAnB,EAA4B;IAAA;;IAAA;IAC1B,0BAAMD,KAAN;IACA,IAAME,gBAAgB,GAAID,OAAO,KAAKA,OAAO,CAACE,KAAR,IAAiBF,OAAO,CAACC,gBAA9B,CAAR,IAA4DE,kBAArF;IAEA,4EAA8B;MAC5BF,gBAAgB,EAAE;QAChBG,KAAK,EAAEH;MADS;IADU,CAA9B;IAJ0B;EAS3B;EAED;AACF;AACA;AACA;;;;;;IAKE;AACF;AACA;AACA;AACA;IACE,oBAAWD,OAAX,EAAoBK,QAApB,EAA8B;MAC5B,IAAIA,QAAQ,CAACC,UAAb,EAAyB;QACvB,IAAID,QAAQ,CAACC,UAAT,GAAsB,GAA1B,EAA+B;UAC7B,OAAO,iBAAQC,OAAR,CAAgBF,QAAhB,CAAP;QACD,CAHsB,CAIvB;;;QACA,IACEA,QAAQ,CAACC,UAAT,KAAwB,GAAxB,IACAD,QAAQ,CAACG,IADT,IAEAH,QAAQ,CAACG,IAAT,CAAcC,SAAd,KAA4BZ,oBAH9B,EAIE;UACA,OAAO,iBAAQU,OAAR,CAAgBF,QAAhB,CAAP;QACD;MACF,CAb2B,CAe5B;MACA;MACA;;;MACA,OAAO,iBAAQK,MAAR,CAAe,KAAK,KAAKT,gBAAL,CAAsBU,MAAtB,CAA6BN,QAAQ,CAACC,UAAtC,CAAL,EAAwDD,QAAxD,CAAf,CAAP;IACD;;;WA5BD,gBAAcL,OAAd,EAAuB;MACrB,OAAO,IAAIF,qBAAJ,CAA0B,IAA1B,EAAgCE,OAAhC,CAAP;IACD;;;EAvBgDY,oB"}
|
package/dist/lib/detect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["detect","buffer","Blob","ArrayBuffer","Uint8Array","Error","type","fromBuffer","fileType","mime"],"sources":["detect.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {fromBuffer} from 'file-type';\n\n/**\n * Determine mimeType for the specified buffer;\n * @param {Buffer|Uint8Array|ArrayBuffer} buffer\n * @returns {Promise<string>}\n */\nexport default async function detect(buffer) {\n
|
|
1
|
+
{"version":3,"names":["detect","buffer","Blob","ArrayBuffer","Uint8Array","Error","type","fromBuffer","fileType","mime"],"sources":["detect.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {fromBuffer} from 'file-type';\n\n/**\n * Determine mimeType for the specified buffer;\n * @param {Buffer|Uint8Array|ArrayBuffer} buffer\n * @returns {Promise<string>}\n */\nexport default async function detect(buffer) {\n if (\n !(buffer instanceof Blob) &&\n !(buffer instanceof ArrayBuffer) &&\n !(buffer instanceof Uint8Array)\n ) {\n throw new Error('`detect` requires a buffer of type Blob, ArrayBuffer, or Uint8Array');\n }\n\n if (buffer instanceof Blob) {\n return buffer.type;\n }\n\n // `fromBuffer()` can take a buffer that is either a ArrayBuffer or Uinit8Array\n const fileType = await fromBuffer(buffer);\n\n if (!fileType) {\n return 'application/octet-stream';\n }\n\n return fileType.mime;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAIA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;SAC8BA,M;;;;;oFAAf,iBAAsBC,MAAtB;IAAA;IAAA;MAAA;QAAA;UAAA;YAAA,MAEX,EAAEA,MAAM,YAAYC,IAApB,KACA,EAAED,MAAM,YAAYE,WAApB,CADA,IAEA,EAAEF,MAAM,YAAYG,UAApB,CAJW;cAAA;cAAA;YAAA;;YAAA,MAML,IAAIC,KAAJ,CAAU,qEAAV,CANK;;UAAA;YAAA,MASTJ,MAAM,YAAYC,IATT;cAAA;cAAA;YAAA;;YAAA,iCAUJD,MAAM,CAACK,IAVH;;UAAA;YAAA;YAAA,OAcU,IAAAC,oBAAA,EAAWN,MAAX,CAdV;;UAAA;YAcPO,QAdO;;YAAA,IAgBRA,QAhBQ;cAAA;cAAA;YAAA;;YAAA,iCAiBJ,0BAjBI;;UAAA;YAAA,iCAoBNA,QAAQ,CAACC,IApBH;;UAAA;UAAA;YAAA;QAAA;MAAA;IAAA;EAAA,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Interceptor","attrs","forEach","key","value","enumerable","options","logger","console","process","env","ENABLE_VERBOSE_NETWORK_LOGGING","info","constructor","name","resolve","reason","reject","response","Error"],"sources":["interceptor.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {get} from 'lodash';\n\n/**\n * @class\n */\nexport default class Interceptor {\n /**\n * @constructor\n * @param {Object} attrs\n * @returns {UrlInterceptor}\n */\n constructor(attrs) {\n if (attrs) {\n Object.keys(attrs).forEach((key) => {\n const value = attrs[key];\n\n Reflect.defineProperty(this, key, {\n enumerable: true,\n value
|
|
1
|
+
{"version":3,"names":["Interceptor","attrs","forEach","key","value","enumerable","options","logger","console","process","env","ENABLE_VERBOSE_NETWORK_LOGGING","info","constructor","name","resolve","reason","reject","response","Error"],"sources":["interceptor.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {get} from 'lodash';\n\n/**\n * @class\n */\nexport default class Interceptor {\n /**\n * @constructor\n * @param {Object} attrs\n * @returns {UrlInterceptor}\n */\n constructor(attrs) {\n if (attrs) {\n Object.keys(attrs).forEach((key) => {\n const value = attrs[key];\n\n Reflect.defineProperty(this, key, {\n enumerable: true,\n value,\n });\n });\n }\n }\n\n /**\n * Logs the options of a request. This should be utilized\n * during the intercepting process, but can be used at any\n * time otherwise.\n * @param {object} options\n * @returns {void}\n */\n logOptions(options = {}) {\n const logger = get(this, 'webex.logger', console);\n\n if (!process.env.ENABLE_VERBOSE_NETWORK_LOGGING || !logger) {\n return;\n }\n\n // prepend a header for the interceptor\n logger.info('/***** Interceptor ****************************************************\\\\');\n\n logger.info(`${this.constructor.name} - ${JSON.stringify(options, null, 2)}`);\n }\n\n /**\n * @abstract\n * @returns {Interceptor}\n */\n static create() {\n throw new Error('`Interceptor.create()` must be defined');\n }\n\n /**\n * Transform request options before sending them\n * @param {Object} options\n * @returns {Promise<Object>}\n */\n onRequest(options) {\n return Promise.resolve(options);\n }\n\n /**\n * Handle request failures\n * @param {Object} options\n * @param {Error} reason\n * @returns {RejectedPromise<Error>}\n */\n onRequestError(options, reason) {\n return Promise.reject(reason);\n }\n\n /**\n * Transform response before returning it\n * @param {Object} options\n * @param {HttpResponse} response\n * @returns {Promise<HttpResponse>}\n */\n onResponse(options, response) {\n return Promise.resolve(response);\n }\n\n /**\n * Handle response errors\n * @param {Object} options\n * @param {WebexHttpError} reason\n * @returns {Promise<WebexHttpError>}\n */\n onResponseError(options, reason) {\n return Promise.reject(reason);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;AACA;AACA;IACqBA,W;EACnB;AACF;AACA;AACA;AACA;EACE,qBAAYC,KAAZ,EAAmB;IAAA;;IAAA;;IACjB,IAAIA,KAAJ,EAAW;MACT,mBAAYA,KAAZ,EAAmBC,OAAnB,CAA2B,UAACC,GAAD,EAAS;QAClC,IAAMC,KAAK,GAAGH,KAAK,CAACE,GAAD,CAAnB;QAEA,6BAAuB,KAAvB,EAA6BA,GAA7B,EAAkC;UAChCE,UAAU,EAAE,IADoB;UAEhCD,KAAK,EAALA;QAFgC,CAAlC;MAID,CAPD;IAQD;EACF;EAED;AACF;AACA;AACA;AACA;AACA;AACA;;;;;WACE,sBAAyB;MAAA,IAAdE,OAAc,uEAAJ,EAAI;MACvB,IAAMC,MAAM,GAAG,mBAAI,IAAJ,EAAU,cAAV,EAA0BC,OAA1B,CAAf;;MAEA,IAAI,CAACC,OAAO,CAACC,GAAR,CAAYC,8BAAb,IAA+C,CAACJ,MAApD,EAA4D;QAC1D;MACD,CALsB,CAOvB;;;MACAA,MAAM,CAACK,IAAP,CAAY,2EAAZ;MAEAL,MAAM,CAACK,IAAP,WAAe,KAAKC,WAAL,CAAiBC,IAAhC,gBAA0C,wBAAeR,OAAf,EAAwB,IAAxB,EAA8B,CAA9B,CAA1C;IACD;IAED;AACF;AACA;AACA;;;;;IAKE;AACF;AACA;AACA;AACA;IACE,mBAAUA,OAAV,EAAmB;MACjB,OAAO,iBAAQS,OAAR,CAAgBT,OAAhB,CAAP;IACD;IAED;AACF;AACA;AACA;AACA;AACA;;;;WACE,wBAAeA,OAAf,EAAwBU,MAAxB,EAAgC;MAC9B,OAAO,iBAAQC,MAAR,CAAeD,MAAf,CAAP;IACD;IAED;AACF;AACA;AACA;AACA;AACA;;;;WACE,oBAAWV,OAAX,EAAoBY,QAApB,EAA8B;MAC5B,OAAO,iBAAQH,OAAR,CAAgBG,QAAhB,CAAP;IACD;IAED;AACF;AACA;AACA;AACA;AACA;;;;WACE,yBAAgBZ,OAAhB,EAAyBU,MAAzB,EAAiC;MAC/B,OAAO,iBAAQC,MAAR,CAAeD,MAAf,CAAP;IACD;;;WAzCD,kBAAgB;MACd,MAAM,IAAIG,KAAJ,CAAU,wCAAV,CAAN;IACD"}
|
package/dist/lib/xhr.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// we're trying to diverge as little as possible.
|
|
9
9
|
|
|
10
10
|
/* eslint-disable */
|
|
11
|
-
|
|
11
|
+
'use strict';
|
|
12
12
|
|
|
13
13
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
14
14
|
|
|
@@ -22,18 +22,18 @@ exports.default = void 0;
|
|
|
22
22
|
|
|
23
23
|
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
24
24
|
|
|
25
|
-
var window = require(
|
|
25
|
+
var window = require('global/window');
|
|
26
26
|
|
|
27
|
-
var isFunction = require(
|
|
27
|
+
var isFunction = require('is-function');
|
|
28
28
|
|
|
29
|
-
var parseHeaders = require(
|
|
29
|
+
var parseHeaders = require('parse-headers');
|
|
30
30
|
|
|
31
|
-
var xtend = require(
|
|
31
|
+
var xtend = require('xtend');
|
|
32
32
|
|
|
33
33
|
createXHR.XMLHttpRequest = window.XMLHttpRequest || noop;
|
|
34
|
-
createXHR.XDomainRequest =
|
|
35
|
-
forEachArray([
|
|
36
|
-
createXHR[method ===
|
|
34
|
+
createXHR.XDomainRequest = 'withCredentials' in new createXHR.XMLHttpRequest() ? createXHR.XMLHttpRequest : window.XDomainRequest;
|
|
35
|
+
forEachArray(['get', 'put', 'post', 'patch', 'head', 'delete'], function (method) {
|
|
36
|
+
createXHR[method === 'delete' ? 'del' : method] = function (uri, options, callback) {
|
|
37
37
|
options = initParams(uri, options, callback);
|
|
38
38
|
options.method = method.toUpperCase();
|
|
39
39
|
return _createXHR(options);
|
|
@@ -60,7 +60,7 @@ function initParams(uri, options, callback) {
|
|
|
60
60
|
if (isFunction(options)) {
|
|
61
61
|
callback = options;
|
|
62
62
|
|
|
63
|
-
if (typeof uri ===
|
|
63
|
+
if (typeof uri === 'string') {
|
|
64
64
|
params = {
|
|
65
65
|
uri: uri
|
|
66
66
|
};
|
|
@@ -81,8 +81,8 @@ function createXHR(uri, options, callback) {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
function _createXHR(options) {
|
|
84
|
-
if (typeof options.callback ===
|
|
85
|
-
throw new Error(
|
|
84
|
+
if (typeof options.callback === 'undefined') {
|
|
85
|
+
throw new Error('callback argument missing');
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
var called = false;
|
|
@@ -123,7 +123,7 @@ function _createXHR(options) {
|
|
|
123
123
|
clearTimeout(timeoutTimer);
|
|
124
124
|
|
|
125
125
|
if (!(evt instanceof Error)) {
|
|
126
|
-
evt = new Error(
|
|
126
|
+
evt = new Error('' + (evt || 'Unknown XMLHttpRequest Error'));
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
evt.statusCode = 0;
|
|
@@ -161,7 +161,7 @@ function _createXHR(options) {
|
|
|
161
161
|
response.headers = parseHeaders(xhr.getAllResponseHeaders());
|
|
162
162
|
}
|
|
163
163
|
} else {
|
|
164
|
-
err = new Error(
|
|
164
|
+
err = new Error('Internal XMLHttpRequest Error');
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
return callback(err, response, response.body);
|
|
@@ -180,7 +180,7 @@ function _createXHR(options) {
|
|
|
180
180
|
var key;
|
|
181
181
|
var aborted;
|
|
182
182
|
var uri = options.uri || options.url;
|
|
183
|
-
var method = options.method ||
|
|
183
|
+
var method = options.method || 'GET';
|
|
184
184
|
var body = options.body || options.data;
|
|
185
185
|
var headers = options.headers || {};
|
|
186
186
|
var sync = !!options.sync;
|
|
@@ -195,12 +195,12 @@ function _createXHR(options) {
|
|
|
195
195
|
rawRequest: xhr
|
|
196
196
|
};
|
|
197
197
|
|
|
198
|
-
if (
|
|
198
|
+
if ('json' in options && options.json !== false) {
|
|
199
199
|
isJson = true;
|
|
200
|
-
headers[
|
|
200
|
+
headers['accept'] || headers['Accept'] || (headers['Accept'] = 'application/json'); //Don't override existing accept header declared by user
|
|
201
201
|
|
|
202
|
-
if (method !==
|
|
203
|
-
headers[
|
|
202
|
+
if (method !== 'GET' && method !== 'HEAD') {
|
|
203
|
+
headers['content-type'] || headers['Content-Type'] || (headers['Content-Type'] = 'application/json'); //Don't override existing accept header declared by user
|
|
204
204
|
|
|
205
205
|
body = (0, _stringify.default)(options.json === true ? body : options.json);
|
|
206
206
|
}
|
|
@@ -232,9 +232,9 @@ function _createXHR(options) {
|
|
|
232
232
|
if (aborted) return;
|
|
233
233
|
aborted = true; //IE9 may still call readystatechange
|
|
234
234
|
|
|
235
|
-
xhr.abort(
|
|
236
|
-
var e = new Error(
|
|
237
|
-
e.code =
|
|
235
|
+
xhr.abort('timeout');
|
|
236
|
+
var e = new Error('XMLHttpRequest timeout');
|
|
237
|
+
e.code = 'ETIMEDOUT';
|
|
238
238
|
errorFunc(e);
|
|
239
239
|
}, options.timeout);
|
|
240
240
|
}
|
|
@@ -246,14 +246,14 @@ function _createXHR(options) {
|
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
} else if (options.headers && !isEmpty(options.headers)) {
|
|
249
|
-
throw new Error(
|
|
249
|
+
throw new Error('Headers cannot be set on an XDomainRequest object');
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
if (
|
|
252
|
+
if ('responseType' in options) {
|
|
253
253
|
xhr.responseType = options.responseType;
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
-
if (
|
|
256
|
+
if ('beforeSend' in options && typeof options.beforeSend === 'function') {
|
|
257
257
|
options.beforeSend(xhr);
|
|
258
258
|
} // Microsoft Edge browser sends "undefined" when send is called with undefined value.
|
|
259
259
|
// XMLHttpRequest spec says to pass null as body to indicate no body
|
|
@@ -265,13 +265,13 @@ function _createXHR(options) {
|
|
|
265
265
|
}
|
|
266
266
|
|
|
267
267
|
function getXml(xhr) {
|
|
268
|
-
if (xhr.responseType ===
|
|
268
|
+
if (xhr.responseType === 'document') {
|
|
269
269
|
return xhr.responseXML;
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
-
var firefoxBugTakenEffect = xhr.responseXML && xhr.responseXML.documentElement.nodeName ===
|
|
272
|
+
var firefoxBugTakenEffect = xhr.responseXML && xhr.responseXML.documentElement.nodeName === 'parsererror';
|
|
273
273
|
|
|
274
|
-
if (xhr.responseType ===
|
|
274
|
+
if (xhr.responseType === '' && !firefoxBugTakenEffect) {
|
|
275
275
|
return xhr.responseXML;
|
|
276
276
|
}
|
|
277
277
|
|
package/dist/lib/xhr.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["window","require","isFunction","parseHeaders","xtend","createXHR","XMLHttpRequest","noop","XDomainRequest","forEachArray","method","uri","options","callback","initParams","toUpperCase","_createXHR","array","iterator","i","length","isEmpty","obj","hasOwnProperty","params","Error","called","cbOnce","err","response","body","readystatechange","xhr","readyState","setTimeout","loadFunc","getBody","undefined","responseText","getXml","isJson","JSON","parse","e","errorFunc","evt","clearTimeout","timeoutTimer","statusCode","failureResponse","aborted","status","useXDR","headers","url","rawRequest","getAllResponseHeaders","cors","key","data","sync","json","onreadystatechange","onload","onerror","onprogress","onabort","ontimeout","open","username","password","withCredentials","timeout","abort","code","setRequestHeader","responseType","beforeSend","send","responseXML","firefoxBugTakenEffect","documentElement","nodeName"],"sources":["xhr.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n// Need to fork xhr to support environments with full object freezing; namely,\n// SalesForce's Aura and Locker environment.\n\n// See https://github.com/naugtur/xhr for license information\n\n// Maintain the original code style of https://github.com/naugtur/xhr since\n// we're trying to diverge as little as possible.\n/* eslint-disable */\n\n\"use strict\";\nvar window = require(\"global/window\")\nvar isFunction = require(\"is-function\")\nvar parseHeaders = require(\"parse-headers\")\nvar xtend = require(\"xtend\")\n\ncreateXHR.XMLHttpRequest = window.XMLHttpRequest || noop\ncreateXHR.XDomainRequest = \"withCredentials\" in (new createXHR.XMLHttpRequest()) ? createXHR.XMLHttpRequest : window.XDomainRequest\n\nforEachArray([\"get\", \"put\", \"post\", \"patch\", \"head\", \"delete\"], function(method) {\n createXHR[method === \"delete\" ? \"del\" : method] = function(uri, options, callback) {\n options = initParams(uri, options, callback)\n options.method = method.toUpperCase()\n return _createXHR(options)\n }\n})\n\nfunction forEachArray(array, iterator) {\n for (var i = 0; i < array.length; i+= 1) {\n iterator(array[i])\n }\n}\n\nfunction isEmpty(obj){\n for(var i in obj){\n if(obj.hasOwnProperty(i)) return false\n }\n return true\n}\n\nfunction initParams(uri, options, callback) {\n var params = uri\n\n if (isFunction(options)) {\n callback = options\n if (typeof uri === \"string\") {\n params = {uri:uri}\n }\n } else {\n params = xtend(options, {uri: uri})\n }\n\n params.callback = callback\n return params\n}\n\nfunction createXHR(uri, options, callback) {\n options = initParams(uri, options, callback)\n return _createXHR(options)\n}\n\nfunction _createXHR(options) {\n if(typeof options.callback === \"undefined\"){\n throw new Error(\"callback argument missing\")\n }\n\n var called = false\n var callback = function cbOnce(err, response, body){\n if(!called){\n called = true\n options.callback(err, response, body)\n }\n }\n\n function readystatechange() {\n if (xhr.readyState === 4) {\n setTimeout(loadFunc, 0)\n }\n }\n\n function getBody() {\n // Chrome with requestType=blob throws errors arround when even testing access to responseText\n var body = undefined\n\n if (xhr.response) {\n body = xhr.response\n } else {\n body = xhr.responseText || getXml(xhr)\n }\n\n if (isJson) {\n try {\n body = JSON.parse(body)\n } catch (e) {}\n }\n\n return body\n }\n\n function errorFunc(evt) {\n clearTimeout(timeoutTimer)\n if(!(evt instanceof Error)){\n evt = new Error(\"\" + (evt || \"Unknown XMLHttpRequest Error\") )\n }\n evt.statusCode = 0\n return callback(evt, failureResponse)\n }\n\n // will load the data & process the response in a special response object\n function loadFunc() {\n if (aborted) return\n var status\n clearTimeout(timeoutTimer)\n if(options.useXDR && xhr.status===undefined) {\n //IE8 CORS GET successful response doesn't have a status field, but body is fine\n status = 200\n } else {\n status = (xhr.status === 1223 ? 204 : xhr.status)\n }\n var response = failureResponse\n var err = null\n\n if (status !== 0){\n response = {\n body: getBody(),\n statusCode: status,\n method: method,\n headers: {},\n url: uri,\n rawRequest: xhr\n }\n if(xhr.getAllResponseHeaders){ //remember xhr can in fact be XDR for CORS in IE\n response.headers = parseHeaders(xhr.getAllResponseHeaders())\n }\n } else {\n err = new Error(\"Internal XMLHttpRequest Error\")\n }\n return callback(err, response, response.body)\n }\n\n var xhr = options.xhr || null\n\n if (!xhr) {\n if (options.cors || options.useXDR) {\n xhr = new createXHR.XDomainRequest()\n }else{\n xhr = new createXHR.XMLHttpRequest()\n }\n }\n\n var key\n var aborted\n var uri = options.uri || options.url\n var method = options.method || \"GET\"\n var body = options.body || options.data\n var headers = options.headers || {}\n var sync = !!options.sync\n var isJson = false\n var timeoutTimer\n var failureResponse = {\n body: undefined,\n headers: {},\n statusCode: 0,\n method: method,\n url: uri,\n rawRequest: xhr\n }\n\n if (\"json\" in options && options.json !== false) {\n isJson = true\n headers[\"accept\"] || headers[\"Accept\"] || (headers[\"Accept\"] = \"application/json\") //Don't override existing accept header declared by user\n if (method !== \"GET\" && method !== \"HEAD\") {\n headers[\"content-type\"] || headers[\"Content-Type\"] || (headers[\"Content-Type\"] = \"application/json\") //Don't override existing accept header declared by user\n body = JSON.stringify(options.json === true ? body : options.json)\n }\n }\n\n xhr.onreadystatechange = readystatechange\n xhr.onload = loadFunc\n xhr.onerror = errorFunc\n // IE9 must have onprogress be set to a unique function.\n xhr.onprogress = function () {\n // IE must die\n }\n xhr.onabort = function(){\n aborted = true;\n }\n xhr.ontimeout = errorFunc\n xhr.open(method, uri, !sync, options.username, options.password)\n //has to be after open\n if(!sync) {\n xhr.withCredentials = !!options.withCredentials\n }\n // Cannot set timeout with sync request\n // not setting timeout on the xhr object, because of old webkits etc. not handling that correctly\n // both npm's request and jquery 1.x use this kind of timeout, so this is being consistent\n if (!sync && options.timeout > 0 ) {\n timeoutTimer = setTimeout(function(){\n if (aborted) return\n aborted = true//IE9 may still call readystatechange\n xhr.abort(\"timeout\")\n var e = new Error(\"XMLHttpRequest timeout\")\n e.code = \"ETIMEDOUT\"\n errorFunc(e)\n }, options.timeout )\n }\n\n if (xhr.setRequestHeader) {\n for(key in headers){\n if(headers.hasOwnProperty(key)){\n xhr.setRequestHeader(key, headers[key])\n }\n }\n } else if (options.headers && !isEmpty(options.headers)) {\n throw new Error(\"Headers cannot be set on an XDomainRequest object\")\n }\n\n if (\"responseType\" in options) {\n xhr.responseType = options.responseType\n }\n\n if (\"beforeSend\" in options &&\n typeof options.beforeSend === \"function\"\n ) {\n options.beforeSend(xhr)\n }\n\n // Microsoft Edge browser sends \"undefined\" when send is called with undefined value.\n // XMLHttpRequest spec says to pass null as body to indicate no body\n // See https://github.com/naugtur/xhr/issues/100.\n xhr.send(body || null)\n\n return xhr\n\n\n}\n\nfunction getXml(xhr) {\n if (xhr.responseType === \"document\") {\n return xhr.responseXML\n }\n var firefoxBugTakenEffect = xhr.responseXML && xhr.responseXML.documentElement.nodeName === \"parsererror\"\n if (xhr.responseType === \"\" && !firefoxBugTakenEffect) {\n return xhr.responseXML\n }\n\n return null\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;EACA;EACA;;;EACAA,GAAG,CAAC8C,IAAJ,CAAShD,IAAI,IAAI,IAAjB;EAEA,OAAOE,GAAP;AAGH;;AAED,SAASO,MAAT,CAAgBP,GAAhB,EAAqB;EACjB,IAAIA,GAAG,CAAC4C,YAAJ,KAAqB,UAAzB,EAAqC;IACjC,OAAO5C,GAAG,CAAC+C,WAAX;EACH;;EACD,IAAIC,qBAAqB,GAAGhD,GAAG,CAAC+C,WAAJ,IAAmB/C,GAAG,CAAC+C,WAAJ,CAAgBE,eAAhB,CAAgCC,QAAhC,KAA6C,aAA5F;;EACA,IAAIlD,GAAG,CAAC4C,YAAJ,KAAqB,EAArB,IAA2B,CAACI,qBAAhC,EAAuD;IACnD,OAAOhD,GAAG,CAAC+C,WAAX;EACH;;EAED,OAAO,IAAP;AACH;;AAED,SAASxE,IAAT,GAAgB,CAAE;;eAEHF,S"}
|
|
1
|
+
{"version":3,"names":["window","require","isFunction","parseHeaders","xtend","createXHR","XMLHttpRequest","noop","XDomainRequest","forEachArray","method","uri","options","callback","initParams","toUpperCase","_createXHR","array","iterator","i","length","isEmpty","obj","hasOwnProperty","params","Error","called","cbOnce","err","response","body","readystatechange","xhr","readyState","setTimeout","loadFunc","getBody","undefined","responseText","getXml","isJson","JSON","parse","e","errorFunc","evt","clearTimeout","timeoutTimer","statusCode","failureResponse","aborted","status","useXDR","headers","url","rawRequest","getAllResponseHeaders","cors","key","data","sync","json","onreadystatechange","onload","onerror","onprogress","onabort","ontimeout","open","username","password","withCredentials","timeout","abort","code","setRequestHeader","responseType","beforeSend","send","responseXML","firefoxBugTakenEffect","documentElement","nodeName"],"sources":["xhr.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n// Need to fork xhr to support environments with full object freezing; namely,\n// SalesForce's Aura and Locker environment.\n\n// See https://github.com/naugtur/xhr for license information\n\n// Maintain the original code style of https://github.com/naugtur/xhr since\n// we're trying to diverge as little as possible.\n/* eslint-disable */\n\n'use strict';\nvar window = require('global/window');\nvar isFunction = require('is-function');\nvar parseHeaders = require('parse-headers');\nvar xtend = require('xtend');\n\ncreateXHR.XMLHttpRequest = window.XMLHttpRequest || noop;\ncreateXHR.XDomainRequest =\n 'withCredentials' in new createXHR.XMLHttpRequest()\n ? createXHR.XMLHttpRequest\n : window.XDomainRequest;\n\nforEachArray(['get', 'put', 'post', 'patch', 'head', 'delete'], function (method) {\n createXHR[method === 'delete' ? 'del' : method] = function (uri, options, callback) {\n options = initParams(uri, options, callback);\n options.method = method.toUpperCase();\n return _createXHR(options);\n };\n});\n\nfunction forEachArray(array, iterator) {\n for (var i = 0; i < array.length; i += 1) {\n iterator(array[i]);\n }\n}\n\nfunction isEmpty(obj) {\n for (var i in obj) {\n if (obj.hasOwnProperty(i)) return false;\n }\n return true;\n}\n\nfunction initParams(uri, options, callback) {\n var params = uri;\n\n if (isFunction(options)) {\n callback = options;\n if (typeof uri === 'string') {\n params = {uri: uri};\n }\n } else {\n params = xtend(options, {uri: uri});\n }\n\n params.callback = callback;\n return params;\n}\n\nfunction createXHR(uri, options, callback) {\n options = initParams(uri, options, callback);\n return _createXHR(options);\n}\n\nfunction _createXHR(options) {\n if (typeof options.callback === 'undefined') {\n throw new Error('callback argument missing');\n }\n\n var called = false;\n var callback = function cbOnce(err, response, body) {\n if (!called) {\n called = true;\n options.callback(err, response, body);\n }\n };\n\n function readystatechange() {\n if (xhr.readyState === 4) {\n setTimeout(loadFunc, 0);\n }\n }\n\n function getBody() {\n // Chrome with requestType=blob throws errors arround when even testing access to responseText\n var body = undefined;\n\n if (xhr.response) {\n body = xhr.response;\n } else {\n body = xhr.responseText || getXml(xhr);\n }\n\n if (isJson) {\n try {\n body = JSON.parse(body);\n } catch (e) {}\n }\n\n return body;\n }\n\n function errorFunc(evt) {\n clearTimeout(timeoutTimer);\n if (!(evt instanceof Error)) {\n evt = new Error('' + (evt || 'Unknown XMLHttpRequest Error'));\n }\n evt.statusCode = 0;\n return callback(evt, failureResponse);\n }\n\n // will load the data & process the response in a special response object\n function loadFunc() {\n if (aborted) return;\n var status;\n clearTimeout(timeoutTimer);\n if (options.useXDR && xhr.status === undefined) {\n //IE8 CORS GET successful response doesn't have a status field, but body is fine\n status = 200;\n } else {\n status = xhr.status === 1223 ? 204 : xhr.status;\n }\n var response = failureResponse;\n var err = null;\n\n if (status !== 0) {\n response = {\n body: getBody(),\n statusCode: status,\n method: method,\n headers: {},\n url: uri,\n rawRequest: xhr,\n };\n if (xhr.getAllResponseHeaders) {\n //remember xhr can in fact be XDR for CORS in IE\n response.headers = parseHeaders(xhr.getAllResponseHeaders());\n }\n } else {\n err = new Error('Internal XMLHttpRequest Error');\n }\n return callback(err, response, response.body);\n }\n\n var xhr = options.xhr || null;\n\n if (!xhr) {\n if (options.cors || options.useXDR) {\n xhr = new createXHR.XDomainRequest();\n } else {\n xhr = new createXHR.XMLHttpRequest();\n }\n }\n\n var key;\n var aborted;\n var uri = options.uri || options.url;\n var method = options.method || 'GET';\n var body = options.body || options.data;\n var headers = options.headers || {};\n var sync = !!options.sync;\n var isJson = false;\n var timeoutTimer;\n var failureResponse = {\n body: undefined,\n headers: {},\n statusCode: 0,\n method: method,\n url: uri,\n rawRequest: xhr,\n };\n\n if ('json' in options && options.json !== false) {\n isJson = true;\n headers['accept'] || headers['Accept'] || (headers['Accept'] = 'application/json'); //Don't override existing accept header declared by user\n if (method !== 'GET' && method !== 'HEAD') {\n headers['content-type'] ||\n headers['Content-Type'] ||\n (headers['Content-Type'] = 'application/json'); //Don't override existing accept header declared by user\n body = JSON.stringify(options.json === true ? body : options.json);\n }\n }\n\n xhr.onreadystatechange = readystatechange;\n xhr.onload = loadFunc;\n xhr.onerror = errorFunc;\n // IE9 must have onprogress be set to a unique function.\n xhr.onprogress = function () {\n // IE must die\n };\n xhr.onabort = function () {\n aborted = true;\n };\n xhr.ontimeout = errorFunc;\n xhr.open(method, uri, !sync, options.username, options.password);\n //has to be after open\n if (!sync) {\n xhr.withCredentials = !!options.withCredentials;\n }\n // Cannot set timeout with sync request\n // not setting timeout on the xhr object, because of old webkits etc. not handling that correctly\n // both npm's request and jquery 1.x use this kind of timeout, so this is being consistent\n if (!sync && options.timeout > 0) {\n timeoutTimer = setTimeout(function () {\n if (aborted) return;\n aborted = true; //IE9 may still call readystatechange\n xhr.abort('timeout');\n var e = new Error('XMLHttpRequest timeout');\n e.code = 'ETIMEDOUT';\n errorFunc(e);\n }, options.timeout);\n }\n\n if (xhr.setRequestHeader) {\n for (key in headers) {\n if (headers.hasOwnProperty(key)) {\n xhr.setRequestHeader(key, headers[key]);\n }\n }\n } else if (options.headers && !isEmpty(options.headers)) {\n throw new Error('Headers cannot be set on an XDomainRequest object');\n }\n\n if ('responseType' in options) {\n xhr.responseType = options.responseType;\n }\n\n if ('beforeSend' in options && typeof options.beforeSend === 'function') {\n options.beforeSend(xhr);\n }\n\n // Microsoft Edge browser sends \"undefined\" when send is called with undefined value.\n // XMLHttpRequest spec says to pass null as body to indicate no body\n // See https://github.com/naugtur/xhr/issues/100.\n xhr.send(body || null);\n\n return xhr;\n}\n\nfunction getXml(xhr) {\n if (xhr.responseType === 'document') {\n return xhr.responseXML;\n }\n var firefoxBugTakenEffect =\n xhr.responseXML && xhr.responseXML.documentElement.nodeName === 'parsererror';\n if (xhr.responseType === '' && !firefoxBugTakenEffect) {\n return xhr.responseXML;\n }\n\n return null;\n}\n\nfunction noop() {}\n\nexport default createXHR;\n"],"mappings":"AAAA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AACA;;AACA;AAEA;;;;;;;;;;;;;;AACA,IAAIA,MAAM,GAAGC,OAAO,CAAC,eAAD,CAApB;;AACA,IAAIC,UAAU,GAAGD,OAAO,CAAC,aAAD,CAAxB;;AACA,IAAIE,YAAY,GAAGF,OAAO,CAAC,eAAD,CAA1B;;AACA,IAAIG,KAAK,GAAGH,OAAO,CAAC,OAAD,CAAnB;;AAEAI,SAAS,CAACC,cAAV,GAA2BN,MAAM,CAACM,cAAP,I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,CAAC4C,YAAJ,KAAqB,EAArB,IAA2B,CAACI,qBAAhC,EAAuD;IACrD,OAAOhD,GAAG,CAAC+C,WAAX;EACD;;EAED,OAAO,IAAP;AACD;;AAED,SAASxE,IAAT,GAAgB,CAAE;;eAEHF,S"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ProgressEvent","loaded","total","enumerable","value","writable","lengthComputable"],"sources":["progress-event.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {isNumber} from 'lodash';\n\n/**\n * Object of the same shape as web browser ProgressEvents\n * @class ProgressEvent\n * @param {integer} loaded\n * @param {integer} total\n * @returns {ProgressEvent}\n */\nexport default function ProgressEvent(loaded, total) {\n Object.defineProperties(this, {\n loaded: {\n enumerable: true,\n value: loaded,\n writable: false
|
|
1
|
+
{"version":3,"names":["ProgressEvent","loaded","total","enumerable","value","writable","lengthComputable"],"sources":["progress-event.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {isNumber} from 'lodash';\n\n/**\n * Object of the same shape as web browser ProgressEvents\n * @class ProgressEvent\n * @param {integer} loaded\n * @param {integer} total\n * @returns {ProgressEvent}\n */\nexport default function ProgressEvent(loaded, total) {\n Object.defineProperties(this, {\n loaded: {\n enumerable: true,\n value: loaded,\n writable: false,\n },\n total: {\n enumerable: true,\n value: total,\n writable: false,\n },\n lengthComputable: {\n enumerable: true,\n value:\n isNumber(loaded) &&\n !Number.isNaN(loaded) &&\n isNumber(total) &&\n !Number.isNaN(total) &&\n total > 0,\n writable: false,\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,aAAT,CAAuBC,MAAvB,EAA+BC,KAA/B,EAAsC;EACnD,+BAAwB,IAAxB,EAA8B;IAC5BD,MAAM,EAAE;MACNE,UAAU,EAAE,IADN;MAENC,KAAK,EAAEH,MAFD;MAGNI,QAAQ,EAAE;IAHJ,CADoB;IAM5BH,KAAK,EAAE;MACLC,UAAU,EAAE,IADP;MAELC,KAAK,EAAEF,KAFF;MAGLG,QAAQ,EAAE;IAHL,CANqB;IAW5BC,gBAAgB,EAAE;MAChBH,UAAU,EAAE,IADI;MAEhBC,KAAK,EACH,wBAASH,MAAT,KACA,CAAC,oBAAaA,MAAb,CADD,IAEA,wBAASC,KAAT,CAFA,IAGA,CAAC,oBAAaA,KAAb,CAHD,IAIAA,KAAK,GAAG,CAPM;MAQhBG,QAAQ,EAAE;IARM;EAXU,CAA9B;AAsBD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["prepareOptions","options","responseType","encoding","withCredentials","jar","isBuffer","body","detect","then","type","headers","resolve","doRequest","logger","r","request","error","response","warn","Buffer","from","statusCode","method","url","on","total","loaded","data","length","download","emit","ProgressEvent","_request"],"sources":["request.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport request from 'request';\nimport {Buffer} from 'safe-buffer';\nimport {isBuffer} from '@webex/common';\n\nimport detect from '../lib/detect';\nimport ProgressEvent from '../progress-event';\n\n/**\n * @param {Object} options\n * @private\n * @returns {Promise}\n */\nfunction prepareOptions(options) {\n if (options.responseType === 'buffer' || options.responseType === 'blob') {\n options.encoding = null;\n }\n\n if (options.withCredentials) {\n options.jar = true;\n }\n\n if (isBuffer(options.body)) {\n return detect(options.body)
|
|
1
|
+
{"version":3,"names":["prepareOptions","options","responseType","encoding","withCredentials","jar","isBuffer","body","detect","then","type","headers","resolve","doRequest","logger","r","request","error","response","warn","Buffer","from","statusCode","method","url","on","total","loaded","data","length","download","emit","ProgressEvent","_request"],"sources":["request.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport request from 'request';\nimport {Buffer} from 'safe-buffer';\nimport {isBuffer} from '@webex/common';\n\nimport detect from '../lib/detect';\nimport ProgressEvent from '../progress-event';\n\n/**\n * @param {Object} options\n * @private\n * @returns {Promise}\n */\nfunction prepareOptions(options) {\n if (options.responseType === 'buffer' || options.responseType === 'blob') {\n options.encoding = null;\n }\n\n if (options.withCredentials) {\n options.jar = true;\n }\n\n if (isBuffer(options.body)) {\n return detect(options.body).then((type) => {\n options.headers['content-type'] = type;\n\n return options;\n });\n }\n\n return Promise.resolve(options);\n}\n\n/**\n * @param {Object} options\n * @private\n * @returns {Promise}\n */\nfunction doRequest(options) {\n return new Promise((resolve) => {\n const {logger} = options;\n\n const r = request(options, (error, response) => {\n if (error) {\n logger.warn(error);\n }\n\n if (response) {\n response.options = options;\n\n // I'm not sure why this line is necessary. request seems to be creating\n // buffers that aren't Buffers.\n if (\n options.responseType === 'buffer' &&\n response.body.type === 'Buffer' &&\n !isBuffer(response.body)\n ) {\n response.body = Buffer.from(response.body);\n }\n\n if (isBuffer(response.body) && !response.body.type) {\n resolve(\n detect(response.body).then((type) => {\n response.body.type = type;\n\n return response;\n })\n );\n\n return;\n }\n\n resolve(response);\n } else {\n // Make a network error behave like a browser network error.\n resolve({\n statusCode: 0,\n options,\n headers: options.headers,\n method: options.method,\n url: options.url,\n body: error,\n });\n }\n });\n\n r.on('response', (response) => {\n const total = parseInt(response.headers['content-length'], 10);\n let loaded = 0;\n\n response.on('data', (data) => {\n loaded += data.length;\n options.download.emit('progress', new ProgressEvent(loaded, total));\n });\n });\n });\n}\n\n/**\n * @name request\n * @param {Object} options\n * @returns {Promise}\n */\nexport default function _request(options) {\n return prepareOptions(options).then(doRequest);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAIA;;AACA;;AACA;;AAEA;;AACA;;AATA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA,SAASA,cAAT,CAAwBC,OAAxB,EAAiC;EAC/B,IAAIA,OAAO,CAACC,YAAR,KAAyB,QAAzB,IAAqCD,OAAO,CAACC,YAAR,KAAyB,MAAlE,EAA0E;IAC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EAAOU,QAAQ,CAACX,IAAhB,EAAsBE,IAAtB,CAA2B,UAACC,IAAD,EAAU;YACnCQ,QAAQ,CAACX,IAAT,CAAcG,IAAd,GAAqBA,IAArB;YAEA,OAAOQ,QAAP;UACD,CAJD,CADK,CAAP;UAQA;QACD;;QAEDN,OAAO,CAACM,QAAD,CAAP;MACD,CA1BD,MA0BO;QACL;QACAN,OAAO,CAAC;UACNU,UAAU,EAAE,CADN;UAENrB,OAAO,EAAPA,OAFM;UAGNU,OAAO,EAAEV,OAAO,CAACU,OAHX;UAINY,MAAM,EAAEtB,OAAO,CAACsB,MAJV;UAKNC,GAAG,EAAEvB,OAAO,CAACuB,GALP;UAMNjB,IAAI,EAAEU;QANA,CAAD,CAAP;MAQD;IACF,CA1CS,CAAV;IA4CAF,CAAC,CAACU,EAAF,CAAK,UAAL,EAAiB,UAACP,QAAD,EAAc;MAC7B,IAAMQ,KAAK,GAAG,wBAASR,QAAQ,CAACP,OAAT,CAAiB,gBAAjB,CAAT,EAA6C,EAA7C,CAAd;MACA,IAAIgB,MAAM,GAAG,CAAb;MAEAT,QAAQ,CAACO,EAAT,CAAY,MAAZ,EAAoB,UAACG,IAAD,EAAU;QAC5BD,MAAM,IAAIC,IAAI,CAACC,MAAf;QACA5B,OAAO,CAAC6B,QAAR,CAAiBC,IAAjB,CAAsB,UAAtB,EAAkC,IAAIC,sBAAJ,CAAkBL,MAAlB,EAA0BD,KAA1B,CAAlC;MACD,CAHD;IAID,CARD;EASD,CAxDM,CAAP;AAyDD;AAED;AACA;AACA;AACA;AACA;;;AACe,SAASO,QAAT,CAAkBhC,OAAlB,EAA2B;EACxC,OAAOD,cAAc,CAACC,OAAD,CAAd,CAAwBQ,IAAxB,CAA6BI,SAA7B,CAAP;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_request","options","resolve","params","response","setXhr","bindProgressEvents","setAuth","setCookies","setDefaults","setResponseType","setContentType","setPayload","setQs","logger","debug","method","uri","x","xhr","error","warn","statusCode","processResponseJson","headers","url","body","onprogress","download","emit","bind","catch","o","includes","toUpperCase","XMLHttpRequest","upload","auth","bearer","authorization","user","username","pass","password","token","btoa","jar","withCredentials","defs","cors","timeout","responseType","Blob","ArrayBuffer","json","detect","qs","stringify","ensureBlob","file","ret","type","filename","name","append","form","key","value","v","formData","reduce","fd","FormData","JSON","parse","e"],"sources":["request.shim.js"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint-env browser */\n\n// Note: several code paths are ignored in this file. As far as I can tell, any\n// error conditions that would provoke those paths are otherwise prevented and\n// reported.\n\nimport {defaults, isArray, pick} from 'lodash';\nimport qs from 'qs';\n\nimport xhr from '../lib/xhr';\nimport detect from '../lib/detect';\n\n/**\n * @name request\n * @param {Object} options\n * @returns {Promise}\n */\nexport default function _request(options) {\n return new Promise((resolve) => {\n const params = pick(options, 'method', 'uri', 'withCredentials', 'headers', 'timeout', 'responseType');\n\n // Set `response` to `true` to approximate an `HttpResponse` object\n params.response = true;\n\n setXhr(params);\n bindProgressEvents(params, options);\n setAuth(params, options);\n setCookies(params, options);\n setDefaults(params, options);\n setResponseType(params, options);\n setContentType(params, options);\n setPayload(params, options);\n setQs(params, options);\n\n options.logger.debug(`start http ${options.method ? options.method : 'request'} to ${options.uri}`);\n\n const x = xhr(params, (error, response) => {\n /* istanbul ignore next */\n if (error) {\n options.logger.warn(error);\n }\n\n /* istanbul ignore else */\n if (response) {\n if (response.statusCode >= 400) {\n options.logger.warn(`http ${options.method ? options.method : 'request'} to ${options.uri} result: ${response.statusCode}`);\n }\n else {\n options.logger.debug(`http ${options.method ? options.method : 'request'} to ${options.uri} result: ${response.statusCode}`);\n }\n response.options = options;\n processResponseJson(response, params);\n resolve(response);\n }\n else {\n resolve({\n statusCode: 0,\n options,\n headers: options.headers,\n method: options.method,\n url: options.uri,\n body: error\n });\n }\n });\n\n x.onprogress = options.download.emit.bind(options.download, 'progress');\n })\n .catch((error) => {\n options.logger.warn(error);\n\n /* eslint arrow-body-style: [0] */\n /* istanbul ignore next */\n return {\n statusCode: 0,\n options,\n headers: options.headers,\n method: options.method,\n url: options.uri,\n body: error\n };\n });\n\n /**\n * @param {Object} params\n * @param {Object} o\n * @private\n * @returns {undefined}\n */\n function bindProgressEvents(params, o) {\n if (params.method && ['PATCH', 'POST', 'PUT'].includes(params.method.toUpperCase())) {\n if (!params.xhr) {\n params.xhr = new XMLHttpRequest();\n }\n params.xhr.upload.onprogress = o.upload.emit.bind(o.upload, 'progress');\n }\n }\n\n /**\n * @param {Object} params\n * @param {Object} o\n * @private\n * @returns {undefined}\n */\n function setXhr(params) {\n params.xhr = new XMLHttpRequest();\n }\n\n /**\n * @param {Object} params\n * @param {Object} o\n * @private\n * @returns {undefined}\n */\n function setAuth(params, o) {\n if (o.auth) {\n if (o.auth.bearer) {\n params.headers.authorization = `Bearer ${o.auth.bearer}`;\n }\n else {\n const user = o.auth.user || o.auth.username;\n const pass = o.auth.pass || o.auth.password;\n\n const token = btoa(`${user}:${pass}`);\n\n params.headers.authorization = `Basic ${token}`;\n }\n }\n }\n\n /**\n * @param {Object} params\n * @param {Object} o\n * @private\n * @returns {undefined}\n */\n function setCookies(params, o) {\n if (o.jar) {\n params.withCredentials = true;\n }\n }\n\n /**\n * @param {Object} params\n * @param {Object} o\n * @private\n * @returns {undefined}\n */\n function setDefaults(params, o) {\n const defs = {\n cors: true,\n // raynos/xhr defaults withCredentials to true if cors is true, so we need\n // to make it explicitly false by default\n withCredentials: false,\n timeout: 0\n };\n\n defaults(params, pick(o, Object.keys(defs)), defs);\n }\n\n /**\n * @param {Object} params\n * @param {Object} o\n * @private\n * @returns {undefined}\n */\n function setResponseType(params, o) {\n if (o.responseType === 'buffer') {\n params.responseType = 'arraybuffer';\n }\n }\n\n /**\n * @param {Object} params\n * @param {Object} o\n * @private\n * @returns {undefined}\n */\n async function setContentType(params, o) {\n if (o.body instanceof Blob || o.body instanceof ArrayBuffer) {\n o.json = params.json = false;\n params.headers['content-type'] = params.headers['content-type'] || await detect(o.body);\n }\n }\n\n /**\n * @param {Object} params\n * @param {Object} o\n * @private\n * @returns {undefined}\n */\n function setQs(params, o) {\n if (o.qs) {\n params.uri += `?${qs.stringify(o.qs)}`;\n }\n }\n\n /**\n * Converts arraybuffers to blobs before uploading them\n * @param {mixed} file\n * @private\n * @returns {mixed}\n */\n function ensureBlob(file) {\n if (file instanceof ArrayBuffer) {\n const ret = file.type ? new Blob([file], {type: file.type}) : new Blob([file]);\n\n ret.filename = file.filename || file.name || 'untitled';\n\n return ret;\n }\n\n return file;\n }\n\n /**\n * Appends an item to a form\n * @param {FormData} form\n * @param {string} key\n * @param {mixed} value\n * @returns {undefined}\n */\n function append(form, key, value) {\n if (isArray(value)) {\n for (const v of value) {\n append(form, key, v);\n }\n\n return;\n }\n\n value = ensureBlob(value);\n if (value.name) {\n value.filename = value.name;\n form.append(key, value, value.name);\n }\n else {\n form.append(key, value);\n }\n }\n\n /**\n * @param {Object} params\n * @param {Object} o\n * @private\n * @returns {undefined}\n */\n function setPayload(params, o) {\n if ((!('json' in o) || o.json === true) && o.body) {\n params.json = o.body;\n }\n else if (o.form) {\n params.headers['Content-Type'] = 'application/x-www-form-urlencoded';\n params.body = qs.stringify(o.form);\n Reflect.deleteProperty(params, 'json');\n }\n else if (o.formData) {\n params.body = Object.keys(o.formData).reduce((fd, key) => {\n const value = o.formData[key];\n\n append(fd, key, value);\n\n return fd;\n }, new FormData());\n }\n else {\n params.body = o.body;\n Reflect.deleteProperty(params, 'json');\n }\n }\n\n /**\n * @param {Object} response\n * @param {Object} params\n * @private\n * @returns {undefined}\n */\n function processResponseJson(response, params) {\n // If params.json is not defined, xhr won't deserialize the response\n // so we should give it a shot just in case.\n if (!params.json && typeof response.body !== 'object') {\n try {\n response.body = JSON.parse(response.body);\n }\n catch (e) {\n /* eslint no-empty: [0] */\n }\n }\n }\n}\n"],"mappings":";;;;;;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,EAAuD;MACrD,IAAI;QACFtB,QAAQ,CAACsB,IAAT,GAAgB+C,IAAI,CAACC,KAAL,CAAWtE,QAAQ,CAACsB,IAApB,CAAhB;MACD,CAFD,CAGA,OAAOiD,CAAP,EAAU;QACR;MACD;IACF;EACF;AACF"}
|
|
1
|
+
{"version":3,"names":["_request","options","resolve","params","response","setXhr","bindProgressEvents","setAuth","setCookies","setDefaults","setResponseType","setContentType","setPayload","setQs","logger","debug","method","uri","x","xhr","error","warn","statusCode","processResponseJson","headers","url","body","onprogress","download","emit","bind","catch","o","includes","toUpperCase","XMLHttpRequest","upload","auth","bearer","authorization","user","username","pass","password","token","btoa","jar","withCredentials","defs","cors","timeout","responseType","Blob","ArrayBuffer","json","detect","qs","stringify","ensureBlob","file","ret","type","filename","name","append","form","key","value","v","formData","reduce","fd","FormData","JSON","parse","e"],"sources":["request.shim.js"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint-env browser */\n\n// Note: several code paths are ignored in this file. As far as I can tell, any\n// error conditions that would provoke those paths are otherwise prevented and\n// reported.\n\nimport {defaults, isArray, pick} from 'lodash';\nimport qs from 'qs';\n\nimport xhr from '../lib/xhr';\nimport detect from '../lib/detect';\n\n/**\n * @name request\n * @param {Object} options\n * @returns {Promise}\n */\nexport default function _request(options) {\n return new Promise((resolve) => {\n const params = pick(\n options,\n 'method',\n 'uri',\n 'withCredentials',\n 'headers',\n 'timeout',\n 'responseType'\n );\n\n // Set `response` to `true` to approximate an `HttpResponse` object\n params.response = true;\n\n setXhr(params);\n bindProgressEvents(params, options);\n setAuth(params, options);\n setCookies(params, options);\n setDefaults(params, options);\n setResponseType(params, options);\n setContentType(params, options);\n setPayload(params, options);\n setQs(params, options);\n\n options.logger.debug(\n `start http ${options.method ? options.method : 'request'} to ${options.uri}`\n );\n\n const x = xhr(params, (error, response) => {\n /* istanbul ignore next */\n if (error) {\n options.logger.warn(error);\n }\n\n /* istanbul ignore else */\n if (response) {\n if (response.statusCode >= 400) {\n options.logger.warn(\n `http ${options.method ? options.method : 'request'} to ${options.uri} result: ${\n response.statusCode\n }`\n );\n } else {\n options.logger.debug(\n `http ${options.method ? options.method : 'request'} to ${options.uri} result: ${\n response.statusCode\n }`\n );\n }\n response.options = options;\n processResponseJson(response, params);\n resolve(response);\n } else {\n resolve({\n statusCode: 0,\n options,\n headers: options.headers,\n method: options.method,\n url: options.uri,\n body: error,\n });\n }\n });\n\n x.onprogress = options.download.emit.bind(options.download, 'progress');\n }).catch((error) => {\n options.logger.warn(error);\n\n /* eslint arrow-body-style: [0] */\n /* istanbul ignore next */\n return {\n statusCode: 0,\n options,\n headers: options.headers,\n method: options.method,\n url: options.uri,\n body: error,\n };\n });\n\n /**\n * @param {Object} params\n * @param {Object} o\n * @private\n * @returns {undefined}\n */\n function bindProgressEvents(params, o) {\n if (params.method && ['PATCH', 'POST', 'PUT'].includes(params.method.toUpperCase())) {\n if (!params.xhr) {\n params.xhr = new XMLHttpRequest();\n }\n params.xhr.upload.onprogress = o.upload.emit.bind(o.upload, 'progress');\n }\n }\n\n /**\n * @param {Object} params\n * @param {Object} o\n * @private\n * @returns {undefined}\n */\n function setXhr(params) {\n params.xhr = new XMLHttpRequest();\n }\n\n /**\n * @param {Object} params\n * @param {Object} o\n * @private\n * @returns {undefined}\n */\n function setAuth(params, o) {\n if (o.auth) {\n if (o.auth.bearer) {\n params.headers.authorization = `Bearer ${o.auth.bearer}`;\n } else {\n const user = o.auth.user || o.auth.username;\n const pass = o.auth.pass || o.auth.password;\n\n const token = btoa(`${user}:${pass}`);\n\n params.headers.authorization = `Basic ${token}`;\n }\n }\n }\n\n /**\n * @param {Object} params\n * @param {Object} o\n * @private\n * @returns {undefined}\n */\n function setCookies(params, o) {\n if (o.jar) {\n params.withCredentials = true;\n }\n }\n\n /**\n * @param {Object} params\n * @param {Object} o\n * @private\n * @returns {undefined}\n */\n function setDefaults(params, o) {\n const defs = {\n cors: true,\n // raynos/xhr defaults withCredentials to true if cors is true, so we need\n // to make it explicitly false by default\n withCredentials: false,\n timeout: 0,\n };\n\n defaults(params, pick(o, Object.keys(defs)), defs);\n }\n\n /**\n * @param {Object} params\n * @param {Object} o\n * @private\n * @returns {undefined}\n */\n function setResponseType(params, o) {\n if (o.responseType === 'buffer') {\n params.responseType = 'arraybuffer';\n }\n }\n\n /**\n * @param {Object} params\n * @param {Object} o\n * @private\n * @returns {undefined}\n */\n async function setContentType(params, o) {\n if (o.body instanceof Blob || o.body instanceof ArrayBuffer) {\n o.json = params.json = false;\n params.headers['content-type'] = params.headers['content-type'] || (await detect(o.body));\n }\n }\n\n /**\n * @param {Object} params\n * @param {Object} o\n * @private\n * @returns {undefined}\n */\n function setQs(params, o) {\n if (o.qs) {\n params.uri += `?${qs.stringify(o.qs)}`;\n }\n }\n\n /**\n * Converts arraybuffers to blobs before uploading them\n * @param {mixed} file\n * @private\n * @returns {mixed}\n */\n function ensureBlob(file) {\n if (file instanceof ArrayBuffer) {\n const ret = file.type ? new Blob([file], {type: file.type}) : new Blob([file]);\n\n ret.filename = file.filename || file.name || 'untitled';\n\n return ret;\n }\n\n return file;\n }\n\n /**\n * Appends an item to a form\n * @param {FormData} form\n * @param {string} key\n * @param {mixed} value\n * @returns {undefined}\n */\n function append(form, key, value) {\n if (isArray(value)) {\n for (const v of value) {\n append(form, key, v);\n }\n\n return;\n }\n\n value = ensureBlob(value);\n if (value.name) {\n value.filename = value.name;\n form.append(key, value, value.name);\n } else {\n form.append(key, value);\n }\n }\n\n /**\n * @param {Object} params\n * @param {Object} o\n * @private\n * @returns {undefined}\n */\n function setPayload(params, o) {\n if ((!('json' in o) || o.json === true) && o.body) {\n params.json = o.body;\n } else if (o.form) {\n params.headers['Content-Type'] = 'application/x-www-form-urlencoded';\n params.body = qs.stringify(o.form);\n Reflect.deleteProperty(params, 'json');\n } else if (o.formData) {\n params.body = Object.keys(o.formData).reduce((fd, key) => {\n const value = o.formData[key];\n\n append(fd, key, value);\n\n return fd;\n }, new FormData());\n } else {\n params.body = o.body;\n Reflect.deleteProperty(params, 'json');\n }\n }\n\n /**\n * @param {Object} response\n * @param {Object} params\n * @private\n * @returns {undefined}\n */\n function processResponseJson(response, params) {\n // If params.json is not defined, xhr won't deserialize the response\n // so we should give it a shot just in case.\n if (!params.json && typeof response.body !== 'object') {\n try {\n response.body = JSON.parse(response.body);\n } catch (e) {\n /* eslint no-empty: [0] */\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA;;AAEA;;AACA;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACe,SAASA,QAAT,CAAkBC,OAAlB,EAA2B;EACxC,OAAO,qBAAY,UAACC,OAAD,EAAa;IAC9B,IAAMC,MAAM,GAAG,oBACbF,OADa,EAEb,QAFa,EAGb,KAHa,EAIb,iBAJa,EAKb,SALa,EAMb,SANa,EAOb,cAPa,CAAf,CAD8B,CAW9B;;IACAE,MAAM,CAACC,QAAP,GAAkB,IAAlB;IAEAC,MAAM,CAACF,MAAD,CAAN;IACAG,kBAAkB,CAACH,MAAD,EAASF,OAAT,CAAlB;IACAM,OAAO,CAACJ,MAAD,EAASF,OAAT,CAAP;IACAO,UAAU,CAACL,MAAD,EAASF,OAAT,CAAV;IACAQ,WAAW,CAACN,MAAD,EAASF,OAAT,CAAX;IACAS,eAAe,CAACP,MAAD,EAASF,OAAT,CAAf;IACAU,cAAc,CAACR,MAAD,EAASF,OAAT,CAAd;IACAW,UAAU,CAACT,MAAD,EAASF,OAAT,CAAV;IACAY,KAAK,CAACV,MAAD,EAASF,OAAT,CAAL;IAEAA,OAAO,CAACa,MAAR,CAAeC,KAAf,sBACgBd,OAAO,CAACe,MAAR,GAAiBf,OAAO,CAACe,MAAzB,GAAkC,SADlD,iBACkEf,OAAO,CAACgB,GAD1E;IAIA,IAAMC,CAAC,GAAG,IAAAC,YAAA,EAAIhB,MAAJ,EAAY,UAAC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A;MACLrE,MAAM,CAACuB,IAAP,GAAcM,CAAC,CAACN,IAAhB;MACA,6BAAuBvB,MAAvB,EAA+B,MAA/B;IACD;EACF;EAED;AACF;AACA;AACA;AACA;AACA;;;EACE,SAASoB,mBAAT,CAA6BnB,QAA7B,EAAuCD,MAAvC,EAA+C;IAC7C;IACA;IACA,IAAI,CAACA,MAAM,CAACmD,IAAR,IAAgB,sBAAOlD,QAAQ,CAACsB,IAAhB,MAAyB,QAA7C,EAAuD;MACrD,IAAI;QACFtB,QAAQ,CAACsB,IAAT,GAAgB+C,IAAI,CAACC,KAAL,CAAWtE,QAAQ,CAACsB,IAApB,CAAhB;MACD,CAFD,CAEE,OAAOiD,CAAP,EAAU;QACV;MACD;IACF;EACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/http-core",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.15",
|
|
4
4
|
"description": "Core HTTP library for the Cisco Webex",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,18 +24,18 @@
|
|
|
24
24
|
]
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@webex/test-helper-chai": "3.0.0-beta.
|
|
28
|
-
"@webex/test-helper-file": "3.0.0-beta.
|
|
29
|
-
"@webex/test-helper-make-local-url": "3.0.0-beta.
|
|
30
|
-
"@webex/test-helper-mocha": "3.0.0-beta.
|
|
27
|
+
"@webex/test-helper-chai": "3.0.0-beta.15",
|
|
28
|
+
"@webex/test-helper-file": "3.0.0-beta.15",
|
|
29
|
+
"@webex/test-helper-make-local-url": "3.0.0-beta.15",
|
|
30
|
+
"@webex/test-helper-mocha": "3.0.0-beta.15",
|
|
31
31
|
"sinon": "^9.2.4"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@webex/common": "3.0.0-beta.
|
|
35
|
-
"@webex/http-core": "3.0.0-beta.
|
|
36
|
-
"@webex/internal-plugin-device": "3.0.0-beta.
|
|
37
|
-
"@webex/test-helper-test-users": "3.0.0-beta.
|
|
38
|
-
"@webex/webex-core": "3.0.0-beta.
|
|
34
|
+
"@webex/common": "3.0.0-beta.15",
|
|
35
|
+
"@webex/http-core": "3.0.0-beta.15",
|
|
36
|
+
"@webex/internal-plugin-device": "3.0.0-beta.15",
|
|
37
|
+
"@webex/test-helper-test-users": "3.0.0-beta.15",
|
|
38
|
+
"@webex/webex-core": "3.0.0-beta.15",
|
|
39
39
|
"file-type": "^16.0.1",
|
|
40
40
|
"global": "^4.4.0",
|
|
41
41
|
"is-function": "^1.0.1",
|