@daloyjs/core 1.0.0-beta.7 → 1.0.0-rc.1
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 +7 -5
- package/dist/adapters/node.js +216 -11
- package/dist/app.d.ts +32 -8
- package/dist/app.js +418 -67
- package/dist/http-signatures.js +44 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/ip-reputation.d.ts +8 -2
- package/dist/ip-reputation.js +7 -1
- package/dist/jwk.js +6 -1
- package/dist/mcp.d.ts +80 -9
- package/dist/mcp.js +206 -4
- package/dist/middleware.d.ts +38 -0
- package/dist/middleware.js +45 -4
- package/dist/mtls.js +6 -1
- package/dist/sbom.cdx.json +9 -9
- package/dist/sbom.spdx.json +5 -5
- package/package.json +1 -1
package/dist/middleware.js
CHANGED
|
@@ -447,6 +447,47 @@ export const CORS_WILDCARD_ORIGIN_MARKER = Symbol.for("daloyjs.middleware.cors.w
|
|
|
447
447
|
* @since 0.17.0
|
|
448
448
|
*/
|
|
449
449
|
export const CSRF_HOOK_MARKER = Symbol.for("daloyjs.middleware.csrf");
|
|
450
|
+
/**
|
|
451
|
+
* Marker stamped on a {@link Hooks} bundle that authenticates the request —
|
|
452
|
+
* i.e. rejects callers without valid credentials. Built-in auth middlewares
|
|
453
|
+
* (`bearerAuth`, `basicAuth`, `jwk`, `httpSignatureAuth`, `clientCertAuth`)
|
|
454
|
+
* stamp it so the framework's route-auth boot guard can confirm that any route
|
|
455
|
+
* declaring an `auth:` requirement is actually enforced by a hook rather than
|
|
456
|
+
* being silently public (a `security` entry in the OpenAPI doc with no runtime
|
|
457
|
+
* check). Wrap a custom authentication hook with {@link markAuthHook} to opt it
|
|
458
|
+
* into the same guard.
|
|
459
|
+
*
|
|
460
|
+
* @since 1.0.0
|
|
461
|
+
*/
|
|
462
|
+
export const AUTH_HOOK_MARKER = Symbol.for("daloyjs.auth.hook");
|
|
463
|
+
/**
|
|
464
|
+
* Mark a custom {@link Hooks} bundle as performing request authentication.
|
|
465
|
+
*
|
|
466
|
+
* Use this when you authenticate with your own hook (not one of the built-in
|
|
467
|
+
* auth middlewares) but still declare `auth:` on the protected routes: it
|
|
468
|
+
* stamps {@link AUTH_HOOK_MARKER} so the production route-auth boot guard treats
|
|
469
|
+
* those routes as enforced. It is also the correct escape hatch when
|
|
470
|
+
* authentication is performed by an upstream gateway/mesh and the in-app hook
|
|
471
|
+
* is intentionally a pass-through.
|
|
472
|
+
*
|
|
473
|
+
* @param hooks - The hook bundle to mark (mutated in place and returned).
|
|
474
|
+
* @returns The same `hooks` object, now stamped as an auth hook.
|
|
475
|
+
*
|
|
476
|
+
* @example
|
|
477
|
+
* ```ts
|
|
478
|
+
* app.use(markAuthHook({
|
|
479
|
+
* async beforeHandle(ctx) {
|
|
480
|
+
* if (!(await myVerify(ctx.request))) throw new UnauthorizedError();
|
|
481
|
+
* },
|
|
482
|
+
* }));
|
|
483
|
+
* ```
|
|
484
|
+
*
|
|
485
|
+
* @since 1.0.0
|
|
486
|
+
*/
|
|
487
|
+
export function markAuthHook(hooks) {
|
|
488
|
+
hooks[AUTH_HOOK_MARKER] = true;
|
|
489
|
+
return hooks;
|
|
490
|
+
}
|
|
450
491
|
/**
|
|
451
492
|
* Cross-Origin Resource Sharing (CORS) middleware. Handles both preflight
|
|
452
493
|
* (`OPTIONS`) and actual requests, attaching the correct
|
|
@@ -838,7 +879,7 @@ export function bearerAuth(opts) {
|
|
|
838
879
|
if (/["\r\n\0]/.test(realm)) {
|
|
839
880
|
throw new Error("bearerAuth(): realm must not contain quotes, CR, LF, or NUL bytes.");
|
|
840
881
|
}
|
|
841
|
-
return {
|
|
882
|
+
return markAuthHook({
|
|
842
883
|
async beforeHandle(ctx) {
|
|
843
884
|
const h = ctx.request.headers.get("authorization") ?? "";
|
|
844
885
|
const m = /^Bearer\s+(.+)$/i.exec(h);
|
|
@@ -866,7 +907,7 @@ export function bearerAuth(opts) {
|
|
|
866
907
|
}
|
|
867
908
|
return undefined;
|
|
868
909
|
},
|
|
869
|
-
};
|
|
910
|
+
});
|
|
870
911
|
}
|
|
871
912
|
const CSRF_STATE_TOKEN = "csrfToken";
|
|
872
913
|
const CSRF_STATE_ISSUED = "__csrfIssued";
|
|
@@ -1115,7 +1156,7 @@ export function basicAuth(opts) {
|
|
|
1115
1156
|
if (!Number.isInteger(maxBytes) || maxBytes < 1) {
|
|
1116
1157
|
throw new Error("basicAuth(): maxCredentialBytes must be a positive integer.");
|
|
1117
1158
|
}
|
|
1118
|
-
return {
|
|
1159
|
+
return markAuthHook({
|
|
1119
1160
|
async beforeHandle(ctx) {
|
|
1120
1161
|
const header = ctx.request.headers.get("authorization") ?? "";
|
|
1121
1162
|
const match = BASIC_AUTH_TOKEN_RE.exec(header);
|
|
@@ -1134,7 +1175,7 @@ export function basicAuth(opts) {
|
|
|
1134
1175
|
}
|
|
1135
1176
|
return undefined;
|
|
1136
1177
|
},
|
|
1137
|
-
};
|
|
1178
|
+
});
|
|
1138
1179
|
}
|
|
1139
1180
|
// ---------- requireScopes ----------
|
|
1140
1181
|
/**
|
package/dist/mtls.js
CHANGED
|
@@ -347,7 +347,7 @@ export function clientCertAuth(opts = {}) {
|
|
|
347
347
|
return certFromHeaders(ctx.request, headerConfig);
|
|
348
348
|
return undefined;
|
|
349
349
|
});
|
|
350
|
-
|
|
350
|
+
const authHooks = {
|
|
351
351
|
async beforeHandle(ctx) {
|
|
352
352
|
const cert = resolve(ctx);
|
|
353
353
|
if (!cert) {
|
|
@@ -386,6 +386,11 @@ export function clientCertAuth(opts = {}) {
|
|
|
386
386
|
return undefined;
|
|
387
387
|
},
|
|
388
388
|
};
|
|
389
|
+
// Same global symbol as middleware's AUTH_HOOK_MARKER (stamped inline to keep
|
|
390
|
+
// the middleware module out of this bundle): lets the route-auth boot guard
|
|
391
|
+
// recognize that a route declaring `auth:` is actually enforced here.
|
|
392
|
+
authHooks[Symbol.for("daloyjs.auth.hook")] = true;
|
|
393
|
+
return authHooks;
|
|
389
394
|
}
|
|
390
395
|
function assertHeaderConfig(cfg) {
|
|
391
396
|
if (cfg.format === "xfcc")
|
package/dist/sbom.cdx.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"bomFormat": "CycloneDX",
|
|
3
3
|
"specVersion": "1.5",
|
|
4
|
-
"serialNumber": "urn:uuid:
|
|
4
|
+
"serialNumber": "urn:uuid:63bae5ad-16c4-5db2-9929-3188903cb4f9",
|
|
5
5
|
"version": 1,
|
|
6
6
|
"metadata": {
|
|
7
|
-
"timestamp": "2026-07-
|
|
7
|
+
"timestamp": "2026-07-04T14:31:15.314Z",
|
|
8
8
|
"tools": [
|
|
9
9
|
{
|
|
10
10
|
"vendor": "DaloyJS",
|
|
11
11
|
"name": "daloy-generate-sbom",
|
|
12
|
-
"version": "1.0.0-
|
|
12
|
+
"version": "1.0.0-rc.1"
|
|
13
13
|
}
|
|
14
14
|
],
|
|
15
15
|
"authors": [
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
],
|
|
20
20
|
"component": {
|
|
21
21
|
"type": "library",
|
|
22
|
-
"bom-ref": "pkg:npm/@daloyjs/core@1.0.0-
|
|
22
|
+
"bom-ref": "pkg:npm/@daloyjs/core@1.0.0-rc.1",
|
|
23
23
|
"name": "@daloyjs/core",
|
|
24
|
-
"version": "1.0.0-
|
|
24
|
+
"version": "1.0.0-rc.1",
|
|
25
25
|
"description": "DaloyJS is a runtime-portable, contract-first TypeScript web framework with built-in OpenAPI (Hey API), typed client generation, large-scale maintainability, and security-first defaults. Hono-grade portability, Elysia-grade DX, FastAPI-grade docs, Fastify-grade ops — distributed via pnpm.",
|
|
26
|
-
"purl": "pkg:npm/@daloyjs/core@1.0.0-
|
|
26
|
+
"purl": "pkg:npm/@daloyjs/core@1.0.0-rc.1",
|
|
27
27
|
"licenses": [
|
|
28
28
|
{
|
|
29
29
|
"license": {
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
}
|
|
47
47
|
],
|
|
48
48
|
"swid": {
|
|
49
|
-
"tagId": "swidtag--daloyjs-core-1.0.0-
|
|
49
|
+
"tagId": "swidtag--daloyjs-core-1.0.0-rc.1",
|
|
50
50
|
"name": "@daloyjs/core",
|
|
51
|
-
"version": "1.0.0-
|
|
51
|
+
"version": "1.0.0-rc.1",
|
|
52
52
|
"tagVersion": 0,
|
|
53
53
|
"patch": false
|
|
54
54
|
}
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"components": [],
|
|
58
58
|
"dependencies": [
|
|
59
59
|
{
|
|
60
|
-
"ref": "pkg:npm/@daloyjs/core@1.0.0-
|
|
60
|
+
"ref": "pkg:npm/@daloyjs/core@1.0.0-rc.1",
|
|
61
61
|
"dependsOn": []
|
|
62
62
|
}
|
|
63
63
|
]
|
package/dist/sbom.spdx.json
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"spdxVersion": "SPDX-2.3",
|
|
3
3
|
"dataLicense": "CC0-1.0",
|
|
4
4
|
"SPDXID": "SPDXRef-DOCUMENT",
|
|
5
|
-
"name": "@daloyjs/core-1.0.0-
|
|
6
|
-
"documentNamespace": "https://github.com/daloyjs/daloy/sbom/@daloyjs/core-1.0.0-
|
|
5
|
+
"name": "@daloyjs/core-1.0.0-rc.1",
|
|
6
|
+
"documentNamespace": "https://github.com/daloyjs/daloy/sbom/@daloyjs/core-1.0.0-rc.1-63bae5ad-16c4-5db2-9929-3188903cb4f9",
|
|
7
7
|
"creationInfo": {
|
|
8
|
-
"created": "2026-07-
|
|
8
|
+
"created": "2026-07-04T14:31:15.314Z",
|
|
9
9
|
"creators": [
|
|
10
10
|
"Tool: daloy-generate-sbom",
|
|
11
11
|
"Organization: DaloyJS"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
{
|
|
17
17
|
"SPDXID": "SPDXRef-Package--daloyjs-core",
|
|
18
18
|
"name": "@daloyjs/core",
|
|
19
|
-
"versionInfo": "1.0.0-
|
|
19
|
+
"versionInfo": "1.0.0-rc.1",
|
|
20
20
|
"downloadLocation": "https://github.com/daloyjs/daloy",
|
|
21
21
|
"filesAnalyzed": false,
|
|
22
22
|
"licenseConcluded": "MIT",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
{
|
|
28
28
|
"referenceCategory": "PACKAGE-MANAGER",
|
|
29
29
|
"referenceType": "purl",
|
|
30
|
-
"referenceLocator": "pkg:npm/@daloyjs/core@1.0.0-
|
|
30
|
+
"referenceLocator": "pkg:npm/@daloyjs/core@1.0.0-rc.1"
|
|
31
31
|
}
|
|
32
32
|
]
|
|
33
33
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@daloyjs/core",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-rc.1",
|
|
4
4
|
"description": "DaloyJS is a runtime-portable, contract-first TypeScript web framework with built-in OpenAPI (Hey API), typed client generation, large-scale maintainability, and security-first defaults. Hono-grade portability, Elysia-grade DX, FastAPI-grade docs, Fastify-grade ops — distributed via pnpm.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|