@astrale-os/kernel-server 0.4.17 → 0.5.0-beta.2
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/dist/capture.d.ts +3 -0
- package/dist/capture.d.ts.map +1 -0
- package/dist/capture.js +10 -0
- package/dist/capture.js.map +1 -0
- package/dist/cors/cors.d.ts +22 -0
- package/dist/cors/cors.d.ts.map +1 -0
- package/dist/cors/cors.js +136 -0
- package/dist/cors/cors.js.map +1 -0
- package/dist/cors/index.d.ts +3 -0
- package/dist/cors/index.d.ts.map +1 -0
- package/dist/cors/index.js +2 -0
- package/dist/cors/index.js.map +1 -0
- package/dist/cors/types.d.ts +12 -0
- package/dist/cors/types.d.ts.map +1 -0
- package/dist/cors/types.js +2 -0
- package/dist/cors/types.js.map +1 -0
- package/dist/errors/availability.d.ts +11 -0
- package/dist/errors/availability.d.ts.map +1 -0
- package/dist/errors/availability.js +15 -0
- package/dist/errors/availability.js.map +1 -0
- package/dist/errors/classify.d.ts +4 -0
- package/dist/errors/classify.d.ts.map +1 -0
- package/dist/errors/classify.js +316 -0
- package/dist/errors/classify.js.map +1 -0
- package/dist/errors/index.d.ts +5 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +5 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/request-body.d.ts +8 -0
- package/dist/errors/request-body.d.ts.map +1 -0
- package/dist/errors/request-body.js +15 -0
- package/dist/errors/request-body.js.map +1 -0
- package/dist/errors/response-body.d.ts +5 -0
- package/dist/errors/response-body.d.ts.map +1 -0
- package/dist/errors/response-body.js +9 -0
- package/dist/errors/response-body.js.map +1 -0
- package/dist/index.d.ts +5 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -18
- package/dist/index.js.map +1 -1
- package/dist/invocation/context.d.ts +7 -0
- package/dist/invocation/context.d.ts.map +1 -0
- package/dist/invocation/context.js +61 -0
- package/dist/invocation/context.js.map +1 -0
- package/dist/invocation/index.d.ts +3 -2
- package/dist/invocation/index.d.ts.map +1 -1
- package/dist/invocation/index.js +2 -2
- package/dist/invocation/index.js.map +1 -1
- package/dist/invocation/publication-route.d.ts +12 -0
- package/dist/invocation/publication-route.d.ts.map +1 -0
- package/dist/invocation/publication-route.js +43 -0
- package/dist/invocation/publication-route.js.map +1 -0
- package/dist/invocation/types.d.ts +38 -0
- package/dist/invocation/types.d.ts.map +1 -0
- package/dist/invocation/types.js +2 -0
- package/dist/invocation/types.js.map +1 -0
- package/dist/issuer/exchange.d.ts +13 -0
- package/dist/issuer/exchange.d.ts.map +1 -0
- package/dist/issuer/exchange.js +135 -0
- package/dist/issuer/exchange.js.map +1 -0
- package/dist/issuer/index.d.ts +4 -0
- package/dist/issuer/index.d.ts.map +1 -0
- package/dist/issuer/index.js +2 -0
- package/dist/issuer/index.js.map +1 -0
- package/dist/issuer/routes.d.ts +14 -0
- package/dist/issuer/routes.d.ts.map +1 -0
- package/dist/issuer/routes.js +147 -0
- package/dist/issuer/routes.js.map +1 -0
- package/dist/issuer/types.d.ts +11 -0
- package/dist/issuer/types.d.ts.map +1 -0
- package/dist/issuer/types.js +2 -0
- package/dist/issuer/types.js.map +1 -0
- package/dist/lifecycle/active.d.ts +40 -0
- package/dist/lifecycle/active.d.ts.map +1 -0
- package/dist/lifecycle/active.js +200 -0
- package/dist/lifecycle/active.js.map +1 -0
- package/dist/lifecycle/index.d.ts +2 -0
- package/dist/lifecycle/index.d.ts.map +1 -0
- package/dist/lifecycle/index.js +2 -0
- package/dist/lifecycle/index.js.map +1 -0
- package/dist/publication/delivery/handler.d.ts +10 -0
- package/dist/publication/delivery/handler.d.ts.map +1 -0
- package/dist/publication/delivery/handler.js +127 -0
- package/dist/publication/delivery/handler.js.map +1 -0
- package/dist/publication/delivery/index.d.ts +3 -0
- package/dist/publication/delivery/index.d.ts.map +1 -0
- package/dist/publication/delivery/index.js +2 -0
- package/dist/publication/delivery/index.js.map +1 -0
- package/dist/publication/delivery/types.d.ts +12 -0
- package/dist/publication/delivery/types.d.ts.map +1 -0
- package/dist/publication/delivery/types.js +2 -0
- package/dist/publication/delivery/types.js.map +1 -0
- package/dist/publication/index.d.ts +4 -0
- package/dist/publication/index.d.ts.map +1 -0
- package/dist/publication/index.js +3 -0
- package/dist/publication/index.js.map +1 -0
- package/dist/publication/snapshot.d.ts +14 -0
- package/dist/publication/snapshot.d.ts.map +1 -0
- package/dist/publication/snapshot.js +30 -0
- package/dist/publication/snapshot.js.map +1 -0
- package/dist/publication/types.d.ts +19 -0
- package/dist/publication/types.d.ts.map +1 -0
- package/dist/publication/types.js +2 -0
- package/dist/publication/types.js.map +1 -0
- package/dist/routes/index.d.ts +2 -0
- package/dist/routes/index.d.ts.map +1 -0
- package/dist/routes/index.js +2 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routes/routes.d.ts +25 -0
- package/dist/routes/routes.d.ts.map +1 -0
- package/dist/routes/routes.js +448 -0
- package/dist/routes/routes.js.map +1 -0
- package/dist/server.d.ts +5 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +260 -0
- package/dist/server.js.map +1 -0
- package/dist/transport/body.d.ts +5 -0
- package/dist/transport/body.d.ts.map +1 -0
- package/dist/transport/body.js +51 -0
- package/dist/transport/body.js.map +1 -0
- package/dist/transport/codecs.d.ts +5 -0
- package/dist/transport/codecs.d.ts.map +1 -0
- package/dist/transport/codecs.js +6 -0
- package/dist/transport/codecs.js.map +1 -0
- package/dist/transport/credential.d.ts +11 -0
- package/dist/transport/credential.d.ts.map +1 -0
- package/dist/transport/credential.js +29 -0
- package/dist/transport/credential.js.map +1 -0
- package/dist/transport/http/handler.d.ts +16 -0
- package/dist/transport/http/handler.d.ts.map +1 -0
- package/dist/transport/http/handler.js +177 -0
- package/dist/transport/http/handler.js.map +1 -0
- package/dist/transport/http/index.d.ts +3 -0
- package/dist/transport/http/index.d.ts.map +1 -0
- package/dist/transport/http/index.js +3 -0
- package/dist/transport/http/index.js.map +1 -0
- package/dist/transport/http/render.d.ts +29 -0
- package/dist/transport/http/render.d.ts.map +1 -0
- package/dist/transport/http/render.js +278 -0
- package/dist/transport/http/render.js.map +1 -0
- package/dist/transport/index.d.ts +10 -0
- package/dist/transport/index.d.ts.map +1 -0
- package/dist/transport/index.js +9 -0
- package/dist/transport/index.js.map +1 -0
- package/dist/transport/router.d.ts +5 -0
- package/dist/transport/router.d.ts.map +1 -0
- package/dist/transport/router.js +5 -0
- package/dist/transport/router.js.map +1 -0
- package/dist/transport/stream-error.d.ts +4 -0
- package/dist/transport/stream-error.d.ts.map +1 -0
- package/dist/transport/stream-error.js +14 -0
- package/dist/transport/stream-error.js.map +1 -0
- package/dist/transport/types.d.ts +29 -0
- package/dist/transport/types.d.ts.map +1 -0
- package/dist/transport/types.js +2 -0
- package/dist/transport/types.js.map +1 -0
- package/dist/transport/websocket/index.d.ts +3 -0
- package/dist/transport/websocket/index.d.ts.map +1 -0
- package/dist/transport/websocket/index.js +3 -0
- package/dist/transport/websocket/index.js.map +1 -0
- package/dist/transport/websocket/session.d.ts +19 -0
- package/dist/transport/websocket/session.d.ts.map +1 -0
- package/dist/transport/websocket/session.js +329 -0
- package/dist/transport/websocket/session.js.map +1 -0
- package/dist/transport/websocket/upgrade.d.ts +19 -0
- package/dist/transport/websocket/upgrade.d.ts.map +1 -0
- package/dist/transport/websocket/upgrade.js +46 -0
- package/dist/transport/websocket/upgrade.js.map +1 -0
- package/dist/types.d.ts +63 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +10 -11
- package/dist/app/create.d.ts +0 -48
- package/dist/app/create.d.ts.map +0 -1
- package/dist/app/create.js +0 -108
- package/dist/app/create.js.map +0 -1
- package/dist/app/index.d.ts +0 -4
- package/dist/app/index.d.ts.map +0 -1
- package/dist/app/index.js +0 -4
- package/dist/app/index.js.map +0 -1
- package/dist/app/multiplexed.d.ts +0 -53
- package/dist/app/multiplexed.d.ts.map +0 -1
- package/dist/app/multiplexed.js +0 -64
- package/dist/app/multiplexed.js.map +0 -1
- package/dist/app/ws-upgrade.d.ts +0 -34
- package/dist/app/ws-upgrade.d.ts.map +0 -1
- package/dist/app/ws-upgrade.js +0 -94
- package/dist/app/ws-upgrade.js.map +0 -1
- package/dist/capabilities/contract.d.ts +0 -8
- package/dist/capabilities/contract.d.ts.map +0 -1
- package/dist/capabilities/contract.js +0 -2
- package/dist/capabilities/contract.js.map +0 -1
- package/dist/capabilities/defer.d.ts +0 -4
- package/dist/capabilities/defer.d.ts.map +0 -1
- package/dist/capabilities/defer.js +0 -2
- package/dist/capabilities/defer.js.map +0 -1
- package/dist/capabilities/hono.d.ts +0 -8
- package/dist/capabilities/hono.d.ts.map +0 -1
- package/dist/capabilities/hono.js +0 -13
- package/dist/capabilities/hono.js.map +0 -1
- package/dist/capabilities/index.d.ts +0 -6
- package/dist/capabilities/index.d.ts.map +0 -1
- package/dist/capabilities/index.js +0 -3
- package/dist/capabilities/index.js.map +0 -1
- package/dist/capabilities/lifecycle.d.ts +0 -17
- package/dist/capabilities/lifecycle.d.ts.map +0 -1
- package/dist/capabilities/lifecycle.js +0 -37
- package/dist/capabilities/lifecycle.js.map +0 -1
- package/dist/capabilities/sleep.d.ts +0 -4
- package/dist/capabilities/sleep.d.ts.map +0 -1
- package/dist/capabilities/sleep.js +0 -8
- package/dist/capabilities/sleep.js.map +0 -1
- package/dist/cors.d.ts +0 -21
- package/dist/cors.d.ts.map +0 -1
- package/dist/cors.js +0 -17
- package/dist/cors.js.map +0 -1
- package/dist/envelope/batch.d.ts +0 -13
- package/dist/envelope/batch.d.ts.map +0 -1
- package/dist/envelope/batch.js +0 -96
- package/dist/envelope/batch.js.map +0 -1
- package/dist/envelope/codec.d.ts +0 -26
- package/dist/envelope/codec.d.ts.map +0 -1
- package/dist/envelope/codec.js +0 -52
- package/dist/envelope/codec.js.map +0 -1
- package/dist/envelope/credential.d.ts +0 -20
- package/dist/envelope/credential.d.ts.map +0 -1
- package/dist/envelope/credential.js +0 -32
- package/dist/envelope/credential.js.map +0 -1
- package/dist/envelope/http.d.ts +0 -31
- package/dist/envelope/http.d.ts.map +0 -1
- package/dist/envelope/http.js +0 -132
- package/dist/envelope/http.js.map +0 -1
- package/dist/envelope/sse.d.ts +0 -11
- package/dist/envelope/sse.d.ts.map +0 -1
- package/dist/envelope/sse.js +0 -73
- package/dist/envelope/sse.js.map +0 -1
- package/dist/envelope/ws.d.ts +0 -35
- package/dist/envelope/ws.d.ts.map +0 -1
- package/dist/envelope/ws.js +0 -142
- package/dist/envelope/ws.js.map +0 -1
- package/dist/invocation/dispatch.d.ts +0 -32
- package/dist/invocation/dispatch.d.ts.map +0 -1
- package/dist/invocation/dispatch.js +0 -68
- package/dist/invocation/dispatch.js.map +0 -1
- package/dist/invocation/dispatcher.d.ts +0 -19
- package/dist/invocation/dispatcher.d.ts.map +0 -1
- package/dist/invocation/dispatcher.js +0 -9
- package/dist/invocation/dispatcher.js.map +0 -1
- package/dist/jwks/discovery.d.ts +0 -40
- package/dist/jwks/discovery.d.ts.map +0 -1
- package/dist/jwks/discovery.js +0 -113
- package/dist/jwks/discovery.js.map +0 -1
- package/dist/jwks/index.d.ts +0 -3
- package/dist/jwks/index.d.ts.map +0 -1
- package/dist/jwks/index.js +0 -3
- package/dist/jwks/index.js.map +0 -1
- package/dist/jwks/issuers.d.ts +0 -47
- package/dist/jwks/issuers.d.ts.map +0 -1
- package/dist/jwks/issuers.js +0 -76
- package/dist/jwks/issuers.js.map +0 -1
- package/dist/jwks/keys.d.ts +0 -44
- package/dist/jwks/keys.d.ts.map +0 -1
- package/dist/jwks/keys.js +0 -56
- package/dist/jwks/keys.js.map +0 -1
- package/dist/plan/host-params.d.ts +0 -13
- package/dist/plan/host-params.d.ts.map +0 -1
- package/dist/plan/host-params.js +0 -23
- package/dist/plan/host-params.js.map +0 -1
- package/dist/plan/host.d.ts +0 -24
- package/dist/plan/host.d.ts.map +0 -1
- package/dist/plan/host.js +0 -24
- package/dist/plan/host.js.map +0 -1
- package/dist/plan/index.d.ts +0 -4
- package/dist/plan/index.d.ts.map +0 -1
- package/dist/plan/index.js +0 -4
- package/dist/plan/index.js.map +0 -1
- package/dist/plan/walk.d.ts +0 -51
- package/dist/plan/walk.d.ts.map +0 -1
- package/dist/plan/walk.js +0 -110
- package/dist/plan/walk.js.map +0 -1
- package/dist/render/binary.d.ts +0 -19
- package/dist/render/binary.d.ts.map +0 -1
- package/dist/render/binary.js +0 -33
- package/dist/render/binary.js.map +0 -1
- package/dist/render/body.d.ts +0 -10
- package/dist/render/body.d.ts.map +0 -1
- package/dist/render/body.js +0 -17
- package/dist/render/body.js.map +0 -1
- package/dist/render/index.d.ts +0 -3
- package/dist/render/index.d.ts.map +0 -1
- package/dist/render/index.js +0 -3
- package/dist/render/index.js.map +0 -1
- package/dist/routed/credential.d.ts +0 -10
- package/dist/routed/credential.d.ts.map +0 -1
- package/dist/routed/credential.js +0 -55
- package/dist/routed/credential.js.map +0 -1
- package/dist/routed/handler.d.ts +0 -38
- package/dist/routed/handler.d.ts.map +0 -1
- package/dist/routed/handler.js +0 -123
- package/dist/routed/handler.js.map +0 -1
- package/dist/routed/index.d.ts +0 -5
- package/dist/routed/index.d.ts.map +0 -1
- package/dist/routed/index.js +0 -5
- package/dist/routed/index.js.map +0 -1
- package/dist/routed/params.d.ts +0 -40
- package/dist/routed/params.d.ts.map +0 -1
- package/dist/routed/params.js +0 -146
- package/dist/routed/params.js.map +0 -1
- package/dist/routed/stream.d.ts +0 -21
- package/dist/routed/stream.d.ts.map +0 -1
- package/dist/routed/stream.js +0 -69
- package/dist/routed/stream.js.map +0 -1
package/dist/jwks/keys.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JWKS — generic OpenID Connect Discovery + JSON Web Key Set exposure.
|
|
3
|
-
*
|
|
4
|
-
* Mounts the standard OIDC discovery and JWKS endpoints for the server's
|
|
5
|
-
* own signing keys. Used by every server that signs JWTs.
|
|
6
|
-
*/
|
|
7
|
-
import type { Hono } from 'hono';
|
|
8
|
-
import { type CorsConfig } from '../cors.js';
|
|
9
|
-
export type JwksKeys = {
|
|
10
|
-
/** The server's own issuer URL. */
|
|
11
|
-
issuer: string;
|
|
12
|
-
/** Return the server's own public signing key(s). */
|
|
13
|
-
loadOwnKeys: () => Promise<Record<string, unknown>[]>;
|
|
14
|
-
};
|
|
15
|
-
export type MultiplexedJwks = {
|
|
16
|
-
/** Resolve the issuer URL for an instance. Return null if unknown. */
|
|
17
|
-
resolveIssuer: (instanceId: string) => string | null;
|
|
18
|
-
/** Load the instance's own public keys. Empty array if unknown. */
|
|
19
|
-
loadOwnKeys: (instanceId: string) => Promise<Record<string, unknown>[]>;
|
|
20
|
-
};
|
|
21
|
-
export type JwksConfig = JwksKeys & {
|
|
22
|
-
/** Signing algorithm (used in openid-configuration). Defaults to 'ES256'. */
|
|
23
|
-
signingAlgorithm?: string;
|
|
24
|
-
cors?: CorsConfig;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Mount OpenID Connect Discovery and JWKS endpoints for the server's own keys.
|
|
28
|
-
*
|
|
29
|
-
* - GET /.well-known/openid-configuration → OIDC discovery document
|
|
30
|
-
* - GET /.well-known/jwks.json → server's own public keys
|
|
31
|
-
*/
|
|
32
|
-
export declare function mountJwks(app: Hono, config: JwksConfig): void;
|
|
33
|
-
export type InstanceJwksConfig = MultiplexedJwks & {
|
|
34
|
-
signingAlgorithm?: string;
|
|
35
|
-
cors?: CorsConfig;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Mount per-instance OpenID Connect Discovery and JWKS endpoints (own keys).
|
|
39
|
-
*
|
|
40
|
-
* Routes are prefixed with the instance path (e.g. `/:id`).
|
|
41
|
-
* The instance ID is extracted from the Hono `:id` param.
|
|
42
|
-
*/
|
|
43
|
-
export declare function mountInstanceJwks(app: Hono, instancePrefix: string, config: InstanceJwksConfig): void;
|
|
44
|
-
//# sourceMappingURL=ke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package/dist/jwks/keys.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JWKS — generic OpenID Connect Discovery + JSON Web Key Set exposure.
|
|
3
|
-
*
|
|
4
|
-
* Mounts the standard OIDC discovery and JWKS endpoints for the server's
|
|
5
|
-
* own signing keys. Used by every server that signs JWTs.
|
|
6
|
-
*/
|
|
7
|
-
import { buildCorsHeaders } from '../cors.js';
|
|
8
|
-
import { discoveryDoc } from './discovery.js';
|
|
9
|
-
/**
|
|
10
|
-
* Mount OpenID Connect Discovery and JWKS endpoints for the server's own keys.
|
|
11
|
-
*
|
|
12
|
-
* - GET /.well-known/openid-configuration → OIDC discovery document
|
|
13
|
-
* - GET /.well-known/jwks.json → server's own public keys
|
|
14
|
-
*/
|
|
15
|
-
export function mountJwks(app, config) {
|
|
16
|
-
const corsHeaders = buildCorsHeaders(config.cors ?? { origin: '*' });
|
|
17
|
-
const headers = { 'cache-control': 'no-cache', ...corsHeaders };
|
|
18
|
-
const alg = config.signingAlgorithm ?? 'ES256';
|
|
19
|
-
app.get('/.well-known/openid-configuration', (c) => {
|
|
20
|
-
return c.json(discoveryDoc(c.req.raw, config.issuer, alg), 200, headers);
|
|
21
|
-
});
|
|
22
|
-
app.get('/.well-known/jwks.json', async (c) => {
|
|
23
|
-
const keys = await config.loadOwnKeys();
|
|
24
|
-
return c.json({ keys }, 200, headers);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Mount per-instance OpenID Connect Discovery and JWKS endpoints (own keys).
|
|
29
|
-
*
|
|
30
|
-
* Routes are prefixed with the instance path (e.g. `/:id`).
|
|
31
|
-
* The instance ID is extracted from the Hono `:id` param.
|
|
32
|
-
*/
|
|
33
|
-
export function mountInstanceJwks(app, instancePrefix, config) {
|
|
34
|
-
const corsHeaders = buildCorsHeaders(config.cors ?? { origin: '*' });
|
|
35
|
-
const headers = { 'cache-control': 'no-cache', ...corsHeaders };
|
|
36
|
-
const alg = config.signingAlgorithm ?? 'ES256';
|
|
37
|
-
app.get(`${instancePrefix}/.well-known/openid-configuration`, (c) => {
|
|
38
|
-
const id = c.req.param('id');
|
|
39
|
-
if (!id)
|
|
40
|
-
return c.json({ error: 'Instance not found' }, 404, headers);
|
|
41
|
-
const issuer = config.resolveIssuer(id);
|
|
42
|
-
if (!issuer)
|
|
43
|
-
return c.json({ error: 'Instance not found' }, 404, headers);
|
|
44
|
-
return c.json(discoveryDoc(c.req.raw, issuer, alg), 200, headers);
|
|
45
|
-
});
|
|
46
|
-
app.get(`${instancePrefix}/.well-known/jwks.json`, async (c) => {
|
|
47
|
-
const id = c.req.param('id');
|
|
48
|
-
if (!id)
|
|
49
|
-
return c.json({ error: 'Instance not found' }, 404, headers);
|
|
50
|
-
const keys = await config.loadOwnKeys(id);
|
|
51
|
-
if (keys.length === 0)
|
|
52
|
-
return c.json({ error: 'Instance not found' }, 404, headers);
|
|
53
|
-
return c.json({ keys }, 200, headers);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=keys.js.map
|
package/dist/jwks/keys.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../jwks/keys.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,gBAAgB,EAAmB,MAAM,YAAY,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AA0B7C;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,GAAS,EAAE,MAAkB;IACrD,MAAM,WAAW,GAAG,gBAAgB,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;IACpE,MAAM,OAAO,GAAG,EAAE,eAAe,EAAE,UAAU,EAAE,GAAG,WAAW,EAAE,CAAA;IAC/D,MAAM,GAAG,GAAG,MAAM,CAAC,gBAAgB,IAAI,OAAO,CAAA;IAE9C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,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,oBAAoB,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;QACzE,OAAO,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;IACnE,CAAC,CAAC,CAAA;IAEF,GAAG,CAAC,GAAG,CAAC,GAAG,cAAc,wBAAwB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QAC7D,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC5B,IAAI,CAAC,EAAE;YAAE,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,oBAAoB,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;QACrE,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;QACzC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,oBAAoB,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;QACnF,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;IACvC,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extract host placeholder values from an incoming request's Host header.
|
|
3
|
-
*
|
|
4
|
-
* Used by request-time middleware to merge tenant identifiers from the host
|
|
5
|
-
* into the dispatched params (at lowest priority).
|
|
6
|
-
*
|
|
7
|
-
* Returns:
|
|
8
|
-
* - `null` when the matcher exists but the host doesn't match (caller 404s)
|
|
9
|
-
* - `{}` when there are no placeholders (single-tenant server)
|
|
10
|
-
* - the captured groups otherwise
|
|
11
|
-
*/
|
|
12
|
-
export declare function extractHostParams(matcher: RegExp | null, request: Request): Record<string, string> | null;
|
|
13
|
-
//# sourceMappingURL=host-params.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"host-params.d.ts","sourceRoot":"","sources":["../../plan/host-params.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,OAAO,EAAE,OAAO,GACf,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAO/B"}
|
package/dist/plan/host-params.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extract host placeholder values from an incoming request's Host header.
|
|
3
|
-
*
|
|
4
|
-
* Used by request-time middleware to merge tenant identifiers from the host
|
|
5
|
-
* into the dispatched params (at lowest priority).
|
|
6
|
-
*
|
|
7
|
-
* Returns:
|
|
8
|
-
* - `null` when the matcher exists but the host doesn't match (caller 404s)
|
|
9
|
-
* - `{}` when there are no placeholders (single-tenant server)
|
|
10
|
-
* - the captured groups otherwise
|
|
11
|
-
*/
|
|
12
|
-
export function extractHostParams(matcher, request) {
|
|
13
|
-
if (!matcher)
|
|
14
|
-
return {};
|
|
15
|
-
const host = request.headers.get('host');
|
|
16
|
-
if (!host)
|
|
17
|
-
return null;
|
|
18
|
-
const result = matcher.exec(host);
|
|
19
|
-
if (!result)
|
|
20
|
-
return null;
|
|
21
|
-
return { ...result.groups };
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=host-params.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"host-params.js","sourceRoot":"","sources":["../../plan/host-params.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,UAAU,iBAAiB,CAC/B,OAAsB,EACtB,OAAgB;IAEhB,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAA;IACvB,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IACxC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IACtB,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACjC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAA;IACxB,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,CAAA;AAC7B,CAAC"}
|
package/dist/plan/host.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Server host URL and its parsed form.
|
|
3
|
-
*
|
|
4
|
-
* The server host URL is the canonical address of THIS kernel server. It may
|
|
5
|
-
* contain host placeholders (`{tenant}.example.com`) for multi-tenant servers.
|
|
6
|
-
* `parseServerHost` extracts the pieces needed by the walker and the
|
|
7
|
-
* request-time host param extractor.
|
|
8
|
-
*/
|
|
9
|
-
export type ServerHost = {
|
|
10
|
-
/** Full server URL — may contain host placeholders for multi-tenant servers. */
|
|
11
|
-
url: string;
|
|
12
|
-
};
|
|
13
|
-
export type ParsedServerHost = {
|
|
14
|
-
/** Canonical host pattern (with `{name}` placeholders) used for anchoring checks. */
|
|
15
|
-
hostPattern: string;
|
|
16
|
-
/** Base path stripped of any trailing slash. */
|
|
17
|
-
basePath: string;
|
|
18
|
-
/** Compiled Host header matcher, or `null` when there are no placeholders. */
|
|
19
|
-
hostMatcher: RegExp | null;
|
|
20
|
-
/** Host placeholder names in source order. */
|
|
21
|
-
hostPlaceholders: string[];
|
|
22
|
-
};
|
|
23
|
-
export declare function parseServerHost(host: ServerHost): ParsedServerHost;
|
|
24
|
-
//# sourceMappingURL=host.d.ts.map
|
package/dist/plan/host.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../plan/host.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,MAAM,UAAU,GAAG;IACvB,gFAAgF;IAChF,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,qFAAqF;IACrF,WAAW,EAAE,MAAM,CAAA;IACnB,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAA;IAChB,8EAA8E;IAC9E,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,8CAA8C;IAC9C,gBAAgB,EAAE,MAAM,EAAE,CAAA;CAC3B,CAAA;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,gBAAgB,CAQlE"}
|
package/dist/plan/host.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Server host URL and its parsed form.
|
|
3
|
-
*
|
|
4
|
-
* The server host URL is the canonical address of THIS kernel server. It may
|
|
5
|
-
* contain host placeholders (`{tenant}.example.com`) for multi-tenant servers.
|
|
6
|
-
* `parseServerHost` extracts the pieces needed by the walker and the
|
|
7
|
-
* request-time host param extractor.
|
|
8
|
-
*/
|
|
9
|
-
import { compileHostMatcher, parseUrlTemplate } from '@astrale-os/kernel-api/routed';
|
|
10
|
-
export function parseServerHost(host) {
|
|
11
|
-
const parsed = parseUrlTemplate(host.url);
|
|
12
|
-
return {
|
|
13
|
-
hostPattern: parsed.hostPattern,
|
|
14
|
-
basePath: stripTrailingSlash(parsed.basePath),
|
|
15
|
-
hostMatcher: parsed.hostPlaceholders.length > 0 ? compileHostMatcher(parsed.hostPattern) : null,
|
|
16
|
-
hostPlaceholders: parsed.hostPlaceholders,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function stripTrailingSlash(p) {
|
|
20
|
-
if (p.length > 1 && p.endsWith('/'))
|
|
21
|
-
return p.slice(0, -1);
|
|
22
|
-
return p;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=host.js.map
|
package/dist/plan/host.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../plan/host.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAkBpF,MAAM,UAAU,eAAe,CAAC,IAAgB;IAC9C,MAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACzC,OAAO;QACL,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,QAAQ,EAAE,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC;QAC7C,WAAW,EAAE,MAAM,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI;QAC/F,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;KAC1C,CAAA;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,CAAS;IACnC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC1D,OAAO,CAAC,CAAA;AACV,CAAC"}
|
package/dist/plan/index.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { walkDomain, type MountedFunction, type MountedRoute, type MountPlan } from './walk.js';
|
|
2
|
-
export { parseServerHost, type ServerHost, type ParsedServerHost } from './host.js';
|
|
3
|
-
export { extractHostParams } from './host-params.js';
|
|
4
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/plan/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../plan/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAA;AAC/F,OAAO,EAAE,eAAe,EAAE,KAAK,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAA;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA"}
|
package/dist/plan/index.js
DELETED
package/dist/plan/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../plan/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA2D,MAAM,WAAW,CAAA;AAC/F,OAAO,EAAE,eAAe,EAA0C,MAAM,WAAW,CAAA;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA"}
|
package/dist/plan/walk.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Domain walker — turns a list of MountableContract into a mount plan.
|
|
3
|
-
*
|
|
4
|
-
* For each contract, decide whether it mounts on THIS server:
|
|
5
|
-
* - ambient (no binding.remoteUrl) → always mount
|
|
6
|
-
* - anchored (binding.remoteUrl set) → match host pattern against host.url
|
|
7
|
-
*
|
|
8
|
-
* Then bucket by base URL to compute one kernel mount per unique (host+basePath).
|
|
9
|
-
* Collect route bindings and check for path collisions.
|
|
10
|
-
*
|
|
11
|
-
* See docs/protocol-redesign.md §6 ("Server").
|
|
12
|
-
*/
|
|
13
|
-
import type { MountableContract, RouteBinding } from '@astrale-os/kernel-api/routed';
|
|
14
|
-
import { type ServerHost } from './host.js';
|
|
15
|
-
export type MountedFunction = {
|
|
16
|
-
contract: MountableContract;
|
|
17
|
-
/**
|
|
18
|
-
* Base URL template for this function's kernel mount.
|
|
19
|
-
*
|
|
20
|
-
* Ambient functions share the server host URL. Anchored functions use
|
|
21
|
-
* their own `binding.remoteUrl` (verified to match the server host).
|
|
22
|
-
*/
|
|
23
|
-
baseUrl: string;
|
|
24
|
-
/** Anchored functions only — the parsed base path from remoteUrl. */
|
|
25
|
-
basePath: string;
|
|
26
|
-
};
|
|
27
|
-
export type MountedRoute = {
|
|
28
|
-
contract: MountableContract;
|
|
29
|
-
route: RouteBinding;
|
|
30
|
-
/** Full path from base URL (host stripped) + route.path. */
|
|
31
|
-
fullPath: string;
|
|
32
|
-
/** Normalized pattern: `{name}` → `:p`, `{name+}` → `*` — used for collision detection. */
|
|
33
|
-
normalizedKey: string;
|
|
34
|
-
};
|
|
35
|
-
export type MountPlan = {
|
|
36
|
-
/** Kernel mounts keyed by their base path (relative to the server host URL). */
|
|
37
|
-
kernelMounts: Map<string, MountedFunction[]>;
|
|
38
|
-
/** Route mounts. */
|
|
39
|
-
routes: MountedRoute[];
|
|
40
|
-
/** Fully-qualified method name → mounted function (for dispatch lookup). */
|
|
41
|
-
methodIndex: Map<string, MountedFunction>;
|
|
42
|
-
/**
|
|
43
|
-
* Compiled Host header matcher when the server host URL contains placeholders.
|
|
44
|
-
* Used at request time to extract host params and merge into params.
|
|
45
|
-
*/
|
|
46
|
-
hostMatcher: RegExp | null;
|
|
47
|
-
/** Names of host placeholders, in source order. */
|
|
48
|
-
hostPlaceholders: string[];
|
|
49
|
-
};
|
|
50
|
-
export declare function walkDomain(contracts: MountableContract[], host: ServerHost): MountPlan;
|
|
51
|
-
//# sourceMappingURL=walk.d.ts.map
|
package/dist/plan/walk.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../../plan/walk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAIpF,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,WAAW,CAAA;AAI5D,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,iBAAiB,CAAA;IAC3B;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAA;IACf,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,KAAK,EAAE,YAAY,CAAA;IACnB,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAA;IAChB,2FAA2F;IAC3F,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,gFAAgF;IAChF,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,CAAA;IAC5C,oBAAoB;IACpB,MAAM,EAAE,YAAY,EAAE,CAAA;IACtB,4EAA4E;IAC5E,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IACzC;;;OAGG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,mDAAmD;IACnD,gBAAgB,EAAE,MAAM,EAAE,CAAA;CAC3B,CAAA;AAID,wBAAgB,UAAU,CAAC,SAAS,EAAE,iBAAiB,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,SAAS,CAgGtF"}
|
package/dist/plan/walk.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Domain walker — turns a list of MountableContract into a mount plan.
|
|
3
|
-
*
|
|
4
|
-
* For each contract, decide whether it mounts on THIS server:
|
|
5
|
-
* - ambient (no binding.remoteUrl) → always mount
|
|
6
|
-
* - anchored (binding.remoteUrl set) → match host pattern against host.url
|
|
7
|
-
*
|
|
8
|
-
* Then bucket by base URL to compute one kernel mount per unique (host+basePath).
|
|
9
|
-
* Collect route bindings and check for path collisions.
|
|
10
|
-
*
|
|
11
|
-
* See docs/protocol-redesign.md §6 ("Server").
|
|
12
|
-
*/
|
|
13
|
-
import { isSubdomainOf, parseUrlTemplate } from '@astrale-os/kernel-api/routed';
|
|
14
|
-
import { parseServerHost } from './host.js';
|
|
15
|
-
// ─── Walk ────────────────────────────────────────────────────────────────────
|
|
16
|
-
export function walkDomain(contracts, host) {
|
|
17
|
-
const parsed = parseServerHost(host);
|
|
18
|
-
const kernelMounts = new Map();
|
|
19
|
-
const routes = [];
|
|
20
|
-
const methodIndex = new Map();
|
|
21
|
-
const routeCollisionKeys = new Map();
|
|
22
|
-
for (const contract of contracts) {
|
|
23
|
-
const binding = contract.binding;
|
|
24
|
-
const remoteUrl = binding?.remoteUrl;
|
|
25
|
-
let basePath;
|
|
26
|
-
let baseUrl;
|
|
27
|
-
if (!remoteUrl) {
|
|
28
|
-
// Ambient — mounts at the server host URL.
|
|
29
|
-
basePath = parsed.basePath;
|
|
30
|
-
baseUrl = host.url;
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
// Anchored — must match or be a subdomain of the server's host pattern.
|
|
34
|
-
const fnParsed = parseUrlTemplate(remoteUrl);
|
|
35
|
-
if (!isSubdomainOf(fnParsed.hostPattern, parsed.hostPattern)) {
|
|
36
|
-
// Not this server's responsibility — skip (debug log).
|
|
37
|
-
// oxlint-disable-next-line no-console
|
|
38
|
-
console.debug(`[server] Skipping ${contract.ref}: remoteUrl host "${fnParsed.hostPattern}" does not match server host "${parsed.hostPattern}"`);
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
basePath = stripTrailingSlash(fnParsed.basePath);
|
|
42
|
-
baseUrl = remoteUrl;
|
|
43
|
-
}
|
|
44
|
-
const mounted = { contract, baseUrl, basePath };
|
|
45
|
-
methodIndex.set(contract.ref, mounted);
|
|
46
|
-
// Add to the kernel mount bucket for this basePath.
|
|
47
|
-
const bucket = kernelMounts.get(basePath) ?? [];
|
|
48
|
-
bucket.push(mounted);
|
|
49
|
-
kernelMounts.set(basePath, bucket);
|
|
50
|
-
// Route binding?
|
|
51
|
-
if (binding?.route) {
|
|
52
|
-
const route = binding.route;
|
|
53
|
-
const fullPath = joinPath(basePath, route.path);
|
|
54
|
-
const normalizedPath = normalizePath(fullPath);
|
|
55
|
-
const normalizedKey = `${route.method} ${normalizedPath}`;
|
|
56
|
-
if (route.method === '*') {
|
|
57
|
-
// Wildcard: collides with ANY existing route on this path.
|
|
58
|
-
const wildcardKey = `* ${normalizedPath}`;
|
|
59
|
-
const existingWild = routeCollisionKeys.get(wildcardKey);
|
|
60
|
-
if (existingWild) {
|
|
61
|
-
throw new Error(`Route collision: ${contract.ref} and ${existingWild} both mount at ${wildcardKey}`);
|
|
62
|
-
}
|
|
63
|
-
for (const m of ['GET', 'POST', 'PUT', 'PATCH', 'DELETE']) {
|
|
64
|
-
const specificKey = `${m} ${normalizedPath}`;
|
|
65
|
-
const existingSpecific = routeCollisionKeys.get(specificKey);
|
|
66
|
-
if (existingSpecific) {
|
|
67
|
-
throw new Error(`Route collision: ${contract.ref} (wildcard) and ${existingSpecific} both mount at ${specificKey}`);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
routeCollisionKeys.set(wildcardKey, contract.ref);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
// Specific method: check same method AND existing wildcard.
|
|
74
|
-
const existing = routeCollisionKeys.get(normalizedKey);
|
|
75
|
-
if (existing) {
|
|
76
|
-
throw new Error(`Route collision: ${contract.ref} and ${existing} both mount at ${normalizedKey}`);
|
|
77
|
-
}
|
|
78
|
-
const existingWild = routeCollisionKeys.get(`* ${normalizedPath}`);
|
|
79
|
-
if (existingWild) {
|
|
80
|
-
throw new Error(`Route collision: ${contract.ref} and ${existingWild} (wildcard) both mount at * ${normalizedPath}`);
|
|
81
|
-
}
|
|
82
|
-
routeCollisionKeys.set(normalizedKey, contract.ref);
|
|
83
|
-
}
|
|
84
|
-
routes.push({ contract, route, fullPath, normalizedKey });
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
kernelMounts,
|
|
89
|
-
routes,
|
|
90
|
-
methodIndex,
|
|
91
|
-
hostMatcher: parsed.hostMatcher,
|
|
92
|
-
hostPlaceholders: parsed.hostPlaceholders,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
|
96
|
-
function stripTrailingSlash(p) {
|
|
97
|
-
if (p.length > 1 && p.endsWith('/'))
|
|
98
|
-
return p.slice(0, -1);
|
|
99
|
-
return p;
|
|
100
|
-
}
|
|
101
|
-
function joinPath(base, child) {
|
|
102
|
-
const b = stripTrailingSlash(base);
|
|
103
|
-
// child is guaranteed to start with '/'
|
|
104
|
-
return `${b}${child}` || '/';
|
|
105
|
-
}
|
|
106
|
-
/** Normalize a path template for collision detection. */
|
|
107
|
-
function normalizePath(path) {
|
|
108
|
-
return path.replace(/\{[a-zA-Z_]\w*[+*]\}/g, '*').replace(/\{[a-zA-Z_]\w*\}/g, ':p');
|
|
109
|
-
}
|
|
110
|
-
//# sourceMappingURL=walk.js.map
|
package/dist/plan/walk.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"walk.js","sourceRoot":"","sources":["../../plan/walk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAE/E,OAAO,EAAE,eAAe,EAAmB,MAAM,WAAW,CAAA;AA0C5D,gFAAgF;AAEhF,MAAM,UAAU,UAAU,CAAC,SAA8B,EAAE,IAAgB;IACzE,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,CAAA;IAEpC,MAAM,YAAY,GAAG,IAAI,GAAG,EAA6B,CAAA;IACzD,MAAM,MAAM,GAAmB,EAAE,CAAA;IACjC,MAAM,WAAW,GAAG,IAAI,GAAG,EAA2B,CAAA;IACtD,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAkB,CAAA;IAEpD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAA;QAChC,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,CAAA;QAEpC,IAAI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→ `Response`.
|
|
3
|
-
*
|
|
4
|
-
* Tags binary responses with `x-binary-result: true` so kernel-client can
|
|
5
|
-
* distinguish them from accidental opaque blobs (the kernel envelope is
|
|
6
|
-
* bypassed for binary results).
|
|
7
|
-
*
|
|
8
|
-
* Header precedence (low → high, later wins):
|
|
9
|
-
* CORS headers < `br.headers` < canonical `content-type` + `x-binary-result`
|
|
10
|
-
*
|
|
11
|
-
* This lets a handler pass through any framing-specific headers its body
|
|
12
|
-
* needs (e.g. `x-vercel-ai-ui-message-stream`, `x-accel-buffering`, a tuned
|
|
13
|
-
* `cache-control`) while guaranteeing the kernel's own invariants
|
|
14
|
-
* (`content-type` matches `br.contentType`, `x-binary-result` is always
|
|
15
|
-
* set) cannot be accidentally clobbered.
|
|
16
|
-
*/
|
|
17
|
-
import type { BinaryResult } from '@astrale-os/kernel-api';
|
|
18
|
-
export declare function buildBinaryResponse(br: BinaryResult, corsHeaders: Record<string, string>): Response;
|
|
19
|
-
//# sourceMappingURL=binary.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"binary.d.ts","sourceRoot":"","sources":["../../render/binary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAM1D,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,YAAY,EAChB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAClC,QAAQ,CAcV"}
|
package/dist/render/binary.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Binary HTTP response — `BinaryResult` → `Response`.
|
|
3
|
-
*
|
|
4
|
-
* Tags binary responses with `x-binary-result: true` so kernel-client can
|
|
5
|
-
* distinguish them from accidental opaque blobs (the kernel envelope is
|
|
6
|
-
* bypassed for binary results).
|
|
7
|
-
*
|
|
8
|
-
* Header precedence (low → high, later wins):
|
|
9
|
-
* CORS headers < `br.headers` < canonical `content-type` + `x-binary-result`
|
|
10
|
-
*
|
|
11
|
-
* This lets a handler pass through any framing-specific headers its body
|
|
12
|
-
* needs (e.g. `x-vercel-ai-ui-message-stream`, `x-accel-buffering`, a tuned
|
|
13
|
-
* `cache-control`) while guaranteeing the kernel's own invariants
|
|
14
|
-
* (`content-type` matches `br.contentType`, `x-binary-result` is always
|
|
15
|
-
* set) cannot be accidentally clobbered.
|
|
16
|
-
*/
|
|
17
|
-
import { BINARY_RESULT_HEADER } from '@astrale-os/kernel-api';
|
|
18
|
-
import { toBody } from './body.js';
|
|
19
|
-
export function buildBinaryResponse(br, corsHeaders) {
|
|
20
|
-
const body = br.body instanceof Uint8Array
|
|
21
|
-
? toBody(br.body)
|
|
22
|
-
: br.body;
|
|
23
|
-
return new Response(body, {
|
|
24
|
-
status: br.status ?? 200,
|
|
25
|
-
headers: {
|
|
26
|
-
...corsHeaders,
|
|
27
|
-
...br.headers,
|
|
28
|
-
'content-type': br.contentType,
|
|
29
|
-
[BINARY_RESULT_HEADER]: 'true',
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=binary.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"binary.js","sourceRoot":"","sources":["../../render/binary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAElC,MAAM,UAAU,mBAAmB,CACjC,EAAgB,EAChB,WAAmC;IAEnC,MAAM,IAAI,GACR,EAAE,CAAC,IAAI,YAAY,UAAU;QAC3B,CAAC,CAAE,MAAM,CAAC,EAAE,CAAC,IAAI,CAAiB;QAClC,CAAC,CAAE,EAAE,CAAC,IAAmC,CAAA;IAC7C,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE;QACxB,MAAM,EAAE,EAAE,CAAC,MAAM,IAAI,GAAG;QACxB,OAAO,EAAE;YACP,GAAG,WAAW;YACd,GAAG,EAAE,CAAC,OAAO;YACb,cAAc,EAAE,EAAE,CAAC,WAAW;YAC9B,CAAC,oBAAoB,CAAC,EAAE,MAAM;SAC/B;KACF,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/render/body.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convert codec output (string or Uint8Array) to a Response-compatible body.
|
|
3
|
-
*
|
|
4
|
-
* Text codecs (JSON) return strings — passed through.
|
|
5
|
-
* Binary codecs (MsgPack) return Uint8Array — narrowed to ArrayBuffer for
|
|
6
|
-
* tsgo's stricter `BodyInit` typing. The fast path avoids a copy when the
|
|
7
|
-
* Uint8Array is a full view of its backing buffer.
|
|
8
|
-
*/
|
|
9
|
-
export declare function toBody(data: string | Uint8Array): string | ArrayBuffer;
|
|
10
|
-
//# sourceMappingURL=body.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"body.d.ts","sourceRoot":"","sources":["../../render/body.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,WAAW,CAMtE"}
|
package/dist/render/body.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convert codec output (string or Uint8Array) to a Response-compatible body.
|
|
3
|
-
*
|
|
4
|
-
* Text codecs (JSON) return strings — passed through.
|
|
5
|
-
* Binary codecs (MsgPack) return Uint8Array — narrowed to ArrayBuffer for
|
|
6
|
-
* tsgo's stricter `BodyInit` typing. The fast path avoids a copy when the
|
|
7
|
-
* Uint8Array is a full view of its backing buffer.
|
|
8
|
-
*/
|
|
9
|
-
export function toBody(data) {
|
|
10
|
-
if (typeof data === 'string')
|
|
11
|
-
return data;
|
|
12
|
-
if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
|
|
13
|
-
return data.buffer;
|
|
14
|
-
}
|
|
15
|
-
return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=body.js.map
|
package/dist/render/body.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"body.js","sourceRoot":"","sources":["../../render/body.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,UAAU,MAAM,CAAC,IAAyB;IAC9C,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAA;IACzC,IAAI,IAAI,CAAC,UAAU,KAAK,CAAC,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QACxE,OAAO,IAAI,CAAC,MAAqB,CAAA;IACnC,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAgB,CAAA;AAC7F,CAAC"}
|
package/dist/render/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../render/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/render/index.js
DELETED
package/dist/render/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../render/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Credential extraction for route bindings.
|
|
3
|
-
*
|
|
4
|
-
* A route binding declares where to find the request credential — header,
|
|
5
|
-
* cookie, or query parameter — via its `route.credential` field. This module
|
|
6
|
-
* implements the lookup, including cookie splitting and URL decoding.
|
|
7
|
-
*/
|
|
8
|
-
import type { CredentialSource } from '@astrale-os/kernel-api';
|
|
9
|
-
export declare function readCredential(req: Request, source: CredentialSource): string;
|
|
10
|
-
//# sourceMappingURL=credential.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"credential.d.ts","sourceRoot":"","sources":["../../routed/credential.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAA0B,MAAM,wBAAwB,CAAA;AAEtF,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAS7E"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Credential extraction for route bindings.
|
|
3
|
-
*
|
|
4
|
-
* A route binding declares where to find the request credential — header,
|
|
5
|
-
* cookie, or query parameter — via its `route.credential` field. This module
|
|
6
|
-
* implements the lookup, including cookie splitting and URL decoding.
|
|
7
|
-
*/
|
|
8
|
-
export function readCredential(req, source) {
|
|
9
|
-
if (Array.isArray(source)) {
|
|
10
|
-
for (const s of source) {
|
|
11
|
-
const value = readSingle(req, s);
|
|
12
|
-
if (value)
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
return '';
|
|
16
|
-
}
|
|
17
|
-
return readSingle(req, source);
|
|
18
|
-
}
|
|
19
|
-
function readSingle(req, source) {
|
|
20
|
-
switch (source.in) {
|
|
21
|
-
case 'header': {
|
|
22
|
-
const raw = req.headers.get(source.name ?? 'authorization') ?? '';
|
|
23
|
-
return stripBearerPrefix(raw);
|
|
24
|
-
}
|
|
25
|
-
case 'query':
|
|
26
|
-
return new URL(req.url).searchParams.get(source.name ?? 'credential') ?? '';
|
|
27
|
-
case 'cookie': {
|
|
28
|
-
const header = req.headers.get('cookie');
|
|
29
|
-
if (!header || !source.name)
|
|
30
|
-
return '';
|
|
31
|
-
const cookies = header.split(';').map((c) => c.trim());
|
|
32
|
-
for (const c of cookies) {
|
|
33
|
-
const [k, v] = c.split('=', 2);
|
|
34
|
-
if (k === source.name)
|
|
35
|
-
return decodeURIComponent(v ?? '');
|
|
36
|
-
}
|
|
37
|
-
return '';
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Strip an optional `Bearer ` (case-insensitive) prefix from an
|
|
43
|
-
* Authorization-header value. Other values pass through as-is —
|
|
44
|
-
* validation is the auth layer's responsibility, not extraction's.
|
|
45
|
-
*
|
|
46
|
-
* Header-source credentials are interpreted per RFC 7235: the header value is
|
|
47
|
-
* `<scheme> <credentials>`, so an optional leading `Bearer ` prefix is
|
|
48
|
-
* stripped. This keeps the reader HTTP-standard-compliant and lets route
|
|
49
|
-
* bindings interoperate with any client that sends `Authorization: Bearer
|
|
50
|
-
* <token>`
|
|
51
|
-
*/
|
|
52
|
-
function stripBearerPrefix(value) {
|
|
53
|
-
return value.trim().replace(/^Bearer\s+/i, '');
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=credential.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"credential.js","sourceRoot":"","sources":["../../routed/credential.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,UAAU,cAAc,CAAC,GAAY,EAAE,MAAwB;IACnE,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;YACvB,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;YAChC,IAAI,KAAK;gBAAE,OAAO,KAAK,CAAA;QACzB,CAAC;QACD,OAAO,EAAE,CAAA;IACX,CAAC;IACD,OAAO,UAAU,CAA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