@nexload-sdk/healthcheck-next 2.0.0 → 2.1.0
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 +2 -0
- package/dist/index.cjs +48 -1
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +47 -1
- package/dist/index.mjs.map +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -16,3 +16,5 @@ export const { GET, HEAD } = createNextHealthRoute(health, {
|
|
|
16
16
|
format: "json"
|
|
17
17
|
});
|
|
18
18
|
```
|
|
19
|
+
|
|
20
|
+
Protection is fail-closed. A supplied `protect` object must configure a non-empty bearer token, valid Basic credentials, or an IPv4 allowlist. IP and CIDR rules require `trustProxy: true`; only enable it when the configured proxy header is controlled by your deployment.
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @nexload-sdk/healthcheck-next
|
|
1
|
+
// @nexload-sdk/healthcheck-next v2.0.1 (build 2026-07-20T16:57:16.775Z)
|
|
2
2
|
"use strict";
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -79,6 +79,48 @@ function cidrContains(cidr, ip) {
|
|
|
79
79
|
const mask = bits === 0 ? 0 : 4294967295 << 32 - bits >>> 0;
|
|
80
80
|
return (rangeNumber & mask) === (ipNumber & mask);
|
|
81
81
|
}
|
|
82
|
+
function isValidCidr(cidr) {
|
|
83
|
+
const [
|
|
84
|
+
range,
|
|
85
|
+
bitsRaw
|
|
86
|
+
] = cidr.split("/");
|
|
87
|
+
const bits = Number(bitsRaw);
|
|
88
|
+
return ipToNumber(range ?? "") !== null && Number.isInteger(bits) && bits >= 0 && bits <= 32;
|
|
89
|
+
}
|
|
90
|
+
function invalidConfig(message) {
|
|
91
|
+
const error = new Error(message);
|
|
92
|
+
error.name = "HEALTHCHECK_INVALID_CONFIG";
|
|
93
|
+
return error;
|
|
94
|
+
}
|
|
95
|
+
function validateProtection(protection) {
|
|
96
|
+
var _a, _b, _c, _d, _e, _f;
|
|
97
|
+
if (!protection) return;
|
|
98
|
+
const hasBearer = "bearerToken" in protection;
|
|
99
|
+
const hasBasic = protection.basicAuth !== void 0;
|
|
100
|
+
const hasIps = (((_a = protection.allowIps) == null ? void 0 : _a.length) ?? 0) > 0;
|
|
101
|
+
const hasCidrs = (((_b = protection.allowCidrs) == null ? void 0 : _b.length) ?? 0) > 0;
|
|
102
|
+
if (!hasBearer && !hasBasic && !hasIps && !hasCidrs) {
|
|
103
|
+
throw invalidConfig("Route protection must configure at least one access policy.");
|
|
104
|
+
}
|
|
105
|
+
if (hasBearer && !((_c = protection.bearerToken) == null ? void 0 : _c.trim())) {
|
|
106
|
+
throw invalidConfig("Bearer token protection requires a non-empty token.");
|
|
107
|
+
}
|
|
108
|
+
if (hasBasic && (!((_d = protection.basicAuth) == null ? void 0 : _d.username.trim()) || !protection.basicAuth.password)) {
|
|
109
|
+
throw invalidConfig("Basic authentication requires a non-empty username and password.");
|
|
110
|
+
}
|
|
111
|
+
if (hasBearer && hasBasic) {
|
|
112
|
+
throw invalidConfig("Bearer and Basic authentication cannot share one Authorization header.");
|
|
113
|
+
}
|
|
114
|
+
if ((hasIps || hasCidrs) && protection.trustProxy !== true) {
|
|
115
|
+
throw invalidConfig("IP and CIDR protection require trustProxy: true.");
|
|
116
|
+
}
|
|
117
|
+
if ((_e = protection.allowIps) == null ? void 0 : _e.some((ip) => ipToNumber(ip) === null)) {
|
|
118
|
+
throw invalidConfig("IP protection currently accepts valid IPv4 addresses only.");
|
|
119
|
+
}
|
|
120
|
+
if ((_f = protection.allowCidrs) == null ? void 0 : _f.some((cidr) => !isValidCidr(cidr))) {
|
|
121
|
+
throw invalidConfig("CIDR protection currently accepts valid IPv4 CIDRs only.");
|
|
122
|
+
}
|
|
123
|
+
}
|
|
82
124
|
function getRequestIp(request, protection) {
|
|
83
125
|
var _a;
|
|
84
126
|
if (!protection.trustProxy) return null;
|
|
@@ -176,6 +218,10 @@ function summaryBody(report) {
|
|
|
176
218
|
});
|
|
177
219
|
}
|
|
178
220
|
function createNextHealthRoute(manager, options) {
|
|
221
|
+
validateProtection(options.protect);
|
|
222
|
+
if (options.cache !== void 0 && options.cache !== "no-store") {
|
|
223
|
+
throw invalidConfig("Health routes only support cache: no-store.");
|
|
224
|
+
}
|
|
179
225
|
async function handle(request, head = false) {
|
|
180
226
|
if (!isAuthorized(
|
|
181
227
|
request,
|
|
@@ -216,6 +262,7 @@ function createNextHealthRoute(manager, options) {
|
|
|
216
262
|
};
|
|
217
263
|
}
|
|
218
264
|
function createNextMetricsRoute(manager, options) {
|
|
265
|
+
validateProtection(options.protect);
|
|
219
266
|
return {
|
|
220
267
|
async GET(request) {
|
|
221
268
|
if (!isAuthorized(
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n DEFAULT_HTTP_STATUS_POLICY,\n statusToHttpStatus,\n stringifyHealthJson,\n toHealthJson\n} from \"@nexload-sdk/healthcheck\";\nimport {\n toOpenMetricsText,\n toPrometheusText\n} from \"@nexload-sdk/healthcheck-prometheus\";\n\nimport type {\n HealthHttpStatusPolicy,\n HealthManager,\n HealthReport,\n HealthRunScope,\n HealthScope\n} from \"@nexload-sdk/healthcheck\";\n\nexport interface NextHealthRouteProtection {\n bearerToken?: string\n basicAuth?: {\n username: string\n password: string\n }\n allowCidrs?: readonly string[]\n allowIps?: readonly string[]\n trustProxy?: boolean\n proxyHeader?: \"x-forwarded-for\" | \"x-real-ip\" | string\n}\n\nexport interface NextHealthRouteOptions {\n scope: HealthScope\n format?: \"json\" | \"summary\"\n httpStatus?: HealthHttpStatusPolicy\n includeDetails?: boolean | ((request: Request) => boolean)\n protect?: NextHealthRouteProtection\n headers?: HeadersInit | ((report: HealthReport) => HeadersInit)\n cache?: \"no-store\"\n}\n\nexport interface NextMetricsRouteOptions {\n format: \"prometheus\" | \"openmetrics\" | \"json\"\n scope?: HealthRunScope\n protect?: NextHealthRouteProtection\n prefix?: string\n defaultLabels?: Record<string, string>\n}\n\nfunction constantTimeEquals (\n input: string, expected: string\n): boolean {\n const encoder = new TextEncoder();\n const inputBytes = encoder.encode(input);\n const expectedBytes = encoder.encode(expected);\n const length = Math.max(\n inputBytes.length, expectedBytes.length\n );\n let mismatch = inputBytes.length === expectedBytes.length ? 0 : 1;\n\n for (let index = 0; index < length; index += 1) {\n mismatch |= (inputBytes[index] ?? 0) ^ (expectedBytes[index] ?? 0);\n }\n\n return mismatch === 0;\n}\n\nfunction parseBasicAuth (value: string | null): { username: string, password: string } | null {\n if (!value?.startsWith(\"Basic \")) return null;\n\n try {\n const decoded = atob(value.slice(\"Basic \".length));\n const separator = decoded.indexOf(\":\");\n if (separator === -1) return null;\n\n return {\n username: decoded.slice(\n 0, separator\n ),\n password: decoded.slice(separator + 1),\n };\n } catch {\n return null;\n }\n}\n\nfunction ipToNumber (ip: string): number | null {\n const parts = ip.split(\".\").map(Number);\n if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part) || part < 0 || part > 255)) {\n return null;\n }\n\n return (((parts[0] ?? 0) << 24) >>> 0) + ((parts[1] ?? 0) << 16) + ((parts[2] ?? 0) << 8) + (parts[3] ?? 0);\n}\n\nfunction cidrContains (\n cidr: string, ip: string\n): boolean {\n const [\n range,\n bitsRaw\n ] = cidr.split(\"/\");\n const bits = Number(bitsRaw);\n const rangeNumber = ipToNumber(range ?? \"\");\n const ipNumber = ipToNumber(ip);\n\n if (rangeNumber === null || ipNumber === null || !Number.isInteger(bits) || bits < 0 || bits > 32) {\n return false;\n }\n\n const mask = bits === 0 ? 0 : (0xffffffff << (32 - bits)) >>> 0;\n return (rangeNumber & mask) === (ipNumber & mask);\n}\n\nfunction getRequestIp (\n request: Request, protection: NextHealthRouteProtection\n): string | null {\n if (!protection.trustProxy) return null;\n\n const header = protection.proxyHeader ?? \"x-forwarded-for\";\n const value = request.headers.get(header);\n if (!value) return null;\n\n return value.split(\",\")[0]?.trim() ?? null;\n}\n\nfunction isAuthorized (\n request: Request, protection?: NextHealthRouteProtection\n): boolean {\n if (!protection) return true;\n\n if (protection.bearerToken) {\n const token = request.headers.get(\"authorization\")?.replace(\n /^Bearer\\s+/i, \"\"\n ) ?? \"\";\n if (!constantTimeEquals(\n token, protection.bearerToken\n )) {\n return false;\n }\n }\n\n if (protection.basicAuth) {\n const parsed = parseBasicAuth(request.headers.get(\"authorization\"));\n if (!parsed || !constantTimeEquals(\n parsed.username, protection.basicAuth.username\n ) || !constantTimeEquals(\n parsed.password, protection.basicAuth.password\n )) {\n return false;\n }\n }\n\n const ip = getRequestIp(\n request, protection\n );\n if (protection.allowIps?.length && (!ip || !protection.allowIps.includes(ip))) {\n return false;\n }\n\n if (protection.allowCidrs?.length && (!ip || !protection.allowCidrs.some((cidr) => cidrContains(\n cidr, ip\n )))) {\n return false;\n }\n\n return true;\n}\n\nfunction unauthorized (): Response {\n return new Response(\n JSON.stringify({\n code: \"HEALTHCHECK_ROUTE_UNAUTHORIZED\",\n message: \"Unauthorized.\",\n }), {\n status: 401,\n headers: {\n \"content-type\": \"application/json; charset=utf-8\",\n \"cache-control\": \"no-store, max-age=0\",\n },\n }\n );\n}\n\nfunction mergeHeaders (...headersList: Array<HeadersInit | undefined>): Headers {\n const headers = new Headers();\n\n for (const headersInit of headersList) {\n if (!headersInit) continue;\n new Headers(headersInit).forEach((\n value, key\n ) => headers.set(\n key, value\n ));\n }\n\n return headers;\n}\n\nfunction baseHeaders (\n report: HealthReport, contentType: string\n): HeadersInit {\n return {\n \"cache-control\": \"no-store, max-age=0\",\n \"content-type\": contentType,\n \"x-health-status\": report.status,\n \"x-health-scope\": String(report.scope),\n \"x-health-duration-ms\": report.durationMs.toFixed(2),\n \"x-health-service\": report.service.name,\n ...(report.service.instanceId ? { \"x-health-instance\": report.service.instanceId, } : {}),\n };\n}\n\nfunction summaryBody (report: HealthReport): string {\n return JSON.stringify({\n status: report.status,\n scope: report.scope,\n observedAt: report.observedAt,\n durationMs: report.durationMs,\n summary: report.summary,\n });\n}\n\nexport function createNextHealthRoute (\n manager: HealthManager, options: NextHealthRouteOptions\n): {\n GET: (request: Request) => Promise<Response>\n HEAD: (request: Request) => Promise<Response>\n} {\n async function handle (\n request: Request, head = false\n ): Promise<Response> {\n if (!isAuthorized(\n request, options.protect\n )) {\n return unauthorized();\n }\n\n const report = await manager.run(options.scope);\n const includeDetails = typeof options.includeDetails === \"function\"\n ? options.includeDetails(request)\n : options.includeDetails ?? false;\n const body = options.format === \"summary\"\n ? summaryBody(report)\n : stringifyHealthJson(\n report, { includeDetails, }\n );\n const headers = mergeHeaders(\n baseHeaders(\n report, \"application/json; charset=utf-8\"\n ), typeof options.headers === \"function\" ? options.headers(report) : options.headers\n );\n\n return new Response(\n head ? null : body, {\n status: statusToHttpStatus(\n report.status, options.httpStatus ?? DEFAULT_HTTP_STATUS_POLICY\n ),\n headers,\n }\n );\n }\n\n return {\n GET: (request) => handle(request),\n HEAD: (request) => handle(\n request, true\n ),\n };\n}\n\nexport function createNextMetricsRoute (\n manager: HealthManager, options: NextMetricsRouteOptions\n): { GET: (request: Request) => Promise<Response> } {\n return {\n async GET (request) {\n if (!isAuthorized(\n request, options.protect\n )) {\n return unauthorized();\n }\n\n const report = await manager.run(\n options.scope ?? \"all\", { profile: \"monitoring\", }\n );\n const contentType = options.format === \"json\"\n ? \"application/json; charset=utf-8\"\n : options.format === \"openmetrics\"\n ? \"application/openmetrics-text; version=1.0.0; charset=utf-8\"\n : \"text/plain; version=0.0.4; charset=utf-8\";\n const body = options.format === \"json\"\n ? JSON.stringify(toHealthJson(\n report, { includeDetails: false, }\n ))\n : options.format === \"openmetrics\"\n ? toOpenMetricsText(\n report, { prefix: options.prefix, defaultLabels: options.defaultLabels, }\n )\n : toPrometheusText(\n report, { prefix: options.prefix, defaultLabels: options.defaultLabels, }\n );\n\n return new Response(\n body, {\n status: 200,\n headers: baseHeaders(\n report, contentType\n ),\n }\n );\n },\n };\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAKO;AACP,oCAGO;AAwCP,SAAS,mBACP,OAAe,UACN;AACT,QAAM,UAAU,IAAI,YAAY;AAChC,QAAM,aAAa,QAAQ,OAAO,KAAK;AACvC,QAAM,gBAAgB,QAAQ,OAAO,QAAQ;AAC7C,QAAM,SAAS,KAAK;AAAA,IAClB,WAAW;AAAA,IAAQ,cAAc;AAAA,EACnC;AACA,MAAI,WAAW,WAAW,WAAW,cAAc,SAAS,IAAI;AAEhE,WAAS,QAAQ,GAAG,QAAQ,QAAQ,SAAS,GAAG;AAC9C,iBAAa,WAAW,KAAK,KAAK,MAAM,cAAc,KAAK,KAAK;AAAA,EAClE;AAEA,SAAO,aAAa;AACtB;AAEA,SAAS,eAAgB,OAAqE;AAC5F,MAAI,EAAC,+BAAO,WAAW,WAAW,QAAO;AAEzC,MAAI;AACF,UAAM,UAAU,KAAK,MAAM,MAAM,SAAS,MAAM,CAAC;AACjD,UAAM,YAAY,QAAQ,QAAQ,GAAG;AACrC,QAAI,cAAc,GAAI,QAAO;AAE7B,WAAO;AAAA,MACL,UAAU,QAAQ;AAAA,QAChB;AAAA,QAAG;AAAA,MACL;AAAA,MACA,UAAU,QAAQ,MAAM,YAAY,CAAC;AAAA,IACvC;AAAA,EACF,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,SAAS,WAAY,IAA2B;AAC9C,QAAM,QAAQ,GAAG,MAAM,GAAG,EAAE,IAAI,MAAM;AACtC,MAAI,MAAM,WAAW,KAAK,MAAM,KAAK,CAAC,SAAS,CAAC,OAAO,UAAU,IAAI,KAAK,OAAO,KAAK,OAAO,GAAG,GAAG;AACjG,WAAO;AAAA,EACT;AAEA,WAAU,MAAM,CAAC,KAAK,MAAM,OAAQ,OAAO,MAAM,CAAC,KAAK,MAAM,QAAQ,MAAM,CAAC,KAAK,MAAM,MAAM,MAAM,CAAC,KAAK;AAC3G;AAEA,SAAS,aACP,MAAc,IACL;AACT,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,EACF,IAAI,KAAK,MAAM,GAAG;AAClB,QAAM,OAAO,OAAO,OAAO;AAC3B,QAAM,cAAc,WAAW,SAAS,EAAE;AAC1C,QAAM,WAAW,WAAW,EAAE;AAE9B,MAAI,gBAAgB,QAAQ,aAAa,QAAQ,CAAC,OAAO,UAAU,IAAI,KAAK,OAAO,KAAK,OAAO,IAAI;AACjG,WAAO;AAAA,EACT;AAEA,QAAM,OAAO,SAAS,IAAI,IAAK,cAAe,KAAK,SAAW;AAC9D,UAAQ,cAAc,WAAW,WAAW;AAC9C;AAEA,SAAS,aACP,SAAkB,YACH;
|
|
4
|
+
"sourcesContent": ["import {\n DEFAULT_HTTP_STATUS_POLICY,\n statusToHttpStatus,\n stringifyHealthJson,\n toHealthJson\n} from \"@nexload-sdk/healthcheck\";\nimport {\n toOpenMetricsText,\n toPrometheusText\n} from \"@nexload-sdk/healthcheck-prometheus\";\n\nimport type {\n HealthHttpStatusPolicy,\n HealthManager,\n HealthReport,\n HealthRunScope,\n HealthScope\n} from \"@nexload-sdk/healthcheck\";\n\nexport interface NextHealthRouteProtection {\n bearerToken?: string\n basicAuth?: {\n username: string\n password: string\n }\n allowCidrs?: readonly string[]\n allowIps?: readonly string[]\n trustProxy?: boolean\n proxyHeader?: \"x-forwarded-for\" | \"x-real-ip\" | string\n}\n\nexport interface NextHealthRouteOptions {\n scope: HealthScope\n format?: \"json\" | \"summary\"\n httpStatus?: HealthHttpStatusPolicy\n includeDetails?: boolean | ((request: Request) => boolean)\n protect?: NextHealthRouteProtection\n headers?: HeadersInit | ((report: HealthReport) => HeadersInit)\n cache?: \"no-store\"\n}\n\nexport interface NextMetricsRouteOptions {\n format: \"prometheus\" | \"openmetrics\" | \"json\"\n scope?: HealthRunScope\n protect?: NextHealthRouteProtection\n prefix?: string\n defaultLabels?: Record<string, string>\n}\n\nfunction constantTimeEquals (\n input: string, expected: string\n): boolean {\n const encoder = new TextEncoder();\n const inputBytes = encoder.encode(input);\n const expectedBytes = encoder.encode(expected);\n const length = Math.max(\n inputBytes.length, expectedBytes.length\n );\n let mismatch = inputBytes.length === expectedBytes.length ? 0 : 1;\n\n for (let index = 0; index < length; index += 1) {\n mismatch |= (inputBytes[index] ?? 0) ^ (expectedBytes[index] ?? 0);\n }\n\n return mismatch === 0;\n}\n\nfunction parseBasicAuth (value: string | null): { username: string, password: string } | null {\n if (!value?.startsWith(\"Basic \")) return null;\n\n try {\n const decoded = atob(value.slice(\"Basic \".length));\n const separator = decoded.indexOf(\":\");\n if (separator === -1) return null;\n\n return {\n username: decoded.slice(\n 0, separator\n ),\n password: decoded.slice(separator + 1),\n };\n } catch {\n return null;\n }\n}\n\nfunction ipToNumber (ip: string): number | null {\n const parts = ip.split(\".\").map(Number);\n if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part) || part < 0 || part > 255)) {\n return null;\n }\n\n return (((parts[0] ?? 0) << 24) >>> 0) + ((parts[1] ?? 0) << 16) + ((parts[2] ?? 0) << 8) + (parts[3] ?? 0);\n}\n\nfunction cidrContains (\n cidr: string, ip: string\n): boolean {\n const [\n range,\n bitsRaw\n ] = cidr.split(\"/\");\n const bits = Number(bitsRaw);\n const rangeNumber = ipToNumber(range ?? \"\");\n const ipNumber = ipToNumber(ip);\n\n if (rangeNumber === null || ipNumber === null || !Number.isInteger(bits) || bits < 0 || bits > 32) {\n return false;\n }\n\n const mask = bits === 0 ? 0 : (0xffffffff << (32 - bits)) >>> 0;\n return (rangeNumber & mask) === (ipNumber & mask);\n}\n\nfunction isValidCidr (cidr: string): boolean {\n const [\n range,\n bitsRaw\n ] = cidr.split(\"/\");\n const bits = Number(bitsRaw);\n\n return ipToNumber(range ?? \"\") !== null\n && Number.isInteger(bits)\n && bits >= 0\n && bits <= 32;\n}\n\nfunction invalidConfig (message: string): Error {\n const error = new Error(message);\n error.name = \"HEALTHCHECK_INVALID_CONFIG\";\n return error;\n}\n\nfunction validateProtection (protection?: NextHealthRouteProtection): void {\n if (!protection) return;\n\n const hasBearer = \"bearerToken\" in protection;\n const hasBasic = protection.basicAuth !== undefined;\n const hasIps = (protection.allowIps?.length ?? 0) > 0;\n const hasCidrs = (protection.allowCidrs?.length ?? 0) > 0;\n\n if (!hasBearer && !hasBasic && !hasIps && !hasCidrs) {\n throw invalidConfig(\"Route protection must configure at least one access policy.\");\n }\n\n if (hasBearer && !protection.bearerToken?.trim()) {\n throw invalidConfig(\"Bearer token protection requires a non-empty token.\");\n }\n\n if (hasBasic && (!protection.basicAuth?.username.trim() || !protection.basicAuth.password)) {\n throw invalidConfig(\"Basic authentication requires a non-empty username and password.\");\n }\n\n if (hasBearer && hasBasic) {\n throw invalidConfig(\"Bearer and Basic authentication cannot share one Authorization header.\");\n }\n\n if ((hasIps || hasCidrs) && protection.trustProxy !== true) {\n throw invalidConfig(\"IP and CIDR protection require trustProxy: true.\");\n }\n\n if (protection.allowIps?.some((ip) => ipToNumber(ip) === null)) {\n throw invalidConfig(\"IP protection currently accepts valid IPv4 addresses only.\");\n }\n\n if (protection.allowCidrs?.some((cidr) => !isValidCidr(cidr))) {\n throw invalidConfig(\"CIDR protection currently accepts valid IPv4 CIDRs only.\");\n }\n}\n\nfunction getRequestIp (\n request: Request, protection: NextHealthRouteProtection\n): string | null {\n if (!protection.trustProxy) return null;\n\n const header = protection.proxyHeader ?? \"x-forwarded-for\";\n const value = request.headers.get(header);\n if (!value) return null;\n\n return value.split(\",\")[0]?.trim() ?? null;\n}\n\nfunction isAuthorized (\n request: Request, protection?: NextHealthRouteProtection\n): boolean {\n if (!protection) return true;\n\n if (protection.bearerToken) {\n const token = request.headers.get(\"authorization\")?.replace(\n /^Bearer\\s+/i, \"\"\n ) ?? \"\";\n if (!constantTimeEquals(\n token, protection.bearerToken\n )) {\n return false;\n }\n }\n\n if (protection.basicAuth) {\n const parsed = parseBasicAuth(request.headers.get(\"authorization\"));\n if (!parsed || !constantTimeEquals(\n parsed.username, protection.basicAuth.username\n ) || !constantTimeEquals(\n parsed.password, protection.basicAuth.password\n )) {\n return false;\n }\n }\n\n const ip = getRequestIp(\n request, protection\n );\n if (protection.allowIps?.length && (!ip || !protection.allowIps.includes(ip))) {\n return false;\n }\n\n if (protection.allowCidrs?.length && (!ip || !protection.allowCidrs.some((cidr) => cidrContains(\n cidr, ip\n )))) {\n return false;\n }\n\n return true;\n}\n\nfunction unauthorized (): Response {\n return new Response(\n JSON.stringify({\n code: \"HEALTHCHECK_ROUTE_UNAUTHORIZED\",\n message: \"Unauthorized.\",\n }), {\n status: 401,\n headers: {\n \"content-type\": \"application/json; charset=utf-8\",\n \"cache-control\": \"no-store, max-age=0\",\n },\n }\n );\n}\n\nfunction mergeHeaders (...headersList: Array<HeadersInit | undefined>): Headers {\n const headers = new Headers();\n\n for (const headersInit of headersList) {\n if (!headersInit) continue;\n new Headers(headersInit).forEach((\n value, key\n ) => headers.set(\n key, value\n ));\n }\n\n return headers;\n}\n\nfunction baseHeaders (\n report: HealthReport, contentType: string\n): HeadersInit {\n return {\n \"cache-control\": \"no-store, max-age=0\",\n \"content-type\": contentType,\n \"x-health-status\": report.status,\n \"x-health-scope\": String(report.scope),\n \"x-health-duration-ms\": report.durationMs.toFixed(2),\n \"x-health-service\": report.service.name,\n ...(report.service.instanceId ? { \"x-health-instance\": report.service.instanceId, } : {}),\n };\n}\n\nfunction summaryBody (report: HealthReport): string {\n return JSON.stringify({\n status: report.status,\n scope: report.scope,\n observedAt: report.observedAt,\n durationMs: report.durationMs,\n summary: report.summary,\n });\n}\n\nexport function createNextHealthRoute (\n manager: HealthManager, options: NextHealthRouteOptions\n): {\n GET: (request: Request) => Promise<Response>\n HEAD: (request: Request) => Promise<Response>\n} {\n validateProtection(options.protect);\n\n if (options.cache !== undefined && options.cache !== \"no-store\") {\n throw invalidConfig(\"Health routes only support cache: no-store.\");\n }\n\n async function handle (\n request: Request, head = false\n ): Promise<Response> {\n if (!isAuthorized(\n request, options.protect\n )) {\n return unauthorized();\n }\n\n const report = await manager.run(options.scope);\n const includeDetails = typeof options.includeDetails === \"function\"\n ? options.includeDetails(request)\n : options.includeDetails ?? false;\n const body = options.format === \"summary\"\n ? summaryBody(report)\n : stringifyHealthJson(\n report, { includeDetails, }\n );\n const headers = mergeHeaders(\n baseHeaders(\n report, \"application/json; charset=utf-8\"\n ), typeof options.headers === \"function\" ? options.headers(report) : options.headers\n );\n\n return new Response(\n head ? null : body, {\n status: statusToHttpStatus(\n report.status, options.httpStatus ?? DEFAULT_HTTP_STATUS_POLICY\n ),\n headers,\n }\n );\n }\n\n return {\n GET: (request) => handle(request),\n HEAD: (request) => handle(\n request, true\n ),\n };\n}\n\nexport function createNextMetricsRoute (\n manager: HealthManager, options: NextMetricsRouteOptions\n): { GET: (request: Request) => Promise<Response> } {\n validateProtection(options.protect);\n\n return {\n async GET (request) {\n if (!isAuthorized(\n request, options.protect\n )) {\n return unauthorized();\n }\n\n const report = await manager.run(\n options.scope ?? \"all\", { profile: \"monitoring\", }\n );\n const contentType = options.format === \"json\"\n ? \"application/json; charset=utf-8\"\n : options.format === \"openmetrics\"\n ? \"application/openmetrics-text; version=1.0.0; charset=utf-8\"\n : \"text/plain; version=0.0.4; charset=utf-8\";\n const body = options.format === \"json\"\n ? JSON.stringify(toHealthJson(\n report, { includeDetails: false, }\n ))\n : options.format === \"openmetrics\"\n ? toOpenMetricsText(\n report, { prefix: options.prefix, defaultLabels: options.defaultLabels, }\n )\n : toPrometheusText(\n report, { prefix: options.prefix, defaultLabels: options.defaultLabels, }\n );\n\n return new Response(\n body, {\n status: 200,\n headers: baseHeaders(\n report, contentType\n ),\n }\n );\n },\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;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
|
3
3
|
// src/index.ts
|
|
4
4
|
import {
|
|
@@ -63,6 +63,47 @@ function cidrContains(cidr, ip) {
|
|
|
63
63
|
const mask = bits === 0 ? 0 : 4294967295 << 32 - bits >>> 0;
|
|
64
64
|
return (rangeNumber & mask) === (ipNumber & mask);
|
|
65
65
|
}
|
|
66
|
+
function isValidCidr(cidr) {
|
|
67
|
+
const [
|
|
68
|
+
range,
|
|
69
|
+
bitsRaw
|
|
70
|
+
] = cidr.split("/");
|
|
71
|
+
const bits = Number(bitsRaw);
|
|
72
|
+
return ipToNumber(range ?? "") !== null && Number.isInteger(bits) && bits >= 0 && bits <= 32;
|
|
73
|
+
}
|
|
74
|
+
function invalidConfig(message) {
|
|
75
|
+
const error = new Error(message);
|
|
76
|
+
error.name = "HEALTHCHECK_INVALID_CONFIG";
|
|
77
|
+
return error;
|
|
78
|
+
}
|
|
79
|
+
function validateProtection(protection) {
|
|
80
|
+
if (!protection) return;
|
|
81
|
+
const hasBearer = "bearerToken" in protection;
|
|
82
|
+
const hasBasic = protection.basicAuth !== void 0;
|
|
83
|
+
const hasIps = (protection.allowIps?.length ?? 0) > 0;
|
|
84
|
+
const hasCidrs = (protection.allowCidrs?.length ?? 0) > 0;
|
|
85
|
+
if (!hasBearer && !hasBasic && !hasIps && !hasCidrs) {
|
|
86
|
+
throw invalidConfig("Route protection must configure at least one access policy.");
|
|
87
|
+
}
|
|
88
|
+
if (hasBearer && !protection.bearerToken?.trim()) {
|
|
89
|
+
throw invalidConfig("Bearer token protection requires a non-empty token.");
|
|
90
|
+
}
|
|
91
|
+
if (hasBasic && (!protection.basicAuth?.username.trim() || !protection.basicAuth.password)) {
|
|
92
|
+
throw invalidConfig("Basic authentication requires a non-empty username and password.");
|
|
93
|
+
}
|
|
94
|
+
if (hasBearer && hasBasic) {
|
|
95
|
+
throw invalidConfig("Bearer and Basic authentication cannot share one Authorization header.");
|
|
96
|
+
}
|
|
97
|
+
if ((hasIps || hasCidrs) && protection.trustProxy !== true) {
|
|
98
|
+
throw invalidConfig("IP and CIDR protection require trustProxy: true.");
|
|
99
|
+
}
|
|
100
|
+
if (protection.allowIps?.some((ip) => ipToNumber(ip) === null)) {
|
|
101
|
+
throw invalidConfig("IP protection currently accepts valid IPv4 addresses only.");
|
|
102
|
+
}
|
|
103
|
+
if (protection.allowCidrs?.some((cidr) => !isValidCidr(cidr))) {
|
|
104
|
+
throw invalidConfig("CIDR protection currently accepts valid IPv4 CIDRs only.");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
66
107
|
function getRequestIp(request, protection) {
|
|
67
108
|
if (!protection.trustProxy) return null;
|
|
68
109
|
const header = protection.proxyHeader ?? "x-forwarded-for";
|
|
@@ -158,6 +199,10 @@ function summaryBody(report) {
|
|
|
158
199
|
});
|
|
159
200
|
}
|
|
160
201
|
function createNextHealthRoute(manager, options) {
|
|
202
|
+
validateProtection(options.protect);
|
|
203
|
+
if (options.cache !== void 0 && options.cache !== "no-store") {
|
|
204
|
+
throw invalidConfig("Health routes only support cache: no-store.");
|
|
205
|
+
}
|
|
161
206
|
async function handle(request, head = false) {
|
|
162
207
|
if (!isAuthorized(
|
|
163
208
|
request,
|
|
@@ -198,6 +243,7 @@ function createNextHealthRoute(manager, options) {
|
|
|
198
243
|
};
|
|
199
244
|
}
|
|
200
245
|
function createNextMetricsRoute(manager, options) {
|
|
246
|
+
validateProtection(options.protect);
|
|
201
247
|
return {
|
|
202
248
|
async GET(request) {
|
|
203
249
|
if (!isAuthorized(
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n DEFAULT_HTTP_STATUS_POLICY,\n statusToHttpStatus,\n stringifyHealthJson,\n toHealthJson\n} from \"@nexload-sdk/healthcheck\";\nimport {\n toOpenMetricsText,\n toPrometheusText\n} from \"@nexload-sdk/healthcheck-prometheus\";\n\nimport type {\n HealthHttpStatusPolicy,\n HealthManager,\n HealthReport,\n HealthRunScope,\n HealthScope\n} from \"@nexload-sdk/healthcheck\";\n\nexport interface NextHealthRouteProtection {\n bearerToken?: string\n basicAuth?: {\n username: string\n password: string\n }\n allowCidrs?: readonly string[]\n allowIps?: readonly string[]\n trustProxy?: boolean\n proxyHeader?: \"x-forwarded-for\" | \"x-real-ip\" | string\n}\n\nexport interface NextHealthRouteOptions {\n scope: HealthScope\n format?: \"json\" | \"summary\"\n httpStatus?: HealthHttpStatusPolicy\n includeDetails?: boolean | ((request: Request) => boolean)\n protect?: NextHealthRouteProtection\n headers?: HeadersInit | ((report: HealthReport) => HeadersInit)\n cache?: \"no-store\"\n}\n\nexport interface NextMetricsRouteOptions {\n format: \"prometheus\" | \"openmetrics\" | \"json\"\n scope?: HealthRunScope\n protect?: NextHealthRouteProtection\n prefix?: string\n defaultLabels?: Record<string, string>\n}\n\nfunction constantTimeEquals (\n input: string, expected: string\n): boolean {\n const encoder = new TextEncoder();\n const inputBytes = encoder.encode(input);\n const expectedBytes = encoder.encode(expected);\n const length = Math.max(\n inputBytes.length, expectedBytes.length\n );\n let mismatch = inputBytes.length === expectedBytes.length ? 0 : 1;\n\n for (let index = 0; index < length; index += 1) {\n mismatch |= (inputBytes[index] ?? 0) ^ (expectedBytes[index] ?? 0);\n }\n\n return mismatch === 0;\n}\n\nfunction parseBasicAuth (value: string | null): { username: string, password: string } | null {\n if (!value?.startsWith(\"Basic \")) return null;\n\n try {\n const decoded = atob(value.slice(\"Basic \".length));\n const separator = decoded.indexOf(\":\");\n if (separator === -1) return null;\n\n return {\n username: decoded.slice(\n 0, separator\n ),\n password: decoded.slice(separator + 1),\n };\n } catch {\n return null;\n }\n}\n\nfunction ipToNumber (ip: string): number | null {\n const parts = ip.split(\".\").map(Number);\n if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part) || part < 0 || part > 255)) {\n return null;\n }\n\n return (((parts[0] ?? 0) << 24) >>> 0) + ((parts[1] ?? 0) << 16) + ((parts[2] ?? 0) << 8) + (parts[3] ?? 0);\n}\n\nfunction cidrContains (\n cidr: string, ip: string\n): boolean {\n const [\n range,\n bitsRaw\n ] = cidr.split(\"/\");\n const bits = Number(bitsRaw);\n const rangeNumber = ipToNumber(range ?? \"\");\n const ipNumber = ipToNumber(ip);\n\n if (rangeNumber === null || ipNumber === null || !Number.isInteger(bits) || bits < 0 || bits > 32) {\n return false;\n }\n\n const mask = bits === 0 ? 0 : (0xffffffff << (32 - bits)) >>> 0;\n return (rangeNumber & mask) === (ipNumber & mask);\n}\n\nfunction getRequestIp (\n request: Request, protection: NextHealthRouteProtection\n): string | null {\n if (!protection.trustProxy) return null;\n\n const header = protection.proxyHeader ?? \"x-forwarded-for\";\n const value = request.headers.get(header);\n if (!value) return null;\n\n return value.split(\",\")[0]?.trim() ?? null;\n}\n\nfunction isAuthorized (\n request: Request, protection?: NextHealthRouteProtection\n): boolean {\n if (!protection) return true;\n\n if (protection.bearerToken) {\n const token = request.headers.get(\"authorization\")?.replace(\n /^Bearer\\s+/i, \"\"\n ) ?? \"\";\n if (!constantTimeEquals(\n token, protection.bearerToken\n )) {\n return false;\n }\n }\n\n if (protection.basicAuth) {\n const parsed = parseBasicAuth(request.headers.get(\"authorization\"));\n if (!parsed || !constantTimeEquals(\n parsed.username, protection.basicAuth.username\n ) || !constantTimeEquals(\n parsed.password, protection.basicAuth.password\n )) {\n return false;\n }\n }\n\n const ip = getRequestIp(\n request, protection\n );\n if (protection.allowIps?.length && (!ip || !protection.allowIps.includes(ip))) {\n return false;\n }\n\n if (protection.allowCidrs?.length && (!ip || !protection.allowCidrs.some((cidr) => cidrContains(\n cidr, ip\n )))) {\n return false;\n }\n\n return true;\n}\n\nfunction unauthorized (): Response {\n return new Response(\n JSON.stringify({\n code: \"HEALTHCHECK_ROUTE_UNAUTHORIZED\",\n message: \"Unauthorized.\",\n }), {\n status: 401,\n headers: {\n \"content-type\": \"application/json; charset=utf-8\",\n \"cache-control\": \"no-store, max-age=0\",\n },\n }\n );\n}\n\nfunction mergeHeaders (...headersList: Array<HeadersInit | undefined>): Headers {\n const headers = new Headers();\n\n for (const headersInit of headersList) {\n if (!headersInit) continue;\n new Headers(headersInit).forEach((\n value, key\n ) => headers.set(\n key, value\n ));\n }\n\n return headers;\n}\n\nfunction baseHeaders (\n report: HealthReport, contentType: string\n): HeadersInit {\n return {\n \"cache-control\": \"no-store, max-age=0\",\n \"content-type\": contentType,\n \"x-health-status\": report.status,\n \"x-health-scope\": String(report.scope),\n \"x-health-duration-ms\": report.durationMs.toFixed(2),\n \"x-health-service\": report.service.name,\n ...(report.service.instanceId ? { \"x-health-instance\": report.service.instanceId, } : {}),\n };\n}\n\nfunction summaryBody (report: HealthReport): string {\n return JSON.stringify({\n status: report.status,\n scope: report.scope,\n observedAt: report.observedAt,\n durationMs: report.durationMs,\n summary: report.summary,\n });\n}\n\nexport function createNextHealthRoute (\n manager: HealthManager, options: NextHealthRouteOptions\n): {\n GET: (request: Request) => Promise<Response>\n HEAD: (request: Request) => Promise<Response>\n} {\n async function handle (\n request: Request, head = false\n ): Promise<Response> {\n if (!isAuthorized(\n request, options.protect\n )) {\n return unauthorized();\n }\n\n const report = await manager.run(options.scope);\n const includeDetails = typeof options.includeDetails === \"function\"\n ? options.includeDetails(request)\n : options.includeDetails ?? false;\n const body = options.format === \"summary\"\n ? summaryBody(report)\n : stringifyHealthJson(\n report, { includeDetails, }\n );\n const headers = mergeHeaders(\n baseHeaders(\n report, \"application/json; charset=utf-8\"\n ), typeof options.headers === \"function\" ? options.headers(report) : options.headers\n );\n\n return new Response(\n head ? null : body, {\n status: statusToHttpStatus(\n report.status, options.httpStatus ?? DEFAULT_HTTP_STATUS_POLICY\n ),\n headers,\n }\n );\n }\n\n return {\n GET: (request) => handle(request),\n HEAD: (request) => handle(\n request, true\n ),\n };\n}\n\nexport function createNextMetricsRoute (\n manager: HealthManager, options: NextMetricsRouteOptions\n): { GET: (request: Request) => Promise<Response> } {\n return {\n async GET (request) {\n if (!isAuthorized(\n request, options.protect\n )) {\n return unauthorized();\n }\n\n const report = await manager.run(\n options.scope ?? \"all\", { profile: \"monitoring\", }\n );\n const contentType = options.format === \"json\"\n ? \"application/json; charset=utf-8\"\n : options.format === \"openmetrics\"\n ? \"application/openmetrics-text; version=1.0.0; charset=utf-8\"\n : \"text/plain; version=0.0.4; charset=utf-8\";\n const body = options.format === \"json\"\n ? JSON.stringify(toHealthJson(\n report, { includeDetails: false, }\n ))\n : options.format === \"openmetrics\"\n ? toOpenMetricsText(\n report, { prefix: options.prefix, defaultLabels: options.defaultLabels, }\n )\n : toPrometheusText(\n report, { prefix: options.prefix, defaultLabels: options.defaultLabels, }\n );\n\n return new Response(\n body, {\n status: 200,\n headers: baseHeaders(\n report, contentType\n ),\n }\n );\n },\n };\n}\n"],
|
|
5
|
-
"mappings": ";;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAwCP,SAAS,mBACP,OAAe,UACN;AACT,QAAM,UAAU,IAAI,YAAY;AAChC,QAAM,aAAa,QAAQ,OAAO,KAAK;AACvC,QAAM,gBAAgB,QAAQ,OAAO,QAAQ;AAC7C,QAAM,SAAS,KAAK;AAAA,IAClB,WAAW;AAAA,IAAQ,cAAc;AAAA,EACnC;AACA,MAAI,WAAW,WAAW,WAAW,cAAc,SAAS,IAAI;AAEhE,WAAS,QAAQ,GAAG,QAAQ,QAAQ,SAAS,GAAG;AAC9C,iBAAa,WAAW,KAAK,KAAK,MAAM,cAAc,KAAK,KAAK;AAAA,EAClE;AAEA,SAAO,aAAa;AACtB;AAEA,SAAS,eAAgB,OAAqE;AAC5F,MAAI,CAAC,OAAO,WAAW,QAAQ,EAAG,QAAO;AAEzC,MAAI;AACF,UAAM,UAAU,KAAK,MAAM,MAAM,SAAS,MAAM,CAAC;AACjD,UAAM,YAAY,QAAQ,QAAQ,GAAG;AACrC,QAAI,cAAc,GAAI,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,cAAc;AAAA,QACvC;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,KAAK,CAAC,YAAY,OAAO,OAAO;AAAA,IAChC,MAAM,CAAC,YAAY;AAAA,MACjB;AAAA,MAAS;AAAA,IACX;AAAA,EACF;AACF;AAEO,SAAS,uBACd,SAAwB,SAC0B;AAClD,SAAO;AAAA,IACL,MAAM,IAAK,SAAS;AAClB,UAAI,CAAC;AAAA,QACH;AAAA,QAAS,QAAQ;AAAA,MACnB,GAAG;AACD,eAAO,aAAa;AAAA,MACtB;AAEA,YAAM,SAAS,MAAM,QAAQ;AAAA,QAC3B,QAAQ,SAAS;AAAA,QAAO,EAAE,SAAS,aAAc;AAAA,MACnD;AACA,YAAM,cAAc,QAAQ,WAAW,SACnC,oCACA,QAAQ,WAAW,gBACjB,+DACA;AACN,YAAM,OAAO,QAAQ,WAAW,SAC5B,KAAK,UAAU;AAAA,QACf;AAAA,QAAQ,EAAE,gBAAgB,MAAO;AAAA,MACnC,CAAC,IACC,QAAQ,WAAW,gBACjB;AAAA,QACA;AAAA,QAAQ,EAAE,QAAQ,QAAQ,QAAQ,eAAe,QAAQ,cAAe;AAAA,MAC1E,IACE;AAAA,QACA;AAAA,QAAQ,EAAE,QAAQ,QAAQ,QAAQ,eAAe,QAAQ,cAAe;AAAA,MAC1E;AAEJ,aAAO,IAAI;AAAA,QACT;AAAA,QAAM;AAAA,UACJ,QAAQ;AAAA,UACR,SAAS;AAAA,YACP;AAAA,YAAQ;AAAA,UACV;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
4
|
+
"sourcesContent": ["import {\n DEFAULT_HTTP_STATUS_POLICY,\n statusToHttpStatus,\n stringifyHealthJson,\n toHealthJson\n} from \"@nexload-sdk/healthcheck\";\nimport {\n toOpenMetricsText,\n toPrometheusText\n} from \"@nexload-sdk/healthcheck-prometheus\";\n\nimport type {\n HealthHttpStatusPolicy,\n HealthManager,\n HealthReport,\n HealthRunScope,\n HealthScope\n} from \"@nexload-sdk/healthcheck\";\n\nexport interface NextHealthRouteProtection {\n bearerToken?: string\n basicAuth?: {\n username: string\n password: string\n }\n allowCidrs?: readonly string[]\n allowIps?: readonly string[]\n trustProxy?: boolean\n proxyHeader?: \"x-forwarded-for\" | \"x-real-ip\" | string\n}\n\nexport interface NextHealthRouteOptions {\n scope: HealthScope\n format?: \"json\" | \"summary\"\n httpStatus?: HealthHttpStatusPolicy\n includeDetails?: boolean | ((request: Request) => boolean)\n protect?: NextHealthRouteProtection\n headers?: HeadersInit | ((report: HealthReport) => HeadersInit)\n cache?: \"no-store\"\n}\n\nexport interface NextMetricsRouteOptions {\n format: \"prometheus\" | \"openmetrics\" | \"json\"\n scope?: HealthRunScope\n protect?: NextHealthRouteProtection\n prefix?: string\n defaultLabels?: Record<string, string>\n}\n\nfunction constantTimeEquals (\n input: string, expected: string\n): boolean {\n const encoder = new TextEncoder();\n const inputBytes = encoder.encode(input);\n const expectedBytes = encoder.encode(expected);\n const length = Math.max(\n inputBytes.length, expectedBytes.length\n );\n let mismatch = inputBytes.length === expectedBytes.length ? 0 : 1;\n\n for (let index = 0; index < length; index += 1) {\n mismatch |= (inputBytes[index] ?? 0) ^ (expectedBytes[index] ?? 0);\n }\n\n return mismatch === 0;\n}\n\nfunction parseBasicAuth (value: string | null): { username: string, password: string } | null {\n if (!value?.startsWith(\"Basic \")) return null;\n\n try {\n const decoded = atob(value.slice(\"Basic \".length));\n const separator = decoded.indexOf(\":\");\n if (separator === -1) return null;\n\n return {\n username: decoded.slice(\n 0, separator\n ),\n password: decoded.slice(separator + 1),\n };\n } catch {\n return null;\n }\n}\n\nfunction ipToNumber (ip: string): number | null {\n const parts = ip.split(\".\").map(Number);\n if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part) || part < 0 || part > 255)) {\n return null;\n }\n\n return (((parts[0] ?? 0) << 24) >>> 0) + ((parts[1] ?? 0) << 16) + ((parts[2] ?? 0) << 8) + (parts[3] ?? 0);\n}\n\nfunction cidrContains (\n cidr: string, ip: string\n): boolean {\n const [\n range,\n bitsRaw\n ] = cidr.split(\"/\");\n const bits = Number(bitsRaw);\n const rangeNumber = ipToNumber(range ?? \"\");\n const ipNumber = ipToNumber(ip);\n\n if (rangeNumber === null || ipNumber === null || !Number.isInteger(bits) || bits < 0 || bits > 32) {\n return false;\n }\n\n const mask = bits === 0 ? 0 : (0xffffffff << (32 - bits)) >>> 0;\n return (rangeNumber & mask) === (ipNumber & mask);\n}\n\nfunction isValidCidr (cidr: string): boolean {\n const [\n range,\n bitsRaw\n ] = cidr.split(\"/\");\n const bits = Number(bitsRaw);\n\n return ipToNumber(range ?? \"\") !== null\n && Number.isInteger(bits)\n && bits >= 0\n && bits <= 32;\n}\n\nfunction invalidConfig (message: string): Error {\n const error = new Error(message);\n error.name = \"HEALTHCHECK_INVALID_CONFIG\";\n return error;\n}\n\nfunction validateProtection (protection?: NextHealthRouteProtection): void {\n if (!protection) return;\n\n const hasBearer = \"bearerToken\" in protection;\n const hasBasic = protection.basicAuth !== undefined;\n const hasIps = (protection.allowIps?.length ?? 0) > 0;\n const hasCidrs = (protection.allowCidrs?.length ?? 0) > 0;\n\n if (!hasBearer && !hasBasic && !hasIps && !hasCidrs) {\n throw invalidConfig(\"Route protection must configure at least one access policy.\");\n }\n\n if (hasBearer && !protection.bearerToken?.trim()) {\n throw invalidConfig(\"Bearer token protection requires a non-empty token.\");\n }\n\n if (hasBasic && (!protection.basicAuth?.username.trim() || !protection.basicAuth.password)) {\n throw invalidConfig(\"Basic authentication requires a non-empty username and password.\");\n }\n\n if (hasBearer && hasBasic) {\n throw invalidConfig(\"Bearer and Basic authentication cannot share one Authorization header.\");\n }\n\n if ((hasIps || hasCidrs) && protection.trustProxy !== true) {\n throw invalidConfig(\"IP and CIDR protection require trustProxy: true.\");\n }\n\n if (protection.allowIps?.some((ip) => ipToNumber(ip) === null)) {\n throw invalidConfig(\"IP protection currently accepts valid IPv4 addresses only.\");\n }\n\n if (protection.allowCidrs?.some((cidr) => !isValidCidr(cidr))) {\n throw invalidConfig(\"CIDR protection currently accepts valid IPv4 CIDRs only.\");\n }\n}\n\nfunction getRequestIp (\n request: Request, protection: NextHealthRouteProtection\n): string | null {\n if (!protection.trustProxy) return null;\n\n const header = protection.proxyHeader ?? \"x-forwarded-for\";\n const value = request.headers.get(header);\n if (!value) return null;\n\n return value.split(\",\")[0]?.trim() ?? null;\n}\n\nfunction isAuthorized (\n request: Request, protection?: NextHealthRouteProtection\n): boolean {\n if (!protection) return true;\n\n if (protection.bearerToken) {\n const token = request.headers.get(\"authorization\")?.replace(\n /^Bearer\\s+/i, \"\"\n ) ?? \"\";\n if (!constantTimeEquals(\n token, protection.bearerToken\n )) {\n return false;\n }\n }\n\n if (protection.basicAuth) {\n const parsed = parseBasicAuth(request.headers.get(\"authorization\"));\n if (!parsed || !constantTimeEquals(\n parsed.username, protection.basicAuth.username\n ) || !constantTimeEquals(\n parsed.password, protection.basicAuth.password\n )) {\n return false;\n }\n }\n\n const ip = getRequestIp(\n request, protection\n );\n if (protection.allowIps?.length && (!ip || !protection.allowIps.includes(ip))) {\n return false;\n }\n\n if (protection.allowCidrs?.length && (!ip || !protection.allowCidrs.some((cidr) => cidrContains(\n cidr, ip\n )))) {\n return false;\n }\n\n return true;\n}\n\nfunction unauthorized (): Response {\n return new Response(\n JSON.stringify({\n code: \"HEALTHCHECK_ROUTE_UNAUTHORIZED\",\n message: \"Unauthorized.\",\n }), {\n status: 401,\n headers: {\n \"content-type\": \"application/json; charset=utf-8\",\n \"cache-control\": \"no-store, max-age=0\",\n },\n }\n );\n}\n\nfunction mergeHeaders (...headersList: Array<HeadersInit | undefined>): Headers {\n const headers = new Headers();\n\n for (const headersInit of headersList) {\n if (!headersInit) continue;\n new Headers(headersInit).forEach((\n value, key\n ) => headers.set(\n key, value\n ));\n }\n\n return headers;\n}\n\nfunction baseHeaders (\n report: HealthReport, contentType: string\n): HeadersInit {\n return {\n \"cache-control\": \"no-store, max-age=0\",\n \"content-type\": contentType,\n \"x-health-status\": report.status,\n \"x-health-scope\": String(report.scope),\n \"x-health-duration-ms\": report.durationMs.toFixed(2),\n \"x-health-service\": report.service.name,\n ...(report.service.instanceId ? { \"x-health-instance\": report.service.instanceId, } : {}),\n };\n}\n\nfunction summaryBody (report: HealthReport): string {\n return JSON.stringify({\n status: report.status,\n scope: report.scope,\n observedAt: report.observedAt,\n durationMs: report.durationMs,\n summary: report.summary,\n });\n}\n\nexport function createNextHealthRoute (\n manager: HealthManager, options: NextHealthRouteOptions\n): {\n GET: (request: Request) => Promise<Response>\n HEAD: (request: Request) => Promise<Response>\n} {\n validateProtection(options.protect);\n\n if (options.cache !== undefined && options.cache !== \"no-store\") {\n throw invalidConfig(\"Health routes only support cache: no-store.\");\n }\n\n async function handle (\n request: Request, head = false\n ): Promise<Response> {\n if (!isAuthorized(\n request, options.protect\n )) {\n return unauthorized();\n }\n\n const report = await manager.run(options.scope);\n const includeDetails = typeof options.includeDetails === \"function\"\n ? options.includeDetails(request)\n : options.includeDetails ?? false;\n const body = options.format === \"summary\"\n ? summaryBody(report)\n : stringifyHealthJson(\n report, { includeDetails, }\n );\n const headers = mergeHeaders(\n baseHeaders(\n report, \"application/json; charset=utf-8\"\n ), typeof options.headers === \"function\" ? options.headers(report) : options.headers\n );\n\n return new Response(\n head ? null : body, {\n status: statusToHttpStatus(\n report.status, options.httpStatus ?? DEFAULT_HTTP_STATUS_POLICY\n ),\n headers,\n }\n );\n }\n\n return {\n GET: (request) => handle(request),\n HEAD: (request) => handle(\n request, true\n ),\n };\n}\n\nexport function createNextMetricsRoute (\n manager: HealthManager, options: NextMetricsRouteOptions\n): { GET: (request: Request) => Promise<Response> } {\n validateProtection(options.protect);\n\n return {\n async GET (request) {\n if (!isAuthorized(\n request, options.protect\n )) {\n return unauthorized();\n }\n\n const report = await manager.run(\n options.scope ?? \"all\", { profile: \"monitoring\", }\n );\n const contentType = options.format === \"json\"\n ? \"application/json; charset=utf-8\"\n : options.format === \"openmetrics\"\n ? \"application/openmetrics-text; version=1.0.0; charset=utf-8\"\n : \"text/plain; version=0.0.4; charset=utf-8\";\n const body = options.format === \"json\"\n ? JSON.stringify(toHealthJson(\n report, { includeDetails: false, }\n ))\n : options.format === \"openmetrics\"\n ? toOpenMetricsText(\n report, { prefix: options.prefix, defaultLabels: options.defaultLabels, }\n )\n : toPrometheusText(\n report, { prefix: options.prefix, defaultLabels: options.defaultLabels, }\n );\n\n return new Response(\n body, {\n status: 200,\n headers: baseHeaders(\n report, contentType\n ),\n }\n );\n },\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAwCP,SAAS,mBACP,OAAe,UACN;AACT,QAAM,UAAU,IAAI,YAAY;AAChC,QAAM,aAAa,QAAQ,OAAO,KAAK;AACvC,QAAM,gBAAgB,QAAQ,OAAO,QAAQ;AAC7C,QAAM,SAAS,KAAK;AAAA,IAClB,WAAW;AAAA,IAAQ,cAAc;AAAA,EACnC;AACA,MAAI,WAAW,WAAW,WAAW,cAAc,SAAS,IAAI;AAEhE,WAAS,QAAQ,GAAG,QAAQ,QAAQ,SAAS,GAAG;AAC9C,iBAAa,WAAW,KAAK,KAAK,MAAM,cAAc,KAAK,KAAK;AAAA,EAClE;AAEA,SAAO,aAAa;AACtB;AAEA,SAAS,eAAgB,OAAqE;AAC5F,MAAI,CAAC,OAAO,WAAW,QAAQ,EAAG,QAAO;AAEzC,MAAI;AACF,UAAM,UAAU,KAAK,MAAM,MAAM,SAAS,MAAM,CAAC;AACjD,UAAM,YAAY,QAAQ,QAAQ,GAAG;AACrC,QAAI,cAAc,GAAI,QAAO;AAE7B,WAAO;AAAA,MACL,UAAU,QAAQ;AAAA,QAChB;AAAA,QAAG;AAAA,MACL;AAAA,MACA,UAAU,QAAQ,MAAM,YAAY,CAAC;AAAA,IAC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;AAAA,EACF;AAEA,SAAO;AAAA,IACL,KAAK,CAAC,YAAY,OAAO,OAAO;AAAA,IAChC,MAAM,CAAC,YAAY;AAAA,MACjB;AAAA,MAAS;AAAA,IACX;AAAA,EACF;AACF;AAEO,SAAS,uBACd,SAAwB,SAC0B;AAClD,qBAAmB,QAAQ,OAAO;AAElC,SAAO;AAAA,IACL,MAAM,IAAK,SAAS;AAClB,UAAI,CAAC;AAAA,QACH;AAAA,QAAS,QAAQ;AAAA,MACnB,GAAG;AACD,eAAO,aAAa;AAAA,MACtB;AAEA,YAAM,SAAS,MAAM,QAAQ;AAAA,QAC3B,QAAQ,SAAS;AAAA,QAAO,EAAE,SAAS,aAAc;AAAA,MACnD;AACA,YAAM,cAAc,QAAQ,WAAW,SACnC,oCACA,QAAQ,WAAW,gBACjB,+DACA;AACN,YAAM,OAAO,QAAQ,WAAW,SAC5B,KAAK,UAAU;AAAA,QACf;AAAA,QAAQ,EAAE,gBAAgB,MAAO;AAAA,MACnC,CAAC,IACC,QAAQ,WAAW,gBACjB;AAAA,QACA;AAAA,QAAQ,EAAE,QAAQ,QAAQ,QAAQ,eAAe,QAAQ,cAAe;AAAA,MAC1E,IACE;AAAA,QACA;AAAA,QAAQ,EAAE,QAAQ,QAAQ,QAAQ,eAAe,QAAQ,cAAe;AAAA,MAC1E;AAEJ,aAAO,IAAI;AAAA,QACT;AAAA,QAAM;AAAA,UACJ,QAAQ;AAAA,UACR,SAAS;AAAA,YACP;AAAA,YAAQ;AAAA,UACV;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexload-sdk/healthcheck-next",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Next.js App Router route factories for @nexload-sdk/healthcheck.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nextjs",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@nexload-sdk/healthcheck
|
|
36
|
-
"@nexload-sdk/healthcheck": "
|
|
35
|
+
"@nexload-sdk/healthcheck": "4.1.0",
|
|
36
|
+
"@nexload-sdk/healthcheck-prometheus": "2.1.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^25.0.3",
|