@webex/internal-plugin-encryption 3.0.0-beta.216 → 3.0.0-beta.218
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/constants.js +14 -0
- package/dist/constants.js.map +1 -0
- package/dist/encryption.js +1 -1
- package/dist/kms-batcher.js +1 -0
- package/dist/kms-batcher.js.map +1 -1
- package/dist/kms-errors.js +12 -1
- package/dist/kms-errors.js.map +1 -1
- package/dist/kms.js +1 -1
- package/package.json +14 -14
- package/src/constants.js +3 -0
- package/src/kms-batcher.js +3 -1
- package/src/kms-errors.js +20 -0
- package/test/unit/spec/kms-errors.js +70 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.KMS_KEY_REVOKE_FAILURE = exports.KMS_KEY_REVOKE_ERROR_STATUS = exports.KMS_KEY_REVOKE_ERROR_CODES = void 0;
|
|
8
|
+
var KMS_KEY_REVOKE_FAILURE = 'event:kms:key:revoke:encryption:failure';
|
|
9
|
+
exports.KMS_KEY_REVOKE_FAILURE = KMS_KEY_REVOKE_FAILURE;
|
|
10
|
+
var KMS_KEY_REVOKE_ERROR_STATUS = 405;
|
|
11
|
+
exports.KMS_KEY_REVOKE_ERROR_STATUS = KMS_KEY_REVOKE_ERROR_STATUS;
|
|
12
|
+
var KMS_KEY_REVOKE_ERROR_CODES = [405005, 405006];
|
|
13
|
+
exports.KMS_KEY_REVOKE_ERROR_CODES = KMS_KEY_REVOKE_ERROR_CODES;
|
|
14
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["KMS_KEY_REVOKE_FAILURE","KMS_KEY_REVOKE_ERROR_STATUS","KMS_KEY_REVOKE_ERROR_CODES"],"sources":["constants.js"],"sourcesContent":["export const KMS_KEY_REVOKE_FAILURE = 'event:kms:key:revoke:encryption:failure';\nexport const KMS_KEY_REVOKE_ERROR_STATUS = 405;\nexport const KMS_KEY_REVOKE_ERROR_CODES = [405005, 405006];\n"],"mappings":";;;;;;;AAAO,IAAMA,sBAAsB,GAAG,yCAAyC;AAAC;AACzE,IAAMC,2BAA2B,GAAG,GAAG;AAAC;AACxC,IAAMC,0BAA0B,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;AAAC"}
|
package/dist/encryption.js
CHANGED
package/dist/kms-batcher.js
CHANGED
|
@@ -131,6 +131,7 @@ var KmsBatcher = _webexCore.Batcher.extend({
|
|
|
131
131
|
* @returns {Promise}
|
|
132
132
|
*/
|
|
133
133
|
handleItemFailure: function handleItemFailure(item, reason) {
|
|
134
|
+
(0, _kmsErrors.handleKmsKeyRevokedEncryptionFailure)(item, this.webex);
|
|
134
135
|
return this.getDeferredForResponse(item).then(function (defer) {
|
|
135
136
|
defer.reject(reason || new _kmsErrors.KmsError(item.body));
|
|
136
137
|
});
|
package/dist/kms-batcher.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TIMEOUT_SYMBOL","KmsBatcher","Batcher","extend","namespace","processKmsMessageEvent","event","logger","info","all","encryption","kmsMessages","map","kmsMessage","resolve","process","env","NODE_ENV","body","acceptItem","prepareItem","item","getDeferredForRequest","then","defer","timeout","Error","timer","safeSetTimeout","warn","requestId","handleItemFailure","KmsTimeoutError","request","promise","clearTimeout","catch","prepareRequest","queue","webex","internal","kms","_getKMSCluster","cluster","destination","req","wrapped","submitHttpRequest","payload","length","method","service","resource","handleHttpSuccess","didItemFail","status","handleItemSuccess","getDeferredForResponse","reason","reject","KmsError","fingerprintRequest","fingerprintResponse"],"sources":["kms-batcher.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {safeSetTimeout} from '@webex/common-timers';\nimport {Batcher} from '@webex/webex-core';\n\nimport {KmsError, KmsTimeoutError} from './kms-errors';\n\nexport const TIMEOUT_SYMBOL = Symbol('TIMEOUT_SYMBOL');\n\n/**\n * @class\n */\nconst KmsBatcher = Batcher.extend({\n namespace: 'Encryption',\n\n /**\n * Accepts a kmsMessage event and passes its contents to acceptItem\n * @param {Object} event\n * @returns {Promise}\n */\n processKmsMessageEvent(event) {\n this.logger.info('kms-batcher: received kms message');\n\n return Promise.all(\n event.encryption.kmsMessages.map(\n (kmsMessage) =>\n new Promise((resolve) => {\n /* istanbul ignore else */\n if (process.env.NODE_ENV !== 'production') {\n this.logger.info('kms-batcher:', kmsMessage.body);\n }\n\n resolve(this.acceptItem(kmsMessage));\n })\n )\n );\n },\n\n /**\n * Attaches a timeout to the given KMS message\n * @param {Object} item\n * @returns {Promise<Object>}\n */\n prepareItem(item) {\n return this.getDeferredForRequest(item).then((defer) => {\n const timeout = item[TIMEOUT_SYMBOL];\n\n /* istanbul ignore if */\n if (!timeout) {\n throw new Error('timeout is required');\n }\n\n const timer = safeSetTimeout(() => {\n this.logger.warn(\n `kms: request timed out; request id: ${item.requestId}; timeout: ${timeout}`\n );\n this.handleItemFailure(\n item,\n new KmsTimeoutError({\n timeout,\n request: item,\n })\n );\n }, timeout);\n\n // Reminder: reassign `promise` is not a viable means of inserting into\n // the Promise chain\n defer.promise.then(() => clearTimeout(timer));\n defer.promise.catch(() => clearTimeout(timer));\n\n return item;\n });\n },\n\n /**\n * Attaches the final bits of cluster info to the payload\n * @param {Array} queue\n * @returns {Promise<Array>}\n */\n prepareRequest(queue) {\n return this.webex.internal.encryption.kms._getKMSCluster().then((cluster) => ({\n destination: cluster,\n kmsMessages: queue.map((req) => req.wrapped),\n }));\n },\n\n /**\n * @param {Object} payload\n * @returns {Promise<HttpResponseObject>}\n */\n submitHttpRequest(payload) {\n this.logger.info('kms: batched-request-length', payload.kmsMessages.length);\n\n return this.webex.request({\n method: 'POST',\n service: 'encryption',\n resource: '/kms/messages',\n body: payload,\n });\n },\n\n /**\n * Does nothing; the http response doesn't carry our response data\n * @returns {Promise}\n */\n handleHttpSuccess() {\n return Promise.resolve();\n },\n\n /**\n * @param {Object} item\n * @returns {Promise<boolean>}\n */\n didItemFail(item) {\n return Promise.resolve(item.status >= 400);\n },\n\n /**\n * @param {Object} item\n * @returns {Promise}\n */\n handleItemSuccess(item) {\n return this.getDeferredForResponse(item).then((defer) => {\n defer.resolve(item.body);\n });\n },\n\n /**\n * @param {Object} item\n * @param {KmsError} [reason]\n * @returns {Promise}\n */\n handleItemFailure(item, reason) {\n return this.getDeferredForResponse(item).then((defer) => {\n defer.reject(reason || new KmsError(item.body));\n });\n },\n\n /**\n * @param {Object} item\n * @returns {Promise}\n */\n fingerprintRequest(item) {\n return Promise.resolve(item.requestId);\n },\n\n /**\n * @param {Object} item\n * @returns {Promise}\n */\n fingerprintResponse(item) {\n return Promise.resolve(item.requestId);\n },\n});\n\nexport default KmsBatcher;\n"],"mappings":";;;;;;;;;;AAIA;AACA;AAEA;AAPA;AACA;AACA;;AAOO,IAAMA,cAAc,GAAG,qBAAO,gBAAgB,CAAC;;AAEtD;AACA;AACA;AAFA;AAGA,IAAMC,UAAU,GAAGC,kBAAO,CAACC,MAAM,CAAC;EAChCC,SAAS,EAAE,YAAY;EAEvB;AACF;AACA;AACA;AACA;EACEC,sBAAsB,kCAACC,KAAK,EAAE;IAAA;IAC5B,IAAI,CAACC,MAAM,CAACC,IAAI,CAAC,mCAAmC,CAAC;IAErD,OAAO,iBAAQC,GAAG,CAChBH,KAAK,CAACI,UAAU,CAACC,WAAW,CAACC,GAAG,CAC9B,UAACC,UAAU;MAAA,OACT,qBAAY,UAACC,OAAO,EAAK;QACvB;QACA,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;UACzC,KAAI,CAACV,MAAM,CAACC,IAAI,CAAC,cAAc,EAAEK,UAAU,CAACK,IAAI,CAAC;QACnD;QAEAJ,OAAO,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CAACC,OAAO;QAAA;MAC7C,CAAC;IAAA,CAAC,CAAC;EACL,CAAC;EAED;AACF;AACA;AACA;EACEC,iBAAiB,6BAACC,OAAO,EAAE;IACzB,IAAI,CAACzC,MAAM,CAACC,IAAI,CAAC,6BAA6B,EAAEwC,OAAO,CAACrC,WAAW,CAACsC,MAAM,CAAC;IAE3E,OAAO,IAAI,CAACV,KAAK,CAACN,OAAO,CAAC;MACxBiB,MAAM,EAAE,MAAM;MACdC,OAAO,EAAE,YAAY;MACrBC,QAAQ,EAAE,eAAe;MACzBlC,IAAI,EAAE8B;IACR,CAAC,CAAC;EACJ,CAAC;EAED;AACF;AACA;AACA;EACEK,iBAAiB,+BAAG;IAClB,OAAO,iBAAQvC,OAAO,EAAE;EAC1B,CAAC;EAED;AACF;AACA;AACA;EACEwC,WAAW,uBAACjC,IAAI,EAAE;IAChB,OAAO,iBAAQP,OAAO,CAACO,IAAI,CAACkC,MAAM,IAAI,GAAG,CAAC;EAC5C,CAAC;EAED;AACF;AACA;AACA;EACEC,iBAAiB,6BAACnC,IAAI,EAAE;IACtB,OAAO,IAAI,CAACoC,sBAAsB,CAACpC,IAAI,CAAC,CAACE,IAAI,CAAC,UAACC,KAAK,EAAK;MACvDA,KAAK,CAACV,OAAO,CAACO,IAAI,CAACH,IAAI,CAAC;IAC1B,CAAC,CAAC;EACJ,CAAC;EAED;AACF;AACA;AACA;AACA;EACEa,iBAAiB,6BAACV,IAAI,EAAEqC,MAAM,EAAE;IAC9B,OAAO,IAAI,
|
|
1
|
+
{"version":3,"names":["TIMEOUT_SYMBOL","KmsBatcher","Batcher","extend","namespace","processKmsMessageEvent","event","logger","info","all","encryption","kmsMessages","map","kmsMessage","resolve","process","env","NODE_ENV","body","acceptItem","prepareItem","item","getDeferredForRequest","then","defer","timeout","Error","timer","safeSetTimeout","warn","requestId","handleItemFailure","KmsTimeoutError","request","promise","clearTimeout","catch","prepareRequest","queue","webex","internal","kms","_getKMSCluster","cluster","destination","req","wrapped","submitHttpRequest","payload","length","method","service","resource","handleHttpSuccess","didItemFail","status","handleItemSuccess","getDeferredForResponse","reason","handleKmsKeyRevokedEncryptionFailure","reject","KmsError","fingerprintRequest","fingerprintResponse"],"sources":["kms-batcher.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {safeSetTimeout} from '@webex/common-timers';\nimport {Batcher} from '@webex/webex-core';\n\nimport {KmsError, KmsTimeoutError, handleKmsKeyRevokedEncryptionFailure} from './kms-errors';\n\nexport const TIMEOUT_SYMBOL = Symbol('TIMEOUT_SYMBOL');\n\n/**\n * @class\n */\nconst KmsBatcher = Batcher.extend({\n namespace: 'Encryption',\n\n /**\n * Accepts a kmsMessage event and passes its contents to acceptItem\n * @param {Object} event\n * @returns {Promise}\n */\n processKmsMessageEvent(event) {\n this.logger.info('kms-batcher: received kms message');\n\n return Promise.all(\n event.encryption.kmsMessages.map(\n (kmsMessage) =>\n new Promise((resolve) => {\n /* istanbul ignore else */\n if (process.env.NODE_ENV !== 'production') {\n this.logger.info('kms-batcher:', kmsMessage.body);\n }\n\n resolve(this.acceptItem(kmsMessage));\n })\n )\n );\n },\n\n /**\n * Attaches a timeout to the given KMS message\n * @param {Object} item\n * @returns {Promise<Object>}\n */\n prepareItem(item) {\n return this.getDeferredForRequest(item).then((defer) => {\n const timeout = item[TIMEOUT_SYMBOL];\n\n /* istanbul ignore if */\n if (!timeout) {\n throw new Error('timeout is required');\n }\n\n const timer = safeSetTimeout(() => {\n this.logger.warn(\n `kms: request timed out; request id: ${item.requestId}; timeout: ${timeout}`\n );\n this.handleItemFailure(\n item,\n new KmsTimeoutError({\n timeout,\n request: item,\n })\n );\n }, timeout);\n\n // Reminder: reassign `promise` is not a viable means of inserting into\n // the Promise chain\n defer.promise.then(() => clearTimeout(timer));\n defer.promise.catch(() => clearTimeout(timer));\n\n return item;\n });\n },\n\n /**\n * Attaches the final bits of cluster info to the payload\n * @param {Array} queue\n * @returns {Promise<Array>}\n */\n prepareRequest(queue) {\n return this.webex.internal.encryption.kms._getKMSCluster().then((cluster) => ({\n destination: cluster,\n kmsMessages: queue.map((req) => req.wrapped),\n }));\n },\n\n /**\n * @param {Object} payload\n * @returns {Promise<HttpResponseObject>}\n */\n submitHttpRequest(payload) {\n this.logger.info('kms: batched-request-length', payload.kmsMessages.length);\n\n return this.webex.request({\n method: 'POST',\n service: 'encryption',\n resource: '/kms/messages',\n body: payload,\n });\n },\n\n /**\n * Does nothing; the http response doesn't carry our response data\n * @returns {Promise}\n */\n handleHttpSuccess() {\n return Promise.resolve();\n },\n\n /**\n * @param {Object} item\n * @returns {Promise<boolean>}\n */\n didItemFail(item) {\n return Promise.resolve(item.status >= 400);\n },\n\n /**\n * @param {Object} item\n * @returns {Promise}\n */\n handleItemSuccess(item) {\n return this.getDeferredForResponse(item).then((defer) => {\n defer.resolve(item.body);\n });\n },\n\n /**\n * @param {Object} item\n * @param {KmsError} [reason]\n * @returns {Promise}\n */\n handleItemFailure(item, reason) {\n handleKmsKeyRevokedEncryptionFailure(item, this.webex);\n\n return this.getDeferredForResponse(item).then((defer) => {\n defer.reject(reason || new KmsError(item.body));\n });\n },\n\n /**\n * @param {Object} item\n * @returns {Promise}\n */\n fingerprintRequest(item) {\n return Promise.resolve(item.requestId);\n },\n\n /**\n * @param {Object} item\n * @returns {Promise}\n */\n fingerprintResponse(item) {\n return Promise.resolve(item.requestId);\n },\n});\n\nexport default KmsBatcher;\n"],"mappings":";;;;;;;;;;AAIA;AACA;AAEA;AAPA;AACA;AACA;;AAOO,IAAMA,cAAc,GAAG,qBAAO,gBAAgB,CAAC;;AAEtD;AACA;AACA;AAFA;AAGA,IAAMC,UAAU,GAAGC,kBAAO,CAACC,MAAM,CAAC;EAChCC,SAAS,EAAE,YAAY;EAEvB;AACF;AACA;AACA;AACA;EACEC,sBAAsB,kCAACC,KAAK,EAAE;IAAA;IAC5B,IAAI,CAACC,MAAM,CAACC,IAAI,CAAC,mCAAmC,CAA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CAAoC,EAACtC,IAAI,EAAE,IAAI,CAACkB,KAAK,CAAC;IAEtD,OAAO,IAAI,CAACkB,sBAAsB,CAACpC,IAAI,CAAC,CAACE,IAAI,CAAC,UAACC,KAAK,EAAK;MACvDA,KAAK,CAACoC,MAAM,CAACF,MAAM,IAAI,IAAIG,mBAAQ,CAACxC,IAAI,CAACH,IAAI,CAAC,CAAC;IACjD,CAAC,CAAC;EACJ,CAAC;EAED;AACF;AACA;AACA;EACE4C,kBAAkB,8BAACzC,IAAI,EAAE;IACvB,OAAO,iBAAQP,OAAO,CAACO,IAAI,CAACS,SAAS,CAAC;EACxC,CAAC;EAED;AACF;AACA;AACA;EACEiC,mBAAmB,+BAAC1C,IAAI,EAAE;IACxB,OAAO,iBAAQP,OAAO,CAACO,IAAI,CAACS,SAAS,CAAC;EACxC;AACF,CAAC,CAAC;AAAC,eAEY7B,UAAU;AAAA"}
|
package/dist/kms-errors.js
CHANGED
|
@@ -6,7 +6,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequ
|
|
|
6
6
|
_Object$defineProperty(exports, "__esModule", {
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
|
-
exports.KmsTimeoutError = exports.KmsError = exports.DryError = void 0;
|
|
9
|
+
exports.handleKmsKeyRevokedEncryptionFailure = exports.KmsTimeoutError = exports.KmsError = exports.DryError = void 0;
|
|
10
10
|
var _defineProperties = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/define-properties"));
|
|
11
11
|
var _apply = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/reflect/apply"));
|
|
12
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
@@ -17,6 +17,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/he
|
|
|
17
17
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
18
18
|
var _common = require("@webex/common");
|
|
19
19
|
var _webexCore = require("@webex/webex-core");
|
|
20
|
+
var _constants = require("./constants");
|
|
20
21
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
21
22
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
22
23
|
/**
|
|
@@ -174,6 +175,16 @@ var DryError = /*#__PURE__*/function (_WebexHttpError) {
|
|
|
174
175
|
}]);
|
|
175
176
|
return DryError;
|
|
176
177
|
}(_webexCore.WebexHttpError);
|
|
178
|
+
/**
|
|
179
|
+
* Function triggers an event when specific encryption failures are received.
|
|
180
|
+
*/
|
|
181
|
+
// eslint-disable-next-line consistent-return
|
|
177
182
|
exports.DryError = DryError;
|
|
178
183
|
(0, _defineProperty2.default)(DryError, "defaultMessage", 'An unknown error was received from a service that proxies to the KMS');
|
|
184
|
+
var handleKmsKeyRevokedEncryptionFailure = function handleKmsKeyRevokedEncryptionFailure(item, webex) {
|
|
185
|
+
if (item.status === _constants.KMS_KEY_REVOKE_ERROR_STATUS && _constants.KMS_KEY_REVOKE_ERROR_CODES.includes(item.body.errorCode)) {
|
|
186
|
+
webex.internal.encryption.trigger(_constants.KMS_KEY_REVOKE_FAILURE);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
exports.handleKmsKeyRevokedEncryptionFailure = handleKmsKeyRevokedEncryptionFailure;
|
|
179
190
|
//# sourceMappingURL=kms-errors.js.map
|
package/dist/kms-errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["KmsError","body","enumerable","value","reason","requestId","status","message","constructor","defaultMessage","statusCode","errorCode","Exception","KmsTimeoutError","request","timeout","method","uri","DryError","WebexHttpError","prototype","parse","_res","options","url","service","toUpperCase","resource","headers","trackingid"],"sources":["kms-errors.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Exception} from '@webex/common';\nimport {WebexHttpError} from '@webex/webex-core';\n\n/**\n * Error class for KMS errors\n */\nexport class KmsError extends Exception {\n static defaultMessage =\n 'An unknown error occurred while communicating with the kms. This implies we received an error response without a body.';\n\n /**\n * @param {HttpResponse} body\n * @returns {string}\n */\n parse(body) {\n body = body.body || body;\n\n Object.defineProperties(this, {\n body: {\n enumerable: false,\n value: body,\n },\n reason: {\n enumerable: false,\n value: body.reason,\n },\n requestId: {\n enumerable: false,\n value: body.requestId,\n },\n status: {\n enumerable: false,\n value: body.status,\n },\n });\n\n let message = typeof body === 'string' ? body : body.reason;\n\n if (!message) {\n message = this.constructor.defaultMessage;\n }\n if (body.status) {\n message += `\\nKMS_RESPONSE_STATUS: ${body.status}`;\n }\n if (body.requestId) {\n message += `\\nKMS_REQUEST_ID: ${body.requestId}`;\n }\n\n if (body.statusCode) {\n message += `\\nKMS_STATUS_CODE: ${body.statusCode}`;\n }\n\n if (body.errorCode) {\n message += `\\nKMS_ErrorCode: ${body.errorCode}`;\n }\n\n return message;\n }\n}\n\n/**\n * Thrown when an expected KMSResponse is not received in a timely manner\n */\nexport class KmsTimeoutError extends KmsError {\n /**\n * @param {KmsRequest} options.request\n * @param {KmsRequest} options.timeout\n * @returns {string}\n */\n parse({request = {}, timeout} = {}) {\n let message = `The KMS did not respond within ${\n timeout ? `${timeout} milliseconds` : 'a timely fashion'\n }`;\n\n if (request) {\n if (request.method && request.uri) {\n message += `\\nKMS_REQUEST: ${request.method} ${request.uri}`;\n }\n\n if (request.requestId) {\n message += `\\nKMS_REQUEST_ID: ${request.requestId}`;\n }\n }\n\n return message;\n }\n}\n\n/**\n * Emitted when a REST request includes an encrypter error\n */\nexport class DryError extends WebexHttpError {\n static defaultMessage = 'An unknown error was received from a service that proxies to the KMS';\n\n /**\n * @param {WebexHttpError} reason\n * @returns {string}\n */\n parse(reason) {\n Reflect.apply(WebexHttpError.prototype.parse, this, [reason._res]);\n const body = reason._res.body.message;\n\n let message = body.reason || body;\n\n if (!message) {\n message = this.constructor.defaultMessage;\n }\n if (this.options.url) {\n message += `\\n${this.options.method} ${this.options.url}`;\n } else if (this.options.uri) {\n message += `\\n${this.options.method} ${this.options.uri}`;\n } else {\n message += `\\n${this.options.method} ${this.options.service.toUpperCase()}/${\n this.options.resource\n }`;\n }\n message += `\\nWEBEX_TRACKING_ID: ${this.options.headers.trackingid}`;\n\n if (body.status) {\n message += `\\nKMS_RESPONSE_STATUS: ${body.status}`;\n }\n if (body.requestId) {\n message += `\\nKMS_REQUEST_ID: ${body.requestId}`;\n }\n\n Object.defineProperties(this, {\n reason: {\n enumerable: false,\n value: body.reason,\n },\n requestId: {\n enumerable: false,\n value: body.requestId,\n },\n status: {\n enumerable: false,\n value: body.status,\n },\n });\n\n return message;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAIA;AACA;
|
|
1
|
+
{"version":3,"names":["KmsError","body","enumerable","value","reason","requestId","status","message","constructor","defaultMessage","statusCode","errorCode","Exception","KmsTimeoutError","request","timeout","method","uri","DryError","WebexHttpError","prototype","parse","_res","options","url","service","toUpperCase","resource","headers","trackingid","handleKmsKeyRevokedEncryptionFailure","item","webex","KMS_KEY_REVOKE_ERROR_STATUS","KMS_KEY_REVOKE_ERROR_CODES","includes","internal","encryption","trigger","KMS_KEY_REVOKE_FAILURE"],"sources":["kms-errors.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Exception} from '@webex/common';\nimport {WebexHttpError} from '@webex/webex-core';\n\nimport {\n KMS_KEY_REVOKE_ERROR_CODES,\n KMS_KEY_REVOKE_FAILURE,\n KMS_KEY_REVOKE_ERROR_STATUS,\n} from './constants';\n\n/**\n * Error class for KMS errors\n */\nexport class KmsError extends Exception {\n static defaultMessage =\n 'An unknown error occurred while communicating with the kms. This implies we received an error response without a body.';\n\n /**\n * @param {HttpResponse} body\n * @returns {string}\n */\n parse(body) {\n body = body.body || body;\n\n Object.defineProperties(this, {\n body: {\n enumerable: false,\n value: body,\n },\n reason: {\n enumerable: false,\n value: body.reason,\n },\n requestId: {\n enumerable: false,\n value: body.requestId,\n },\n status: {\n enumerable: false,\n value: body.status,\n },\n });\n\n let message = typeof body === 'string' ? body : body.reason;\n\n if (!message) {\n message = this.constructor.defaultMessage;\n }\n if (body.status) {\n message += `\\nKMS_RESPONSE_STATUS: ${body.status}`;\n }\n if (body.requestId) {\n message += `\\nKMS_REQUEST_ID: ${body.requestId}`;\n }\n\n if (body.statusCode) {\n message += `\\nKMS_STATUS_CODE: ${body.statusCode}`;\n }\n\n if (body.errorCode) {\n message += `\\nKMS_ErrorCode: ${body.errorCode}`;\n }\n\n return message;\n }\n}\n\n/**\n * Thrown when an expected KMSResponse is not received in a timely manner\n */\nexport class KmsTimeoutError extends KmsError {\n /**\n * @param {KmsRequest} options.request\n * @param {KmsRequest} options.timeout\n * @returns {string}\n */\n parse({request = {}, timeout} = {}) {\n let message = `The KMS did not respond within ${\n timeout ? `${timeout} milliseconds` : 'a timely fashion'\n }`;\n\n if (request) {\n if (request.method && request.uri) {\n message += `\\nKMS_REQUEST: ${request.method} ${request.uri}`;\n }\n\n if (request.requestId) {\n message += `\\nKMS_REQUEST_ID: ${request.requestId}`;\n }\n }\n\n return message;\n }\n}\n\n/**\n * Emitted when a REST request includes an encrypter error\n */\nexport class DryError extends WebexHttpError {\n static defaultMessage = 'An unknown error was received from a service that proxies to the KMS';\n\n /**\n * @param {WebexHttpError} reason\n * @returns {string}\n */\n parse(reason) {\n Reflect.apply(WebexHttpError.prototype.parse, this, [reason._res]);\n const body = reason._res.body.message;\n\n let message = body.reason || body;\n\n if (!message) {\n message = this.constructor.defaultMessage;\n }\n if (this.options.url) {\n message += `\\n${this.options.method} ${this.options.url}`;\n } else if (this.options.uri) {\n message += `\\n${this.options.method} ${this.options.uri}`;\n } else {\n message += `\\n${this.options.method} ${this.options.service.toUpperCase()}/${\n this.options.resource\n }`;\n }\n message += `\\nWEBEX_TRACKING_ID: ${this.options.headers.trackingid}`;\n\n if (body.status) {\n message += `\\nKMS_RESPONSE_STATUS: ${body.status}`;\n }\n if (body.requestId) {\n message += `\\nKMS_REQUEST_ID: ${body.requestId}`;\n }\n\n Object.defineProperties(this, {\n reason: {\n enumerable: false,\n value: body.reason,\n },\n requestId: {\n enumerable: false,\n value: body.requestId,\n },\n status: {\n enumerable: false,\n value: body.status,\n },\n });\n\n return message;\n }\n}\n\n/**\n * Function triggers an event when specific encryption failures are received.\n */\n\n// eslint-disable-next-line consistent-return\nexport const handleKmsKeyRevokedEncryptionFailure = (item, webex) => {\n if (\n item.status === KMS_KEY_REVOKE_ERROR_STATUS &&\n KMS_KEY_REVOKE_ERROR_CODES.includes(item.body.errorCode)\n ) {\n webex.internal.encryption.trigger(KMS_KEY_REVOKE_FAILURE);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAIA;AACA;AAEA;AAIqB;AAAA;AAErB;AACA;AACA;AAFA,IAGaA,QAAQ;EAAA;EAAA;EAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAInB;AACF;AACA;AACA;IACE,eAAMC,IAAI,EAAE;MACVA,IAAI,GAAGA,IAAI,CAACA,IAAI,IAAIA,IAAI;MAExB,+BAAwB,IAAI,EAAE;QAC5BA,IAAI,EAAE;UACJC,UAAU,EAAE,KAAK;UACjBC,KAAK,EAAEF;QACT,CAAC;QACDG,MAAM,EAAE;UACNF,UAAU,EAAE,KAAK;UACjBC,KAAK,EAAEF,IAAI,CAACG;QACd,CAAC;QACDC,SAAS,EAAE;UACTH,UAAU,EA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EAAE;QACfC,OAAO,qCAA8BN,IAAI,CAACK,MAAM,CAAE;MACpD;MACA,IAAIL,IAAI,CAACI,SAAS,EAAE;QAClBE,OAAO,gCAAyBN,IAAI,CAACI,SAAS,CAAE;MAClD;MAEA,+BAAwB,IAAI,EAAE;QAC5BD,MAAM,EAAE;UACNF,UAAU,EAAE,KAAK;UACjBC,KAAK,EAAEF,IAAI,CAACG;QACd,CAAC;QACDC,SAAS,EAAE;UACTH,UAAU,EAAE,KAAK;UACjBC,KAAK,EAAEF,IAAI,CAACI;QACd,CAAC;QACDC,MAAM,EAAE;UACNJ,UAAU,EAAE,KAAK;UACjBC,KAAK,EAAEF,IAAI,CAACK;QACd;MACF,CAAC,CAAC;MAEF,OAAOC,OAAO;IAChB;EAAC;EAAA;AAAA,EAlD2BY,yBAAc;AAqD5C;AACA;AACA;AAEA;AAAA;AAAA,8BAzDaD,QAAQ,oBACK,sEAAsE;AAyDzF,IAAMY,oCAAoC,GAAG,SAAvCA,oCAAoC,CAAIC,IAAI,EAAEC,KAAK,EAAK;EACnE,IACED,IAAI,CAACzB,MAAM,KAAK2B,sCAA2B,IAC3CC,qCAA0B,CAACC,QAAQ,CAACJ,IAAI,CAAC9B,IAAI,CAACU,SAAS,CAAC,EACxD;IACAqB,KAAK,CAACI,QAAQ,CAACC,UAAU,CAACC,OAAO,CAACC,iCAAsB,CAAC;EAC3D;AACF,CAAC;AAAC"}
|
package/dist/kms.js
CHANGED
|
@@ -802,7 +802,7 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
802
802
|
context.ephemeralKey = originalContext.ephemeralKey;
|
|
803
803
|
return context;
|
|
804
804
|
},
|
|
805
|
-
version: "3.0.0-beta.
|
|
805
|
+
version: "3.0.0-beta.218"
|
|
806
806
|
}, ((0, _applyDecoratedDescriptor2.default)(_obj, "fetchKey", [_dec], (0, _getOwnPropertyDescriptor.default)(_obj, "fetchKey"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "_getContext", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, "_getContext"), _obj)), _obj)));
|
|
807
807
|
var _default = KMS;
|
|
808
808
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/internal-plugin-encryption",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.218",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,22 +24,22 @@
|
|
|
24
24
|
]
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@webex/test-helper-chai": "3.0.0-beta.
|
|
28
|
-
"@webex/test-helper-make-local-url": "3.0.0-beta.
|
|
29
|
-
"@webex/test-helper-mocha": "3.0.0-beta.
|
|
30
|
-
"@webex/test-helper-mock-webex": "3.0.0-beta.
|
|
31
|
-
"@webex/test-helper-test-users": "3.0.0-beta.
|
|
27
|
+
"@webex/test-helper-chai": "3.0.0-beta.218",
|
|
28
|
+
"@webex/test-helper-make-local-url": "3.0.0-beta.218",
|
|
29
|
+
"@webex/test-helper-mocha": "3.0.0-beta.218",
|
|
30
|
+
"@webex/test-helper-mock-webex": "3.0.0-beta.218",
|
|
31
|
+
"@webex/test-helper-test-users": "3.0.0-beta.218",
|
|
32
32
|
"sinon": "^9.2.4"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@webex/common": "3.0.0-beta.
|
|
36
|
-
"@webex/common-timers": "3.0.0-beta.
|
|
37
|
-
"@webex/http-core": "3.0.0-beta.
|
|
38
|
-
"@webex/internal-plugin-device": "3.0.0-beta.
|
|
39
|
-
"@webex/internal-plugin-encryption": "3.0.0-beta.
|
|
40
|
-
"@webex/internal-plugin-mercury": "3.0.0-beta.
|
|
41
|
-
"@webex/test-helper-file": "3.0.0-beta.
|
|
42
|
-
"@webex/webex-core": "3.0.0-beta.
|
|
35
|
+
"@webex/common": "3.0.0-beta.218",
|
|
36
|
+
"@webex/common-timers": "3.0.0-beta.218",
|
|
37
|
+
"@webex/http-core": "3.0.0-beta.218",
|
|
38
|
+
"@webex/internal-plugin-device": "3.0.0-beta.218",
|
|
39
|
+
"@webex/internal-plugin-encryption": "3.0.0-beta.218",
|
|
40
|
+
"@webex/internal-plugin-mercury": "3.0.0-beta.218",
|
|
41
|
+
"@webex/test-helper-file": "3.0.0-beta.218",
|
|
42
|
+
"@webex/webex-core": "3.0.0-beta.218",
|
|
43
43
|
"asn1js": "^2.0.26",
|
|
44
44
|
"debug": "^4.3.4",
|
|
45
45
|
"isomorphic-webcrypto": "^2.3.8",
|
package/src/constants.js
ADDED
package/src/kms-batcher.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import {safeSetTimeout} from '@webex/common-timers';
|
|
6
6
|
import {Batcher} from '@webex/webex-core';
|
|
7
7
|
|
|
8
|
-
import {KmsError, KmsTimeoutError} from './kms-errors';
|
|
8
|
+
import {KmsError, KmsTimeoutError, handleKmsKeyRevokedEncryptionFailure} from './kms-errors';
|
|
9
9
|
|
|
10
10
|
export const TIMEOUT_SYMBOL = Symbol('TIMEOUT_SYMBOL');
|
|
11
11
|
|
|
@@ -133,6 +133,8 @@ const KmsBatcher = Batcher.extend({
|
|
|
133
133
|
* @returns {Promise}
|
|
134
134
|
*/
|
|
135
135
|
handleItemFailure(item, reason) {
|
|
136
|
+
handleKmsKeyRevokedEncryptionFailure(item, this.webex);
|
|
137
|
+
|
|
136
138
|
return this.getDeferredForResponse(item).then((defer) => {
|
|
137
139
|
defer.reject(reason || new KmsError(item.body));
|
|
138
140
|
});
|
package/src/kms-errors.js
CHANGED
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
import {Exception} from '@webex/common';
|
|
6
6
|
import {WebexHttpError} from '@webex/webex-core';
|
|
7
7
|
|
|
8
|
+
import {
|
|
9
|
+
KMS_KEY_REVOKE_ERROR_CODES,
|
|
10
|
+
KMS_KEY_REVOKE_FAILURE,
|
|
11
|
+
KMS_KEY_REVOKE_ERROR_STATUS,
|
|
12
|
+
} from './constants';
|
|
13
|
+
|
|
8
14
|
/**
|
|
9
15
|
* Error class for KMS errors
|
|
10
16
|
*/
|
|
@@ -145,3 +151,17 @@ export class DryError extends WebexHttpError {
|
|
|
145
151
|
return message;
|
|
146
152
|
}
|
|
147
153
|
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Function triggers an event when specific encryption failures are received.
|
|
157
|
+
*/
|
|
158
|
+
|
|
159
|
+
// eslint-disable-next-line consistent-return
|
|
160
|
+
export const handleKmsKeyRevokedEncryptionFailure = (item, webex) => {
|
|
161
|
+
if (
|
|
162
|
+
item.status === KMS_KEY_REVOKE_ERROR_STATUS &&
|
|
163
|
+
KMS_KEY_REVOKE_ERROR_CODES.includes(item.body.errorCode)
|
|
164
|
+
) {
|
|
165
|
+
webex.internal.encryption.trigger(KMS_KEY_REVOKE_FAILURE);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {assert} from '@webex/test-helper-chai';
|
|
2
|
+
import {handleKmsKeyRevokedEncryptionFailure} from '../../../src/kms-errors'
|
|
3
|
+
import sinon from 'sinon';
|
|
4
|
+
|
|
5
|
+
describe('handleKmsKeyRevokedEncryptionFailure', () => {
|
|
6
|
+
|
|
7
|
+
it('triggers `event:kms:key:revoke:encryption:failure` event when correct error code is detected', () => {
|
|
8
|
+
const webex = {
|
|
9
|
+
internal: {
|
|
10
|
+
encryption: {
|
|
11
|
+
trigger: sinon.spy()
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const item = {
|
|
17
|
+
status: 405,
|
|
18
|
+
body: {
|
|
19
|
+
errorCode: 405005,
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
handleKmsKeyRevokedEncryptionFailure(item, webex);
|
|
24
|
+
|
|
25
|
+
assert.calledOnce(webex.internal.encryption.trigger);
|
|
26
|
+
assert.calledWithExactly(webex.internal.encryption.trigger, `event:kms:key:revoke:encryption:failure`);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('does not trigger `event:kms:key:revoke:encryption:failure` event when correct status but wrong error code is detected', () => {
|
|
30
|
+
const webex = {
|
|
31
|
+
internal: {
|
|
32
|
+
encryption: {
|
|
33
|
+
trigger: sinon.spy()
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const item = {
|
|
39
|
+
status: 405,
|
|
40
|
+
body: {
|
|
41
|
+
errorCode: 405009,
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
handleKmsKeyRevokedEncryptionFailure(item, webex);
|
|
46
|
+
|
|
47
|
+
assert.notCalled(webex.internal.encryption.trigger);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('does not trigger `event:kms:key:revoke:encryption:failure` event when wrong status but correct error code is detected', () => {
|
|
51
|
+
const webex = {
|
|
52
|
+
internal: {
|
|
53
|
+
encryption: {
|
|
54
|
+
trigger: sinon.spy()
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const item = {
|
|
60
|
+
status: 403,
|
|
61
|
+
body: {
|
|
62
|
+
errorCode: 405005,
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
handleKmsKeyRevokedEncryptionFailure(item, webex);
|
|
67
|
+
|
|
68
|
+
assert.notCalled(webex.internal.encryption.trigger);
|
|
69
|
+
});
|
|
70
|
+
});
|