@webex/internal-plugin-encryption 2.29.2 → 2.29.5
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/encryption.js +3 -3
- package/dist/encryption.js.map +1 -1
- package/dist/kms-dry-error-interceptor.js +1 -1
- package/dist/kms-dry-error-interceptor.js.map +1 -1
- package/dist/kms.js +1 -1
- package/package.json +28 -20
- package/src/encryption.js +2 -2
- package/src/kms-dry-error-interceptor.js +1 -1
package/dist/encryption.js
CHANGED
|
@@ -101,7 +101,7 @@ var Encryption = _webexCore.WebexPlugin.extend({
|
|
|
101
101
|
* Validate and initiate a Download request for requested file
|
|
102
102
|
*
|
|
103
103
|
* @param {Object} scr - Plaintext
|
|
104
|
-
* @param {Object} options - optional
|
|
104
|
+
* @param {Object} options - optional parameters to download a file
|
|
105
105
|
* @returns {promise}
|
|
106
106
|
*/
|
|
107
107
|
download: function download(scr, options) {
|
|
@@ -137,7 +137,7 @@ var Encryption = _webexCore.WebexPlugin.extend({
|
|
|
137
137
|
* Fetch Download URL for the requested file
|
|
138
138
|
*
|
|
139
139
|
* @param {Object} scr - Plaintext
|
|
140
|
-
* @param {Object} options - optional
|
|
140
|
+
* @param {Object} options - optional parameters to download a file
|
|
141
141
|
* @returns {promise} url of the downloadable file
|
|
142
142
|
*/
|
|
143
143
|
_fetchDownloadUrl: function _fetchDownloadUrl(scr, options) {
|
|
@@ -273,7 +273,7 @@ var Encryption = _webexCore.WebexPlugin.extend({
|
|
|
273
273
|
}));
|
|
274
274
|
});
|
|
275
275
|
},
|
|
276
|
-
version: "2.29.
|
|
276
|
+
version: "2.29.5"
|
|
277
277
|
});
|
|
278
278
|
/**
|
|
279
279
|
* JSON.stringify replacer that ensures private key data is serialized.
|
package/dist/encryption.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Encryption","WebexPlugin","extend","children","kms","KMS","namespace","processKmsMessageEvent","event","decryptBinary","scr","buffer","ensureBuffer","then","b","length","byteLength","reject","Error","decrypt","decryptScr","key","cipherScr","options","getKey","k","SCR","fromJWE","jwk","decryptText","ciphertext","jose","JWE","createDecrypt","result","plaintext","toString","download","loc","shunt","EventEmitter","promise","_fetchDownloadUrl","uri","method","responseType","ret","request","transferEvents","res","body","proxyEvents","logger","info","process","env","NODE_ENV","includes","resolve","inputBody","endpoints","endpointUrl","url","parse","protocol","pathname","format","allow","params","warn","encryptBinary","file","create","encrypt","cdata","encryptScr","toJWE","encryptText","createEncrypt","config","joseOptions","header","alg","reference","final","onBehalfOf","asKey","storageKey","unboundedStorage","get","keyString","JSON","keyObject","catch","fetchKey","tap","put","replacer","v","json","toJSON"],"sources":["encryption.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {EventEmitter} from 'events';\nimport url from 'url';\n\nimport {WebexPlugin} from '@webex/webex-core';\nimport {proxyEvents, tap, transferEvents} from '@webex/common';\nimport jose from 'node-jose';\nimport SCR from 'node-scr';\n\nimport ensureBuffer from './ensure-buffer';\nimport KMS from './kms';\n\nconst Encryption = WebexPlugin.extend({\n children: {\n kms: KMS\n },\n\n namespace: 'Encryption',\n\n processKmsMessageEvent(event) {\n return this.kms.processKmsMessageEvent(event);\n },\n\n decryptBinary(scr, buffer) {\n return ensureBuffer(buffer)\n .then((b) => {\n /* istanbul ignore if */\n if (buffer.length === 0 || buffer.byteLength === 0) {\n return Promise.reject(new Error('Attempted to decrypt zero-length buffer'));\n }\n\n return scr.decrypt(b);\n });\n },\n\n /**\n * Decrypt a SCR (Secure Content Resource) using the supplied key uri.\n *\n * @param {string} key - The uri of a key stored in KMS\n * @param {Object} cipherScr - An encrypted SCR\n * @param {Object} options\n * @param {string} options.onBehalfOf - Fetch the KMS key on behalf of another user (using the user's UUID), active user requires the 'spark.kms_orgagent' role\n * @returns {Object} Decrypted SCR\n */\n decryptScr(key, cipherScr, options) {\n return this.getKey(key, options)\n .then((k) => SCR.fromJWE(k.jwk, cipherScr));\n },\n\n /**\n * Decrypt text using the supplied key uri.\n *\n * @param {string} key - The uri of a key stored in KMS\n * @param {string} ciphertext - Encrypted text\n * @param {Object} options\n * @param {string} options.onBehalfOf - Fetch the KMS key on behalf of another user (using the user's UUID), active user requires the 'spark.kms_orgagent' role\n * @returns {string} Decrypted plaintext\n */\n decryptText(key, ciphertext, options) {\n return this.getKey(key, options)\n .then((k) => jose.JWE\n .createDecrypt(k.jwk)\n .decrypt(ciphertext)\n .then((result) => result.plaintext.toString()));\n },\n\n /**\n * Validate and initiate a Download request for requested file\n *\n * @param {Object} scr - Plaintext\n * @param {Object} options - optional paramaters to download a file\n * @returns {promise}\n */\n download(scr, options) {\n /* istanbul ignore if */\n if (!scr.loc) {\n return Promise.reject(new Error('`scr.loc` is required'));\n }\n\n const shunt = new EventEmitter();\n const promise = this._fetchDownloadUrl(scr, options)\n .then((uri) => {\n const options = {\n method: 'GET',\n uri,\n responseType: 'buffer'\n };\n\n const ret = this.request(options);\n\n transferEvents('progress', options.download, shunt);\n\n return ret;\n })\n .then((res) => this.decryptBinary(scr, res.body));\n\n proxyEvents(shunt, promise);\n\n return promise;\n },\n\n /**\n * Fetch Download URL for the requested file\n *\n * @param {Object} scr - Plaintext\n * @param {Object} options - optional paramaters to download a file\n * @returns {promise} url of the downloadable file\n */\n _fetchDownloadUrl(scr, options) {\n this.logger.info('encryption: retrieving download url for encrypted file');\n\n if (process.env.NODE_ENV !== 'production' && scr.loc.includes('localhost')) {\n this.logger.info('encryption: bypassing webex files because this looks to be a test file on localhost');\n\n return Promise.resolve(scr.loc);\n }\n\n const inputBody = {\n endpoints: [scr.loc]\n };\n const endpointUrl = url.parse(scr.loc);\n\n // hardcode the url to use 'https' and the file service '/v1/download/endpoints' api\n endpointUrl.protocol = 'https';\n endpointUrl.pathname = '/v1/download/endpoints';\n\n return this.request({\n method: 'POST',\n uri: url.format(endpointUrl),\n body: options ? {\n ...inputBody,\n allow: options.params.allow\n } : inputBody\n })\n .then((res) => {\n const url = res.body.endpoints[scr.loc];\n\n if (!url) {\n this.logger.warn('encryption: could not determine download url for `scr.loc`; attempting to download `scr.loc` directly');\n\n return scr.loc;\n }\n this.logger.info('encryption: retrieved download url for encrypted file');\n\n return url;\n });\n },\n\n encryptBinary(file) {\n return ensureBuffer(file)\n .then((buffer) => SCR.create()\n .then((scr) => scr.encrypt(buffer)\n .then(ensureBuffer)\n // eslint-disable-next-line max-nested-callbacks\n .then((cdata) => ({scr, cdata}))));\n },\n\n /**\n * Encrypt a SCR (Secure Content Resource) using the supplied key uri.\n *\n * @param {string} key - The uri of a key stored in KMS\n * @param {Object} scr - Plaintext\n * @param {Object} options\n * @param {string} options.onBehalfOf - Fetch the KMS key on behalf of another user (using the user's UUID), active user requires the 'spark.kms_orgagent' role\n * @returns {string} Encrypted SCR\n */\n encryptScr(key, scr, options) {\n /* istanbul ignore if */\n if (!scr.loc) {\n return Promise.reject(new Error('Cannot encrypt `scr` without first setting `loc`'));\n }\n\n return this.getKey(key, options)\n .then((k) => scr.toJWE(k.jwk));\n },\n\n /**\n * Encrypt plaintext using the supplied key uri.\n *\n * @param {string} key - The uri of a key stored in KMS\n * @param {string} plaintext\n * @param {Object} options\n * @param {string} options.onBehalfOf - Fetch the KMS key on behalf of another user (using the user's UUID), active user requires the 'spark.kms_orgagent' role\n * @returns {string} Encrypted text\n */\n encryptText(key, plaintext, options) {\n return this.getKey(key, options)\n .then((k) => jose.JWE\n .createEncrypt(this.config.joseOptions, {\n key: k.jwk,\n header: {\n alg: 'dir'\n },\n reference: null\n })\n .final(plaintext, 'utf8'));\n },\n\n /**\n * Fetch the key associated with the supplied KMS uri.\n *\n * @param {string} uri - The uri of a key stored in KMS\n * @param {Object} options\n * @param {string} options.onBehalfOf - Fetch the KMS key on behalf of another user (using the user's UUID), active user requires the 'spark.kms_orgagent' role\n * @returns {string} Key\n */\n getKey(uri, {onBehalfOf} = {}) {\n if (uri.jwk) {\n return this.kms.asKey(uri);\n }\n\n let storageKey = uri;\n\n if (onBehalfOf) {\n storageKey += `/onBehalfOf/${onBehalfOf}`;\n }\n\n return this.unboundedStorage.get(storageKey)\n .then((keyString) => JSON.parse(keyString))\n .then((keyObject) => this.kms.asKey(keyObject))\n .catch(() => this.kms.fetchKey({uri, onBehalfOf})\n .then(tap((key) => this.unboundedStorage.put(storageKey, JSON.stringify(key, replacer)))));\n }\n});\n\n/**\n * JSON.stringify replacer that ensures private key data is serialized.\n * @param {string} k\n * @param {mixed} v\n * @returns {mixed}\n */\nfunction replacer(k, v) {\n if (k === 'jwk') {\n // note: this[k] and v may be different representations of the same value\n // eslint-disable-next-line no-invalid-this\n const json = this[k].toJSON(true);\n\n return json;\n }\n\n return v;\n}\n\nexport default Encryption;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;AAEA,IAAMA,UAAU,GAAGC,sBAAA,CAAYC,MAAZ,CAAmB;EACpCC,QAAQ,EAAE;IACRC,GAAG,EAAEC;EADG,CAD0B;EAKpCC,SAAS,EAAE,YALyB;EAOpCC,sBAPoC,kCAObC,KAPa,EAON;IAC5B,OAAO,KAAKJ,GAAL,CAASG,sBAAT,CAAgCC,KAAhC,CAAP;EACD,CATmC;EAWpCC,aAXoC,yBAWtBC,GAXsB,EAWjBC,MAXiB,EAWT;IACzB,OAAO,IAAAC,qBAAA,EAAaD,MAAb,EACJE,IADI,CACC,UAACC,CAAD,EAAO;MACX;MACA,IAAIH,MAAM,CAACI,MAAP,KAAkB,CAAlB,IAAuBJ,MAAM,CAACK,UAAP,KAAsB,CAAjD,EAAoD;QAClD,OAAO,iBAAQC,MAAR,CAAe,IAAIC,KAAJ,CAAU,yCAAV,CAAf,CAAP;MACD;;MAED,OAAOR,GAAG,CAACS,OAAJ,CAAYL,CAAZ,CAAP;IACD,CARI,CAAP;EASD,CArBmC;;EAuBpC;AACF;AACA;AACA;AACA;AACA;AACA;AAC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AAM,MAAI,CAACzF,GAAL,CAAS0F,QAAT,CAAkB;QAACnD,GAAG,EAAHA,GAAD;QAAM0C,UAAU,EAAVA;MAAN,CAAlB,EACVxE,IADU,CACL,IAAAkF,WAAA,EAAI,UAAC1E,GAAD;QAAA,OAAS,MAAI,CAACmE,gBAAL,CAAsBQ,GAAtB,CAA0BT,UAA1B,EAAsC,wBAAelE,GAAf,EAAoB4E,QAApB,CAAtC,CAAT;MAAA,CAAJ,CADK,CAAN;IAAA,CAHF,CAAP;EAKD,CAlNmC;EAAA;AAAA,CAAnB,CAAnB;AAqNA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASA,QAAT,CAAkBxE,CAAlB,EAAqByE,CAArB,EAAwB;EACtB,IAAIzE,CAAC,KAAK,KAAV,EAAiB;IACf;IACA;IACA,IAAM0E,IAAI,GAAG,KAAK1E,CAAL,EAAQ2E,MAAR,CAAe,IAAf,CAAb;IAEA,OAAOD,IAAP;EACD;;EAED,OAAOD,CAAP;AACD;;eAEclG,U"}
|
|
1
|
+
{"version":3,"names":["Encryption","WebexPlugin","extend","children","kms","KMS","namespace","processKmsMessageEvent","event","decryptBinary","scr","buffer","ensureBuffer","then","b","length","byteLength","reject","Error","decrypt","decryptScr","key","cipherScr","options","getKey","k","SCR","fromJWE","jwk","decryptText","ciphertext","jose","JWE","createDecrypt","result","plaintext","toString","download","loc","shunt","EventEmitter","promise","_fetchDownloadUrl","uri","method","responseType","ret","request","transferEvents","res","body","proxyEvents","logger","info","process","env","NODE_ENV","includes","resolve","inputBody","endpoints","endpointUrl","url","parse","protocol","pathname","format","allow","params","warn","encryptBinary","file","create","encrypt","cdata","encryptScr","toJWE","encryptText","createEncrypt","config","joseOptions","header","alg","reference","final","onBehalfOf","asKey","storageKey","unboundedStorage","get","keyString","JSON","keyObject","catch","fetchKey","tap","put","replacer","v","json","toJSON"],"sources":["encryption.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {EventEmitter} from 'events';\nimport url from 'url';\n\nimport {WebexPlugin} from '@webex/webex-core';\nimport {proxyEvents, tap, transferEvents} from '@webex/common';\nimport jose from 'node-jose';\nimport SCR from 'node-scr';\n\nimport ensureBuffer from './ensure-buffer';\nimport KMS from './kms';\n\nconst Encryption = WebexPlugin.extend({\n children: {\n kms: KMS\n },\n\n namespace: 'Encryption',\n\n processKmsMessageEvent(event) {\n return this.kms.processKmsMessageEvent(event);\n },\n\n decryptBinary(scr, buffer) {\n return ensureBuffer(buffer)\n .then((b) => {\n /* istanbul ignore if */\n if (buffer.length === 0 || buffer.byteLength === 0) {\n return Promise.reject(new Error('Attempted to decrypt zero-length buffer'));\n }\n\n return scr.decrypt(b);\n });\n },\n\n /**\n * Decrypt a SCR (Secure Content Resource) using the supplied key uri.\n *\n * @param {string} key - The uri of a key stored in KMS\n * @param {Object} cipherScr - An encrypted SCR\n * @param {Object} options\n * @param {string} options.onBehalfOf - Fetch the KMS key on behalf of another user (using the user's UUID), active user requires the 'spark.kms_orgagent' role\n * @returns {Object} Decrypted SCR\n */\n decryptScr(key, cipherScr, options) {\n return this.getKey(key, options)\n .then((k) => SCR.fromJWE(k.jwk, cipherScr));\n },\n\n /**\n * Decrypt text using the supplied key uri.\n *\n * @param {string} key - The uri of a key stored in KMS\n * @param {string} ciphertext - Encrypted text\n * @param {Object} options\n * @param {string} options.onBehalfOf - Fetch the KMS key on behalf of another user (using the user's UUID), active user requires the 'spark.kms_orgagent' role\n * @returns {string} Decrypted plaintext\n */\n decryptText(key, ciphertext, options) {\n return this.getKey(key, options)\n .then((k) => jose.JWE\n .createDecrypt(k.jwk)\n .decrypt(ciphertext)\n .then((result) => result.plaintext.toString()));\n },\n\n /**\n * Validate and initiate a Download request for requested file\n *\n * @param {Object} scr - Plaintext\n * @param {Object} options - optional parameters to download a file\n * @returns {promise}\n */\n download(scr, options) {\n /* istanbul ignore if */\n if (!scr.loc) {\n return Promise.reject(new Error('`scr.loc` is required'));\n }\n\n const shunt = new EventEmitter();\n const promise = this._fetchDownloadUrl(scr, options)\n .then((uri) => {\n const options = {\n method: 'GET',\n uri,\n responseType: 'buffer'\n };\n\n const ret = this.request(options);\n\n transferEvents('progress', options.download, shunt);\n\n return ret;\n })\n .then((res) => this.decryptBinary(scr, res.body));\n\n proxyEvents(shunt, promise);\n\n return promise;\n },\n\n /**\n * Fetch Download URL for the requested file\n *\n * @param {Object} scr - Plaintext\n * @param {Object} options - optional parameters to download a file\n * @returns {promise} url of the downloadable file\n */\n _fetchDownloadUrl(scr, options) {\n this.logger.info('encryption: retrieving download url for encrypted file');\n\n if (process.env.NODE_ENV !== 'production' && scr.loc.includes('localhost')) {\n this.logger.info('encryption: bypassing webex files because this looks to be a test file on localhost');\n\n return Promise.resolve(scr.loc);\n }\n\n const inputBody = {\n endpoints: [scr.loc]\n };\n const endpointUrl = url.parse(scr.loc);\n\n // hardcode the url to use 'https' and the file service '/v1/download/endpoints' api\n endpointUrl.protocol = 'https';\n endpointUrl.pathname = '/v1/download/endpoints';\n\n return this.request({\n method: 'POST',\n uri: url.format(endpointUrl),\n body: options ? {\n ...inputBody,\n allow: options.params.allow\n } : inputBody\n })\n .then((res) => {\n const url = res.body.endpoints[scr.loc];\n\n if (!url) {\n this.logger.warn('encryption: could not determine download url for `scr.loc`; attempting to download `scr.loc` directly');\n\n return scr.loc;\n }\n this.logger.info('encryption: retrieved download url for encrypted file');\n\n return url;\n });\n },\n\n encryptBinary(file) {\n return ensureBuffer(file)\n .then((buffer) => SCR.create()\n .then((scr) => scr.encrypt(buffer)\n .then(ensureBuffer)\n // eslint-disable-next-line max-nested-callbacks\n .then((cdata) => ({scr, cdata}))));\n },\n\n /**\n * Encrypt a SCR (Secure Content Resource) using the supplied key uri.\n *\n * @param {string} key - The uri of a key stored in KMS\n * @param {Object} scr - Plaintext\n * @param {Object} options\n * @param {string} options.onBehalfOf - Fetch the KMS key on behalf of another user (using the user's UUID), active user requires the 'spark.kms_orgagent' role\n * @returns {string} Encrypted SCR\n */\n encryptScr(key, scr, options) {\n /* istanbul ignore if */\n if (!scr.loc) {\n return Promise.reject(new Error('Cannot encrypt `scr` without first setting `loc`'));\n }\n\n return this.getKey(key, options)\n .then((k) => scr.toJWE(k.jwk));\n },\n\n /**\n * Encrypt plaintext using the supplied key uri.\n *\n * @param {string} key - The uri of a key stored in KMS\n * @param {string} plaintext\n * @param {Object} options\n * @param {string} options.onBehalfOf - Fetch the KMS key on behalf of another user (using the user's UUID), active user requires the 'spark.kms_orgagent' role\n * @returns {string} Encrypted text\n */\n encryptText(key, plaintext, options) {\n return this.getKey(key, options)\n .then((k) => jose.JWE\n .createEncrypt(this.config.joseOptions, {\n key: k.jwk,\n header: {\n alg: 'dir'\n },\n reference: null\n })\n .final(plaintext, 'utf8'));\n },\n\n /**\n * Fetch the key associated with the supplied KMS uri.\n *\n * @param {string} uri - The uri of a key stored in KMS\n * @param {Object} options\n * @param {string} options.onBehalfOf - Fetch the KMS key on behalf of another user (using the user's UUID), active user requires the 'spark.kms_orgagent' role\n * @returns {string} Key\n */\n getKey(uri, {onBehalfOf} = {}) {\n if (uri.jwk) {\n return this.kms.asKey(uri);\n }\n\n let storageKey = uri;\n\n if (onBehalfOf) {\n storageKey += `/onBehalfOf/${onBehalfOf}`;\n }\n\n return this.unboundedStorage.get(storageKey)\n .then((keyString) => JSON.parse(keyString))\n .then((keyObject) => this.kms.asKey(keyObject))\n .catch(() => this.kms.fetchKey({uri, onBehalfOf})\n .then(tap((key) => this.unboundedStorage.put(storageKey, JSON.stringify(key, replacer)))));\n }\n});\n\n/**\n * JSON.stringify replacer that ensures private key data is serialized.\n * @param {string} k\n * @param {mixed} v\n * @returns {mixed}\n */\nfunction replacer(k, v) {\n if (k === 'jwk') {\n // note: this[k] and v may be different representations of the same value\n // eslint-disable-next-line no-invalid-this\n const json = this[k].toJSON(true);\n\n return json;\n }\n\n return v;\n}\n\nexport default Encryption;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA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AI,GAAG,KAAK1E,CAAL,EAAQ2E,MAAR,CAAe,IAAf,CAAb;IAEA,OAAOD,IAAP;EACD;;EAED,OAAOD,CAAP;AACD;;eAEclG,U"}
|
|
@@ -34,7 +34,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_R
|
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Interceptor (only to be used in test mode) intended to replay requests that
|
|
37
|
-
* fail as a result of the test-user
|
|
37
|
+
* fail as a result of the test-user incompatibility in KMS.
|
|
38
38
|
* @class
|
|
39
39
|
*/
|
|
40
40
|
var KmsDryErrorInterceptor = /*#__PURE__*/function (_Interceptor) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["KmsDryErrorInterceptor","options","reason","DryError","message","match","webex","logger","error","replay","reject","replayCount","config","maxAuthenticationReplays","info","request","Interceptor"],"sources":["kms-dry-error-interceptor.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\n\nimport {DryError} from './kms-errors';\n/**\n * Interceptor (only to be used in test mode) intended to replay requests that\n * fail as a result of the test-user
|
|
1
|
+
{"version":3,"names":["KmsDryErrorInterceptor","options","reason","DryError","message","match","webex","logger","error","replay","reject","replayCount","config","maxAuthenticationReplays","info","request","Interceptor"],"sources":["kms-dry-error-interceptor.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Interceptor} from '@webex/http-core';\n\nimport {DryError} from './kms-errors';\n/**\n * Interceptor (only to be used in test mode) intended to replay requests that\n * fail as a result of the test-user incompatibility in KMS.\n * @class\n */\nexport default class KmsDryErrorInterceptor extends Interceptor {\n /**\n * @returns {KmsDryErrorInterceptor}\n */\n static create() {\n return new KmsDryErrorInterceptor({webex: this});\n }\n\n /**\n * @param {Object} options\n * @param {Exception} reason\n * @returns {Promise}\n */\n onResponseError(options, reason) {\n if (reason instanceof DryError && reason.message.match(/Failed to resolve authorization token in KmsMessage request for user/)) {\n this.webex.logger.error('DRY Request Failed due to kms/test-user flakiness');\n this.webex.logger.error(reason);\n\n return this.replay(options, reason);\n }\n\n return Promise.reject(reason);\n }\n\n /**\n * Replays the request\n * @param {Object} options\n * @param {DryError} reason\n * @returns {Object}\n */\n replay(options, reason) {\n if (options.replayCount) {\n options.replayCount += 1;\n }\n else {\n options.replayCount = 1;\n }\n\n if (options.replayCount > this.webex.config.maxAuthenticationReplays) {\n this.webex.logger.error(`kms: failed after ${this.webex.config.maxAuthenticationReplays} replay attempts`);\n\n return Promise.reject(reason);\n }\n\n this.webex.logger.info(`kms: replaying request ${options.replayCount} time`);\n\n return this.webex.request(options);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;AAEA;;;;;;AACA;AACA;AACA;AACA;AACA;IACqBA,sB;;;;;;;;;;;;;IAQnB;AACF;AACA;AACA;AACA;IACE,yBAAgBC,OAAhB,EAAyBC,MAAzB,EAAiC;MAC/B,IAAIA,MAAM,YAAYC,mBAAlB,IAA8BD,MAAM,CAACE,OAAP,CAAeC,KAAf,CAAqB,sEAArB,CAAlC,EAAgI;QAC9H,KAAKC,KAAL,CAAWC,MAAX,CAAkBC,KAAlB,CAAwB,mDAAxB;QACA,KAAKF,KAAL,CAAWC,MAAX,CAAkBC,KAAlB,CAAwBN,MAAxB;QAEA,OAAO,KAAKO,MAAL,CAAYR,OAAZ,EAAqBC,MAArB,CAAP;MACD;;MAED,OAAO,iBAAQQ,MAAR,CAAeR,MAAf,CAAP;IACD;IAED;AACF;AACA;AACA;AACA;AACA;;;;WACE,gBAAOD,OAAP,EAAgBC,MAAhB,EAAwB;MACtB,IAAID,OAAO,CAACU,WAAZ,EAAyB;QACvBV,OAAO,CAACU,WAAR,IAAuB,CAAvB;MACD,CAFD,MAGK;QACHV,OAAO,CAACU,WAAR,GAAsB,CAAtB;MACD;;MAED,IAAIV,OAAO,CAACU,WAAR,GAAsB,KAAKL,KAAL,CAAWM,MAAX,CAAkBC,wBAA5C,EAAsE;QACpE,KAAKP,KAAL,CAAWC,MAAX,CAAkBC,KAAlB,6BAA6C,KAAKF,KAAL,CAAWM,MAAX,CAAkBC,wBAA/D;QAEA,OAAO,iBAAQH,MAAR,CAAeR,MAAf,CAAP;MACD;;MAED,KAAKI,KAAL,CAAWC,MAAX,CAAkBO,IAAlB,kCAAiDb,OAAO,CAACU,WAAzD;MAEA,OAAO,KAAKL,KAAL,CAAWS,OAAX,CAAmBd,OAAnB,CAAP;IACD;;;;IA9CD;AACF;AACA;IACE,kBAAgB;MACd,OAAO,IAAID,sBAAJ,CAA2B;QAACM,KAAK,EAAE;MAAR,CAA3B,CAAP;IACD;;;EANiDU,qB"}
|
package/dist/kms.js
CHANGED
|
@@ -931,7 +931,7 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
931
931
|
context.ephemeralKey = originalContext.ephemeralKey;
|
|
932
932
|
return context;
|
|
933
933
|
},
|
|
934
|
-
version: "2.29.
|
|
934
|
+
version: "2.29.5"
|
|
935
935
|
}, ((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)));
|
|
936
936
|
|
|
937
937
|
var _default = KMS;
|
package/package.json
CHANGED
|
@@ -1,43 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/internal-plugin-encryption",
|
|
3
|
-
"version": "2.29.
|
|
3
|
+
"version": "2.29.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"author": "Ian W. Remmel <iremmel@cisco.com>",
|
|
7
6
|
"main": "dist/index.js",
|
|
8
7
|
"devMain": "src/index.js",
|
|
9
|
-
"repository": "https://github.com/webex/webex-js-sdk/tree/master/packages
|
|
8
|
+
"repository": "https://github.com/webex/webex-js-sdk/tree/master/packages/@webex/internal-plugin-encryption",
|
|
10
9
|
"engines": {
|
|
11
|
-
"node": ">=
|
|
10
|
+
"node": ">=14"
|
|
12
11
|
},
|
|
13
12
|
"browser": {
|
|
14
|
-
"./
|
|
15
|
-
"./
|
|
13
|
+
"./dist/ensure-buffer.js": "./dist/ensure-buffer.browser.js",
|
|
14
|
+
"./src/ensure-buffer.js": "./src/ensure-buffer.browser.js"
|
|
16
15
|
},
|
|
17
16
|
"browserify": {
|
|
18
17
|
"transform": [
|
|
18
|
+
"babelify",
|
|
19
19
|
"envify"
|
|
20
20
|
]
|
|
21
21
|
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@webex/test-helper-chai": "workspace:^",
|
|
24
|
+
"@webex/test-helper-make-local-url": "workspace:^",
|
|
25
|
+
"@webex/test-helper-mocha": "workspace:^",
|
|
26
|
+
"@webex/test-helper-mock-webex": "workspace:^",
|
|
27
|
+
"@webex/test-helper-test-users": "workspace:^",
|
|
28
|
+
"sinon": "^9.2.4"
|
|
29
|
+
},
|
|
22
30
|
"dependencies": {
|
|
23
|
-
"@
|
|
31
|
+
"@webex/common": "workspace:^",
|
|
32
|
+
"@webex/common-timers": "workspace:^",
|
|
33
|
+
"@webex/http-core": "workspace:^",
|
|
34
|
+
"@webex/internal-plugin-device": "workspace:^",
|
|
35
|
+
"@webex/internal-plugin-encryption": "workspace:^",
|
|
36
|
+
"@webex/internal-plugin-mercury": "workspace:^",
|
|
37
|
+
"@webex/test-helper-file": "workspace:^",
|
|
38
|
+
"@webex/webex-core": "workspace:^",
|
|
39
|
+
"asn1js": "^2.0.26",
|
|
40
|
+
"debug": "^4.3.4",
|
|
41
|
+
"isomorphic-webcrypto": "^2.3.8",
|
|
24
42
|
"lodash": "^4.17.21",
|
|
25
|
-
"@webex/webex-core": "2.29.2",
|
|
26
|
-
"@webex/common": "2.29.2",
|
|
27
43
|
"node-jose": "^2.0.0",
|
|
28
|
-
"node-scr": "^0.3.0",
|
|
29
|
-
"@webex/common-timers": "2.29.2",
|
|
30
44
|
"node-kms": "^0.4.0",
|
|
31
|
-
"
|
|
32
|
-
"valid-url": "^1.0.9",
|
|
33
|
-
"asn1js": "^2.0.26",
|
|
45
|
+
"node-scr": "^0.3.0",
|
|
34
46
|
"pkijs": "^2.1.84",
|
|
35
|
-
"isomorphic-webcrypto": "^2.3.8",
|
|
36
47
|
"safe-buffer": "^5.2.0",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"@webex/internal-plugin-mercury": "2.29.2",
|
|
40
|
-
"@webex/http-core": "2.29.2",
|
|
41
|
-
"envify": "^4.1.0"
|
|
48
|
+
"uuid": "^3.3.2",
|
|
49
|
+
"valid-url": "^1.0.9"
|
|
42
50
|
}
|
|
43
51
|
}
|
package/src/encryption.js
CHANGED
|
@@ -71,7 +71,7 @@ const Encryption = WebexPlugin.extend({
|
|
|
71
71
|
* Validate and initiate a Download request for requested file
|
|
72
72
|
*
|
|
73
73
|
* @param {Object} scr - Plaintext
|
|
74
|
-
* @param {Object} options - optional
|
|
74
|
+
* @param {Object} options - optional parameters to download a file
|
|
75
75
|
* @returns {promise}
|
|
76
76
|
*/
|
|
77
77
|
download(scr, options) {
|
|
@@ -106,7 +106,7 @@ const Encryption = WebexPlugin.extend({
|
|
|
106
106
|
* Fetch Download URL for the requested file
|
|
107
107
|
*
|
|
108
108
|
* @param {Object} scr - Plaintext
|
|
109
|
-
* @param {Object} options - optional
|
|
109
|
+
* @param {Object} options - optional parameters to download a file
|
|
110
110
|
* @returns {promise} url of the downloadable file
|
|
111
111
|
*/
|
|
112
112
|
_fetchDownloadUrl(scr, options) {
|
|
@@ -7,7 +7,7 @@ import {Interceptor} from '@webex/http-core';
|
|
|
7
7
|
import {DryError} from './kms-errors';
|
|
8
8
|
/**
|
|
9
9
|
* Interceptor (only to be used in test mode) intended to replay requests that
|
|
10
|
-
* fail as a result of the test-user
|
|
10
|
+
* fail as a result of the test-user incompatibility in KMS.
|
|
11
11
|
* @class
|
|
12
12
|
*/
|
|
13
13
|
export default class KmsDryErrorInterceptor extends Interceptor {
|