@clairejs/server 3.16.2 → 3.16.3
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
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
## Change Log
|
|
2
2
|
|
|
3
|
-
#### 3.16.
|
|
3
|
+
#### 3.16.3:
|
|
4
4
|
|
|
5
|
+
- fix socket authentication, fix http error code in response
|
|
5
6
|
- update claire orm
|
|
6
7
|
- update packages, fix mount undefined:undefined when introducing updateRecords
|
|
7
8
|
- remove webpack build config, export as esm module
|
|
@@ -204,7 +204,7 @@ export class AbstractServerSocketManager {
|
|
|
204
204
|
const endpoints = [];
|
|
205
205
|
for (const channel of channels) {
|
|
206
206
|
let canSend = false;
|
|
207
|
-
let
|
|
207
|
+
let canReceive = false;
|
|
208
208
|
const mountedEndpoints = await this.getMountedEndpointInfo();
|
|
209
209
|
const currentEndpoint = mountedEndpoints.find((e) => e.endpointMetadata.url === channel);
|
|
210
210
|
if (!currentEndpoint) {
|
|
@@ -216,8 +216,9 @@ export class AbstractServerSocketManager {
|
|
|
216
216
|
pathName: channel,
|
|
217
217
|
headers: { [SOCKET_ACTION_HEADER]: SOCKET_ACTION_READ },
|
|
218
218
|
}, currentEndpoint.endpointMetadata);
|
|
219
|
+
request.setAuthInfo(clientSocket.getAuthInfo());
|
|
219
220
|
await this.requestAuthorizer.authorize(request, currentEndpoint);
|
|
220
|
-
|
|
221
|
+
canReceive = true;
|
|
221
222
|
}
|
|
222
223
|
catch (err) {
|
|
223
224
|
this.logger.debug("Error in read authorize", err);
|
|
@@ -228,18 +229,19 @@ export class AbstractServerSocketManager {
|
|
|
228
229
|
pathName: channel,
|
|
229
230
|
headers: { [SOCKET_ACTION_HEADER]: SOCKET_ACTION_WRITE },
|
|
230
231
|
}, currentEndpoint.endpointMetadata);
|
|
232
|
+
request.setAuthInfo(clientSocket.getAuthInfo());
|
|
231
233
|
await this.requestAuthorizer.authorize(request, currentEndpoint);
|
|
232
234
|
canSend = true;
|
|
233
235
|
}
|
|
234
236
|
catch (err) {
|
|
235
237
|
this.logger.debug("Error in write authorize", err);
|
|
236
238
|
}
|
|
237
|
-
if (canSend ||
|
|
238
|
-
this.logger.debug(
|
|
239
|
+
if (canSend || canReceive) {
|
|
240
|
+
this.logger.debug(`Adding channel info: ${channel}, canSend: ${canSend}, canReceive: ${canReceive}`);
|
|
239
241
|
channelsInfo.push({
|
|
240
242
|
name: channel,
|
|
241
243
|
clientToServerAllowed: canSend,
|
|
242
|
-
serverToClientAllowed:
|
|
244
|
+
serverToClientAllowed: canReceive,
|
|
243
245
|
});
|
|
244
246
|
endpoints.push(currentEndpoint);
|
|
245
247
|
}
|
|
@@ -112,7 +112,8 @@ export class ExpressWrapper {
|
|
|
112
112
|
res.status(result.code || 200).send(result.value);
|
|
113
113
|
}
|
|
114
114
|
})().catch((err) => {
|
|
115
|
-
|
|
115
|
+
const code = typeof err.code === "number" ? err.code : 500;
|
|
116
|
+
res.status(code).json({ name: err.name, message: err.message, code: err.code || 500 });
|
|
116
117
|
});
|
|
117
118
|
});
|
|
118
119
|
return new Promise((resolve, reject) => {
|
|
@@ -141,7 +141,7 @@ export class LambdaWrapper {
|
|
|
141
141
|
}
|
|
142
142
|
catch (err) {
|
|
143
143
|
return toApiGatewayFormat({
|
|
144
|
-
code: err.code
|
|
144
|
+
code: typeof err.code === "number" ? err.code : 500,
|
|
145
145
|
value: { name: err.name, message: err.message, code: err.code || 500 },
|
|
146
146
|
headers: corsHeaders,
|
|
147
147
|
cookies: {},
|