Add Node types to dev dependencies
This commit is contained in:
1 parent
44a2fe11ee
commit
9f4b421b59
5 files changed
+23
-23
No files matched your search
+12
-14
@@ -90,9 +90,7 @@ async function authenticate(
|
||||
}
|
||||
|
||||
if (authentication && authentication.method === "Digest") {
|
||||
const sessionNonce = sessionsNonces.get(
|
||||
sessionContext.httpRequest.connection
|
||||
);
|
||||
const sessionNonce = sessionsNonces.get(sessionContext.httpRequest.socket);
|
||||
|
||||
if (
|
||||
!sessionNonce ||
|
||||
@@ -185,7 +183,7 @@ async function writeResponse(
|
||||
}
|
||||
|
||||
const httpResponse = sessionContext.httpResponse;
|
||||
const connection = httpResponse.connection;
|
||||
const connection = httpResponse.socket;
|
||||
|
||||
httpResponse.setHeader("Content-Length", Buffer.byteLength(data));
|
||||
httpResponse.writeHead(res.code, res.headers);
|
||||
@@ -988,7 +986,7 @@ async function reportBadState(sessionContext: SessionContext): Promise<void> {
|
||||
sessionContext: sessionContext,
|
||||
});
|
||||
const httpResponse = sessionContext.httpResponse;
|
||||
currentSessions.delete(httpResponse.connection);
|
||||
currentSessions.delete(httpResponse.socket);
|
||||
const body = "Bad session state";
|
||||
httpResponse.setHeader("Content-Length", Buffer.byteLength(body));
|
||||
httpResponse.writeHead(400, { Connection: "close" });
|
||||
@@ -1015,14 +1013,14 @@ async function responseUnauthorized(
|
||||
resHeaders["WWW-Authenticate"] = `Basic realm="${REALM}"`;
|
||||
} else {
|
||||
const nonce = crypto.randomBytes(16).toString("hex");
|
||||
sessionsNonces.set(sessionContext.httpRequest.connection, nonce);
|
||||
sessionsNonces.set(sessionContext.httpRequest.socket, nonce);
|
||||
let d = `Digest realm="${REALM}"`;
|
||||
d += ',qop="auth,auth-int"';
|
||||
d += `,nonce="${nonce}"`;
|
||||
|
||||
resHeaders["WWW-Authenticate"] = d;
|
||||
}
|
||||
currentSessions.set(sessionContext.httpRequest.connection, sessionContext);
|
||||
currentSessions.set(sessionContext.httpRequest.socket, sessionContext);
|
||||
}
|
||||
|
||||
const httpResponse = sessionContext.httpResponse;
|
||||
@@ -1210,13 +1208,13 @@ export function listener(
|
||||
stats.concurrentRequests -= 1;
|
||||
})
|
||||
.catch((err) => {
|
||||
currentSessions.delete(httpResponse.connection);
|
||||
currentSessions.delete(httpResponse.socket);
|
||||
stats.concurrentRequests -= 1;
|
||||
setTimeout(() => {
|
||||
throw err;
|
||||
});
|
||||
try {
|
||||
httpResponse.connection.unref();
|
||||
httpResponse.socket.unref();
|
||||
httpResponse.writeHead(500, { Connection: "close" });
|
||||
httpResponse.end(`${err.name}: ${err.message}`);
|
||||
} catch (err) {
|
||||
@@ -1227,7 +1225,7 @@ export function listener(
|
||||
|
||||
function decodeString(buffer: Buffer, charset: string): string {
|
||||
try {
|
||||
return buffer.toString(charset);
|
||||
return buffer.toString(charset as BufferEncoding);
|
||||
} catch (err) {
|
||||
if (encodingExists(charset)) return decode(buffer, charset);
|
||||
}
|
||||
@@ -1312,9 +1310,9 @@ async function listenerAsync(
|
||||
// Request aborted
|
||||
if (!body) return;
|
||||
|
||||
const newConnection = !currentSessions.has(httpRequest.connection);
|
||||
const newConnection = !currentSessions.has(httpRequest.socket);
|
||||
|
||||
const sessionContext = await getSession(httpRequest.connection, sessionId);
|
||||
const sessionContext = await getSession(httpRequest.socket, sessionId);
|
||||
|
||||
if (sessionContext) {
|
||||
sessionContext.httpRequest = httpRequest;
|
||||
@@ -1352,7 +1350,7 @@ async function listenerAsync(
|
||||
return;
|
||||
}
|
||||
|
||||
let charset;
|
||||
let charset: string;
|
||||
if (httpRequest.headers["content-type"]) {
|
||||
const m = httpRequest.headers["content-type"].match(
|
||||
/charset=['"]?([^'"\s]+)/i
|
||||
@@ -1519,7 +1517,7 @@ async function listenerAsync(
|
||||
_sessionContext.httpRequest = httpRequest;
|
||||
_sessionContext.httpResponse = httpResponse;
|
||||
_sessionContext.sessionId = crypto.randomBytes(8).toString("hex");
|
||||
httpRequest.connection.setTimeout(_sessionContext.timeout * 1000);
|
||||
httpRequest.socket.setTimeout(_sessionContext.timeout * 1000);
|
||||
|
||||
const {
|
||||
tasks: dueTasks,
|
||||
|
||||
+5
-5
@@ -49,7 +49,7 @@ export function incomingHttpRequest(
|
||||
): void {
|
||||
if (!DEBUG_FILE) return;
|
||||
const now = new Date();
|
||||
const con = httpRequest.connection;
|
||||
const con = httpRequest.socket;
|
||||
const msg = {
|
||||
event: "incoming HTTP request",
|
||||
timestamp: now,
|
||||
@@ -77,7 +77,7 @@ export function outgoingHttpResponse(
|
||||
): void {
|
||||
if (!DEBUG_FILE) return;
|
||||
const now = new Date();
|
||||
const con = httpResponse.connection;
|
||||
const con = httpResponse.socket;
|
||||
const msg = {
|
||||
event: "outgoing HTTP response",
|
||||
timestamp: now,
|
||||
@@ -104,7 +104,7 @@ export function outgoingHttpRequest(
|
||||
): void {
|
||||
if (!DEBUG_FILE) return;
|
||||
const now = new Date();
|
||||
const con = httpRequest.connection;
|
||||
const con = httpRequest.socket;
|
||||
const msg = {
|
||||
event: "outgoing HTTP request",
|
||||
timestamp: now,
|
||||
@@ -160,13 +160,13 @@ export function incomingHttpResponse(
|
||||
): void {
|
||||
if (!DEBUG_FILE) return;
|
||||
const now = new Date();
|
||||
const con = httpResponse.connection;
|
||||
const con = httpResponse.socket;
|
||||
const msg = {
|
||||
event: "incoming HTTP response",
|
||||
timestamp: now,
|
||||
remoteAddress: con.remoteAddress,
|
||||
deviceId: deviceId,
|
||||
connection: getConnectionTimestamp(httpResponse.connection),
|
||||
connection: getConnectionTimestamp(httpResponse.socket),
|
||||
statusCode: httpResponse.statusCode,
|
||||
headers: httpResponse.headers,
|
||||
body: body,
|
||||
|
||||
+2
-1
@@ -53,7 +53,8 @@ export interface Element {
|
||||
}
|
||||
|
||||
export function parseXmlDeclaration(buffer: Buffer): Attribute[] {
|
||||
for (const enc of ["utf16le", "utf8", "latin1", "ascii"]) {
|
||||
const encodings: BufferEncoding[] = ["utf16le", "utf8", "latin1", "ascii"];
|
||||
for (const enc of encodings) {
|
||||
let str = buffer.toString(enc, 0, 150);
|
||||
if (str.startsWith("<?xml")) {
|
||||
str = str.split("\n")[0].trim();
|
||||
|
||||
Generated
+3
-3
@@ -480,9 +480,9 @@
|
||||
}
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "12.6.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.6.8.tgz",
|
||||
"integrity": "sha512-aX+gFgA5GHcDi89KG5keey2zf0WfZk/HAQotEamsK2kbey+8yGKcson0hbK8E+v0NArlCJQCqMP161YhV6ZXLg==",
|
||||
"version": "14.11.10",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.10.tgz",
|
||||
"integrity": "sha512-yV1nWZPlMFpoXyoknm4S56y2nlTAuFYaJuQtYRAOU7xA/FJ9RY0Xm7QOkaYMMmr8ESdHIuUb6oQgR/0+2NqlyA==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/normalize-package-data": {
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
"@types/koa-static": "^4.0.1",
|
||||
"@types/mithril": "^2.0.4",
|
||||
"@types/mongodb": "^3.5.27",
|
||||
"@types/node": "^14.11.10",
|
||||
"@types/parsimmon": "^1.10.3",
|
||||
"@types/seedrandom": "^2.4.28",
|
||||
"@types/svgo": "^1.3.3",
|
||||
|
||||
Reference in new issue
Block a user