@interopio/gateway-server 0.6.1-beta → 0.6.2-beta

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/dist/index.js CHANGED
@@ -159,8 +159,7 @@ var HttpServerRequest = class {
159
159
  return void 0;
160
160
  }
161
161
  const text = await blob.text();
162
- const json = JSON.parse(text);
163
- return json;
162
+ return JSON.parse(text);
164
163
  });
165
164
  }
166
165
  };
@@ -275,15 +274,19 @@ var HttpServerResponse = class {
275
274
  }
276
275
  end(chunk) {
277
276
  if (!this._res.headersSent) {
278
- return new Promise((resolve) => {
279
- if (chunk === void 0) {
280
- this._res.end(() => {
281
- resolve(true);
282
- });
283
- } else {
284
- this._res.end(chunk, () => {
285
- resolve(true);
286
- });
277
+ return new Promise((resolve, reject) => {
278
+ try {
279
+ if (chunk === void 0) {
280
+ this._res.end(() => {
281
+ resolve(true);
282
+ });
283
+ } else {
284
+ this._res.end(chunk, () => {
285
+ resolve(true);
286
+ });
287
+ }
288
+ } catch (e) {
289
+ reject(e instanceof Error ? e : new Error(`end failed: ${e}`));
287
290
  }
288
291
  });
289
292
  } else {
@@ -771,9 +774,10 @@ function routes(connections, config, authorize) {
771
774
  } else {
772
775
  const nodes = json;
773
776
  const result = connections.announce(nodes);
774
- const body = new Blob([JSON.stringify(result)], { type: "application/json" });
777
+ const buffer = Buffer.from(JSON.stringify(result), "utf-8");
775
778
  ctx.response.statusCode = 200;
776
- await ctx.response.end(body);
779
+ ctx.response.headers.set("Content-Type", "application/json").set("Content-Length", buffer.length);
780
+ await ctx.response.end(buffer);
777
781
  }
778
782
  } else {
779
783
  await next();
@@ -1842,14 +1846,25 @@ function authenticationFilter(opts) {
1842
1846
  // src/server/security/oauth2/token-error.ts
1843
1847
  var BearerTokenErrorCodes = {
1844
1848
  invalid_request: "invalid_request",
1845
- invalid_token: "invalid_token"
1849
+ invalid_token: "invalid_token",
1850
+ insufficient_scope: "insufficient_scope"
1846
1851
  };
1847
1852
  var DEFAULT_URI = "https://tools.ietf.org/html/rfc6750#section-3.1";
1848
1853
  function invalidToken(message) {
1849
- return { errorCode: BearerTokenErrorCodes.invalid_token, httpStatus: 401, description: message, uri: DEFAULT_URI };
1854
+ return {
1855
+ errorCode: BearerTokenErrorCodes.invalid_token,
1856
+ httpStatus: 401,
1857
+ description: message,
1858
+ uri: DEFAULT_URI
1859
+ };
1850
1860
  }
1851
1861
  function invalidRequest(message) {
1852
- return { errorCode: BearerTokenErrorCodes.invalid_request, httpStatus: 400, description: message, uri: DEFAULT_URI };
1862
+ return {
1863
+ errorCode: BearerTokenErrorCodes.invalid_request,
1864
+ httpStatus: 400,
1865
+ description: message,
1866
+ uri: DEFAULT_URI
1867
+ };
1853
1868
  }
1854
1869
 
1855
1870
  // src/server/security/oauth2/token-converter.ts
@@ -2134,7 +2149,7 @@ function httpBasic(opts) {
2134
2149
  const preferredMatcher = or([xhrMatcher, restNoHtmlMatcher]);
2135
2150
  opts.defaultEntryPoints.push([preferredMatcher, entryPoint]);
2136
2151
  const failureHandler = opts.failureHandler ?? serverAuthenticationEntryPointFailureHandler({ entryPoint });
2137
- const successHandler = delegatingSuccessHandler(opts.successHandlers === void 0 ? opts.defaultSuccessHandlers : opts.successHandlers);
2152
+ const successHandler = delegatingSuccessHandler(opts.successHandlers ?? opts.defaultSuccessHandlers);
2138
2153
  const converter = httpBasicAuthenticationConverter({});
2139
2154
  return authenticationFilter({
2140
2155
  storage: opts.storage,