@astrale-os/kernel-server 0.4.17 → 0.5.0-beta.10
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 +2 -0
- package/dist/capture.js +9 -0
- package/dist/cors/cors.d.ts +21 -0
- package/dist/cors/cors.js +135 -0
- package/dist/cors/index.d.ts +2 -0
- package/dist/cors/index.js +1 -0
- package/dist/cors/types.d.ts +11 -0
- package/dist/cors/types.js +1 -0
- package/dist/errors/availability.d.ts +10 -0
- package/dist/errors/availability.js +14 -0
- package/dist/errors/classify.d.ts +3 -0
- package/dist/errors/classify.js +41 -0
- package/dist/errors/index.d.ts +4 -0
- package/dist/errors/index.js +4 -0
- package/dist/errors/request-body.d.ts +7 -0
- package/dist/errors/request-body.js +14 -0
- package/dist/errors/response-body.d.ts +4 -0
- package/dist/errors/response-body.js +8 -0
- package/dist/index.d.ts +5 -12
- package/dist/index.js +4 -19
- package/dist/invocation/context.d.ts +6 -0
- package/dist/invocation/context.js +60 -0
- package/dist/invocation/identity.d.ts +9 -0
- package/dist/invocation/identity.js +11 -0
- package/dist/invocation/index.d.ts +4 -3
- package/dist/invocation/index.js +3 -3
- package/dist/invocation/publication-route.d.ts +13 -0
- package/dist/invocation/publication-route.js +44 -0
- package/dist/invocation/types.d.ts +62 -0
- package/dist/invocation/types.js +1 -0
- package/dist/issuer/exchange.d.ts +12 -0
- package/dist/issuer/exchange.js +136 -0
- package/dist/issuer/index.d.ts +3 -0
- package/dist/issuer/index.js +1 -0
- package/dist/issuer/routes.d.ts +13 -0
- package/dist/issuer/routes.js +149 -0
- package/dist/issuer/types.d.ts +11 -0
- package/dist/issuer/types.js +1 -0
- package/dist/lifecycle/active.d.ts +39 -0
- package/dist/lifecycle/active.js +199 -0
- package/dist/lifecycle/index.d.ts +1 -0
- package/dist/lifecycle/index.js +1 -0
- package/dist/publication/delivery/handler.d.ts +9 -0
- package/dist/publication/delivery/handler.js +127 -0
- package/dist/publication/delivery/index.d.ts +2 -0
- package/dist/publication/delivery/index.js +1 -0
- package/dist/publication/delivery/types.d.ts +11 -0
- package/dist/publication/delivery/types.js +1 -0
- package/dist/publication/index.d.ts +3 -0
- package/dist/publication/index.js +2 -0
- package/dist/publication/snapshot.d.ts +16 -0
- package/dist/publication/snapshot.js +37 -0
- package/dist/publication/table.d.ts +4 -0
- package/dist/publication/table.js +16 -0
- package/dist/publication/types.d.ts +22 -0
- package/dist/publication/types.js +1 -0
- package/dist/routes/index.d.ts +1 -0
- package/dist/routes/index.js +1 -0
- package/dist/routes/routes.d.ts +25 -0
- package/dist/routes/routes.js +448 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.js +266 -0
- package/dist/transport/body.d.ts +4 -0
- package/dist/transport/body.js +50 -0
- package/dist/transport/codecs.d.ts +4 -0
- package/dist/transport/codecs.js +5 -0
- package/dist/transport/credential.d.ts +10 -0
- package/dist/transport/credential.js +28 -0
- package/dist/transport/http/handler.d.ts +17 -0
- package/dist/transport/http/handler.js +180 -0
- package/dist/transport/http/index.d.ts +2 -0
- package/dist/transport/http/index.js +2 -0
- package/dist/transport/http/render.d.ts +31 -0
- package/dist/transport/http/render.js +288 -0
- package/dist/transport/index.d.ts +9 -0
- package/dist/transport/index.js +8 -0
- package/dist/transport/router.d.ts +4 -0
- package/dist/transport/router.js +4 -0
- package/dist/transport/stream-error.d.ts +3 -0
- package/dist/transport/stream-error.js +13 -0
- package/dist/transport/types.d.ts +28 -0
- package/dist/transport/types.js +1 -0
- package/dist/transport/websocket/index.d.ts +2 -0
- package/dist/transport/websocket/index.js +2 -0
- package/dist/transport/websocket/session.d.ts +20 -0
- package/dist/transport/websocket/session.js +335 -0
- package/dist/transport/websocket/upgrade.d.ts +20 -0
- package/dist/transport/websocket/upgrade.js +46 -0
- package/dist/types.d.ts +65 -0
- package/dist/types.js +1 -0
- package/package.json +24 -14
- 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/index.d.ts.map +0 -1
- package/dist/index.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/invocation/index.d.ts.map +0 -1
- package/dist/invocation/index.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/envelope/ws.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Kernel envelope WS connection — universal RPC envelope over WebSockets.
|
|
3
|
-
*
|
|
4
|
-
* Each frame is a kernel envelope. Codec is fixed for the lifetime of the
|
|
5
|
-
* connection (negotiated at upgrade via `?codec=`). Stream responses use
|
|
6
|
-
* kernel stream framing (`{stream:{id,index,data}}`). Per-message credentials
|
|
7
|
-
* live in the top-level `creds` field.
|
|
8
|
-
*
|
|
9
|
-
* Binary output mode is partially supported: small Uint8Array bodies are
|
|
10
|
-
* delivered as a single stream chunk + end frame; ReadableStream bodies are
|
|
11
|
-
* marked TODO and rejected with INTERNAL_ERROR for now.
|
|
12
|
-
*/
|
|
13
|
-
import { KERNEL_ERROR_CODES, classifyError, decodeKernelRequest, encodeKernelError, encodeKernelRedirect, encodeKernelResponse, encodeStreamChunk, encodeStreamEnd, encodeStreamError, isBinaryResult, } from '@astrale-os/kernel-api';
|
|
14
|
-
import { dispatchInvocation } from '../invocation/index.js';
|
|
15
|
-
const WS_OPEN = 1;
|
|
16
|
-
// ─── Connection ─────────────────────────────────────────────────────────────
|
|
17
|
-
export class KernelWsConnection {
|
|
18
|
-
ws;
|
|
19
|
-
codec;
|
|
20
|
-
dispatcher;
|
|
21
|
-
host;
|
|
22
|
-
constructor(ws, codec, dispatcher, host) {
|
|
23
|
-
this.ws = ws;
|
|
24
|
-
this.codec = codec;
|
|
25
|
-
this.dispatcher = dispatcher;
|
|
26
|
-
this.host = host;
|
|
27
|
-
}
|
|
28
|
-
start() {
|
|
29
|
-
/* no-op — protocol-level ping handled by transport */
|
|
30
|
-
}
|
|
31
|
-
handleMessage(data) {
|
|
32
|
-
this.processMessage(data).catch((err) => {
|
|
33
|
-
// oxlint-disable-next-line no-console
|
|
34
|
-
console.error('[ws] message handler crashed:', err);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
async processMessage(data) {
|
|
38
|
-
// 1. Decode codec frame
|
|
39
|
-
let raw;
|
|
40
|
-
try {
|
|
41
|
-
const input = typeof data === 'string' ? data : data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
42
|
-
raw = this.codec.decode(input);
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
this.sendFrame(encodeKernelError(null, {
|
|
46
|
-
code: KERNEL_ERROR_CODES.PARSE_ERROR,
|
|
47
|
-
message: 'Parse error',
|
|
48
|
-
}));
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
// 2. Decode envelope
|
|
52
|
-
let request;
|
|
53
|
-
try {
|
|
54
|
-
request = decodeKernelRequest(raw);
|
|
55
|
-
}
|
|
56
|
-
catch (e) {
|
|
57
|
-
this.sendFrame(encodeKernelError(null, {
|
|
58
|
-
code: KERNEL_ERROR_CODES.INVALID_REQUEST,
|
|
59
|
-
message: e instanceof Error ? e.message : 'Invalid request',
|
|
60
|
-
}));
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
// 3. Credential — fixed `creds` top-level field on each frame.
|
|
64
|
-
const cred = request.creds ?? '';
|
|
65
|
-
// 4. Dispatch
|
|
66
|
-
const isAck = request.id === undefined;
|
|
67
|
-
const result = await dispatchInvocation(this.dispatcher, {
|
|
68
|
-
path: request.method,
|
|
69
|
-
credential: cred,
|
|
70
|
-
params: request.params,
|
|
71
|
-
...(request.self === undefined ? {} : { self: request.self }),
|
|
72
|
-
}, isAck ? { ack: true } : { id: request.id }, this.host);
|
|
73
|
-
// 5. Send result
|
|
74
|
-
switch (result.kind) {
|
|
75
|
-
case 'ack':
|
|
76
|
-
return;
|
|
77
|
-
case 'success': {
|
|
78
|
-
if (isBinaryResult(result.data)) {
|
|
79
|
-
// Binary output over WS: only handle Uint8Array bodies inline.
|
|
80
|
-
// ReadableStream / AsyncIterable bodies require duplex framing — TODO.
|
|
81
|
-
const br = result.data;
|
|
82
|
-
if (br.body instanceof Uint8Array) {
|
|
83
|
-
// Frame as a stream chunk + end so the client knows it's the full body.
|
|
84
|
-
// Use the kernel stream id semantics: id from request, single chunk.
|
|
85
|
-
this.sendFrame(encodeStreamChunk(result.id, 0, {
|
|
86
|
-
_binary: true,
|
|
87
|
-
contentType: br.contentType,
|
|
88
|
-
bytes: Array.from(br.body),
|
|
89
|
-
}));
|
|
90
|
-
this.sendFrame(encodeStreamEnd(result.id));
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
this.sendFrame(encodeKernelError(result.id, {
|
|
94
|
-
code: KERNEL_ERROR_CODES.INTERNAL_ERROR,
|
|
95
|
-
message: 'Streaming binary bodies over WS are not yet supported',
|
|
96
|
-
}));
|
|
97
|
-
}
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
this.sendFrame(encodeKernelResponse(result.id, result.data));
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
case 'error':
|
|
104
|
-
this.sendFrame(encodeKernelError(result.id, result.error));
|
|
105
|
-
return;
|
|
106
|
-
case 'redirect':
|
|
107
|
-
this.sendFrame(encodeKernelRedirect(result.id, result.redirection));
|
|
108
|
-
return;
|
|
109
|
-
case 'stream':
|
|
110
|
-
await this.sendStream(result.id, result.generator);
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
async sendStream(id, generator) {
|
|
115
|
-
try {
|
|
116
|
-
let index = 0;
|
|
117
|
-
for await (const chunk of generator) {
|
|
118
|
-
if (this.ws.readyState !== WS_OPEN)
|
|
119
|
-
return;
|
|
120
|
-
this.sendFrame(encodeStreamChunk(id, index++, chunk));
|
|
121
|
-
}
|
|
122
|
-
this.sendFrame(encodeStreamEnd(id));
|
|
123
|
-
}
|
|
124
|
-
catch (err) {
|
|
125
|
-
const error = classifyError(err);
|
|
126
|
-
this.sendFrame(encodeStreamError(id, error));
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
sendFrame(obj) {
|
|
130
|
-
if (this.ws.readyState !== WS_OPEN)
|
|
131
|
-
return;
|
|
132
|
-
this.ws.send(this.codec.encode(obj));
|
|
133
|
-
}
|
|
134
|
-
handleClose() {
|
|
135
|
-
/* future: cancel in-flight dispatches */
|
|
136
|
-
}
|
|
137
|
-
handleError(error) {
|
|
138
|
-
// oxlint-disable-next-line no-console
|
|
139
|
-
console.error('[ws] connection error:', error.message);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
//# sourceMappingURL=ws.js.map
|
package/dist/envelope/ws.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ws.js","sourceRoot":"","sources":["../../envelope/ws.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,cAAc,GACf,MAAM,wBAAwB,CAAA;AAK/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAU3D,MAAM,OAAO,GAAG,CAAC,CAAA;AAEjB,+EAA+E;AAE/E,MAAM,OAAO,kBAAkB;IAEV,EAAE;IACF,KAAK;IACL,UAAU;IACV,IAAI;IAJvB,YACmB,EAAiB,EACjB,KAAY,EACZ,UAAsB,EACtB,IAAqB;kBAHrB,EAAE;qBACF,KAAK;0BACL,UAAU;oBACV,IAAI;IACpB,CAAC;IAEJ,KAAK;QACH,sDAAsD;IACxD,CAAC;IAED,aAAa,CAAC,IAAuC;QACnD,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACtC,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,GAAG,CAAC,CAAA;QACrD,CAAC,CAAC,CAAA;IACJ,CAAC;IAEO,KAAK,CAAC,cAAc,CAAC,IAAu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KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;IACtC,CAAC;IAED,WAAW;QACT,yCAAyC;IAC3C,CAAC;IAED,WAAW,CAAC,KAAY;QACtB,sCAAsC;QACtC,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;IACxD,CAAC;CACF"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,KAAK,eAAe,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACvF,OAAO,EACL,0BAA0B,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,GACxB,MAAM,sBAAsB,CAAA;AAI7B,OAAO,EACL,UAAU,EACV,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,SAAS,GACf,MAAM,iBAAiB,CAAA;AAIxB,OAAO,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAA;AAI7D,OAAO,EAAE,sBAAsB,EAAE,KAAK,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AACzF,OAAO,EAAE,kBAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,KAAK,EACV,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,KAAK,GACX,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,UAAU,GAChB,MAAM,uBAAuB,CAAA;AAI9B,OAAO,EAAE,kBAA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
|
-
import type { CallRedirection, DispatchResult, KernelErrorPayload, RequestId } from '@astrale-os/kernel-api';
|
|
2
|
-
import type { CapabilityHost } from '../capabilities/index.js';
|
|
3
|
-
import type { Invocation, Dispatcher } from './dispatcher.js';
|
|
4
|
-
export type InvocationResponse = {
|
|
5
|
-
kind: 'success';
|
|
6
|
-
id: RequestId;
|
|
7
|
-
data: unknown;
|
|
8
|
-
} | {
|
|
9
|
-
kind: 'error';
|
|
10
|
-
id: RequestId;
|
|
11
|
-
error: KernelErrorPayload;
|
|
12
|
-
} | {
|
|
13
|
-
kind: 'stream';
|
|
14
|
-
id: RequestId;
|
|
15
|
-
generator: AsyncGenerator<unknown>;
|
|
16
|
-
} | {
|
|
17
|
-
kind: 'redirect';
|
|
18
|
-
id: RequestId;
|
|
19
|
-
redirection: CallRedirection;
|
|
20
|
-
} | {
|
|
21
|
-
kind: 'ack';
|
|
22
|
-
};
|
|
23
|
-
export type InvocationReply = {
|
|
24
|
-
ack: true;
|
|
25
|
-
} | {
|
|
26
|
-
id: RequestId;
|
|
27
|
-
};
|
|
28
|
-
/** Execute one invocation with unconditional, host-adapted capabilities. */
|
|
29
|
-
export declare function executeInvocation(dispatcher: Dispatcher, invocation: Invocation, host?: CapabilityHost): Promise<DispatchResult>;
|
|
30
|
-
/** Add request correlation, acknowledgement, and error classification. */
|
|
31
|
-
export declare function dispatchInvocation(dispatcher: Dispatcher, invocation: Invocation, reply: InvocationReply, host?: CapabilityHost): Promise<InvocationResponse>;
|
|
32
|
-
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../invocation/dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,SAAS,EACV,MAAM,wBAAwB,CAAA;AAI/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAI7D,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GACjD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,GAC3D;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,cAAc,CAAC,OAAO,CAAC,CAAA;CAAE,GACrE;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,SAAS,CAAC;IAAC,WAAW,EAAE,eAAe,CAAA;CAAE,GACjE;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,CAAA;AAEnB,MAAM,MAAM,eAAe,GAAG;IAAE,GAAG,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,SAAS,CAAA;CAAE,CAAA;AAE/D,4EAA4E;AAC5E,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CAAC,cAAc,CAAC,CAgBzB;AAED,0EAA0E;AAC1E,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,eAAe,EACtB,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CAAC,kBAAkB,CAAC,CA+B7B"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { classifyError } from '@astrale-os/kernel-api';
|
|
2
|
-
import { createCapabilityLifecycle } from '../capabilities/index.js';
|
|
3
|
-
/** Execute one invocation with unconditional, host-adapted capabilities. */
|
|
4
|
-
export async function executeInvocation(dispatcher, invocation, host) {
|
|
5
|
-
const lifecycle = createCapabilityLifecycle(host);
|
|
6
|
-
try {
|
|
7
|
-
const result = await dispatcher.invoke(invocation, lifecycle.capabilities);
|
|
8
|
-
if (result.kind === 'stream') {
|
|
9
|
-
return {
|
|
10
|
-
kind: 'stream',
|
|
11
|
-
generator: settleStream(result.generator, lifecycle.settle),
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
await lifecycle.settle();
|
|
15
|
-
return result;
|
|
16
|
-
}
|
|
17
|
-
catch (error) {
|
|
18
|
-
await lifecycle.settle();
|
|
19
|
-
throw error;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/** Add request correlation, acknowledgement, and error classification. */
|
|
23
|
-
export async function dispatchInvocation(dispatcher, invocation, reply, host) {
|
|
24
|
-
if ('ack' in reply) {
|
|
25
|
-
const lifecycle = createCapabilityLifecycle(host);
|
|
26
|
-
const background = Promise.resolve().then(async () => {
|
|
27
|
-
try {
|
|
28
|
-
await dispatcher.invoke(invocation, lifecycle.capabilities);
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
// There is no response channel for acknowledged invocations.
|
|
32
|
-
// oxlint-disable-next-line no-console
|
|
33
|
-
console.error(`[invocation] Ack-mode error (${pathToString(invocation.path)}):`, error);
|
|
34
|
-
}
|
|
35
|
-
finally {
|
|
36
|
-
await lifecycle.settle();
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
host?.register(background);
|
|
40
|
-
return { kind: 'ack' };
|
|
41
|
-
}
|
|
42
|
-
try {
|
|
43
|
-
const result = await executeInvocation(dispatcher, invocation, host);
|
|
44
|
-
switch (result.kind) {
|
|
45
|
-
case 'value':
|
|
46
|
-
return { kind: 'success', id: reply.id, data: result.value };
|
|
47
|
-
case 'stream':
|
|
48
|
-
return { kind: 'stream', id: reply.id, generator: result.generator };
|
|
49
|
-
case 'redirect':
|
|
50
|
-
return { kind: 'redirect', id: reply.id, redirection: result.redirection };
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
return { kind: 'error', id: reply.id, error: classifyError(error) };
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
async function* settleStream(generator, settle) {
|
|
58
|
-
try {
|
|
59
|
-
yield* generator;
|
|
60
|
-
}
|
|
61
|
-
finally {
|
|
62
|
-
await settle();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function pathToString(path) {
|
|
66
|
-
return typeof path === 'string' ? path : path.raw;
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=dispatch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../invocation/dispatch.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAKtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAA;AAWpE,4EAA4E;AAC5E,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,UAAsB,EACtB,UAAsB,EACtB,IAAqB;IAErB,MAAM,SAAS,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAA;IACjD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,YAAY,CAAC,CAAA;QAC1E,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,SAAS,EAAE,YAAY,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC;aAC5D,CAAA;QACH,CAAC;QACD,MAAM,SAAS,CAAC,MAAM,EAAE,CAAA;QACxB,OAAO,MAAM,CAAA;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,SAAS,CAAC,MAAM,EAAE,CAAA;QACxB,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC;AAED,0EAA0E;AAC1E,MAAM,CAA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E,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAA;QAC9E,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,CAAA;IACrE,CAAC;AACH,CAAC;AAED,KAAK,SAAS,CAAC,CAAC,YAAY,CAC1B,SAAkC,EAClC,MAA2B;IAE3B,IAAI,CAAC;QACH,KAAK,CAAC,CAAC,SAAS,CAAA;IAClB,CAAC;YAAS,CAAC;QACT,MAAM,MAAM,EAAE,CAAA;IAChB,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,IAAwB;IAC5C,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAA;AACnD,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { DispatchResult, KernelAPI } from '@astrale-os/kernel-api';
|
|
2
|
-
import type { CredentialInput, Path } from '@astrale-os/kernel-core';
|
|
3
|
-
import type { Capabilities } from '../capabilities/index.js';
|
|
4
|
-
/** Accepts canonical strings and any Path implementation exposing its raw form. */
|
|
5
|
-
export type InvocationPath = string | Pick<Path, 'raw'>;
|
|
6
|
-
/** A transport-neutral call entering a hosted Astrale dispatcher. */
|
|
7
|
-
export type Invocation = {
|
|
8
|
-
path: InvocationPath;
|
|
9
|
-
credential: CredentialInput;
|
|
10
|
-
params: unknown;
|
|
11
|
-
self?: string;
|
|
12
|
-
};
|
|
13
|
-
/** The sole invocation contract required by kernel-server transports. */
|
|
14
|
-
export type Dispatcher = {
|
|
15
|
-
invoke(invocation: Invocation, caps: Capabilities): Promise<DispatchResult>;
|
|
16
|
-
};
|
|
17
|
-
/** Adapt a canonical kernel dispatcher to the narrower hosting contract. */
|
|
18
|
-
export declare function kernelDispatcher(kernel: Pick<KernelAPI, 'dispatch'>): Dispatcher;
|
|
19
|
-
//# sourceMappingURL=dispatcher.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../invocation/dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAA;AAEpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAE5D,mFAAmF;AACnF,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AAEvD,qEAAqE;AACrE,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,cAAc,CAAA;IACpB,UAAU,EAAE,eAAe,CAAA;IAC3B,MAAM,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED,yEAAyE;AACzE,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;CAC5E,CAAA;AAED,4EAA4E;AAC5E,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,UAAU,CAMhF"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/** Adapt a canonical kernel dispatcher to the narrower hosting contract. */
|
|
2
|
-
export function kernelDispatcher(kernel) {
|
|
3
|
-
return {
|
|
4
|
-
invoke({ path, credential, params, self }) {
|
|
5
|
-
return kernel.dispatch(typeof path === 'string' ? path : path.raw, credential, params, self);
|
|
6
|
-
},
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=dispatcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../invocation/dispatcher.ts"],"names":[],"mappings":"AAqBA,4EAA4E;AAC5E,MAAM,UAAU,gBAAgB,CAAC,MAAmC;IAClE,OAAO;QACL,MAAM,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE;YACvC,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;QAC9F,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../invocation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,eAAe,EACpB,KAAK,kBAAkB,GACxB,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,gBAAgB,EAChB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,UAAU,GAChB,MAAM,iBAAiB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../invocation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,GAGlB,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,gBAAgB,GAIjB,MAAM,iBAAiB,CAAA"}
|
package/dist/jwks/discovery.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OIDC discovery-document construction — the `issuer`/`jwks_uri` pair and the
|
|
3
|
-
* reachable-URL derivation behind it. Shared by `mountJwks`,
|
|
4
|
-
* `mountInstanceJwks`, and the issuer-registry mounts.
|
|
5
|
-
*
|
|
6
|
-
* Identity vs reachability — the two published fields are intentionally
|
|
7
|
-
* asymmetric, and that asymmetry is load-bearing:
|
|
8
|
-
* • `issuer` is the IDENTITY claim, published VERBATIM. OIDC Discovery /
|
|
9
|
-
* RFC 8414 require it to equal the issuer used to build the discovery URL
|
|
10
|
-
* and the `iss` claim the kernel signs into tokens. Normalizing it would
|
|
11
|
-
* break token validation whenever the configured issuer is non-canonical
|
|
12
|
-
* (a bare slug, odd casing, …) — so it is never rewritten here.
|
|
13
|
-
* • `jwks_uri` is a REACHABILITY concern: it must be a fetchable absolute URL.
|
|
14
|
-
* It is derived from the canonical issuer URL when that is usable, else from
|
|
15
|
-
* the request's externally-reachable origin (proxy headers). A bare-slug or
|
|
16
|
-
* port-0 issuer is a valid identity but an unfetchable URL — hence the
|
|
17
|
-
* divergence. (Regression coverage: M-19, host `jwks-keys.test.ts`.)
|
|
18
|
-
*
|
|
19
|
-
* Edge-topology contract — KEEP IN SYNC with kernel/host/network/Caddyfile:
|
|
20
|
-
* In the Caddy-only edge the host kernel is mounted publicly under
|
|
21
|
-
* `/kernel/{slug}` (the issuer carries that path) but served internally at the
|
|
22
|
-
* stripped path (`/` for the host, `/{id}` for children). `jwks_uri` is built
|
|
23
|
-
* from the ISSUER's path, never the request path, so the edge only strips the
|
|
24
|
-
* prefix on the way IN — no response-body rewrite. If a future edge stops
|
|
25
|
-
* stripping `/kernel/{slug}`, or a kernel is mounted at a different public
|
|
26
|
-
* path, the issuer's path and that edge rule must move together.
|
|
27
|
-
*/
|
|
28
|
-
export interface DiscoveryDoc {
|
|
29
|
-
issuer: string;
|
|
30
|
-
jwks_uri: string;
|
|
31
|
-
subject_types_supported: string[];
|
|
32
|
-
id_token_signing_alg_values_supported: string[];
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Build the OIDC discovery document served at `/.well-known/openid-configuration`.
|
|
36
|
-
* `issuer` is echoed verbatim (identity); `jwks_uri` is derived to be reachable.
|
|
37
|
-
* See the file header for why the two diverge.
|
|
38
|
-
*/
|
|
39
|
-
export declare function discoveryDoc(req: Request, issuer: string, signingAlgorithm: string): DiscoveryDoc;
|
|
40
|
-
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../jwks/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,uBAAuB,EAAE,MAAM,EAAE,CAAA;IACjC,qCAAqC,EAAE,MAAM,EAAE,CAAA;CAChD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,YAAY,CAOjG"}
|
package/dist/jwks/discovery.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OIDC discovery-document construction — the `issuer`/`jwks_uri` pair and the
|
|
3
|
-
* reachable-URL derivation behind it. Shared by `mountJwks`,
|
|
4
|
-
* `mountInstanceJwks`, and the issuer-registry mounts.
|
|
5
|
-
*
|
|
6
|
-
* Identity vs reachability — the two published fields are intentionally
|
|
7
|
-
* asymmetric, and that asymmetry is load-bearing:
|
|
8
|
-
* • `issuer` is the IDENTITY claim, published VERBATIM. OIDC Discovery /
|
|
9
|
-
* RFC 8414 require it to equal the issuer used to build the discovery URL
|
|
10
|
-
* and the `iss` claim the kernel signs into tokens. Normalizing it would
|
|
11
|
-
* break token validation whenever the configured issuer is non-canonical
|
|
12
|
-
* (a bare slug, odd casing, …) — so it is never rewritten here.
|
|
13
|
-
* • `jwks_uri` is a REACHABILITY concern: it must be a fetchable absolute URL.
|
|
14
|
-
* It is derived from the canonical issuer URL when that is usable, else from
|
|
15
|
-
* the request's externally-reachable origin (proxy headers). A bare-slug or
|
|
16
|
-
* port-0 issuer is a valid identity but an unfetchable URL — hence the
|
|
17
|
-
* divergence. (Regression coverage: M-19, host `jwks-keys.test.ts`.)
|
|
18
|
-
*
|
|
19
|
-
* Edge-topology contract — KEEP IN SYNC with kernel/host/network/Caddyfile:
|
|
20
|
-
* In the Caddy-only edge the host kernel is mounted publicly under
|
|
21
|
-
* `/kernel/{slug}` (the issuer carries that path) but served internally at the
|
|
22
|
-
* stripped path (`/` for the host, `/{id}` for children). `jwks_uri` is built
|
|
23
|
-
* from the ISSUER's path, never the request path, so the edge only strips the
|
|
24
|
-
* prefix on the way IN — no response-body rewrite. If a future edge stops
|
|
25
|
-
* stripping `/kernel/{slug}`, or a kernel is mounted at a different public
|
|
26
|
-
* path, the issuer's path and that edge rule must move together.
|
|
27
|
-
*/
|
|
28
|
-
import { normalizeIssuerId } from '@astrale-os/kernel-core';
|
|
29
|
-
/**
|
|
30
|
-
* Build the OIDC discovery document served at `/.well-known/openid-configuration`.
|
|
31
|
-
* `issuer` is echoed verbatim (identity); `jwks_uri` is derived to be reachable.
|
|
32
|
-
* See the file header for why the two diverge.
|
|
33
|
-
*/
|
|
34
|
-
export function discoveryDoc(req, issuer, signingAlgorithm) {
|
|
35
|
-
return {
|
|
36
|
-
issuer,
|
|
37
|
-
jwks_uri: jwksUriFor(req, issuer),
|
|
38
|
-
subject_types_supported: ['public'],
|
|
39
|
-
id_token_signing_alg_values_supported: [signingAlgorithm],
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
// Public URL of a discovery document's sibling `jwks.json`. Three cases, in
|
|
43
|
-
// priority order:
|
|
44
|
-
// 1. `issuer` is a usable http(s) URL WITH a path → that path is this
|
|
45
|
-
// kernel/instance's full public mount (e.g. `…/kernel/host`). jwks lives
|
|
46
|
-
// directly under it (`{issuer}/.well-known/jwks.json`) — the OIDC invariant
|
|
47
|
-
// that needs no proxy body-rewrite.
|
|
48
|
-
// 2. `issuer` is a usable http(s) URL but origin-only → the public mount path
|
|
49
|
-
// comes from the request path (kernel reached at its canonical origin).
|
|
50
|
-
// 3. `issuer` is a bare slug / non-URL / port-0 fixture → fall back to the
|
|
51
|
-
// request's externally-reachable origin (proxy headers) plus its own path.
|
|
52
|
-
function jwksUriFor(req, issuer) {
|
|
53
|
-
const requestJwksPath = new URL(req.url).pathname.replace(/\/openid-configuration$/, '/jwks.json');
|
|
54
|
-
const canonical = canonicalIssuerUrl(issuer);
|
|
55
|
-
if (!canonical) {
|
|
56
|
-
return `${externalOriginFromRequest(req)}${requestJwksPath}`;
|
|
57
|
-
}
|
|
58
|
-
if (canonical.pathname && canonical.pathname !== '/') {
|
|
59
|
-
return `${canonical.origin}${canonical.pathname.replace(/\/+$/, '')}/.well-known/jwks.json`;
|
|
60
|
-
}
|
|
61
|
-
return `${canonical.origin}${requestJwksPath}`;
|
|
62
|
-
}
|
|
63
|
-
// Parse `issuer` into its canonical http(s) URL, or null when it is not a
|
|
64
|
-
// verifier-reachable origin: a bare slug (no scheme), a non-http(s) scheme, or
|
|
65
|
-
// the `:0` placeholder port that test/dev fixtures use as a non-canonical stand-in.
|
|
66
|
-
function canonicalIssuerUrl(issuer) {
|
|
67
|
-
try {
|
|
68
|
-
const u = new URL(normalizeIssuerId(issuer));
|
|
69
|
-
if (!u.host)
|
|
70
|
-
return null;
|
|
71
|
-
if (u.protocol !== 'http:' && u.protocol !== 'https:')
|
|
72
|
-
return null;
|
|
73
|
-
if (u.port === '0')
|
|
74
|
-
return null;
|
|
75
|
-
return u;
|
|
76
|
-
}
|
|
77
|
-
catch {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
// Externally-reachable origin of the request. Reverse proxies commonly
|
|
82
|
-
// terminate TLS and rewrite Host to an internal hostname; prefer the forwarding
|
|
83
|
-
// headers (X-Forwarded-* then RFC 7239 Forwarded) before the request URL, so
|
|
84
|
-
// discovery never publishes an unreachable jwks_uri.
|
|
85
|
-
function externalOriginFromRequest(req) {
|
|
86
|
-
const xfHost = firstHeaderValue(req.headers.get('x-forwarded-host'));
|
|
87
|
-
if (xfHost) {
|
|
88
|
-
const proto = (firstHeaderValue(req.headers.get('x-forwarded-proto')) ?? 'https').toLowerCase();
|
|
89
|
-
return `${proto}://${xfHost.toLowerCase()}`;
|
|
90
|
-
}
|
|
91
|
-
const fwd = firstHeaderValue(req.headers.get('forwarded'));
|
|
92
|
-
if (fwd) {
|
|
93
|
-
const map = {};
|
|
94
|
-
for (const part of fwd.split(';')) {
|
|
95
|
-
const [k, v] = part.split('=');
|
|
96
|
-
if (k && v)
|
|
97
|
-
map[k.trim().toLowerCase()] = stripQuotes(v.trim());
|
|
98
|
-
}
|
|
99
|
-
if (map.host) {
|
|
100
|
-
const proto = (map.proto ?? 'https').toLowerCase();
|
|
101
|
-
return `${proto}://${map.host.toLowerCase()}`;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return new URL(req.url).origin;
|
|
105
|
-
}
|
|
106
|
-
function firstHeaderValue(value) {
|
|
107
|
-
const first = value?.split(',')[0]?.trim();
|
|
108
|
-
return first ? stripQuotes(first) : null;
|
|
109
|
-
}
|
|
110
|
-
function stripQuotes(value) {
|
|
111
|
-
return value.replace(/^"|"$/g, '');
|
|
112
|
-
}
|
|
113
|
-
//# sourceMappingURL=discovery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../jwks/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAS3D;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,GAAY,EAAE,MAAc,EAAE,gBAAwB;IACjF,OAAO;QACL,MAAM;QACN,QAAQ,EAAE,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;QACjC,uBAAuB,EAAE,CAAC,QAAQ,CAAC;QACnC,qCAAqC,EAAE,CAAC,gBAAgB,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;QAC/C,CAAC;IACH,CAAC;IAED,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CAAA;AAChC,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAoB;IAC5C,MAAM,KAAK,GAAG,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAA;IAC1C,OAAO,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAC1C,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;AACpC,CAAC"}
|
package/dist/jwks/index.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { mountJwks, mountInstanceJwks, type JwksKeys, type MultiplexedJwks, type JwksConfig, type InstanceJwksConfig, } from './keys.js';
|
|
2
|
-
export { mountIssuerRegistry, mountInstanceIssuerRegistry, type IssuerRegistryConfig, type InstanceIssuerRegistryConfig, } from './issuers.js';
|
|
3
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/jwks/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../jwks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAA;AAElB,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,GAClC,MAAM,cAAc,CAAA"}
|
package/dist/jwks/index.js
DELETED
package/dist/jwks/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../jwks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,iBAAiB,GAKlB,MAAM,WAAW,CAAA;AAElB,OAAO,EACL,mBAAmB,EACnB,2BAA2B,GAG5B,MAAM,cAAc,CAAA"}
|
package/dist/jwks/issuers.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Issuer Registry — kernel-specific convention for hosting external issuers' keys.
|
|
3
|
-
*
|
|
4
|
-
* The kernel allows external identities to publish their public keys via
|
|
5
|
-
* `Authentication.publishIssuer()`. Those issuers get stable URLs of the form
|
|
6
|
-
* `{kernel}/iss/{issId}`, and their JWKS is served at
|
|
7
|
-
* `{kernel}/iss/{issId}/.well-known/jwks.json`.
|
|
8
|
-
*
|
|
9
|
-
* This is NOT standard OIDC — it's a kernel-specific trust model. Only kernels
|
|
10
|
-
* with an issuer store should mount these routes. Generic services that just
|
|
11
|
-
* sign their own JWTs don't need this.
|
|
12
|
-
*/
|
|
13
|
-
import type { Hono } from 'hono';
|
|
14
|
-
import { type CorsConfig } from '../cors.js';
|
|
15
|
-
export type IssuerRegistryConfig = {
|
|
16
|
-
/** Base issuer URL — registered issuer URLs are constructed as `${issuer}/iss/{issId}`. */
|
|
17
|
-
issuer: string;
|
|
18
|
-
/** Load a registered external issuer's keys. Empty array if unknown. */
|
|
19
|
-
loadKeys: (issuerId: string) => Promise<Record<string, unknown>[]>;
|
|
20
|
-
/** Signing algorithm (used in openid-configuration). Defaults to 'ES256'. */
|
|
21
|
-
signingAlgorithm?: string;
|
|
22
|
-
cors?: CorsConfig;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Mount issuer registry endpoints — kernel-specific convention for hosting
|
|
26
|
-
* externally-registered issuers' keys.
|
|
27
|
-
*
|
|
28
|
-
* - GET /iss/:issId/.well-known/openid-configuration → external issuer discovery
|
|
29
|
-
* - GET /iss/:issId/.well-known/jwks.json → external issuer keys
|
|
30
|
-
*/
|
|
31
|
-
export declare function mountIssuerRegistry(app: Hono, config: IssuerRegistryConfig): void;
|
|
32
|
-
export type InstanceIssuerRegistryConfig = {
|
|
33
|
-
/** Resolve the instance's base issuer URL. Return null if unknown. */
|
|
34
|
-
resolveIssuer: (instanceId: string) => string | null;
|
|
35
|
-
/** Load a registered external issuer's keys for an instance. */
|
|
36
|
-
loadKeys: (instanceId: string, issuerId: string) => Promise<Record<string, unknown>[]>;
|
|
37
|
-
signingAlgorithm?: string;
|
|
38
|
-
cors?: CorsConfig;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Mount per-instance issuer registry endpoints (multiplexed kernel-specific).
|
|
42
|
-
*
|
|
43
|
-
* - GET /:id/iss/:issId/.well-known/openid-configuration
|
|
44
|
-
* - GET /:id/iss/:issId/.well-known/jwks.json
|
|
45
|
-
*/
|
|
46
|
-
export declare function mountInstanceIssuerRegistry(app: Hono, instancePrefix: string, config: InstanceIssuerRegistryConfig): void;
|
|
47
|
-
//# sourceMappingURL=issuers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"issuers.d.ts","sourceRoot":"","sources":["../../jwks/issuers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAEhC,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;AAK9D,MAAM,MAAM,oBAAoB,GAAG;IACjC,2FAA2F;IAC3F,MAAM,EAAE,MAAM,CAAA;IACd,wEAAwE;IACxE,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;IAClE,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAoBjF;AAID,MAAM,MAAM,4BAA4B,GAAG;IACzC,sEAAsE;IACtE,aAAa,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAA;IACpD,gEAAgE;IAChE,QAAQ,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;IACtF,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,IAAI,EACT,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,4BAA4B,GACnC,IAAI,CAyBN"}
|
package/dist/jwks/issuers.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Issuer Registry — kernel-specific convention for hosting external issuers' keys.
|
|
3
|
-
*
|
|
4
|
-
* The kernel allows external identities to publish their public keys via
|
|
5
|
-
* `Authentication.publishIssuer()`. Those issuers get stable URLs of the form
|
|
6
|
-
* `{kernel}/iss/{issId}`, and their JWKS is served at
|
|
7
|
-
* `{kernel}/iss/{issId}/.well-known/jwks.json`.
|
|
8
|
-
*
|
|
9
|
-
* This is NOT standard OIDC — it's a kernel-specific trust model. Only kernels
|
|
10
|
-
* with an issuer store should mount these routes. Generic services that just
|
|
11
|
-
* sign their own JWTs don't need this.
|
|
12
|
-
*/
|
|
13
|
-
import { buildCorsHeaders } from '../cors.js';
|
|
14
|
-
import { discoveryDoc } from './discovery.js';
|
|
15
|
-
/**
|
|
16
|
-
* Mount issuer registry endpoints — kernel-specific convention for hosting
|
|
17
|
-
* externally-registered issuers' keys.
|
|
18
|
-
*
|
|
19
|
-
* - GET /iss/:issId/.well-known/openid-configuration → external issuer discovery
|
|
20
|
-
* - GET /iss/:issId/.well-known/jwks.json → external issuer keys
|
|
21
|
-
*/
|
|
22
|
-
export function mountIssuerRegistry(app, config) {
|
|
23
|
-
const corsHeaders = buildCorsHeaders(config.cors ?? { origin: '*' });
|
|
24
|
-
const headers = { 'cache-control': 'no-cache', ...corsHeaders };
|
|
25
|
-
const alg = config.signingAlgorithm ?? 'ES256';
|
|
26
|
-
app.get('/iss/:issId/.well-known/openid-configuration', (c) => {
|
|
27
|
-
const issId = c.req.param('issId');
|
|
28
|
-
const issuerUrl = `${config.issuer}/iss/${issId}`;
|
|
29
|
-
return c.json(discoveryDoc(c.req.raw, issuerUrl, alg), 200, headers);
|
|
30
|
-
});
|
|
31
|
-
app.get('/iss/:issId/.well-known/jwks.json', async (c) => {
|
|
32
|
-
const issId = c.req.param('issId');
|
|
33
|
-
const issuerUrl = `${config.issuer}/iss/${issId}`;
|
|
34
|
-
const keys = await config.loadKeys(issuerUrl);
|
|
35
|
-
if (keys.length === 0) {
|
|
36
|
-
return c.json({ error: 'Issuer not found' }, 404, headers);
|
|
37
|
-
}
|
|
38
|
-
return c.json({ keys }, 200, headers);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Mount per-instance issuer registry endpoints (multiplexed kernel-specific).
|
|
43
|
-
*
|
|
44
|
-
* - GET /:id/iss/:issId/.well-known/openid-configuration
|
|
45
|
-
* - GET /:id/iss/:issId/.well-known/jwks.json
|
|
46
|
-
*/
|
|
47
|
-
export function mountInstanceIssuerRegistry(app, instancePrefix, config) {
|
|
48
|
-
const corsHeaders = buildCorsHeaders(config.cors ?? { origin: '*' });
|
|
49
|
-
const headers = { 'cache-control': 'no-cache', ...corsHeaders };
|
|
50
|
-
const alg = config.signingAlgorithm ?? 'ES256';
|
|
51
|
-
app.get(`${instancePrefix}/iss/:issId/.well-known/openid-configuration`, (c) => {
|
|
52
|
-
const id = c.req.param('id');
|
|
53
|
-
const issId = c.req.param('issId');
|
|
54
|
-
if (!id || !issId)
|
|
55
|
-
return c.json({ error: 'Instance not found' }, 404, headers);
|
|
56
|
-
const issuer = config.resolveIssuer(id);
|
|
57
|
-
if (!issuer)
|
|
58
|
-
return c.json({ error: 'Instance not found' }, 404, headers);
|
|
59
|
-
const issuerUrl = `${issuer}/iss/${issId}`;
|
|
60
|
-
return c.json(discoveryDoc(c.req.raw, issuerUrl, alg), 200, headers);
|
|
61
|
-
});
|
|
62
|
-
app.get(`${instancePrefix}/iss/:issId/.well-known/jwks.json`, async (c) => {
|
|
63
|
-
const id = c.req.param('id');
|
|
64
|
-
const issId = c.req.param('issId');
|
|
65
|
-
if (!id || !issId)
|
|
66
|
-
return c.json({ error: 'Instance not found' }, 404, headers);
|
|
67
|
-
const issuer = config.resolveIssuer(id);
|
|
68
|
-
if (!issuer)
|
|
69
|
-
return c.json({ error: 'Instance not found' }, 404, headers);
|
|
70
|
-
const keys = await config.loadKeys(id, `${issuer}/iss/${issId}`);
|
|
71
|
-
if (keys.length === 0)
|
|
72
|
-
return c.json({ error: 'Issuer not found' }, 404, headers);
|
|
73
|
-
return c.json({ keys }, 200, headers);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
//# sourceMappingURL=issuers.js.map
|