@webex/internal-plugin-encryption 3.0.0-beta.9 → 3.0.0-bnr.0
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 +1 -3
- package/dist/config.js +0 -9
- package/dist/config.js.map +1 -1
- package/dist/encryption.js +9 -60
- package/dist/encryption.js.map +1 -1
- package/dist/ensure-buffer.browser.js +0 -12
- package/dist/ensure-buffer.browser.js.map +1 -1
- package/dist/ensure-buffer.js +5 -12
- package/dist/ensure-buffer.js.map +1 -1
- package/dist/index.js +7 -33
- package/dist/index.js.map +1 -1
- package/dist/kms-batcher.js +6 -30
- package/dist/kms-batcher.js.map +1 -1
- package/dist/kms-certificate-validation.js +20 -88
- package/dist/kms-certificate-validation.js.map +1 -1
- package/dist/kms-dry-error-interceptor.js +1 -23
- package/dist/kms-dry-error-interceptor.js.map +1 -1
- package/dist/kms-errors.js +3 -50
- package/dist/kms-errors.js.map +1 -1
- package/dist/kms.js +74 -213
- package/dist/kms.js.map +1 -1
- package/dist/types/config.d.ts +16 -0
- package/dist/types/encryption.d.ts +2 -0
- package/dist/types/ensure-buffer.browser.d.ts +10 -0
- package/dist/types/ensure-buffer.d.ts +7 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/kms-batcher.d.ts +6 -0
- package/dist/types/kms-certificate-validation.d.ts +24 -0
- package/dist/types/kms-dry-error-interceptor.d.ts +25 -0
- package/dist/types/kms-errors.d.ts +33 -0
- package/dist/types/kms.d.ts +5 -0
- package/package.json +15 -15
- package/src/config.js +3 -3
- package/src/encryption.js +66 -56
- package/src/ensure-buffer.browser.js +0 -1
- package/src/ensure-buffer.js +5 -5
- package/src/index.js +120 -96
- package/src/kms-batcher.js +50 -44
- package/src/kms-certificate-validation.js +45 -47
- package/src/kms-dry-error-interceptor.js +8 -4
- package/src/kms-errors.js +19 -16
- package/src/kms.js +210 -206
- package/test/integration/spec/encryption.js +311 -230
- package/test/integration/spec/kms.js +532 -404
- package/test/integration/spec/payload-transfom.js +69 -69
- package/test/unit/spec/encryption.js +16 -13
- package/test/unit/spec/kms-certificate-validation.js +41 -32
package/dist/kms.js
CHANGED
|
@@ -1,77 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
|
|
4
|
-
|
|
5
4
|
var _WeakMap2 = require("@babel/runtime-corejs2/core-js/weak-map");
|
|
6
|
-
|
|
7
5
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
8
|
-
|
|
9
6
|
var _Object$getOwnPropertyDescriptor2 = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
10
|
-
|
|
11
7
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
12
|
-
|
|
13
8
|
_Object$defineProperty(exports, "__esModule", {
|
|
14
9
|
value: true
|
|
15
10
|
});
|
|
16
|
-
|
|
17
11
|
exports.default = void 0;
|
|
18
|
-
|
|
19
12
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
|
|
20
|
-
|
|
21
13
|
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/applyDecoratedDescriptor"));
|
|
22
|
-
|
|
23
14
|
var _weakMap = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/weak-map"));
|
|
24
|
-
|
|
25
15
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
26
|
-
|
|
27
16
|
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
28
|
-
|
|
29
17
|
var _now = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/date/now"));
|
|
30
|
-
|
|
31
18
|
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor"));
|
|
32
|
-
|
|
33
19
|
var _omit2 = _interopRequireDefault(require("lodash/omit"));
|
|
34
|
-
|
|
35
20
|
var _querystring = _interopRequireDefault(require("querystring"));
|
|
36
|
-
|
|
37
21
|
var _util = _interopRequireDefault(require("util"));
|
|
38
|
-
|
|
39
22
|
var _commonTimers = require("@webex/common-timers");
|
|
40
|
-
|
|
41
23
|
var _common = require("@webex/common");
|
|
42
|
-
|
|
43
24
|
var _webexCore = require("@webex/webex-core");
|
|
44
|
-
|
|
45
25
|
var _nodeKms = require("node-kms");
|
|
46
|
-
|
|
47
26
|
var _nodeJose = _interopRequireDefault(require("node-jose"));
|
|
48
|
-
|
|
49
27
|
var _uuid = _interopRequireDefault(require("uuid"));
|
|
50
|
-
|
|
51
28
|
var _kmsBatcher = _interopRequireWildcard(require("./kms-batcher"));
|
|
52
|
-
|
|
53
29
|
var _kmsCertificateValidation = _interopRequireWildcard(require("./kms-certificate-validation"));
|
|
54
|
-
|
|
55
30
|
var _dec, _obj;
|
|
56
|
-
|
|
57
31
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap2 !== "function") return null; var cacheBabelInterop = new _WeakMap2(); var cacheNodeInterop = new _WeakMap2(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
58
|
-
|
|
59
32
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor2; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor2(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
60
|
-
|
|
61
33
|
var contexts = new _weakMap.default();
|
|
62
34
|
var kmsDetails = new _weakMap.default();
|
|
63
35
|
var partialContexts = new _weakMap.default();
|
|
64
|
-
|
|
65
36
|
var consoleDebug = require('debug')('kms');
|
|
37
|
+
|
|
66
38
|
/**
|
|
67
39
|
* @class
|
|
68
40
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
41
|
var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
72
42
|
keyFactory: function keyFactory(_ref) {
|
|
73
43
|
var uri = _ref.uri,
|
|
74
|
-
|
|
44
|
+
onBehalfOf = _ref.onBehalfOf;
|
|
75
45
|
return "".concat(uri, "/").concat(onBehalfOf);
|
|
76
46
|
}
|
|
77
47
|
}), (_obj = {
|
|
@@ -79,7 +49,6 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
79
49
|
children: {
|
|
80
50
|
batcher: _kmsBatcher.default
|
|
81
51
|
},
|
|
82
|
-
|
|
83
52
|
/**
|
|
84
53
|
* Binds a key to a resource
|
|
85
54
|
* @param {Object} options
|
|
@@ -91,37 +60,32 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
91
60
|
*/
|
|
92
61
|
bindKey: function bindKey(_ref2) {
|
|
93
62
|
var _this = this;
|
|
94
|
-
|
|
95
63
|
var kro = _ref2.kro,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
64
|
+
kroUri = _ref2.kroUri,
|
|
65
|
+
key = _ref2.key,
|
|
66
|
+
keyUri = _ref2.keyUri;
|
|
99
67
|
kroUri = kroUri || kro.uri;
|
|
100
68
|
keyUri = keyUri || key.uri;
|
|
101
69
|
this.logger.info('kms: binding key to resource');
|
|
102
|
-
/* istanbul ignore if */
|
|
103
70
|
|
|
71
|
+
/* istanbul ignore if */
|
|
104
72
|
if (!kroUri) {
|
|
105
73
|
return _promise.default.reject(new Error('`kro` or `kroUri` is required'));
|
|
106
74
|
}
|
|
107
|
-
/* istanbul ignore if */
|
|
108
|
-
|
|
109
75
|
|
|
76
|
+
/* istanbul ignore if */
|
|
110
77
|
if (!keyUri) {
|
|
111
78
|
return _promise.default.reject(new Error('`key` or `keyUri` is required'));
|
|
112
79
|
}
|
|
113
|
-
|
|
114
80
|
return this.request({
|
|
115
81
|
method: 'update',
|
|
116
82
|
resourceUri: kroUri,
|
|
117
83
|
uri: keyUri
|
|
118
84
|
}).then(function (res) {
|
|
119
85
|
_this.logger.info('kms: bound key to resource');
|
|
120
|
-
|
|
121
86
|
return res.key;
|
|
122
87
|
});
|
|
123
88
|
},
|
|
124
|
-
|
|
125
89
|
/**
|
|
126
90
|
* Creates a new KMS Resource
|
|
127
91
|
* @param {Object} options
|
|
@@ -133,33 +97,28 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
133
97
|
*/
|
|
134
98
|
createResource: function createResource(_ref3) {
|
|
135
99
|
var _this2 = this;
|
|
136
|
-
|
|
137
100
|
var userIds = _ref3.userIds,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
101
|
+
keyUris = _ref3.keyUris,
|
|
102
|
+
key = _ref3.key,
|
|
103
|
+
keys = _ref3.keys;
|
|
141
104
|
keyUris = keyUris || [];
|
|
142
105
|
/* istanbul ignore if */
|
|
143
|
-
|
|
144
106
|
if (keys) {
|
|
145
107
|
keyUris = keys.reduce(function (uris, k) {
|
|
146
108
|
uris.push(k.uri);
|
|
147
109
|
return uris;
|
|
148
110
|
}, keyUris);
|
|
149
111
|
}
|
|
150
|
-
/* istanbul ignore else */
|
|
151
|
-
|
|
152
112
|
|
|
113
|
+
/* istanbul ignore else */
|
|
153
114
|
if (key) {
|
|
154
115
|
keyUris.push(key.uri);
|
|
155
116
|
}
|
|
156
|
-
/* istanbul ignore if */
|
|
157
|
-
|
|
158
117
|
|
|
118
|
+
/* istanbul ignore if */
|
|
159
119
|
if (keyUris.length === 0) {
|
|
160
120
|
return _promise.default.reject(new Error('Cannot create KMS Resource without at least one keyUri'));
|
|
161
121
|
}
|
|
162
|
-
|
|
163
122
|
this.logger.info('kms: creating resource');
|
|
164
123
|
return this.request({
|
|
165
124
|
method: 'create',
|
|
@@ -168,11 +127,9 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
168
127
|
keyUris: keyUris
|
|
169
128
|
}).then(function (res) {
|
|
170
129
|
_this2.logger.info('kms: created resource');
|
|
171
|
-
|
|
172
130
|
return res.resource;
|
|
173
131
|
});
|
|
174
132
|
},
|
|
175
|
-
|
|
176
133
|
/**
|
|
177
134
|
* Authorizes a user or KRO to a KRO
|
|
178
135
|
* @param {Object} options
|
|
@@ -184,30 +141,25 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
184
141
|
*/
|
|
185
142
|
addAuthorization: function addAuthorization(_ref4) {
|
|
186
143
|
var _this3 = this;
|
|
187
|
-
|
|
188
144
|
var userIds = _ref4.userIds,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
145
|
+
authIds = _ref4.authIds,
|
|
146
|
+
kro = _ref4.kro,
|
|
147
|
+
kroUri = _ref4.kroUri;
|
|
192
148
|
userIds = userIds || [];
|
|
193
149
|
kroUri = kroUri || kro.uri;
|
|
194
|
-
|
|
195
150
|
if (authIds) {
|
|
196
151
|
userIds = userIds.concat(authIds);
|
|
197
152
|
}
|
|
198
|
-
/* istanbul ignore if */
|
|
199
|
-
|
|
200
153
|
|
|
154
|
+
/* istanbul ignore if */
|
|
201
155
|
if (userIds.length === 0) {
|
|
202
156
|
return _promise.default.reject(new Error('Cannot add authorization without userIds or authIds'));
|
|
203
157
|
}
|
|
204
|
-
/* istanbul ignore if */
|
|
205
|
-
|
|
206
158
|
|
|
159
|
+
/* istanbul ignore if */
|
|
207
160
|
if (!kroUri) {
|
|
208
161
|
return _promise.default.reject(new Error('`kro` or `kroUri` is required'));
|
|
209
162
|
}
|
|
210
|
-
|
|
211
163
|
this.logger.info('kms: adding authorization to kms resource');
|
|
212
164
|
return this.request({
|
|
213
165
|
method: 'create',
|
|
@@ -216,11 +168,9 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
216
168
|
userIds: userIds
|
|
217
169
|
}).then(function (res) {
|
|
218
170
|
_this3.logger.info('kms: added authorization');
|
|
219
|
-
|
|
220
171
|
return res.authorizations;
|
|
221
172
|
});
|
|
222
173
|
},
|
|
223
|
-
|
|
224
174
|
/**
|
|
225
175
|
* Retrieve a list of users that have been authorized to the KRO
|
|
226
176
|
* @param {Object} options
|
|
@@ -230,26 +180,21 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
230
180
|
*/
|
|
231
181
|
listAuthorizations: function listAuthorizations(_ref5) {
|
|
232
182
|
var _this4 = this;
|
|
233
|
-
|
|
234
183
|
var kro = _ref5.kro,
|
|
235
|
-
|
|
184
|
+
kroUri = _ref5.kroUri;
|
|
236
185
|
kroUri = kroUri || kro.uri;
|
|
237
186
|
/* istanbul ignore if */
|
|
238
|
-
|
|
239
187
|
if (!kroUri) {
|
|
240
188
|
return _promise.default.reject(new Error('`kro` or `kroUri` is required'));
|
|
241
189
|
}
|
|
242
|
-
|
|
243
190
|
return this.request({
|
|
244
191
|
method: 'retrieve',
|
|
245
192
|
uri: "".concat(kroUri, "/authorizations")
|
|
246
193
|
}).then(function (res) {
|
|
247
194
|
_this4.logger.info('kms: retrieved authorization list');
|
|
248
|
-
|
|
249
195
|
return res.authorizations;
|
|
250
196
|
});
|
|
251
197
|
},
|
|
252
|
-
|
|
253
198
|
/**
|
|
254
199
|
* Deauthorizes a user or KRO from a KRO
|
|
255
200
|
* @param {Object} options
|
|
@@ -261,25 +206,22 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
261
206
|
*/
|
|
262
207
|
removeAuthorization: function removeAuthorization(_ref6) {
|
|
263
208
|
var _this5 = this;
|
|
264
|
-
|
|
265
209
|
var authId = _ref6.authId,
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
210
|
+
userId = _ref6.userId,
|
|
211
|
+
kro = _ref6.kro,
|
|
212
|
+
kroUri = _ref6.kroUri;
|
|
269
213
|
authId = authId || userId;
|
|
270
214
|
kroUri = kroUri || kro.uri;
|
|
271
|
-
/* istanbul ignore if */
|
|
272
215
|
|
|
216
|
+
/* istanbul ignore if */
|
|
273
217
|
if (!authId) {
|
|
274
218
|
return _promise.default.reject(new Error('Cannot remove authorization without authId'));
|
|
275
219
|
}
|
|
276
|
-
/* istanbul ignore if */
|
|
277
|
-
|
|
278
220
|
|
|
221
|
+
/* istanbul ignore if */
|
|
279
222
|
if (!kroUri) {
|
|
280
223
|
return _promise.default.reject(new Error('`kro` or `kroUri` is required'));
|
|
281
224
|
}
|
|
282
|
-
|
|
283
225
|
this.logger.info('kms: removing authorization from kms resource');
|
|
284
226
|
return this.request({
|
|
285
227
|
method: 'delete',
|
|
@@ -288,11 +230,9 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
288
230
|
}))
|
|
289
231
|
}).then(function (res) {
|
|
290
232
|
_this5.logger.info('kms: removed authorization');
|
|
291
|
-
|
|
292
233
|
return res.authorizations;
|
|
293
234
|
});
|
|
294
235
|
},
|
|
295
|
-
|
|
296
236
|
/**
|
|
297
237
|
* Requests `count` unbound keys from the kms
|
|
298
238
|
* @param {Object} options
|
|
@@ -301,33 +241,28 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
301
241
|
*/
|
|
302
242
|
createUnboundKeys: function createUnboundKeys(_ref7) {
|
|
303
243
|
var _this6 = this;
|
|
304
|
-
|
|
305
244
|
var count = _ref7.count;
|
|
306
245
|
this.logger.info("kms: request ".concat(count, " unbound keys"));
|
|
307
|
-
/* istanbul ignore if */
|
|
308
246
|
|
|
247
|
+
/* istanbul ignore if */
|
|
309
248
|
if (!count) {
|
|
310
249
|
return _promise.default.reject(new Error('`options.count` is required'));
|
|
311
250
|
}
|
|
312
|
-
|
|
313
251
|
return this.request({
|
|
314
252
|
method: 'create',
|
|
315
253
|
uri: '/keys',
|
|
316
254
|
count: count
|
|
317
255
|
}).then(function (res) {
|
|
318
256
|
_this6.logger.info('kms: received unbound keys');
|
|
319
|
-
|
|
320
257
|
return _promise.default.all(res.keys.map(_this6.asKey));
|
|
321
258
|
});
|
|
322
259
|
},
|
|
323
|
-
|
|
324
260
|
/**
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
261
|
+
* @typedef {Object} FetchPublicKeyResponse
|
|
262
|
+
* @property {number} status 200,400(Bad Request: Request payload missing info),404(Not Found: HSM Public Key not found),501(Not Implemented: This KMS does not support BYOK),502(Bad Gateway: KMS could not communicate with HSM)
|
|
263
|
+
* @property {UUID} requestId this is should be unique, used for debug.
|
|
264
|
+
* @property {string} publicKey
|
|
265
|
+
*/
|
|
331
266
|
/**
|
|
332
267
|
* get public key from kms
|
|
333
268
|
* @param {Object} options
|
|
@@ -336,7 +271,6 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
336
271
|
*/
|
|
337
272
|
fetchPublicKey: function fetchPublicKey(_ref8) {
|
|
338
273
|
var _this7 = this;
|
|
339
|
-
|
|
340
274
|
var assignedOrgId = _ref8.assignedOrgId;
|
|
341
275
|
this.logger.info('kms: fetch public key for byok');
|
|
342
276
|
return this.request({
|
|
@@ -345,19 +279,16 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
345
279
|
assignedOrgId: assignedOrgId
|
|
346
280
|
}).then(function (res) {
|
|
347
281
|
_this7.logger.info('kms: received public key');
|
|
348
|
-
|
|
349
282
|
return res.publicKey;
|
|
350
283
|
});
|
|
351
284
|
},
|
|
352
|
-
|
|
353
285
|
/**
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
286
|
+
* @typedef {Object} UploadCmkResponse
|
|
287
|
+
* @property {number} status
|
|
288
|
+
* @property {UUID} requestId
|
|
289
|
+
* @property {string} uri
|
|
290
|
+
* @property {string} keysState
|
|
291
|
+
*/
|
|
361
292
|
/**
|
|
362
293
|
* upload master key for one org.
|
|
363
294
|
* @param {Object} options
|
|
@@ -367,9 +298,8 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
367
298
|
*/
|
|
368
299
|
uploadCustomerMasterKey: function uploadCustomerMasterKey(_ref9) {
|
|
369
300
|
var _this8 = this;
|
|
370
|
-
|
|
371
301
|
var assignedOrgId = _ref9.assignedOrgId,
|
|
372
|
-
|
|
302
|
+
customerMasterKey = _ref9.customerMasterKey;
|
|
373
303
|
this.logger.info('kms: upload customer master key for byok');
|
|
374
304
|
return this.request({
|
|
375
305
|
method: 'create',
|
|
@@ -379,11 +309,9 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
379
309
|
requestId: _uuid.default.v4()
|
|
380
310
|
}).then(function (res) {
|
|
381
311
|
_this8.logger.info('kms: finish to upload customer master key');
|
|
382
|
-
|
|
383
312
|
return res;
|
|
384
313
|
});
|
|
385
314
|
},
|
|
386
|
-
|
|
387
315
|
/**
|
|
388
316
|
* get all customer master keys for one org.
|
|
389
317
|
* @param {Object} options
|
|
@@ -392,7 +320,6 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
392
320
|
*/
|
|
393
321
|
listAllCustomerMasterKey: function listAllCustomerMasterKey(_ref10) {
|
|
394
322
|
var _this9 = this;
|
|
395
|
-
|
|
396
323
|
var assignedOrgId = _ref10.assignedOrgId;
|
|
397
324
|
this.logger.info('kms: get all customer master keys for byok');
|
|
398
325
|
return this.request({
|
|
@@ -402,18 +329,15 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
402
329
|
requestId: _uuid.default.v4()
|
|
403
330
|
}).then(function (res) {
|
|
404
331
|
_this9.logger.info('kms: finish to get all customer master keys');
|
|
405
|
-
|
|
406
332
|
return res;
|
|
407
333
|
});
|
|
408
334
|
},
|
|
409
|
-
|
|
410
335
|
/**
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
336
|
+
* @typedef {Object} ActivateCmkResponse
|
|
337
|
+
* @property {number} status
|
|
338
|
+
* @property {UUID} requestId
|
|
339
|
+
* @property {Array<CMK>} customerMasterKeys
|
|
340
|
+
*/
|
|
417
341
|
/**
|
|
418
342
|
*
|
|
419
343
|
* @typedef {Object} CMK
|
|
@@ -424,7 +348,6 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
424
348
|
* @property {Date | undefined} stateUpdatedOn
|
|
425
349
|
* @property {Date | undefined} rotation
|
|
426
350
|
*/
|
|
427
|
-
|
|
428
351
|
/**
|
|
429
352
|
* change one customer master key state for one org.
|
|
430
353
|
* delete pending key, then the keyState should be 'removedclean';
|
|
@@ -438,10 +361,9 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
438
361
|
*/
|
|
439
362
|
changeCustomerMasterKeyState: function changeCustomerMasterKeyState(_ref11) {
|
|
440
363
|
var _this10 = this;
|
|
441
|
-
|
|
442
364
|
var keyId = _ref11.keyId,
|
|
443
|
-
|
|
444
|
-
|
|
365
|
+
keyState = _ref11.keyState,
|
|
366
|
+
assignedOrgId = _ref11.assignedOrgId;
|
|
445
367
|
this.logger.info('kms: change one customer master key state for byok');
|
|
446
368
|
return this.request({
|
|
447
369
|
method: 'update',
|
|
@@ -451,11 +373,9 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
451
373
|
requestId: _uuid.default.v4()
|
|
452
374
|
}).then(function (res) {
|
|
453
375
|
_this10.logger.info('kms: finish to change the customer master key state to {}', keyState);
|
|
454
|
-
|
|
455
376
|
return res;
|
|
456
377
|
});
|
|
457
378
|
},
|
|
458
|
-
|
|
459
379
|
/**
|
|
460
380
|
* this is for test case. it will delete all CMKs, no matter what their status is. This is mainly for test purpose
|
|
461
381
|
* @param {Object} options
|
|
@@ -464,7 +384,6 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
464
384
|
*/
|
|
465
385
|
deleteAllCustomerMasterKeys: function deleteAllCustomerMasterKeys(_ref12) {
|
|
466
386
|
var _this11 = this;
|
|
467
|
-
|
|
468
387
|
var assignedOrgId = _ref12.assignedOrgId;
|
|
469
388
|
this.logger.info('kms: delete all customer master keys at the same time');
|
|
470
389
|
return this.request({
|
|
@@ -474,11 +393,9 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
474
393
|
requestId: _uuid.default.v4()
|
|
475
394
|
}).then(function (res) {
|
|
476
395
|
_this11.logger.info('kms: finish to delete all customer master keys');
|
|
477
|
-
|
|
478
396
|
return res;
|
|
479
397
|
});
|
|
480
398
|
},
|
|
481
|
-
|
|
482
399
|
/**
|
|
483
400
|
* return to use global master key for one org.
|
|
484
401
|
* @param {Object} options
|
|
@@ -487,7 +404,6 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
487
404
|
*/
|
|
488
405
|
useGlobalMasterKey: function useGlobalMasterKey(_ref13) {
|
|
489
406
|
var _this12 = this;
|
|
490
|
-
|
|
491
407
|
var assignedOrgId = _ref13.assignedOrgId;
|
|
492
408
|
this.logger.info('kms: return to use global master key');
|
|
493
409
|
return this.request({
|
|
@@ -498,21 +414,17 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
498
414
|
requestId: _uuid.default.v4()
|
|
499
415
|
}).then(function (res) {
|
|
500
416
|
_this12.logger.info('kms: finish to return to global master key');
|
|
501
|
-
|
|
502
417
|
return res;
|
|
503
418
|
});
|
|
504
419
|
},
|
|
505
420
|
fetchKey: function fetchKey(_ref14) {
|
|
506
421
|
var _this13 = this;
|
|
507
|
-
|
|
508
422
|
var uri = _ref14.uri,
|
|
509
|
-
|
|
510
|
-
|
|
423
|
+
onBehalfOf = _ref14.onBehalfOf;
|
|
511
424
|
/* istanbul ignore if */
|
|
512
425
|
if (!uri) {
|
|
513
426
|
return _promise.default.reject(new Error('`options.uri` is required'));
|
|
514
427
|
}
|
|
515
|
-
|
|
516
428
|
this.logger.info('kms: fetching key');
|
|
517
429
|
return this.request({
|
|
518
430
|
method: 'retrieve',
|
|
@@ -521,11 +433,9 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
521
433
|
onBehalfOf: onBehalfOf
|
|
522
434
|
}).then(function (res) {
|
|
523
435
|
_this13.logger.info('kms: fetched key');
|
|
524
|
-
|
|
525
436
|
return _this13.asKey(res.key);
|
|
526
437
|
});
|
|
527
438
|
},
|
|
528
|
-
|
|
529
439
|
/**
|
|
530
440
|
* Pings the kms. Mostly for testing
|
|
531
441
|
* @returns {Promise}
|
|
@@ -536,7 +446,6 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
536
446
|
uri: '/ping'
|
|
537
447
|
});
|
|
538
448
|
},
|
|
539
|
-
|
|
540
449
|
/**
|
|
541
450
|
* Ensures a key obect is Key instance
|
|
542
451
|
* @param {Object} key
|
|
@@ -548,7 +457,6 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
548
457
|
return key;
|
|
549
458
|
});
|
|
550
459
|
},
|
|
551
|
-
|
|
552
460
|
/**
|
|
553
461
|
* Adds appropriate metadata to the KMS request
|
|
554
462
|
* @param {Object} payload
|
|
@@ -557,18 +465,14 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
557
465
|
*/
|
|
558
466
|
prepareRequest: function prepareRequest(payload, onBehalfOf) {
|
|
559
467
|
var _this14 = this;
|
|
560
|
-
|
|
561
468
|
var isECDHRequest = payload.method === 'create' && payload.uri.includes('/ecdhe');
|
|
562
469
|
return _promise.default.resolve(isECDHRequest ? partialContexts.get(this) : this._getContext()).then(function (context) {
|
|
563
470
|
_this14.logger.info("kms: wrapping ".concat(isECDHRequest ? 'ephemeral key' : 'kms', " request"));
|
|
564
|
-
|
|
565
471
|
var req = new _nodeKms.Request(payload);
|
|
566
472
|
var requestContext = context;
|
|
567
|
-
|
|
568
473
|
if (onBehalfOf) {
|
|
569
474
|
requestContext = _this14._contextOnBehalfOf(context, onBehalfOf);
|
|
570
475
|
}
|
|
571
|
-
|
|
572
476
|
return req.wrap(requestContext, {
|
|
573
477
|
serverKey: isECDHRequest
|
|
574
478
|
}).then(function () {
|
|
@@ -578,12 +482,10 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
578
482
|
depth: null
|
|
579
483
|
}));
|
|
580
484
|
}
|
|
581
|
-
|
|
582
485
|
return req;
|
|
583
486
|
});
|
|
584
487
|
});
|
|
585
488
|
},
|
|
586
|
-
|
|
587
489
|
/**
|
|
588
490
|
* Accepts a kms message event, decrypts it, and passes it to the batcher
|
|
589
491
|
* @param {Object} event
|
|
@@ -591,27 +493,29 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
591
493
|
*/
|
|
592
494
|
processKmsMessageEvent: function processKmsMessageEvent(event) {
|
|
593
495
|
var _this15 = this;
|
|
594
|
-
|
|
595
496
|
this.logger.info('kms: received kms message');
|
|
596
497
|
return _promise.default.all(event.encryption.kmsMessages.map(function (kmsMessage, index) {
|
|
597
498
|
return _this15._isECDHEMessage(kmsMessage).then(function (isECDHMessage) {
|
|
598
499
|
_this15.logger.info("kms: received ".concat(isECDHMessage ? 'ecdhe' : 'normal', " message"));
|
|
599
|
-
|
|
600
500
|
var res = new _nodeKms.Response(kmsMessage);
|
|
601
|
-
return _promise.default.resolve(isECDHMessage ? partialContexts.get(_this15) : contexts.get(_this15))
|
|
501
|
+
return _promise.default.resolve(isECDHMessage ? partialContexts.get(_this15) : contexts.get(_this15))
|
|
502
|
+
// eslint-disable-next-line max-nested-callbacks
|
|
602
503
|
.then(function (context) {
|
|
603
504
|
return res.unwrap(context);
|
|
604
|
-
})
|
|
505
|
+
})
|
|
506
|
+
// eslint-disable-next-line max-nested-callbacks
|
|
605
507
|
.then(function () {
|
|
606
508
|
if (process.env.NODE_ENV !== 'production') {
|
|
607
509
|
_this15.logger.info('kms: response payload', _util.default.inspect((0, _omit2.default)(JSON.parse((0, _stringify.default)(res)), 'wrapped'), {
|
|
608
510
|
depth: null
|
|
609
511
|
}));
|
|
610
512
|
}
|
|
611
|
-
})
|
|
513
|
+
})
|
|
514
|
+
// eslint-disable-next-line max-nested-callbacks
|
|
612
515
|
.then(function () {
|
|
613
516
|
event.encryption.kmsMessages[index] = res;
|
|
614
|
-
})
|
|
517
|
+
})
|
|
518
|
+
// eslint-disable-next-line max-nested-callbacks
|
|
615
519
|
.then(function () {
|
|
616
520
|
return res;
|
|
617
521
|
});
|
|
@@ -620,13 +524,11 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
620
524
|
return _this15.batcher.processKmsMessageEvent(event);
|
|
621
525
|
}).catch(function (reason) {
|
|
622
526
|
_this15.logger.error('kms: decrypt failed', reason.stack);
|
|
623
|
-
|
|
624
527
|
return _promise.default.reject(reason);
|
|
625
528
|
}).then(function () {
|
|
626
529
|
return event;
|
|
627
530
|
});
|
|
628
531
|
},
|
|
629
|
-
|
|
630
532
|
/**
|
|
631
533
|
* Decrypts a kms message
|
|
632
534
|
* @param {Object} kmsMessage
|
|
@@ -640,7 +542,6 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
640
542
|
return res.body;
|
|
641
543
|
});
|
|
642
544
|
},
|
|
643
|
-
|
|
644
545
|
/**
|
|
645
546
|
* Determines if the kms message is an ecdhe message or a normal message
|
|
646
547
|
* @param {Object} kmsMessage
|
|
@@ -649,16 +550,13 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
649
550
|
_isECDHEMessage: function _isECDHEMessage(kmsMessage) {
|
|
650
551
|
return this._getKMSStaticPubKey().then(function (kmsStaticPubKey) {
|
|
651
552
|
var fields = kmsMessage.split('.');
|
|
652
|
-
|
|
653
553
|
if (fields.length !== 3) {
|
|
654
554
|
return false;
|
|
655
555
|
}
|
|
656
|
-
|
|
657
556
|
var header = JSON.parse(_nodeJose.default.util.base64url.decode(fields[0]));
|
|
658
557
|
return header.kid === kmsStaticPubKey.kid;
|
|
659
558
|
});
|
|
660
559
|
},
|
|
661
|
-
|
|
662
560
|
/**
|
|
663
561
|
* Sends a request to the kms
|
|
664
562
|
* @param {Object} payload
|
|
@@ -669,83 +567,72 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
669
567
|
*/
|
|
670
568
|
request: function request(payload) {
|
|
671
569
|
var _this16 = this;
|
|
672
|
-
|
|
673
570
|
var _ref15 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
674
|
-
|
|
675
|
-
|
|
571
|
+
timeout = _ref15.timeout,
|
|
572
|
+
onBehalfOf = _ref15.onBehalfOf;
|
|
573
|
+
timeout = timeout || this.config.kmsInitialTimeout;
|
|
676
574
|
|
|
677
|
-
|
|
575
|
+
// Note: this should only happen when we're using the async kms batcher;
|
|
678
576
|
// once we implement the sync batcher, this'll need to be smarter.
|
|
679
|
-
|
|
680
577
|
return this.webex.internal.mercury.connect().then(function () {
|
|
681
578
|
return _this16.prepareRequest(payload, onBehalfOf);
|
|
682
579
|
}).then(function (req) {
|
|
683
580
|
req[_kmsBatcher.TIMEOUT_SYMBOL] = timeout;
|
|
684
581
|
return _this16.batcher.request(req);
|
|
685
|
-
})
|
|
582
|
+
})
|
|
583
|
+
// High complexity is due to attempt at test mode resiliency
|
|
686
584
|
// eslint-disable-next-line complexity
|
|
687
585
|
.catch(function (reason) {
|
|
688
586
|
if (process.env.NODE_ENV === 'test' && (reason.status === 403 || reason.statusCode === 403) && reason.message.match(/Failed to resolve authorization token in KmsMessage request for user/)) {
|
|
689
587
|
_this16.logger.warn('kms: rerequested key due to test-mode kms auth failure');
|
|
690
|
-
|
|
691
588
|
return _this16.request(payload, {
|
|
692
589
|
onBehalfOf: onBehalfOf
|
|
693
590
|
});
|
|
694
|
-
}
|
|
695
|
-
|
|
591
|
+
}
|
|
696
592
|
|
|
593
|
+
// KMS Error. Notify the user
|
|
697
594
|
if (reason instanceof _kmsCertificateValidation.KMSError) {
|
|
698
595
|
_this16.webex.trigger('client:InvalidRequestError');
|
|
699
|
-
|
|
700
596
|
return _promise.default.reject(reason);
|
|
701
|
-
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// Ideally, most or all of the code below would go in kms-batcher, but
|
|
702
600
|
// but batching needs at least one more round of refactoring for that to
|
|
703
601
|
// work.
|
|
704
|
-
|
|
705
|
-
|
|
706
602
|
if (!reason.statusCode && !reason.status) {
|
|
707
603
|
/* istanbul ignore else */
|
|
708
604
|
if (process.env.NODE_ENV !== 'production') {
|
|
709
605
|
/* istanbul ignore next: reason.stack vs stack difficult to control in test */
|
|
710
606
|
_this16.logger.info('kms: request error', reason.stack || reason);
|
|
711
607
|
}
|
|
712
|
-
|
|
713
608
|
consoleDebug("timeout ".concat(timeout));
|
|
714
609
|
timeout *= 2;
|
|
715
|
-
|
|
716
610
|
if (timeout >= _this16.config.ecdhMaxTimeout) {
|
|
717
611
|
_this16.logger.info('kms: exceeded maximum KMS request retries');
|
|
718
|
-
|
|
719
612
|
return _promise.default.reject(reason);
|
|
720
|
-
}
|
|
721
|
-
// will exceed the maximum timeout for renegotiating ECDH keys.
|
|
722
|
-
|
|
613
|
+
}
|
|
723
614
|
|
|
615
|
+
// Peek ahead to make sure we don't reset the timeout if the next timeout
|
|
616
|
+
// will exceed the maximum timeout for renegotiating ECDH keys.
|
|
724
617
|
var nextTimeout = timeout * 2;
|
|
725
|
-
|
|
726
618
|
if (timeout >= _this16.config.kmsMaxTimeout && nextTimeout < _this16.config.ecdhMaxTimeout) {
|
|
727
619
|
_this16.logger.info('kms: exceeded maximum KMS request retries; negotiating new ecdh key');
|
|
728
|
-
/* istanbul ignore else */
|
|
729
|
-
|
|
730
620
|
|
|
621
|
+
/* istanbul ignore else */
|
|
731
622
|
if (process.env.NODE_ENV !== 'production') {
|
|
732
623
|
_this16.logger.info('kms: timeout/maxtimeout', timeout, _this16.config.kmsMaxTimeout);
|
|
733
624
|
}
|
|
734
|
-
|
|
735
625
|
contexts.delete(_this16);
|
|
736
626
|
timeout = 0;
|
|
737
627
|
}
|
|
738
|
-
|
|
739
628
|
return _this16.request(payload, {
|
|
740
629
|
timeout: timeout,
|
|
741
630
|
onBehalfOf: onBehalfOf
|
|
742
631
|
});
|
|
743
632
|
}
|
|
744
|
-
|
|
745
633
|
return _promise.default.reject(reason);
|
|
746
634
|
});
|
|
747
635
|
},
|
|
748
|
-
|
|
749
636
|
/**
|
|
750
637
|
* @private
|
|
751
638
|
* @returns {Promise<string>}
|
|
@@ -755,7 +642,6 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
755
642
|
return token.access_token;
|
|
756
643
|
});
|
|
757
644
|
},
|
|
758
|
-
|
|
759
645
|
/**
|
|
760
646
|
* @private
|
|
761
647
|
* @param {String} onBehalfOf create context on behalf of another user, undefined when this is not necessary
|
|
@@ -763,9 +649,7 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
763
649
|
*/
|
|
764
650
|
_getContext: function _getContext() {
|
|
765
651
|
var _this17 = this;
|
|
766
|
-
|
|
767
652
|
var promise = contexts.get(this);
|
|
768
|
-
|
|
769
653
|
if (!promise) {
|
|
770
654
|
promise = this._prepareContext();
|
|
771
655
|
contexts.set(this, promise);
|
|
@@ -776,17 +660,14 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
776
660
|
}, expiresIn);
|
|
777
661
|
});
|
|
778
662
|
}
|
|
779
|
-
|
|
780
663
|
return _promise.default.all([promise, this._getAuthorization()]).then(function (_ref16) {
|
|
781
664
|
var _ref17 = (0, _slicedToArray2.default)(_ref16, 2),
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
665
|
+
context = _ref17[0],
|
|
666
|
+
authorization = _ref17[1];
|
|
785
667
|
context.clientInfo.credential.bearer = authorization;
|
|
786
668
|
return context;
|
|
787
669
|
});
|
|
788
670
|
},
|
|
789
|
-
|
|
790
671
|
/**
|
|
791
672
|
* @private
|
|
792
673
|
* @returns {Promise<Object>}
|
|
@@ -798,16 +679,13 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
798
679
|
return kmsCluster;
|
|
799
680
|
});
|
|
800
681
|
},
|
|
801
|
-
|
|
802
682
|
/**
|
|
803
683
|
* @private
|
|
804
684
|
* @returns {Promise<Object>}
|
|
805
685
|
*/
|
|
806
686
|
_getKMSDetails: function _getKMSDetails() {
|
|
807
687
|
var _this18 = this;
|
|
808
|
-
|
|
809
688
|
var details = kmsDetails.get(this);
|
|
810
|
-
|
|
811
689
|
if (!details) {
|
|
812
690
|
this.logger.info('kms: fetching KMS details');
|
|
813
691
|
details = this.webex.request({
|
|
@@ -815,21 +693,17 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
815
693
|
resource: "/kms/".concat(this.webex.internal.device.userId)
|
|
816
694
|
}).then(function (res) {
|
|
817
695
|
_this18.logger.info('kms: fetched KMS details');
|
|
818
|
-
|
|
819
696
|
var body = res.body;
|
|
820
697
|
body.rsaPublicKey = JSON.parse(body.rsaPublicKey);
|
|
821
698
|
return body;
|
|
822
699
|
}).catch(function (reason) {
|
|
823
700
|
_this18.logger.error('kms: failed to fetch KMS details', reason);
|
|
824
|
-
|
|
825
701
|
return _promise.default.reject(reason);
|
|
826
702
|
});
|
|
827
703
|
kmsDetails.set(this, details);
|
|
828
704
|
}
|
|
829
|
-
|
|
830
705
|
return details;
|
|
831
706
|
},
|
|
832
|
-
|
|
833
707
|
/**
|
|
834
708
|
* @private
|
|
835
709
|
* @returns {Promise<Object>}
|
|
@@ -841,21 +715,18 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
841
715
|
return rsaPublicKey;
|
|
842
716
|
});
|
|
843
717
|
},
|
|
844
|
-
|
|
845
718
|
/**
|
|
846
719
|
* @private
|
|
847
720
|
* @returns {Promise<Object>}
|
|
848
721
|
*/
|
|
849
722
|
_prepareContext: function _prepareContext() {
|
|
850
723
|
var _this19 = this;
|
|
851
|
-
|
|
852
724
|
this.logger.info('kms: creating context');
|
|
853
725
|
var context = new _nodeKms.Context();
|
|
854
726
|
return _promise.default.all([this._getKMSStaticPubKey().then((0, _kmsCertificateValidation.default)(this.config.caroots)), this._getAuthorization()]).then(function (_ref20) {
|
|
855
727
|
var _ref21 = (0, _slicedToArray2.default)(_ref20, 2),
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
728
|
+
kmsStaticPubKey = _ref21[0],
|
|
729
|
+
authorization = _ref21[1];
|
|
859
730
|
context.clientInfo = {
|
|
860
731
|
clientId: _this19.webex.internal.device.url,
|
|
861
732
|
credential: {
|
|
@@ -866,9 +737,7 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
866
737
|
context.serverInfo = {
|
|
867
738
|
key: kmsStaticPubKey
|
|
868
739
|
};
|
|
869
|
-
|
|
870
740
|
_this19.logger.info('kms: creating local ephemeral key');
|
|
871
|
-
|
|
872
741
|
return context.createECDHKey();
|
|
873
742
|
}).then(function (localECDHKey) {
|
|
874
743
|
context.ephemeralKey = localECDHKey;
|
|
@@ -876,11 +745,9 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
876
745
|
return _promise.default.all([localECDHKey.asKey(), _this19._getKMSCluster()]);
|
|
877
746
|
}).then(function (_ref22) {
|
|
878
747
|
var _ref23 = (0, _slicedToArray2.default)(_ref22, 2),
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
748
|
+
localECDHKey = _ref23[0],
|
|
749
|
+
cluster = _ref23[1];
|
|
882
750
|
_this19.logger.info('kms: submitting ephemeral key request');
|
|
883
|
-
|
|
884
751
|
return _this19.request({
|
|
885
752
|
uri: "".concat(cluster, "/ecdhe"),
|
|
886
753
|
method: 'create',
|
|
@@ -888,22 +755,17 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
888
755
|
});
|
|
889
756
|
}).then(function (res) {
|
|
890
757
|
_this19.logger.info('kms: deriving final ephemeral key');
|
|
891
|
-
|
|
892
758
|
return context.deriveEphemeralKey(res.key);
|
|
893
759
|
}).then(function (key) {
|
|
894
760
|
context.ephemeralKey = key;
|
|
895
761
|
partialContexts.delete(_this19);
|
|
896
|
-
|
|
897
762
|
_this19.logger.info('kms: derived final ephemeral key');
|
|
898
|
-
|
|
899
763
|
return context;
|
|
900
764
|
}).catch(function (reason) {
|
|
901
765
|
_this19.logger.error('kms: failed to negotiate ephemeral key', reason);
|
|
902
|
-
|
|
903
766
|
return _promise.default.reject(reason);
|
|
904
767
|
});
|
|
905
768
|
},
|
|
906
|
-
|
|
907
769
|
/**
|
|
908
770
|
* KMS 'retrieve' requests can be made on behalf of another user. This is useful
|
|
909
771
|
* for scenarios such as eDiscovery. i.e. Where an authorized compliance officer is
|
|
@@ -931,9 +793,8 @@ var KMS = _webexCore.WebexPlugin.extend((_dec = (0, _common.oneFlight)({
|
|
|
931
793
|
context.ephemeralKey = originalContext.ephemeralKey;
|
|
932
794
|
return context;
|
|
933
795
|
},
|
|
934
|
-
version: "3.0.0-
|
|
796
|
+
version: "3.0.0-bnr.0"
|
|
935
797
|
}, ((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
|
-
|
|
937
798
|
var _default = KMS;
|
|
938
799
|
exports.default = _default;
|
|
939
800
|
//# sourceMappingURL=kms.js.map
|