@atproto/oauth-provider 0.2.5 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +21 -0
- package/dist/account/account-store.js +3 -3
- package/dist/account/account-store.js.map +1 -1
- package/dist/assets/app/bundle-manifest.json +2 -2
- package/dist/assets/app/main.js +3 -3
- package/dist/assets/app/main.js.map +1 -1
- package/dist/assets/asset.d.ts +0 -1
- package/dist/assets/asset.d.ts.map +1 -1
- package/dist/assets/assets-middleware.js +2 -3
- package/dist/assets/assets-middleware.js.map +1 -1
- package/dist/assets/index.js +2 -2
- package/dist/assets/index.js.map +1 -1
- package/dist/client/client-auth.js +2 -3
- package/dist/client/client-auth.js.map +1 -1
- package/dist/client/client-manager.d.ts +1 -1
- package/dist/client/client-manager.d.ts.map +1 -1
- package/dist/client/client-manager.js +3 -4
- package/dist/client/client-manager.js.map +1 -1
- package/dist/client/client-store.js +3 -4
- package/dist/client/client-store.js.map +1 -1
- package/dist/client/client-utils.d.ts +0 -1
- package/dist/client/client-utils.d.ts.map +1 -1
- package/dist/client/client-utils.js +2 -3
- package/dist/client/client-utils.js.map +1 -1
- package/dist/device/device-details.d.ts +0 -1
- package/dist/device/device-details.d.ts.map +1 -1
- package/dist/device/device-details.js +3 -3
- package/dist/device/device-details.js.map +1 -1
- package/dist/device/device-id.d.ts.map +1 -1
- package/dist/device/device-manager.d.ts +1 -2
- package/dist/device/device-manager.d.ts.map +1 -1
- package/dist/device/device-store.js +2 -3
- package/dist/device/device-store.js.map +1 -1
- package/dist/device/session-id.d.ts.map +1 -1
- package/dist/dpop/dpop-manager.d.ts +0 -1
- package/dist/dpop/dpop-manager.d.ts.map +1 -1
- package/dist/lib/html/build-document.d.ts +0 -1
- package/dist/lib/html/build-document.d.ts.map +1 -1
- package/dist/lib/html/escapers.js +4 -5
- package/dist/lib/html/escapers.js.map +1 -1
- package/dist/lib/html/util.js +2 -3
- package/dist/lib/html/util.js.map +1 -1
- package/dist/lib/http/accept.d.ts +1 -1
- package/dist/lib/http/accept.d.ts.map +1 -1
- package/dist/lib/http/accept.js +2 -2
- package/dist/lib/http/accept.js.map +1 -1
- package/dist/lib/http/context.js +1 -2
- package/dist/lib/http/context.js.map +1 -1
- package/dist/lib/http/method.d.ts +0 -1
- package/dist/lib/http/method.d.ts.map +1 -1
- package/dist/lib/http/method.js +1 -2
- package/dist/lib/http/method.js.map +1 -1
- package/dist/lib/http/middleware.d.ts +0 -1
- package/dist/lib/http/middleware.d.ts.map +1 -1
- package/dist/lib/http/middleware.js +5 -6
- package/dist/lib/http/middleware.js.map +1 -1
- package/dist/lib/http/parser.d.ts +2 -5
- package/dist/lib/http/parser.d.ts.map +1 -1
- package/dist/lib/http/parser.js +2 -2
- package/dist/lib/http/parser.js.map +1 -1
- package/dist/lib/http/path.js +1 -2
- package/dist/lib/http/path.js.map +1 -1
- package/dist/lib/http/request.d.ts +0 -1
- package/dist/lib/http/request.d.ts.map +1 -1
- package/dist/lib/http/request.js +9 -10
- package/dist/lib/http/request.js.map +1 -1
- package/dist/lib/http/response.d.ts +9 -8
- package/dist/lib/http/response.d.ts.map +1 -1
- package/dist/lib/http/response.js +24 -66
- package/dist/lib/http/response.js.map +1 -1
- package/dist/lib/http/route.d.ts +0 -1
- package/dist/lib/http/route.d.ts.map +1 -1
- package/dist/lib/http/route.js +1 -2
- package/dist/lib/http/route.js.map +1 -1
- package/dist/lib/http/router.d.ts +2 -4
- package/dist/lib/http/router.d.ts.map +1 -1
- package/dist/lib/http/stream.d.ts +2 -7
- package/dist/lib/http/stream.d.ts.map +1 -1
- package/dist/lib/http/stream.js +5 -5
- package/dist/lib/http/stream.js.map +1 -1
- package/dist/lib/http/types.d.ts +0 -1
- package/dist/lib/http/types.d.ts.map +1 -1
- package/dist/lib/http/url.d.ts +0 -1
- package/dist/lib/http/url.d.ts.map +1 -1
- package/dist/lib/http/url.js +1 -2
- package/dist/lib/http/url.js.map +1 -1
- package/dist/lib/redis.d.ts.map +1 -1
- package/dist/lib/redis.js +7 -6
- package/dist/lib/redis.js.map +1 -1
- package/dist/lib/util/cast.js +1 -2
- package/dist/lib/util/cast.js.map +1 -1
- package/dist/lib/util/crypto.js +2 -2
- package/dist/lib/util/crypto.js.map +1 -1
- package/dist/lib/util/date.js +2 -3
- package/dist/lib/util/date.js.map +1 -1
- package/dist/lib/util/hostname.d.ts +0 -1
- package/dist/lib/util/hostname.d.ts.map +1 -1
- package/dist/lib/util/hostname.js +4 -5
- package/dist/lib/util/hostname.js.map +1 -1
- package/dist/lib/util/redirect-uri.js +1 -2
- package/dist/lib/util/redirect-uri.js.map +1 -1
- package/dist/lib/util/time.js +1 -2
- package/dist/lib/util/time.js.map +1 -1
- package/dist/lib/util/well-known.d.ts +0 -1
- package/dist/lib/util/well-known.d.ts.map +1 -1
- package/dist/lib/util/well-known.js +1 -2
- package/dist/lib/util/well-known.js.map +1 -1
- package/dist/metadata/build-metadata.d.ts.map +1 -1
- package/dist/metadata/build-metadata.js +4 -4
- package/dist/metadata/build-metadata.js.map +1 -1
- package/dist/oauth-provider.d.ts +1 -2
- package/dist/oauth-provider.d.ts.map +1 -1
- package/dist/oauth-provider.js +19 -9
- package/dist/oauth-provider.js.map +1 -1
- package/dist/oauth-verifier.d.ts +1 -2
- package/dist/oauth-verifier.d.ts.map +1 -1
- package/dist/output/build-authorize-data.js +1 -2
- package/dist/output/build-authorize-data.js.map +1 -1
- package/dist/output/build-error-payload.js +2 -3
- package/dist/output/build-error-payload.js.map +1 -1
- package/dist/output/customization.d.ts +1 -1
- package/dist/output/customization.d.ts.map +1 -1
- package/dist/output/customization.js +3 -4
- package/dist/output/customization.js.map +1 -1
- package/dist/output/output-manager.d.ts +0 -1
- package/dist/output/output-manager.d.ts.map +1 -1
- package/dist/output/send-authorize-redirect.d.ts +0 -1
- package/dist/output/send-authorize-redirect.d.ts.map +1 -1
- package/dist/output/send-authorize-redirect.js +1 -2
- package/dist/output/send-authorize-redirect.js.map +1 -1
- package/dist/output/send-web-page.d.ts +3 -4
- package/dist/output/send-web-page.d.ts.map +1 -1
- package/dist/output/send-web-page.js +4 -5
- package/dist/output/send-web-page.js.map +1 -1
- package/dist/replay/replay-store-redis.d.ts +1 -1
- package/dist/replay/replay-store-redis.d.ts.map +1 -1
- package/dist/replay/replay-store.js +3 -4
- package/dist/replay/replay-store.js.map +1 -1
- package/dist/request/code.d.ts +1 -1
- package/dist/request/code.d.ts.map +1 -1
- package/dist/request/request-data.d.ts.map +1 -1
- package/dist/request/request-id.d.ts.map +1 -1
- package/dist/request/request-manager.d.ts.map +1 -1
- package/dist/request/request-manager.js +2 -1
- package/dist/request/request-manager.js.map +1 -1
- package/dist/request/request-store-redis.d.ts +1 -1
- package/dist/request/request-store-redis.d.ts.map +1 -1
- package/dist/request/request-store-redis.js.map +1 -1
- package/dist/request/request-store.js +2 -3
- package/dist/request/request-store.js.map +1 -1
- package/dist/request/request-uri.js +3 -3
- package/dist/request/request-uri.js.map +1 -1
- package/dist/signer/signed-token-payload.d.ts +90 -90
- package/dist/signer/signed-token-payload.d.ts.map +1 -1
- package/dist/signer/signer.d.ts +6 -6
- package/dist/signer/signer.d.ts.map +1 -1
- package/dist/token/refresh-token.d.ts +1 -1
- package/dist/token/refresh-token.d.ts.map +1 -1
- package/dist/token/token-claims.d.ts +90 -90
- package/dist/token/token-claims.d.ts.map +1 -1
- package/dist/token/token-id.d.ts +1 -1
- package/dist/token/token-id.d.ts.map +1 -1
- package/dist/token/token-store.js +2 -3
- package/dist/token/token-store.js.map +1 -1
- package/dist/token/verify-token-claims.js +1 -2
- package/dist/token/verify-token-claims.js.map +1 -1
- package/package.json +3 -7
- package/src/assets/assets-middleware.ts +1 -1
- package/src/client/client-manager.ts +3 -3
- package/src/lib/http/accept.ts +1 -0
- package/src/lib/http/middleware.ts +1 -1
- package/src/lib/http/response.ts +37 -78
- package/src/lib/http/stream.ts +4 -2
- package/src/lib/redis.ts +5 -3
- package/src/metadata/build-metadata.ts +6 -3
- package/src/oauth-provider.ts +19 -11
- package/src/oauth-verifier.ts +1 -1
- package/src/output/send-web-page.ts +5 -3
- package/src/replay/replay-store-redis.ts +1 -1
- package/src/request/request-manager.ts +4 -1
- package/src/request/request-store-redis.ts +2 -1
- package/tsconfig.backend.tsbuildinfo +1 -0
- package/tsconfig.frontend.tsbuildinfo +1 -0
- package/tsconfig.tools.tsbuildinfo +1 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"method.d.ts","sourceRoot":"","sources":["../../../src/lib/http/method.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"method.d.ts","sourceRoot":"","sources":["../../../src/lib/http/method.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5C,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,aAAa,CAAA;AAC1E,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,CAAA;AAE7D,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,kBAAkB,GAAG,aAAa,CAY7E"}
|
package/dist/lib/http/method.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.createMethodMatcher =
|
3
|
+
exports.createMethodMatcher = createMethodMatcher;
|
4
4
|
function createMethodMatcher(method) {
|
5
5
|
if (method === '*')
|
6
6
|
return () => true;
|
@@ -15,5 +15,4 @@ function createMethodMatcher(method) {
|
|
15
15
|
return () => false;
|
16
16
|
return (req) => req.method != null && set.has(req.method);
|
17
17
|
}
|
18
|
-
exports.createMethodMatcher = createMethodMatcher;
|
19
18
|
//# sourceMappingURL=method.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"method.js","sourceRoot":"","sources":["../../../src/lib/http/method.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"method.js","sourceRoot":"","sources":["../../../src/lib/http/method.ts"],"names":[],"mappings":";;AAKA,kDAYC;AAZD,SAAgB,mBAAmB,CAAC,MAA0B;IAC5D,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,GAAG,EAAE,CAAC,IAAI,CAAA;IACrC,IAAI,OAAO,MAAM,KAAK,UAAU;QAAE,OAAO,MAAM,CAAA;IAE/C,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAA;QAC7B,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,MAAM,CAAA;IACvC,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAA;IAC/D,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,GAAG,EAAE,CAAC,KAAK,CAAA;IACtC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,IAAI,IAAI,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AAC3D,CAAC"}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
/// <reference types="node" />
|
2
1
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
3
2
|
import { Middleware, Handler, NextFunction } from './types.js';
|
4
3
|
export declare function combineMiddlewares<M extends Middleware<any, any, any>>(middlewares: Iterable<null | undefined | M>, options?: {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/lib/http/middleware.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/lib/http/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAEhE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9D,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EACpE,WAAW,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,GAAG,CAAC,CAAC,EAC3C,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GACjC,CAAC,CAAA;AAwCJ,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IACvD,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,EAAE,MAAM,GAAG,CAAC,GAC/C,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,GACpB,KAAK,CAAA;AAEX;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC3D,UAAU,EAAE,CAAC,EACb,OAAO,CAAC,EAAE,mBAAmB,GASxB,SAAS,CAAC,CAAC,CAAC,CAClB;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,YAAY,CAqBd;AA4CD,wBAAgB,IAAI,CAAC,CAAC,SAAS,YAAY,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAQvD"}
|
@@ -1,6 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.combineMiddlewares = combineMiddlewares;
|
4
|
+
exports.asHandler = asHandler;
|
5
|
+
exports.createFinalHandler = createFinalHandler;
|
6
|
+
exports.once = once;
|
4
7
|
const response_js_1 = require("./response.js");
|
5
8
|
/**
|
6
9
|
* Combine express/connect like middlewares (that can be async) into a single
|
@@ -38,7 +41,6 @@ function combineMiddlewares(middlewares, { skipKeyword } = {}) {
|
|
38
41
|
nextMiddleware();
|
39
42
|
};
|
40
43
|
}
|
41
|
-
exports.combineMiddlewares = combineMiddlewares;
|
42
44
|
/**
|
43
45
|
* Convert a middleware in a function that can be used as both a middleware and
|
44
46
|
* and handler.
|
@@ -48,7 +50,6 @@ function asHandler(middleware, options) {
|
|
48
50
|
return middleware.call(this, req, res, next);
|
49
51
|
};
|
50
52
|
}
|
51
|
-
exports.asHandler = asHandler;
|
52
53
|
function createFinalHandler(req, res, options) {
|
53
54
|
return (err) => {
|
54
55
|
if (err && (options?.debug ?? process.env['NODE_ENV'] === 'development')) {
|
@@ -64,10 +65,9 @@ function createFinalHandler(req, res, options) {
|
|
64
65
|
const { status, ...payload } = buildFallbackPayload(req, err);
|
65
66
|
res.setHeader('Content-Security-Policy', "default-src 'none'");
|
66
67
|
res.setHeader('X-Content-Type-Options', 'nosniff');
|
67
|
-
(0, response_js_1.writeJson)(res, payload, status);
|
68
|
+
(0, response_js_1.writeJson)(res, payload, { status });
|
68
69
|
};
|
69
70
|
}
|
70
|
-
exports.createFinalHandler = createFinalHandler;
|
71
71
|
function buildFallbackPayload(req, err) {
|
72
72
|
const status = err ? getErrorStatusCode(err) : 404;
|
73
73
|
const expose = getProp(err, 'expose', 'boolean') ?? status < 500;
|
@@ -106,7 +106,6 @@ function once(next) {
|
|
106
106
|
return next(err);
|
107
107
|
};
|
108
108
|
}
|
109
|
-
exports.once = once;
|
110
109
|
function getProp(obj, key, type) {
|
111
110
|
if (obj != null && typeof obj === 'object' && key in obj) {
|
112
111
|
const value = obj[key];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../src/lib/http/middleware.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"middleware.js","source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M,CAAC,CAAC,CAAC,GAAG,CAAA;AACvE,CAAC;AAED,SAAgB,IAAI,CAAyB,IAAO;IAClD,IAAI,YAAY,GAAa,IAAI,CAAA;IACjC,OAAO,UAAU,GAAG;QAClB,IAAI,CAAC,YAAY;YAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;QAClE,MAAM,IAAI,GAAG,YAAY,CAAA;QACzB,YAAY,GAAG,IAAI,CAAA;QACnB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;IAClB,CAAM,CAAA;AACR,CAAC;AAyBD,SAAS,OAAO,CAAC,GAAY,EAAE,GAAW,EAAE,IAAY;IACtD,IAAI,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;QACzD,MAAM,KAAK,GAAI,GAA+B,CAAC,GAAG,CAAC,CAAA;QACnD,IAAI,OAAO,KAAK,KAAK,IAAI;YAAE,OAAO,KAAK,CAAA;IACzC,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
/// <reference types="node" />
|
2
1
|
export type JsonScalar = string | number | boolean | null;
|
3
2
|
export type Json = JsonScalar | Json[] | {
|
4
3
|
[_ in string]?: Json;
|
@@ -27,14 +26,12 @@ export type ParserResult<P extends Parser> = ReturnType<P['parse']>;
|
|
27
26
|
export type ParserForType<P extends Parser, T> = P extends Parser<infer U> ? (U extends T ? P : never) : never;
|
28
27
|
export declare const parsers: [{
|
29
28
|
readonly name: "json";
|
30
|
-
readonly test: (mime: string) => mime is
|
29
|
+
readonly test: (mime: string) => mime is `application/json` | `application/${string}+json`;
|
31
30
|
readonly parse: (buffer: Buffer, { charset }: ContentType) => Json;
|
32
31
|
}, {
|
33
32
|
readonly name: "urlencoded";
|
34
33
|
readonly test: (mime: string) => mime is "application/x-www-form-urlencoded";
|
35
|
-
readonly parse: (buffer: Buffer, { charset }: ContentType) => {
|
36
|
-
[x: string]: string | undefined;
|
37
|
-
};
|
34
|
+
readonly parse: (buffer: Buffer, { charset }: ContentType) => { [_ in string]?: string; };
|
38
35
|
}, {
|
39
36
|
readonly name: "bytes";
|
40
37
|
readonly test: (mime: string) => mime is "application/octet-stream";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/lib/http/parser.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/lib/http/parser.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;AACzD,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG,IAAI,EAAE,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,IAAI;CAAE,CAAA;AAEjE;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,CAiB3D;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,OAAO,IAAI;IAC3D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,IAAI,CAAC,CAAA;IAC1C,QAAQ,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,KAAK,CAAC,CAAA;CACzD,CAAA;AAED,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;CAAE,GAC3E,CAAC,GACD,KAAK,CAAA;AACT,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAChF,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,IAAI,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAA;AAEnE,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,IAC3C,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,KAAK,CAAA;AAE/D,eAAO,MAAM,OAAO;;qCAGF,IAAI,IAAI,kBAAkB,GAAG,eAAe,MAAM,OAAO;kEAGzC,IAAI;;;qCAapB,IAAI,IAAI,mCAAmC;kEAG3B,GAAG,CAAW,IAAN,MAAM,CAAC,CAAC,EAAE,MAAM,GAAE;;;qCAgB1C,IAAI,IAAI,0BAA0B;wCAG/B,MAAM;EAEE,CAAA;AAE7B,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAA;AAElD,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;AAC5C,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC,CAAA"}
|
package/dist/lib/http/parser.js
CHANGED
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.parsers =
|
6
|
+
exports.parsers = void 0;
|
7
|
+
exports.parseContentType = parseContentType;
|
7
8
|
const bourne_1 = require("@hapi/bourne");
|
8
9
|
const content_1 = require("@hapi/content");
|
9
10
|
const http_errors_1 = __importDefault(require("http-errors"));
|
@@ -24,7 +25,6 @@ function parseContentType(type) {
|
|
24
25
|
throw (0, http_errors_1.default)(415, err instanceof Error ? err.message : 'Invalid content-type');
|
25
26
|
}
|
26
27
|
}
|
27
|
-
exports.parseContentType = parseContentType;
|
28
28
|
exports.parsers = [
|
29
29
|
{
|
30
30
|
name: 'json',
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/lib/http/parser.ts"],"names":[],"mappings":";;;;;;
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/lib/http/parser.ts"],"names":[],"mappings":";;;;;;AAYA,4CAiBC;AA7BD,yCAAiD;AACjD,2CAAuD;AACvD,8DAAyC;AAKzC;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,IAAa;IAC5C,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,MAAM,IAAA,qBAAe,EACnB,GAAG,EACH,yBAAyB,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,CACrE,CAAA;IACH,CAAC;IAED,IAAI,CAAC;QACH,OAAO,IAAA,cAAe,EAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,uBAAuB;QACvB,MAAM,IAAA,qBAAe,EACnB,GAAG,EACH,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,sBAAsB,CAC5D,CAAA;IACH,CAAC;AACH,CAAC;AAuBY,QAAA,OAAO,GAAG;IACrB;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,CAAC,IAAI,EAA6D,EAAE;YACxE,OAAO,8BAA8B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAClD,CAAC;QACD,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,EAAQ,EAAE;YACnC,I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CAAC;QACH,CAAC;KACF;IACD;QACE,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,CAAC,IAAI,EAAsC,EAAE;YACjD,OAAO,IAAI,KAAK,0BAA0B,CAAA;QAC5C,CAAC;QACD,KAAK,EAAE,CAAC,MAAM,EAAU,EAAE,CAAC,MAAM;KAClC;CAC0B,CAAA"}
|
package/dist/lib/http/path.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.createPathMatcher =
|
3
|
+
exports.createPathMatcher = createPathMatcher;
|
4
4
|
function createPathMatcher(refPath) {
|
5
5
|
if (typeof refPath === 'string') {
|
6
6
|
// Create a path matcher for a path with parameters (like /foo/:fooId/bar/:barId).
|
@@ -50,5 +50,4 @@ function createPathMatcher(refPath) {
|
|
50
50
|
}
|
51
51
|
return refPath;
|
52
52
|
}
|
53
|
-
exports.createPathMatcher = createPathMatcher;
|
54
53
|
//# sourceMappingURL=path.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"path.js","sourceRoot":"","sources":["../../../src/lib/http/path.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"path.js","sourceRoot":"","sources":["../../../src/lib/http/path.ts"],"names":[],"mappings":";;AAqBA,8CA4DC;AA5DD,SAAgB,iBAAiB,CAC/B,OAAgB;IAEhB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,kFAAkF;QAClF,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,MAAM,QAAQ,GAAG,OAAO;iBACrB,KAAK,CAAC,CAAC,CAAC;iBACR,KAAK,CAAC,GAAG,CAAC;iBACV,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAU,CAAC,CAAA;YACvC,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAA;YAEt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AC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAA;oBAC9B,MAAM,GAAG,GAAG,UAAU,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAA;oBAE7B,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA;oBAE3B,0CAA0C;oBAC1C,IAAI,CAAC,KAAK;wBAAE,OAAO,SAAS,CAAA;oBAE5B,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;gBACtB,CAAC;gBAED,OAAO,MAAW,CAAA;YACpB,CAAC,CAAA;QACH,CAAC;QAED,OAAO,CAAC,OAAe,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC,CAAE,EAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IAC3E,CAAC;IAED,IAAI,OAAO,YAAY,MAAM,EAAE,CAAC;QAC9B,OAAO,CAAC,OAAe,EAAE,EAAE;YACzB,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;YACpC,OAAO,KAAK,CAAC,CAAC,CAAE,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAO,CAAC,CAAC,CAAC,SAAS,CAAA;QACxD,CAAC,CAAA;IACH,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
/// <reference types="node" />
|
2
1
|
import { IncomingMessage, ServerResponse } from './types.js';
|
3
2
|
import { UrlReference } from './url.js';
|
4
3
|
export declare function validateHeaderValue(req: IncomingMessage, name: keyof IncomingMessage['headers'], allowedValues: readonly (string | null)[]): void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/lib/http/request.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/lib/http/request.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MA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EACpB,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,MAAM,EACjB,UAAU,SAAe,EACzB,WAAW,UAAQ,QAwBpB;AAED,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,eAAe,GACnB,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC,CAM3C"}
|
package/dist/lib/http/request.js
CHANGED
@@ -3,7 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.
|
6
|
+
exports.validateHeaderValue = validateHeaderValue;
|
7
|
+
exports.validateFetchMode = validateFetchMode;
|
8
|
+
exports.validateFetchDest = validateFetchDest;
|
9
|
+
exports.validateFetchSite = validateFetchSite;
|
10
|
+
exports.validateReferer = validateReferer;
|
11
|
+
exports.setupCsrfToken = setupCsrfToken;
|
12
|
+
exports.validateSameOrigin = validateSameOrigin;
|
13
|
+
exports.validateCsrfToken = validateCsrfToken;
|
14
|
+
exports.parseHttpCookies = parseHttpCookies;
|
7
15
|
const cookie_1 = require("cookie");
|
8
16
|
const crypto_1 = require("crypto");
|
9
17
|
const http_errors_1 = __importDefault(require("http-errors"));
|
@@ -20,19 +28,15 @@ function validateHeaderValue(req, name, allowedValues) {
|
|
20
28
|
: `Missing ${name} header`);
|
21
29
|
}
|
22
30
|
}
|
23
|
-
exports.validateHeaderValue = validateHeaderValue;
|
24
31
|
function validateFetchMode(req, res, expectedMode) {
|
25
32
|
validateHeaderValue(req, 'sec-fetch-mode', expectedMode);
|
26
33
|
}
|
27
|
-
exports.validateFetchMode = validateFetchMode;
|
28
34
|
function validateFetchDest(req, res, expectedDest) {
|
29
35
|
validateHeaderValue(req, 'sec-fetch-dest', expectedDest);
|
30
36
|
}
|
31
|
-
exports.validateFetchDest = validateFetchDest;
|
32
37
|
function validateFetchSite(req, res, expectedSite) {
|
33
38
|
validateHeaderValue(req, 'sec-fetch-site', expectedSite);
|
34
39
|
}
|
35
|
-
exports.validateFetchSite = validateFetchSite;
|
36
40
|
function validateReferer(req, res, reference, allowNull = false) {
|
37
41
|
const referer = req.headers['referer'];
|
38
42
|
const refererUrl = referer ? new URL(referer) : null;
|
@@ -40,7 +44,6 @@ function validateReferer(req, res, reference, allowNull = false) {
|
|
40
44
|
throw (0, http_errors_1.default)(400, `Invalid referer ${referer}`);
|
41
45
|
}
|
42
46
|
}
|
43
|
-
exports.validateReferer = validateReferer;
|
44
47
|
async function setupCsrfToken(req, res, cookieName = 'csrf_token') {
|
45
48
|
const csrfToken = (0, crypto_1.randomBytes)(8).toString('hex');
|
46
49
|
(0, response_js_1.appendHeader)(res, 'Set-Cookie', (0, cookie_1.serialize)(cookieName, csrfToken, {
|
@@ -50,7 +53,6 @@ async function setupCsrfToken(req, res, cookieName = 'csrf_token') {
|
|
50
53
|
path: req.url?.split('?', 1)[0] || '/',
|
51
54
|
}));
|
52
55
|
}
|
53
|
-
exports.setupCsrfToken = setupCsrfToken;
|
54
56
|
// CORS ensure not cross origin
|
55
57
|
function validateSameOrigin(req, res, origin, allowNull = true) {
|
56
58
|
const reqOrigin = req.headers['origin'];
|
@@ -58,7 +60,6 @@ function validateSameOrigin(req, res, origin, allowNull = true) {
|
|
58
60
|
throw (0, http_errors_1.default)(400, `Invalid origin ${reqOrigin}`);
|
59
61
|
}
|
60
62
|
}
|
61
|
-
exports.validateSameOrigin = validateSameOrigin;
|
62
63
|
function validateCsrfToken(req, res, csrfToken, cookieName = 'csrf_token', clearCookie = false) {
|
63
64
|
const cookies = parseHttpCookies(req);
|
64
65
|
if (!csrfToken ||
|
@@ -76,7 +77,6 @@ function validateCsrfToken(req, res, csrfToken, cookieName = 'csrf_token', clear
|
|
76
77
|
}));
|
77
78
|
}
|
78
79
|
}
|
79
|
-
exports.validateCsrfToken = validateCsrfToken;
|
80
80
|
function parseHttpCookies(req) {
|
81
81
|
return 'cookies' in req && req.cookies // Already parsed by another middleware
|
82
82
|
? req.cookies
|
@@ -84,5 +84,4 @@ function parseHttpCookies(req) {
|
|
84
84
|
? (req.cookies = (0, cookie_1.parse)(req.headers['cookie']))
|
85
85
|
: null;
|
86
86
|
}
|
87
|
-
exports.parseHttpCookies = parseHttpCookies;
|
88
87
|
//# sourceMappingURL=request.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/lib/http/request.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/lib/http/request.ts"],"names":[],"mappings":";;;;;AAQA,kDAmBC;AAED,8CAYC;AAED,8CAsBC;AAED,8CAYC;AAED,0CAWC;AAED,wCAgBC;AAGD,gDAUC;AAED,8CA6BC;AAED,4CAQC;AApKD,mCAA2E;AAC3E,mCAAoC;AACpC,8DAAyC;AAEzC,+CAA4C;AAE5C,qCAAiD;AAEjD,SAAgB,mBAAmB,CACjC,GAAoB,EACpB,IAAsC,EACtC,aAAyC;IAEzC,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAA;IAEvC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAA,qBAAe,EAAC,GAAG,EAAE,WAAW,IAAI,SAAS,CAAC,CAAA;IACtD,CAAC;IAED,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACnC,MAAM,IAAA,qBAAe,EACnB,GAAG,EACH,KAAK;YACH,CAAC,CAAC,aAAa,IAAI,YAAY,KAAK,eAAe,aAAa,GAAG;YACnE,CAAC,CAAC,WAAW,IAAI,SAAS,CAC7B,CAAA;IACH,CAAC;AACH,CAAC;AAED,SAAgB,iBAAiB,CAC/B,GAAoB,EACpB,GAAmB,EACnB,YAMG;IAEH,mBAAmB,CAAC,GAAG,EAAE,gBAAgB,EAAE,Y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GAAW,CAAC,OAAO,GAAG,IAAA,cAAW,EAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC7D,CAAC,CAAC,IAAI,CAAA;AACZ,CAAC"}
|
@@ -1,13 +1,14 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
/// <reference types="node" />
|
3
|
-
/// <reference types="node" />
|
4
1
|
import { Readable } from 'node:stream';
|
5
2
|
import { Handler, ServerResponse } from './types.js';
|
6
3
|
export declare function appendHeader(res: ServerResponse, header: string, value: string | readonly string[]): void;
|
7
4
|
export declare function writeRedirect(res: ServerResponse, url: string, status?: number): void;
|
8
|
-
export
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
export declare function
|
5
|
+
export type WriteResponseOptions = {
|
6
|
+
status?: number;
|
7
|
+
contentType?: string;
|
8
|
+
};
|
9
|
+
export declare function writeStream(res: ServerResponse, stream: Readable, { status, contentType, }?: WriteResponseOptions): void;
|
10
|
+
export declare function writeBuffer(res: ServerResponse, chunk: string | Buffer, { status, contentType, }?: WriteResponseOptions): void;
|
11
|
+
export declare function writeJson(res: ServerResponse, payload: unknown, { contentType, ...options }?: WriteResponseOptions): void;
|
12
|
+
export declare function staticJsonMiddleware(value: unknown, { contentType, ...options }?: WriteResponseOptions): Handler<unknown>;
|
13
|
+
export declare function writeHtml(res: ServerResponse, html: Buffer | string, { contentType, ...options }?: WriteResponseOptions): void;
|
13
14
|
//# sourceMappingURL=response.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../src/lib/http/response.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../src/lib/http/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAY,MAAM,aAAa,CAAA;AAEhD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEpD,wBAAgB,YAAY,CAC1B,GAAG,EAAE,cAAc,EACnB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAChC,IAAI,CAQN;AAED,wBAAgB,aAAa,CAC3B,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,MAAM,EACX,MAAM,SAAM,GACX,IAAI,CAEN;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,wBAAgB,WAAW,CACzB,GAAG,EAAE,cAAc,EACnB,MAAM,EAAE,QAAQ,EAChB,EACE,MAAY,EACZ,WAAwC,GACzC,GAAE,oBAAyB,GAC3B,IAAI,CAYN;AAED,wBAAgB,WAAW,CACzB,GAAG,EAAE,cAAc,EACnB,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,EACE,MAAY,EACZ,WAAwC,GACzC,GAAE,oBAAyB,GAC3B,IAAI,CAIN;AAED,wBAAgB,SAAS,CACvB,GAAG,EAAE,cAAc,EACnB,OAAO,EAAE,OAAO,EAChB,EAAE,WAAgC,EAAE,GAAG,OAAO,EAAE,GAAE,oBAAyB,GAC1E,IAAI,CAGN;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,EAAE,WAAgC,EAAE,GAAG,OAAO,EAAE,GAAE,oBAAyB,GAC1E,OAAO,CAAC,OAAO,CAAC,CAMlB;AAED,wBAAgB,SAAS,CACvB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,EAAE,WAAyB,EAAE,GAAG,OAAO,EAAE,GAAE,oBAAyB,GACnE,IAAI,CAEN"}
|
@@ -1,9 +1,13 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.appendHeader = appendHeader;
|
4
|
+
exports.writeRedirect = writeRedirect;
|
5
|
+
exports.writeStream = writeStream;
|
6
|
+
exports.writeBuffer = writeBuffer;
|
7
|
+
exports.writeJson = writeJson;
|
8
|
+
exports.staticJsonMiddleware = staticJsonMiddleware;
|
9
|
+
exports.writeHtml = writeHtml;
|
4
10
|
const node_stream_1 = require("node:stream");
|
5
|
-
const promises_1 = require("node:stream/promises");
|
6
|
-
const node_zlib_1 = require("node:zlib");
|
7
11
|
function appendHeader(res, header, value) {
|
8
12
|
const existing = res.getHeader(header);
|
9
13
|
if (existing == null) {
|
@@ -14,85 +18,39 @@ function appendHeader(res, header, value) {
|
|
14
18
|
res.setHeader(header, arr.concat(value));
|
15
19
|
}
|
16
20
|
}
|
17
|
-
exports.appendHeader = appendHeader;
|
18
21
|
function writeRedirect(res, url, status = 302) {
|
19
22
|
res.writeHead(status, { Location: url }).end();
|
20
23
|
}
|
21
|
-
|
22
|
-
function negotiateEncoding(accept) {
|
23
|
-
if (accept?.includes('br'))
|
24
|
-
return 'br';
|
25
|
-
if (accept?.includes('gzip'))
|
26
|
-
return 'gzip';
|
27
|
-
return 'identity';
|
28
|
-
}
|
29
|
-
function getEncoder(encoding) {
|
30
|
-
switch (encoding) {
|
31
|
-
case 'br':
|
32
|
-
return (0, node_zlib_1.createBrotliCompress)({
|
33
|
-
// Default quality is too slow
|
34
|
-
params: { [node_zlib_1.constants.BROTLI_PARAM_QUALITY]: 5 },
|
35
|
-
});
|
36
|
-
case 'gzip':
|
37
|
-
return (0, node_zlib_1.createGzip)();
|
38
|
-
case 'identity':
|
39
|
-
return new node_stream_1.PassThrough();
|
40
|
-
default:
|
41
|
-
throw new Error(`Unsupported encoding: ${encoding}`);
|
42
|
-
}
|
43
|
-
}
|
44
|
-
const ifString = (value) => typeof value === 'string' ? value : undefined;
|
45
|
-
async function writeStream(res, stream, contentType = ifString(stream.headers?.['content-type']) ||
|
46
|
-
'application/octet-stream', status = 200) {
|
24
|
+
function writeStream(res, stream, { status = 200, contentType = 'application/octet-stream', } = {}) {
|
47
25
|
res.statusCode = status;
|
48
26
|
res.setHeader('content-type', contentType);
|
49
|
-
appendHeader(res, 'vary', 'accept-encoding');
|
50
|
-
const encoding = negotiateEncoding(res.req.headers['accept-encoding']);
|
51
|
-
res.setHeader('content-encoding', encoding);
|
52
|
-
res.setHeader('transfer-encoding', 'chunked');
|
53
27
|
if (res.req.method === 'HEAD') {
|
54
28
|
res.end();
|
55
29
|
stream.destroy();
|
56
|
-
return;
|
57
|
-
}
|
58
|
-
try {
|
59
|
-
await (0, promises_1.pipeline)(stream, getEncoder(encoding), res);
|
60
30
|
}
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
// If an abort signal is used, we can consider this function's job successful
|
66
|
-
if ('name' in err && err.name === 'AbortError')
|
67
|
-
return;
|
68
|
-
// If the client closes the connection, we don't care about the error
|
69
|
-
if ('code' in err && err.code === 'ERR_STREAM_PREMATURE_CLOSE')
|
70
|
-
return;
|
71
|
-
}
|
72
|
-
throw err;
|
31
|
+
else {
|
32
|
+
(0, node_stream_1.pipeline)([stream, res], (_err) => {
|
33
|
+
// The error will be propagated through the streams
|
34
|
+
});
|
73
35
|
}
|
74
36
|
}
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
37
|
+
function writeBuffer(res, chunk, { status = 200, contentType = 'application/octet-stream', } = {}) {
|
38
|
+
res.statusCode = status;
|
39
|
+
res.setHeader('content-type', contentType);
|
40
|
+
res.end(chunk);
|
79
41
|
}
|
80
|
-
|
81
|
-
async function writeJson(res, payload, status = 200, contentType = 'application/json') {
|
42
|
+
function writeJson(res, payload, { contentType = 'application/json', ...options } = {}) {
|
82
43
|
const buffer = Buffer.from(JSON.stringify(payload));
|
83
|
-
|
44
|
+
writeBuffer(res, buffer, { ...options, contentType });
|
84
45
|
}
|
85
|
-
|
86
|
-
function staticJsonHandler(value, contentType = 'application/json', status = 200) {
|
46
|
+
function staticJsonMiddleware(value, { contentType = 'application/json', ...options } = {}) {
|
87
47
|
const buffer = Buffer.from(JSON.stringify(value));
|
88
|
-
|
89
|
-
|
48
|
+
const staticOptions = { ...options, contentType };
|
49
|
+
return function (req, res) {
|
50
|
+
writeBuffer(res, buffer, staticOptions);
|
90
51
|
};
|
91
52
|
}
|
92
|
-
|
93
|
-
|
94
|
-
const buffer = Buffer.isBuffer(html) ? html : Buffer.from(html);
|
95
|
-
return writeBuffer(res, buffer, contentType, status);
|
53
|
+
function writeHtml(res, html, { contentType = 'text/html', ...options } = {}) {
|
54
|
+
writeBuffer(res, html, { ...options, contentType });
|
96
55
|
}
|
97
|
-
exports.writeHtml = writeHtml;
|
98
56
|
//# sourceMappingURL=response.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../../src/lib/http/response.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../../src/lib/http/response.ts"],"names":[],"mappings":";;AAIA,oCAYC;AAED,sCAMC;AAOD,kCAmBC;AAED,kCAWC;AAED,8BAOC;AAED,oDASC;AAED,8BAMC;AA3FD,6CAAgD;AAIhD,SAAgB,YAAY,CAC1B,GAAmB,EACnB,MAAc,EACd,KAAiC;IAEjC,MAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IACtC,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACrB,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IAC9B,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAA;QACnE,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IAC1C,CAAC;AACH,CAAC;AAED,SAAgB,aAAa,CAC3B,GAAmB,EACnB,GAAW,EACX,MAAM,GAAG,GAAG;IAE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SAAgB,oBAAoB,CAClC,KAAc,EACd,EAAE,WAAW,GAAG,kBAAkB,EAAE,GAAG,OAAO,KAA2B,EAAE;IAE3E,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;IACjD,MAAM,aAAa,GAAyB,EAAE,GAAG,OAAO,EAAE,WAAW,EAAE,CAAA;IACvE,OAAO,UAAU,GAAG,EAAE,GAAG;QACvB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,CAAC,CAAA;IACzC,CAAC,CAAA;AACH,CAAC;AAED,SAAgB,SAAS,CACvB,GAAmB,EACnB,IAAqB,EACrB,EAAE,WAAW,GAAG,WAAW,EAAE,GAAG,OAAO,KAA2B,EAAE;IAEpE,WAAW,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,WAAW,EAAE,CAAC,CAAA;AACrD,CAAC"}
|
package/dist/lib/http/route.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../src/lib/http/route.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../src/lib/http/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAuB,MAAM,aAAa,CAAA;AAErE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAqB,MAAM,WAAW,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAExE,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,MAAM,CAAC,CAAC,EAAE;IAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;CAAE,CAAC,CAAA;AAC9E,MAAM,MAAM,eAAe,CACzB,CAAC,EACD,CAAC,SAAS,MAAM,EAChB,GAAG,GAAG,eAAe,EACrB,GAAG,GAAG,cAAc,IAClB,UAAU,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;AAExC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CACzB,CAAC,SAAS,MAAM,EAChB,CAAC,GAAG,IAAI,EACR,GAAG,SAAS,eAAe,GAAG,eAAe,EAC7C,GAAG,SAAS,cAAc,GAAG,cAAc,EAE3C,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EACb,GAAG,EAAE,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GACvC,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAkBzB"}
|
package/dist/lib/http/route.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.createRoute =
|
3
|
+
exports.createRoute = createRoute;
|
4
4
|
const context_js_1 = require("./context.js");
|
5
5
|
const method_js_1 = require("./method.js");
|
6
6
|
const middleware_js_1 = require("./middleware.js");
|
@@ -35,5 +35,4 @@ function createRoute(method, path, ...mw) {
|
|
35
35
|
return next();
|
36
36
|
};
|
37
37
|
}
|
38
|
-
exports.createRoute = createRoute;
|
39
38
|
//# sourceMappingURL=route.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../src/lib/http/route.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../src/lib/http/route.ts"],"names":[],"mappings":";;AA4BA,kCA2BC;AAvDD,6CAA6C;AAC7C,2CAAqE;AACrE,mDAAoD;AACpD,uCAA2D;AAW3D;;;;;;;;;;;;;GAaG;AACH,SAAgB,WAAW,CAMzB,MAA0B,EAC1B,IAAa,EACb,GAAG,EAAqC;IAExC,MAAM,aAAa,GAAG,IAAA,2BAAiB,EAAI,IAAI,CAAC,CAAA;IAChD,MAAM,aAAa,GAAG,IAAA,+BAAmB,EAAC,MAAM,CAAC,CAAA;IAEjD,MAAM,UAAU,GAAG,IAAA,kCAAkB,EAAC,EAAE,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CAAA;IAEnE,OAAO,UAAU,GAAG,EAAE,GAAG,EAAE,IAAI;QAC7B,IAAI,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,QAAQ,GAAG,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAA;YAC9C,MAAM,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAA;YACtC,IAAI,MAAM,EAAE,CAAC;gBACX,MAAM,OAAO,GAAG,IAAA,mBAAM,EAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;gBAC9C,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;YACjD,CAAC;QACH,CAAC;QAED,OAAO,IAAI,EAAE,CAAA;IACf,CAAC,CAAA;AACH,CAAC"}
|
@@ -1,5 +1,3 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
/// <reference types="node" />
|
3
1
|
import { SubCtx } from './context.js';
|
4
2
|
import { MethodMatcherInput } from './method.js';
|
5
3
|
import { Params, Path } from './path.js';
|
@@ -14,9 +12,9 @@ export declare class Router<T = void, Req extends IncomingMessage = IncomingMess
|
|
14
12
|
private readonly middlewares;
|
15
13
|
constructor(url?: {
|
16
14
|
/** Used to build the origin of the {@link RouterCtx['url']} context property */
|
17
|
-
protocol?: string
|
15
|
+
protocol?: string;
|
18
16
|
/** Used to build the origin of the {@link RouterCtx['url']} context property */
|
19
|
-
host?: string
|
17
|
+
host?: string;
|
20
18
|
} | undefined);
|
21
19
|
use(...middlewares: RouterMiddleware<T, Req, Res>[]): this;
|
22
20
|
all<P extends Params = Params>(path: Path<P>, ...mw: RouteMiddleware<RouterCtx<T>, P, Req, Res>[]): this;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/lib/http/router.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/lib/http/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,eAAe,EAAe,MAAM,YAAY,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAExE,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE;IAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAA;CAAE,CAAC,CAAA;AAC5D,MAAM,MAAM,gBAAgB,CAC1B,CAAC,GAAG,IAAI,EACR,GAAG,GAAG,eAAe,EACrB,GAAG,GAAG,cAAc,IAClB,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;AAEtC,qBAAa,MAAM,CACjB,CAAC,GAAG,IAAI,EACR,GAAG,SAAS,eAAe,GAAG,eAAe,EAC7C,GAAG,SAAS,cAAc,GAAG,cAAc;IAKzC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;IAHvB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAsC;gBAG/C,GAAG,CAAC,EAAE;QACrB,gFAAgF;QAChF,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,gFAAgF;QAChF,IAAI,CAA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// <reference types="node" />
|
3
|
-
/// <reference types="node" />
|
4
1
|
import { IncomingMessage } from 'node:http';
|
5
2
|
import { Readable } from 'node:stream';
|
6
3
|
import { KnownNames, ParserResult } from './parser.js';
|
@@ -13,16 +10,14 @@ export declare function decodeHttpRequest(req: IncomingMessage): Readable;
|
|
13
10
|
*/
|
14
11
|
export declare function parseHttpRequest<A extends readonly KnownNames[]>(req: IncomingMessage, allow: A): Promise<ParserResult<Extract<{
|
15
12
|
readonly name: "json";
|
16
|
-
readonly test: (mime: string) => mime is
|
13
|
+
readonly test: (mime: string) => mime is `application/json` | `application/${string}+json`;
|
17
14
|
readonly parse: (buffer: Buffer, { charset }: import("./parser.js").ContentType) => import("./parser.js").Json;
|
18
15
|
}, {
|
19
16
|
name: A[number];
|
20
17
|
}> | Extract<{
|
21
18
|
readonly name: "urlencoded";
|
22
19
|
readonly test: (mime: string) => mime is "application/x-www-form-urlencoded";
|
23
|
-
readonly parse: (buffer: Buffer, { charset }: import("./parser.js").ContentType) => {
|
24
|
-
[x: string]: string | undefined;
|
25
|
-
};
|
20
|
+
readonly parse: (buffer: Buffer, { charset }: import("./parser.js").ContentType) => { [_ in string]?: string; };
|
26
21
|
}, {
|
27
22
|
name: A[number];
|
28
23
|
}> | Extract<{
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/lib/http/stream.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/lib/http/stream.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,EACL,UAAU,EAGV,YAAY,EAEb,MAAM,aAAa,CAAA;AAEpB,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,eAAe,GAAG,QAAQ,CAQhE;AAED;;;;;GAKG;AAEH,wBAAsB,gBAAgB,CAAC,CAAC,SAAS,SAAS,UAAU,EAAE,EACpE,GAAG,EAAE,eAAe,EACpB,KAAK,EAAE,CAAC;;;;;UAiBuB,CAAC,CAAC,MAAM,CAAC;;;;uGAGmrB,CAAC;;UAH7rB,CAAC,CAAC,MAAM,CAAC;;;;;;UAAT,CAAC,CAAC,MAAM,CAAC;KAEzC"}
|