@webex/internal-plugin-encryption 3.0.0-beta.2 → 3.0.0-beta.200
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 +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 +6 -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 +9 -50
- 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/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 +50 -44
- package/src/kms-certificate-validation.js +48 -50
- package/src/kms-dry-error-interceptor.js +8 -4
- package/src/kms-errors.js +27 -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.js +103 -0
package/src/kms-errors.js
CHANGED
|
@@ -9,7 +9,8 @@ import {WebexHttpError} from '@webex/webex-core';
|
|
|
9
9
|
* Error class for KMS errors
|
|
10
10
|
*/
|
|
11
11
|
export class KmsError extends Exception {
|
|
12
|
-
static defaultMessage =
|
|
12
|
+
static defaultMessage =
|
|
13
|
+
'An unknown error occurred while communicating with the kms. This implies we received an error response without a body.';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* @param {HttpResponse} body
|
|
@@ -21,20 +22,20 @@ export class KmsError extends Exception {
|
|
|
21
22
|
Object.defineProperties(this, {
|
|
22
23
|
body: {
|
|
23
24
|
enumerable: false,
|
|
24
|
-
value: body
|
|
25
|
+
value: body,
|
|
25
26
|
},
|
|
26
27
|
reason: {
|
|
27
28
|
enumerable: false,
|
|
28
|
-
value: body.reason
|
|
29
|
+
value: body.reason,
|
|
29
30
|
},
|
|
30
31
|
requestId: {
|
|
31
32
|
enumerable: false,
|
|
32
|
-
value: body.requestId
|
|
33
|
+
value: body.requestId,
|
|
33
34
|
},
|
|
34
35
|
status: {
|
|
35
36
|
enumerable: false,
|
|
36
|
-
value: body.status
|
|
37
|
-
}
|
|
37
|
+
value: body.status,
|
|
38
|
+
},
|
|
38
39
|
});
|
|
39
40
|
|
|
40
41
|
let message = typeof body === 'string' ? body : body.reason;
|
|
@@ -49,6 +50,14 @@ export class KmsError extends Exception {
|
|
|
49
50
|
message += `\nKMS_REQUEST_ID: ${body.requestId}`;
|
|
50
51
|
}
|
|
51
52
|
|
|
53
|
+
if (body.statusCode) {
|
|
54
|
+
message += `\nKMS_STATUS_CODE: ${body.statusCode}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (body.errorCode) {
|
|
58
|
+
message += `\nKMS_ErrorCode: ${body.errorCode}`;
|
|
59
|
+
}
|
|
60
|
+
|
|
52
61
|
return message;
|
|
53
62
|
}
|
|
54
63
|
}
|
|
@@ -63,7 +72,9 @@ export class KmsTimeoutError extends KmsError {
|
|
|
63
72
|
* @returns {string}
|
|
64
73
|
*/
|
|
65
74
|
parse({request = {}, timeout} = {}) {
|
|
66
|
-
let message = `The KMS did not respond within ${
|
|
75
|
+
let message = `The KMS did not respond within ${
|
|
76
|
+
timeout ? `${timeout} milliseconds` : 'a timely fashion'
|
|
77
|
+
}`;
|
|
67
78
|
|
|
68
79
|
if (request) {
|
|
69
80
|
if (request.method && request.uri) {
|
|
@@ -100,12 +111,12 @@ export class DryError extends WebexHttpError {
|
|
|
100
111
|
}
|
|
101
112
|
if (this.options.url) {
|
|
102
113
|
message += `\n${this.options.method} ${this.options.url}`;
|
|
103
|
-
}
|
|
104
|
-
else if (this.options.uri) {
|
|
114
|
+
} else if (this.options.uri) {
|
|
105
115
|
message += `\n${this.options.method} ${this.options.uri}`;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
116
|
+
} else {
|
|
117
|
+
message += `\n${this.options.method} ${this.options.service.toUpperCase()}/${
|
|
118
|
+
this.options.resource
|
|
119
|
+
}`;
|
|
109
120
|
}
|
|
110
121
|
message += `\nWEBEX_TRACKING_ID: ${this.options.headers.trackingid}`;
|
|
111
122
|
|
|
@@ -119,16 +130,16 @@ export class DryError extends WebexHttpError {
|
|
|
119
130
|
Object.defineProperties(this, {
|
|
120
131
|
reason: {
|
|
121
132
|
enumerable: false,
|
|
122
|
-
value: body.reason
|
|
133
|
+
value: body.reason,
|
|
123
134
|
},
|
|
124
135
|
requestId: {
|
|
125
136
|
enumerable: false,
|
|
126
|
-
value: body.requestId
|
|
137
|
+
value: body.requestId,
|
|
127
138
|
},
|
|
128
139
|
status: {
|
|
129
140
|
enumerable: false,
|
|
130
|
-
value: body.status
|
|
131
|
-
}
|
|
141
|
+
value: body.status,
|
|
142
|
+
},
|
|
132
143
|
});
|
|
133
144
|
|
|
134
145
|
return message;
|