@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/changelog.md +5 -0
- package/dist/index.cjs +32 -17
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +32 -17
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/changelog.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -190,8 +190,7 @@ var HttpServerRequest = class {
|
|
|
190
190
|
return void 0;
|
|
191
191
|
}
|
|
192
192
|
const text = await blob.text();
|
|
193
|
-
|
|
194
|
-
return json;
|
|
193
|
+
return JSON.parse(text);
|
|
195
194
|
});
|
|
196
195
|
}
|
|
197
196
|
};
|
|
@@ -306,15 +305,19 @@ var HttpServerResponse = class {
|
|
|
306
305
|
}
|
|
307
306
|
end(chunk) {
|
|
308
307
|
if (!this._res.headersSent) {
|
|
309
|
-
return new Promise((resolve) => {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
308
|
+
return new Promise((resolve, reject) => {
|
|
309
|
+
try {
|
|
310
|
+
if (chunk === void 0) {
|
|
311
|
+
this._res.end(() => {
|
|
312
|
+
resolve(true);
|
|
313
|
+
});
|
|
314
|
+
} else {
|
|
315
|
+
this._res.end(chunk, () => {
|
|
316
|
+
resolve(true);
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
} catch (e) {
|
|
320
|
+
reject(e instanceof Error ? e : new Error(`end failed: ${e}`));
|
|
318
321
|
}
|
|
319
322
|
});
|
|
320
323
|
} else {
|
|
@@ -802,9 +805,10 @@ function routes(connections, config, authorize) {
|
|
|
802
805
|
} else {
|
|
803
806
|
const nodes = json;
|
|
804
807
|
const result = connections.announce(nodes);
|
|
805
|
-
const
|
|
808
|
+
const buffer = Buffer.from(JSON.stringify(result), "utf-8");
|
|
806
809
|
ctx.response.statusCode = 200;
|
|
807
|
-
|
|
810
|
+
ctx.response.headers.set("Content-Type", "application/json").set("Content-Length", buffer.length);
|
|
811
|
+
await ctx.response.end(buffer);
|
|
808
812
|
}
|
|
809
813
|
} else {
|
|
810
814
|
await next();
|
|
@@ -1873,14 +1877,25 @@ function authenticationFilter(opts) {
|
|
|
1873
1877
|
// src/server/security/oauth2/token-error.ts
|
|
1874
1878
|
var BearerTokenErrorCodes = {
|
|
1875
1879
|
invalid_request: "invalid_request",
|
|
1876
|
-
invalid_token: "invalid_token"
|
|
1880
|
+
invalid_token: "invalid_token",
|
|
1881
|
+
insufficient_scope: "insufficient_scope"
|
|
1877
1882
|
};
|
|
1878
1883
|
var DEFAULT_URI = "https://tools.ietf.org/html/rfc6750#section-3.1";
|
|
1879
1884
|
function invalidToken(message) {
|
|
1880
|
-
return {
|
|
1885
|
+
return {
|
|
1886
|
+
errorCode: BearerTokenErrorCodes.invalid_token,
|
|
1887
|
+
httpStatus: 401,
|
|
1888
|
+
description: message,
|
|
1889
|
+
uri: DEFAULT_URI
|
|
1890
|
+
};
|
|
1881
1891
|
}
|
|
1882
1892
|
function invalidRequest(message) {
|
|
1883
|
-
return {
|
|
1893
|
+
return {
|
|
1894
|
+
errorCode: BearerTokenErrorCodes.invalid_request,
|
|
1895
|
+
httpStatus: 400,
|
|
1896
|
+
description: message,
|
|
1897
|
+
uri: DEFAULT_URI
|
|
1898
|
+
};
|
|
1884
1899
|
}
|
|
1885
1900
|
|
|
1886
1901
|
// src/server/security/oauth2/token-converter.ts
|
|
@@ -2165,7 +2180,7 @@ function httpBasic(opts) {
|
|
|
2165
2180
|
const preferredMatcher = or([xhrMatcher, restNoHtmlMatcher]);
|
|
2166
2181
|
opts.defaultEntryPoints.push([preferredMatcher, entryPoint]);
|
|
2167
2182
|
const failureHandler = opts.failureHandler ?? serverAuthenticationEntryPointFailureHandler({ entryPoint });
|
|
2168
|
-
const successHandler = delegatingSuccessHandler(opts.successHandlers
|
|
2183
|
+
const successHandler = delegatingSuccessHandler(opts.successHandlers ?? opts.defaultSuccessHandlers);
|
|
2169
2184
|
const converter = httpBasicAuthenticationConverter({});
|
|
2170
2185
|
return authenticationFilter({
|
|
2171
2186
|
storage: opts.storage,
|