@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.
Files changed (38) hide show
  1. package/README.md +1 -3
  2. package/dist/config.js +0 -9
  3. package/dist/config.js.map +1 -1
  4. package/dist/encryption.js +25 -74
  5. package/dist/encryption.js.map +1 -1
  6. package/dist/ensure-buffer.browser.js +0 -12
  7. package/dist/ensure-buffer.browser.js.map +1 -1
  8. package/dist/ensure-buffer.js +5 -12
  9. package/dist/ensure-buffer.js.map +1 -1
  10. package/dist/index.js +7 -33
  11. package/dist/index.js.map +1 -1
  12. package/dist/kms-batcher.js +6 -30
  13. package/dist/kms-batcher.js.map +1 -1
  14. package/dist/kms-certificate-validation.js +24 -90
  15. package/dist/kms-certificate-validation.js.map +1 -1
  16. package/dist/kms-dry-error-interceptor.js +1 -23
  17. package/dist/kms-dry-error-interceptor.js.map +1 -1
  18. package/dist/kms-errors.js +9 -50
  19. package/dist/kms-errors.js.map +1 -1
  20. package/dist/kms.js +88 -218
  21. package/dist/kms.js.map +1 -1
  22. package/package.json +15 -15
  23. package/src/config.js +3 -3
  24. package/src/encryption.js +74 -57
  25. package/src/ensure-buffer.browser.js +0 -1
  26. package/src/ensure-buffer.js +5 -5
  27. package/src/index.js +120 -96
  28. package/src/kms-batcher.js +50 -44
  29. package/src/kms-certificate-validation.js +48 -50
  30. package/src/kms-dry-error-interceptor.js +8 -4
  31. package/src/kms-errors.js +27 -16
  32. package/src/kms.js +219 -212
  33. package/test/integration/spec/encryption.js +313 -231
  34. package/test/integration/spec/kms.js +532 -405
  35. package/test/integration/spec/payload-transfom.js +69 -69
  36. package/test/unit/spec/encryption.js +21 -18
  37. package/test/unit/spec/kms-certificate-validation.js +76 -34
  38. 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 = 'An unknown error occurred while communicating with the kms. This implies we received an error response without a body.';
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 ${timeout ? `${timeout} milliseconds` : 'a timely fashion'}`;
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
- else {
108
- message += `\n${this.options.method} ${this.options.service.toUpperCase()}/${this.options.resource}`;
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;