@webex/internal-plugin-encryption 3.0.0-beta.4 → 3.0.0-beta.400
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/constants.js +14 -0
- package/dist/constants.js.map +1 -0
- package/dist/encryption.js +25 -74
- 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 +7 -30
- package/dist/kms-batcher.js.map +1 -1
- package/dist/kms-certificate-validation.js +24 -90
- 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 +21 -51
- package/dist/kms-errors.js.map +1 -1
- package/dist/kms.js +88 -218
- package/dist/kms.js.map +1 -1
- package/package.json +15 -15
- package/src/config.js +3 -3
- package/src/constants.js +3 -0
- package/src/encryption.js +74 -57
- 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 +53 -45
- package/src/kms-certificate-validation.js +48 -50
- package/src/kms-dry-error-interceptor.js +8 -4
- package/src/kms-errors.js +47 -16
- package/src/kms.js +219 -212
- package/test/integration/spec/encryption.js +313 -231
- package/test/integration/spec/kms.js +532 -405
- package/test/integration/spec/payload-transfom.js +69 -69
- package/test/unit/spec/encryption.js +21 -18
- package/test/unit/spec/kms-certificate-validation.js +76 -34
- package/test/unit/spec/kms-errors.js +70 -0
- package/test/unit/spec/kms.js +103 -0
package/src/kms-errors.js
CHANGED
|
@@ -5,11 +5,18 @@
|
|
|
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
|
*/
|
|
11
17
|
export class KmsError extends Exception {
|
|
12
|
-
static defaultMessage =
|
|
18
|
+
static defaultMessage =
|
|
19
|
+
'An unknown error occurred while communicating with the kms. This implies we received an error response without a body.';
|
|
13
20
|
|
|
14
21
|
/**
|
|
15
22
|
* @param {HttpResponse} body
|
|
@@ -21,20 +28,20 @@ export class KmsError extends Exception {
|
|
|
21
28
|
Object.defineProperties(this, {
|
|
22
29
|
body: {
|
|
23
30
|
enumerable: false,
|
|
24
|
-
value: body
|
|
31
|
+
value: body,
|
|
25
32
|
},
|
|
26
33
|
reason: {
|
|
27
34
|
enumerable: false,
|
|
28
|
-
value: body.reason
|
|
35
|
+
value: body.reason,
|
|
29
36
|
},
|
|
30
37
|
requestId: {
|
|
31
38
|
enumerable: false,
|
|
32
|
-
value: body.requestId
|
|
39
|
+
value: body.requestId,
|
|
33
40
|
},
|
|
34
41
|
status: {
|
|
35
42
|
enumerable: false,
|
|
36
|
-
value: body.status
|
|
37
|
-
}
|
|
43
|
+
value: body.status,
|
|
44
|
+
},
|
|
38
45
|
});
|
|
39
46
|
|
|
40
47
|
let message = typeof body === 'string' ? body : body.reason;
|
|
@@ -49,6 +56,14 @@ export class KmsError extends Exception {
|
|
|
49
56
|
message += `\nKMS_REQUEST_ID: ${body.requestId}`;
|
|
50
57
|
}
|
|
51
58
|
|
|
59
|
+
if (body.statusCode) {
|
|
60
|
+
message += `\nKMS_STATUS_CODE: ${body.statusCode}`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (body.errorCode) {
|
|
64
|
+
message += `\nKMS_ErrorCode: ${body.errorCode}`;
|
|
65
|
+
}
|
|
66
|
+
|
|
52
67
|
return message;
|
|
53
68
|
}
|
|
54
69
|
}
|
|
@@ -63,7 +78,9 @@ export class KmsTimeoutError extends KmsError {
|
|
|
63
78
|
* @returns {string}
|
|
64
79
|
*/
|
|
65
80
|
parse({request = {}, timeout} = {}) {
|
|
66
|
-
let message = `The KMS did not respond within ${
|
|
81
|
+
let message = `The KMS did not respond within ${
|
|
82
|
+
timeout ? `${timeout} milliseconds` : 'a timely fashion'
|
|
83
|
+
}`;
|
|
67
84
|
|
|
68
85
|
if (request) {
|
|
69
86
|
if (request.method && request.uri) {
|
|
@@ -100,12 +117,12 @@ export class DryError extends WebexHttpError {
|
|
|
100
117
|
}
|
|
101
118
|
if (this.options.url) {
|
|
102
119
|
message += `\n${this.options.method} ${this.options.url}`;
|
|
103
|
-
}
|
|
104
|
-
else if (this.options.uri) {
|
|
120
|
+
} else if (this.options.uri) {
|
|
105
121
|
message += `\n${this.options.method} ${this.options.uri}`;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
122
|
+
} else {
|
|
123
|
+
message += `\n${this.options.method} ${this.options.service.toUpperCase()}/${
|
|
124
|
+
this.options.resource
|
|
125
|
+
}`;
|
|
109
126
|
}
|
|
110
127
|
message += `\nWEBEX_TRACKING_ID: ${this.options.headers.trackingid}`;
|
|
111
128
|
|
|
@@ -119,18 +136,32 @@ export class DryError extends WebexHttpError {
|
|
|
119
136
|
Object.defineProperties(this, {
|
|
120
137
|
reason: {
|
|
121
138
|
enumerable: false,
|
|
122
|
-
value: body.reason
|
|
139
|
+
value: body.reason,
|
|
123
140
|
},
|
|
124
141
|
requestId: {
|
|
125
142
|
enumerable: false,
|
|
126
|
-
value: body.requestId
|
|
143
|
+
value: body.requestId,
|
|
127
144
|
},
|
|
128
145
|
status: {
|
|
129
146
|
enumerable: false,
|
|
130
|
-
value: body.status
|
|
131
|
-
}
|
|
147
|
+
value: body.status,
|
|
148
|
+
},
|
|
132
149
|
});
|
|
133
150
|
|
|
134
151
|
return message;
|
|
135
152
|
}
|
|
136
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
|
+
};
|