@bedrock/kms-http 14.0.0 → 14.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # bedrock-kms-http ChangeLog
2
2
 
3
+ ## 14.1.0 - 2022-05-12
4
+
5
+ ### Added
6
+ - Include full error as non-public `cause` in `onError` handler.
7
+
3
8
  ## 14.0.0 - 2022-04-29
4
9
 
5
10
  ### Changed
package/lib/middleware.js CHANGED
@@ -152,27 +152,25 @@ async function inspectCapabilityChain({
152
152
  }
153
153
 
154
154
  function onError({error}) {
155
- // cause must be a public BedrockError to be surfaced to the HTTP client
156
- let cause;
157
- if(error instanceof BedrockError) {
158
- cause = error;
159
- } else {
155
+ if(!(error instanceof BedrockError)) {
156
+ // always expose cause message and name; expose cause details as
157
+ // BedrockError if error is marked public
160
158
  let details = {};
161
159
  if(error.details && error.details.public) {
162
160
  details = error.details;
163
161
  }
164
- cause = new BedrockError(
162
+ error = new BedrockError(
165
163
  error.message,
166
164
  error.name || 'NotAllowedError', {
167
165
  ...details,
168
166
  public: true,
169
- });
167
+ }, error);
170
168
  }
171
169
  throw new BedrockError(
172
170
  'Authorization error.', 'NotAllowedError', {
173
171
  httpStatusCode: 403,
174
172
  public: true,
175
- }, cause);
173
+ }, error);
176
174
  }
177
175
 
178
176
  // hook used to create suites for verifying zcap delegation chains
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrock/kms-http",
3
- "version": "14.0.0",
3
+ "version": "14.1.0",
4
4
  "type": "module",
5
5
  "description": "Bedrock KMS HTTP API",
6
6
  "main": "./lib/index.js",