@astrale-os/sdk 0.1.2 → 0.1.3
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/auth/compose.d.ts +19 -0
- package/dist/auth/compose.d.ts.map +1 -1
- package/dist/auth/compose.js +24 -2
- package/dist/auth/compose.js.map +1 -1
- package/dist/auth/kernel-client.d.ts +15 -0
- package/dist/auth/kernel-client.d.ts.map +1 -1
- package/dist/auth/kernel-client.js +71 -9
- package/dist/auth/kernel-client.js.map +1 -1
- package/dist/define/remote-function.d.ts +10 -0
- package/dist/define/remote-function.d.ts.map +1 -1
- package/dist/define/remote-function.js.map +1 -1
- package/dist/server/auxiliary-routes.d.ts.map +1 -1
- package/dist/server/auxiliary-routes.js +3 -1
- package/dist/server/auxiliary-routes.js.map +1 -1
- package/dist/server/start.d.ts.map +1 -1
- package/dist/server/start.js +5 -1
- package/dist/server/start.js.map +1 -1
- package/package.json +5 -5
- package/src/auth/compose.ts +27 -2
- package/src/auth/kernel-client.ts +103 -11
- package/src/define/remote-function.ts +10 -0
- package/src/server/auxiliary-routes.ts +3 -1
- package/src/server/start.ts +5 -1
package/dist/auth/compose.d.ts
CHANGED
|
@@ -9,6 +9,15 @@
|
|
|
9
9
|
* identity. Union means either identity's permissions work.
|
|
10
10
|
*/
|
|
11
11
|
import type { Delegation } from '@astrale-os/kernel-core';
|
|
12
|
+
/**
|
|
13
|
+
* The composed identity expression: union of the caller's delegated access
|
|
14
|
+
* (a kernel-signed credential leaf) and the function's own identity (self).
|
|
15
|
+
*
|
|
16
|
+
* Used both as the grant on outbound kernel calls AND as the delegation
|
|
17
|
+
* expression when minting a NEXT-HOP credential — the next worker receives
|
|
18
|
+
* principal = this function, authority = union(caller's delegated, own).
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildComposedExpr(delegation: Delegation): import("@astrale-os/kernel-core").UnresolvedIdentityExpr;
|
|
12
21
|
/**
|
|
13
22
|
* Build the grant expression that unions the caller's delegated access
|
|
14
23
|
* with the function's own identity.
|
|
@@ -19,4 +28,14 @@ import type { Delegation } from '@astrale-os/kernel-core';
|
|
|
19
28
|
export declare function buildComposedGrant(delegation: Delegation): {
|
|
20
29
|
grant: import("@astrale-os/kernel-core").UnresolvedGrant;
|
|
21
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* The SELF-ONLY expression: the function's own identity, nothing delegated.
|
|
33
|
+
* Used by `selfKernel` sessions (public/webhook handlers acting on their own
|
|
34
|
+
* authority) — both as the credential grant and as the next-hop delegation.
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildSelfExpr(): import("@astrale-os/kernel-core").UnresolvedIdentityExpr;
|
|
37
|
+
/** Self-only grant for `selfKernel` credentials. */
|
|
38
|
+
export declare function buildSelfGrant(): {
|
|
39
|
+
grant: import("@astrale-os/kernel-core").UnresolvedGrant;
|
|
40
|
+
};
|
|
22
41
|
//# sourceMappingURL=compose.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../src/auth/compose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AASzD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU;
|
|
1
|
+
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../src/auth/compose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AASzD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,4DAEvD;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU;IAC9C,KAAK;EACf;AAED;;;;GAIG;AACH,wBAAgB,aAAa,6DAE5B;AAED,oDAAoD;AACpD,wBAAgB,cAAc;IACnB,KAAK;EACf"}
|
package/dist/auth/compose.js
CHANGED
|
@@ -9,6 +9,17 @@
|
|
|
9
9
|
* identity. Union means either identity's permissions work.
|
|
10
10
|
*/
|
|
11
11
|
import { createUnresolvedGrant, unresolvedCredential, unresolvedSelf, unresolvedUnion, } from '@astrale-os/kernel-core';
|
|
12
|
+
/**
|
|
13
|
+
* The composed identity expression: union of the caller's delegated access
|
|
14
|
+
* (a kernel-signed credential leaf) and the function's own identity (self).
|
|
15
|
+
*
|
|
16
|
+
* Used both as the grant on outbound kernel calls AND as the delegation
|
|
17
|
+
* expression when minting a NEXT-HOP credential — the next worker receives
|
|
18
|
+
* principal = this function, authority = union(caller's delegated, own).
|
|
19
|
+
*/
|
|
20
|
+
export function buildComposedExpr(delegation) {
|
|
21
|
+
return unresolvedUnion(unresolvedCredential(delegation.credential), unresolvedSelf());
|
|
22
|
+
}
|
|
12
23
|
/**
|
|
13
24
|
* Build the grant expression that unions the caller's delegated access
|
|
14
25
|
* with the function's own identity.
|
|
@@ -17,7 +28,18 @@ import { createUnresolvedGrant, unresolvedCredential, unresolvedSelf, unresolved
|
|
|
17
28
|
* @returns The unresolved grant object with version and expression
|
|
18
29
|
*/
|
|
19
30
|
export function buildComposedGrant(delegation) {
|
|
20
|
-
|
|
21
|
-
|
|
31
|
+
return { grant: createUnresolvedGrant(buildComposedExpr(delegation)) };
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The SELF-ONLY expression: the function's own identity, nothing delegated.
|
|
35
|
+
* Used by `selfKernel` sessions (public/webhook handlers acting on their own
|
|
36
|
+
* authority) — both as the credential grant and as the next-hop delegation.
|
|
37
|
+
*/
|
|
38
|
+
export function buildSelfExpr() {
|
|
39
|
+
return unresolvedSelf();
|
|
40
|
+
}
|
|
41
|
+
/** Self-only grant for `selfKernel` credentials. */
|
|
42
|
+
export function buildSelfGrant() {
|
|
43
|
+
return { grant: createUnresolvedGrant(buildSelfExpr()) };
|
|
22
44
|
}
|
|
23
45
|
//# sourceMappingURL=compose.js.map
|
package/dist/auth/compose.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../../src/auth/compose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,eAAe,GAChB,MAAM,yBAAyB,CAAA;AAEhC;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAAsB;IACvD,
|
|
1
|
+
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../../src/auth/compose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,eAAe,GAChB,MAAM,yBAAyB,CAAA;AAEhC;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAsB;IACtD,OAAO,eAAe,CAAC,oBAAoB,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC,CAAA;AACvF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAAsB;IACvD,OAAO,EAAE,KAAK,EAAE,qBAAqB,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,EAAE,CAAA;AACxE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,cAAc,EAAE,CAAA;AACzB,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,cAAc;IAC5B,OAAO,EAAE,KAAK,EAAE,qBAAqB,CAAC,aAAa,EAAE,CAAC,EAAE,CAAA;AAC1D,CAAC"}
|
|
@@ -25,4 +25,19 @@ import type { RemoteIdentityConfig } from './identity';
|
|
|
25
25
|
* worker-scoped delegation via `@<subject>::mintDelegationCredential`.
|
|
26
26
|
*/
|
|
27
27
|
export declare function bindKernel(delegation: Delegation, kernelUrl: string, config: RemoteIdentityConfig): Promise<BoundClientSessionView<FnMap>>;
|
|
28
|
+
/**
|
|
29
|
+
* Build a `BoundClientSessionView` authenticated as the FUNCTION'S OWN
|
|
30
|
+
* identity — no inbound delegation, authority = the function's own grants
|
|
31
|
+
* only. The seam behind `selfKernel` for public/webhook handlers: an HMAC- or
|
|
32
|
+
* signature-verified webhook can act on the graph as itself after verifying
|
|
33
|
+
* the upstream. Next-hop mints delegate self only.
|
|
34
|
+
*/
|
|
35
|
+
export declare function bindSelfKernel(kernelUrl: string, config: RemoteIdentityConfig): Promise<BoundClientSessionView<FnMap>>;
|
|
36
|
+
/**
|
|
37
|
+
* Build the `selfKernel` accessor handed to remote-function handlers.
|
|
38
|
+
* Resolves the kernel URL from the explicit argument or `deps.KERNEL_URL`
|
|
39
|
+
* (a public request carries no credential, so the parent kernel cannot be
|
|
40
|
+
* inferred — it must be configured).
|
|
41
|
+
*/
|
|
42
|
+
export declare function makeSelfKernel(identity: RemoteIdentityConfig, deps: unknown): (kernelUrl?: string) => Promise<BoundClientSessionView<FnMap>>;
|
|
28
43
|
//# sourceMappingURL=kernel-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernel-client.d.ts","sourceRoot":"","sources":["../../src/auth/kernel-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"kernel-client.d.ts","sourceRoot":"","sources":["../../src/auth/kernel-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAGzD,OAAO,EAAgC,KAAK,KAAK,EAAE,MAAM,2BAA2B,CAAA;AAEpF,OAAO,EAAiB,KAAK,sBAAsB,EAAE,MAAM,mCAAmC,CAAA;AAE9F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAsCtD;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAIxC;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAExC;AA0DD;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,oBAAoB,EAC9B,IAAI,EAAE,OAAO,GACZ,CAAC,SAAS,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAWhE"}
|
|
@@ -17,9 +17,13 @@
|
|
|
17
17
|
import { KernelClient, SchemaRegistry } from '@astrale-os/kernel-client';
|
|
18
18
|
import { ClientPool } from '@astrale-os/kernel-client/pool';
|
|
19
19
|
import { ClientSession } from '@astrale-os/kernel-client/session';
|
|
20
|
-
import { buildComposedGrant } from './compose';
|
|
20
|
+
import { buildComposedExpr, buildComposedGrant, buildSelfExpr, buildSelfGrant } from './compose';
|
|
21
21
|
import { signCredential } from './sign';
|
|
22
22
|
const DELEGATION_TTL_SECONDS = 3600;
|
|
23
|
+
// The kernel's whoami — returns the AUTHENTICATED principal's graph node, so
|
|
24
|
+
// the resolved id satisfies the mint syscall's `self.id === auth.principal`
|
|
25
|
+
// invariant by construction (same seam the shell uses to resolve self).
|
|
26
|
+
const WHOAMI_PATH = '/:kernel.astrale.ai:interface.Identity:whoami';
|
|
23
27
|
// Shared per kernel URL — the expensive, identity-agnostic state. Sessions are
|
|
24
28
|
// NOT shared (each binds a subject-specific delegation mint), but the pool
|
|
25
29
|
// (connections) and registry (learned schemas) are reused across them.
|
|
@@ -51,8 +55,24 @@ function getPool(url) {
|
|
|
51
55
|
* worker-scoped delegation via `@<subject>::mintDelegationCredential`.
|
|
52
56
|
*/
|
|
53
57
|
export async function bindKernel(delegation, kernelUrl, config) {
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
return bindSession(kernelUrl, config, buildComposedGrant(delegation).grant, () => buildComposedExpr(delegation));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Build a `BoundClientSessionView` authenticated as the FUNCTION'S OWN
|
|
62
|
+
* identity — no inbound delegation, authority = the function's own grants
|
|
63
|
+
* only. The seam behind `selfKernel` for public/webhook handlers: an HMAC- or
|
|
64
|
+
* signature-verified webhook can act on the graph as itself after verifying
|
|
65
|
+
* the upstream. Next-hop mints delegate self only.
|
|
66
|
+
*/
|
|
67
|
+
export async function bindSelfKernel(kernelUrl, config) {
|
|
68
|
+
return bindSession(kernelUrl, config, buildSelfGrant().grant, () => buildSelfExpr());
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Shared session construction: sign a credential as this function's identity
|
|
72
|
+
* carrying `grant`, bind the session to it, and wire the lazy NEXT-HOP mint.
|
|
73
|
+
*/
|
|
74
|
+
async function bindSession(kernelUrl, config, grant, nextHopDelegation) {
|
|
75
|
+
const credential = await signCredential({ grant }, {
|
|
56
76
|
issuer: config.issuer,
|
|
57
77
|
subject: config.subject,
|
|
58
78
|
audience: kernelUrl,
|
|
@@ -65,12 +85,18 @@ export async function bindKernel(delegation, kernelUrl, config) {
|
|
|
65
85
|
schema: getRegistry(kernelUrl),
|
|
66
86
|
pool: getPool(kernelUrl),
|
|
67
87
|
delegation: {
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
88
|
+
// NEXT-HOP mint: each hop mints AS ITSELF. The anchor is this function's
|
|
89
|
+
// identity NODE id (resolved via whoami — `@` only accepts node ids, not
|
|
90
|
+
// paths), so `self.id === auth.principal` holds by construction. The
|
|
91
|
+
// minted delegation carries the session's authority expression (composed
|
|
92
|
+
// for delegated sessions, self-only for selfKernel): the next worker
|
|
93
|
+
// sees WHO called it while inheriting exactly that authority.
|
|
94
|
+
// `skipDelegation` keeps the whoami + mint from re-entering this
|
|
95
|
+
// closure — both target the kernel (same origin), so no delegation is
|
|
96
|
+
// needed.
|
|
72
97
|
mint: async (audience) => {
|
|
73
|
-
const
|
|
98
|
+
const selfId = await resolveSelfId(session, credential, kernelUrl, config);
|
|
99
|
+
const envelope = await session.call(`@${selfId}::mintDelegationCredential`, { audience, delegation: nextHopDelegation(), ttl: DELEGATION_TTL_SECONDS }, { credential, skipDelegation: true });
|
|
74
100
|
if (typeof envelope !== 'string') {
|
|
75
101
|
throw new Error(`mintDelegationCredential returned ${typeof envelope}, expected a credential string`);
|
|
76
102
|
}
|
|
@@ -79,6 +105,42 @@ export async function bindKernel(delegation, kernelUrl, config) {
|
|
|
79
105
|
ttl: DELEGATION_TTL_SECONDS,
|
|
80
106
|
},
|
|
81
107
|
});
|
|
82
|
-
return session.as(
|
|
108
|
+
return session.as(credential);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Build the `selfKernel` accessor handed to remote-function handlers.
|
|
112
|
+
* Resolves the kernel URL from the explicit argument or `deps.KERNEL_URL`
|
|
113
|
+
* (a public request carries no credential, so the parent kernel cannot be
|
|
114
|
+
* inferred — it must be configured).
|
|
115
|
+
*/
|
|
116
|
+
export function makeSelfKernel(identity, deps) {
|
|
117
|
+
return async (kernelUrl) => {
|
|
118
|
+
const url = kernelUrl ?? deps?.KERNEL_URL;
|
|
119
|
+
if (typeof url !== 'string' || url.length === 0) {
|
|
120
|
+
throw new Error('selfKernel: no kernel URL — pass one explicitly or set KERNEL_URL in the worker env ' +
|
|
121
|
+
'(managed deploys set it automatically).');
|
|
122
|
+
}
|
|
123
|
+
return bindSelfKernel(url, identity);
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
// Function-identity node ids, cached per (kernel, issuer, subject). Sessions
|
|
127
|
+
// are per-request, but a function's identity node is stable for the worker's
|
|
128
|
+
// lifetime — one whoami per function, not one per redirect.
|
|
129
|
+
const selfIds = new Map();
|
|
130
|
+
/**
|
|
131
|
+
* Resolve THIS function's identity node id on the parent kernel via whoami,
|
|
132
|
+
* authenticated with the composed credential (whose principal IS the function).
|
|
133
|
+
*/
|
|
134
|
+
async function resolveSelfId(session, credential, kernelUrl, config) {
|
|
135
|
+
const key = `${kernelUrl}|${config.issuer}|${config.subject}`;
|
|
136
|
+
const cached = selfIds.get(key);
|
|
137
|
+
if (cached)
|
|
138
|
+
return cached;
|
|
139
|
+
const me = (await session.call(WHOAMI_PATH, {}, { credential, skipDelegation: true }));
|
|
140
|
+
if (!me?.id) {
|
|
141
|
+
throw new Error(`whoami returned no identity node for ${config.subject} — cannot anchor the next-hop delegation mint`);
|
|
142
|
+
}
|
|
143
|
+
selfIds.set(key, me.id);
|
|
144
|
+
return me.id;
|
|
83
145
|
}
|
|
84
146
|
//# sourceMappingURL=kernel-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernel-client.js","sourceRoot":"","sources":["../../src/auth/kernel-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;
|
|
1
|
+
{"version":3,"file":"kernel-client.js","sourceRoot":"","sources":["../../src/auth/kernel-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAc,MAAM,2BAA2B,CAAA;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAC3D,OAAO,EAAE,aAAa,EAA+B,MAAM,mCAAmC,CAAA;AAI9F,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAEvC,MAAM,sBAAsB,GAAG,IAAI,CAAA;AAEnC,6EAA6E;AAC7E,4EAA4E;AAC5E,wEAAwE;AACxE,MAAM,WAAW,GAAG,+CAA+C,CAAA;AAEnE,+EAA+E;AAC/E,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AE,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,wCAAwC,MAAM,CAAC,OAAO,+CAA+C,CACtG,CAAA;IACH,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,CAAA;IACvB,OAAO,EAAE,CAAC,EAAE,CAAA;AACd,CAAC"}
|
|
@@ -45,6 +45,16 @@ export type RemoteFunctionContext<TParams, TDeps = unknown> = {
|
|
|
45
45
|
* `Identity.mintDelegationCredential` + the target method's grants.
|
|
46
46
|
*/
|
|
47
47
|
callRemote: CallRemoteFn;
|
|
48
|
+
/**
|
|
49
|
+
* Acquire a kernel session authenticated as THIS FUNCTION'S OWN identity —
|
|
50
|
+
* authority = the function's own grants only, no caller delegation. The
|
|
51
|
+
* webhook seam: when an `auth: 'public'` upstream can't carry an Astrale
|
|
52
|
+
* token (HMAC-signature webhooks, Stripe-style), VERIFY THE UPSTREAM'S
|
|
53
|
+
* SIGNATURE FIRST, then act on the graph as yourself. `kernelUrl` defaults
|
|
54
|
+
* to `deps.KERNEL_URL` (set automatically on managed deploys); pass it
|
|
55
|
+
* explicitly for other targets.
|
|
56
|
+
*/
|
|
57
|
+
selfKernel: (kernelUrl?: string) => Promise<BoundClientSessionView<FnMap>>;
|
|
48
58
|
};
|
|
49
59
|
export type RemoteFunctionDef<TParams = unknown, TResult = unknown, TDeps = unknown> = {
|
|
50
60
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-function.d.ts","sourceRoot":"","sources":["../../src/define/remote-function.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAChF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAA;AAC/E,OAAO,KAAK,EAAE,WAAW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,CAAA;AAEnE;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,GAAG,OAAO,EACpE,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,GAC9C,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAE5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-function.js","sourceRoot":"","sources":["../../src/define/remote-function.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;
|
|
1
|
+
{"version":3,"file":"remote-function.js","sourceRoot":"","sources":["../../src/define/remote-function.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAiFH;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,GAA+C;IAE/C,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auxiliary-routes.d.ts","sourceRoot":"","sources":["../../src/server/auxiliary-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAA;AAQzC,OAAO,EAKL,KAAK,eAAe,EAErB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAG7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"auxiliary-routes.d.ts","sourceRoot":"","sources":["../../src/server/auxiliary-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAA;AAQzC,OAAO,EAKL,KAAK,eAAe,EAErB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAG7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAS1D,MAAM,MAAM,qBAAqB,CAAC,KAAK,IAAI;IACzC,GAAG,EAAE,IAAI,CAAA;IACT,gFAAgF;IAChF,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAC9C,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;IACtD,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IACxD,IAAI,EAAE,KAAK,CAAA;IACX;;;;OAIG;IACH,UAAU,EAAE,cAAc,CAAA;IAC1B;;;;;OAKG;IACH,IAAI,EAAE,UAAU,CAAA;CACjB,CAAA;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,qBAAqB,CAAC,KAAK,CAAC,GAAG,IAAI,CA4EtF"}
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import { isKernelErrorClassifiable, KERNEL_ERROR_CODES, kernelErrorHttpStatus, } from '@astrale-os/kernel-api';
|
|
15
15
|
import { isSubdomainOf, matchHost, compileHostMatcher, parseUrlTemplate, } from '@astrale-os/kernel-api/routed';
|
|
16
16
|
import { buildCorsHeaders } from '@astrale-os/kernel-server';
|
|
17
|
+
import { makeSelfKernel } from '../auth/kernel-client';
|
|
17
18
|
import { resolveInboundAuth } from '../auth/resolve';
|
|
18
19
|
import { runAuthorize } from '../dispatch/authorize';
|
|
19
20
|
import { makeCallRemote } from '../dispatch/call-remote';
|
|
@@ -64,12 +65,13 @@ export function mountAuxiliaryRoutes(config) {
|
|
|
64
65
|
identity,
|
|
65
66
|
corsHeaders,
|
|
66
67
|
run: async ({ c, auth, kernel, callRemote }) => {
|
|
68
|
+
const selfKernel = makeSelfKernel(identity, deps);
|
|
67
69
|
const rawBody = await c.req.json().catch(() => ({}));
|
|
68
70
|
const validation = validateParams(def.inputSchema, rawBody);
|
|
69
71
|
if (!validation.ok) {
|
|
70
72
|
throw new SdkValidationError(validation.issues);
|
|
71
73
|
}
|
|
72
|
-
const ctx = { params: validation.data, c, auth, deps, kernel, callRemote };
|
|
74
|
+
const ctx = { params: validation.data, c, auth, deps, kernel, callRemote, selfKernel };
|
|
73
75
|
if (def.authorize)
|
|
74
76
|
await runAuthorize(def.authorize, ctx);
|
|
75
77
|
const result = await def.execute(ctx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auxiliary-routes.js","sourceRoot":"","sources":["../../src/server/auxiliary-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,qBAAqB,GAEtB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,gBAAgB,GAGjB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAmB,MAAM,2BAA2B,CAAA;AAQ7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACjF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM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AO,CAAC,CAAA;IAChB,MAAM,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACjD,MAAM,KAAK,GAAG,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAA;IAC7C,OAAO,GAAG,IAAI,GAAG,KAAK,EAAE,IAAI,GAAG,CAAA;AACjC,CAAC;AAED,oEAAoE;AACpE,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,IAAI;SACR,OAAO,CAAC,cAAc,EAAE,SAAS,CAAC;SAClC,OAAO,CAAC,cAAc,EAAE,SAAS,CAAC;SAClC,OAAO,CAAC,YAAY,EAAE,KAAK,CAAC,CAAA;AACjC,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAa;IACtC,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAA;AAChD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/server/start.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAEhC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAElD,wBAAsB,eAAe,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,SAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/server/start.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAEhC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAElD,wBAAsB,eAAe,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,SAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA4BzF"}
|
package/dist/server/start.js
CHANGED
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
* Cloudflare, consumers go through `server.app.fetch` directly.
|
|
7
7
|
*/
|
|
8
8
|
export async function startNodeServer(app, port = 3000) {
|
|
9
|
-
|
|
9
|
+
// Opaque specifier: the `./server` barrel re-exports this module, so worker
|
|
10
|
+
// bundles (wrangler/esbuild) traverse it even though they never call it. A
|
|
11
|
+
// literal import() would make them resolve the optional peer and fail.
|
|
12
|
+
const nodeServerModule = '@hono/node-server';
|
|
13
|
+
const { serve } = (await import(nodeServerModule));
|
|
10
14
|
// oxlint-disable-next-line no-explicit-any
|
|
11
15
|
const server = serve({ fetch: app.fetch, port });
|
|
12
16
|
await new Promise((resolve, reject) => {
|
package/dist/server/start.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/server/start.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,GAAS,EAAE,IAAI,GAAG,IAAI;IAC1D,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/server/start.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,GAAS,EAAE,IAAI,GAAG,IAAI;IAC1D,4EAA4E;IAC5E,2EAA2E;IAC3E,uEAAuE;IACvE,MAAM,gBAAgB,GAAG,mBAAmB,CAAA;IAC5C,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,MAAM,CAAC,gBAAgB,CAAC,CAAuC,CAAA;IACxF,2CAA2C;IAC3C,MAAM,MAAM,GAAG,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,CAAQ,CAAA;IAEvD,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC1C,IAAI,MAAM,CAAC,SAAS;YAAE,OAAO,OAAO,EAAE,CAAA;QACtC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAA;QACzC,sEAAsE;QACtE,yEAAyE;QACzE,mCAAmC;QACnC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,GAAU,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;IACnD,CAAC,CAAC,CAAA;IAEF,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAA8C,CAAA;IAC5E,MAAM,UAAU,GAAG,OAAO,EAAE,IAAI,IAAI,IAAI,CAAA;IAExC,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,GAAG,EAAE,CACV,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACpC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAiB,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;QACtE,CAAC,CAAC;KACL,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrale-os/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Astrale Remote Domain SDK - Define and deploy domains as standalone Hono servers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astrale",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"registry": "https://npm.pkg.github.com"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@astrale-os/kernel-api": ">=0.4.
|
|
44
|
-
"@astrale-os/kernel-client": ">=0.
|
|
45
|
-
"@astrale-os/kernel-core": ">=0.3
|
|
46
|
-
"@astrale-os/kernel-dsl": ">=0.1.
|
|
43
|
+
"@astrale-os/kernel-api": ">=0.4.5 <1.0.0",
|
|
44
|
+
"@astrale-os/kernel-client": ">=0.2.2 <1.0.0",
|
|
45
|
+
"@astrale-os/kernel-core": ">=0.4.3 <1.0.0",
|
|
46
|
+
"@astrale-os/kernel-dsl": ">=0.1.2 <1.0.0",
|
|
47
47
|
"@astrale-os/kernel-server": ">=0.4.0 <1.0.0",
|
|
48
48
|
"hono": "^4.6.20",
|
|
49
49
|
"jose": "^6.1.3",
|
package/src/auth/compose.ts
CHANGED
|
@@ -18,6 +18,18 @@ import {
|
|
|
18
18
|
unresolvedUnion,
|
|
19
19
|
} from '@astrale-os/kernel-core'
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* The composed identity expression: union of the caller's delegated access
|
|
23
|
+
* (a kernel-signed credential leaf) and the function's own identity (self).
|
|
24
|
+
*
|
|
25
|
+
* Used both as the grant on outbound kernel calls AND as the delegation
|
|
26
|
+
* expression when minting a NEXT-HOP credential — the next worker receives
|
|
27
|
+
* principal = this function, authority = union(caller's delegated, own).
|
|
28
|
+
*/
|
|
29
|
+
export function buildComposedExpr(delegation: Delegation) {
|
|
30
|
+
return unresolvedUnion(unresolvedCredential(delegation.credential), unresolvedSelf())
|
|
31
|
+
}
|
|
32
|
+
|
|
21
33
|
/**
|
|
22
34
|
* Build the grant expression that unions the caller's delegated access
|
|
23
35
|
* with the function's own identity.
|
|
@@ -26,6 +38,19 @@ import {
|
|
|
26
38
|
* @returns The unresolved grant object with version and expression
|
|
27
39
|
*/
|
|
28
40
|
export function buildComposedGrant(delegation: Delegation) {
|
|
29
|
-
|
|
30
|
-
|
|
41
|
+
return { grant: createUnresolvedGrant(buildComposedExpr(delegation)) }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The SELF-ONLY expression: the function's own identity, nothing delegated.
|
|
46
|
+
* Used by `selfKernel` sessions (public/webhook handlers acting on their own
|
|
47
|
+
* authority) — both as the credential grant and as the next-hop delegation.
|
|
48
|
+
*/
|
|
49
|
+
export function buildSelfExpr() {
|
|
50
|
+
return unresolvedSelf()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Self-only grant for `selfKernel` credentials. */
|
|
54
|
+
export function buildSelfGrant() {
|
|
55
|
+
return { grant: createUnresolvedGrant(buildSelfExpr()) }
|
|
31
56
|
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import type { Delegation } from '@astrale-os/kernel-core'
|
|
19
|
+
import type { UnresolvedIdentityExpr } from '@astrale-os/kernel-core'
|
|
19
20
|
|
|
20
21
|
import { KernelClient, SchemaRegistry, type FnMap } from '@astrale-os/kernel-client'
|
|
21
22
|
import { ClientPool } from '@astrale-os/kernel-client/pool'
|
|
@@ -23,11 +24,16 @@ import { ClientSession, type BoundClientSessionView } from '@astrale-os/kernel-c
|
|
|
23
24
|
|
|
24
25
|
import type { RemoteIdentityConfig } from './identity'
|
|
25
26
|
|
|
26
|
-
import { buildComposedGrant } from './compose'
|
|
27
|
+
import { buildComposedExpr, buildComposedGrant, buildSelfExpr, buildSelfGrant } from './compose'
|
|
27
28
|
import { signCredential } from './sign'
|
|
28
29
|
|
|
29
30
|
const DELEGATION_TTL_SECONDS = 3600
|
|
30
31
|
|
|
32
|
+
// The kernel's whoami — returns the AUTHENTICATED principal's graph node, so
|
|
33
|
+
// the resolved id satisfies the mint syscall's `self.id === auth.principal`
|
|
34
|
+
// invariant by construction (same seam the shell uses to resolve self).
|
|
35
|
+
const WHOAMI_PATH = '/:kernel.astrale.ai:interface.Identity:whoami'
|
|
36
|
+
|
|
31
37
|
// Shared per kernel URL — the expensive, identity-agnostic state. Sessions are
|
|
32
38
|
// NOT shared (each binds a subject-specific delegation mint), but the pool
|
|
33
39
|
// (connections) and registry (learned schemas) are reused across them.
|
|
@@ -65,8 +71,36 @@ export async function bindKernel(
|
|
|
65
71
|
kernelUrl: string,
|
|
66
72
|
config: RemoteIdentityConfig,
|
|
67
73
|
): Promise<BoundClientSessionView<FnMap>> {
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
return bindSession(kernelUrl, config, buildComposedGrant(delegation).grant, () =>
|
|
75
|
+
buildComposedExpr(delegation),
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Build a `BoundClientSessionView` authenticated as the FUNCTION'S OWN
|
|
81
|
+
* identity — no inbound delegation, authority = the function's own grants
|
|
82
|
+
* only. The seam behind `selfKernel` for public/webhook handlers: an HMAC- or
|
|
83
|
+
* signature-verified webhook can act on the graph as itself after verifying
|
|
84
|
+
* the upstream. Next-hop mints delegate self only.
|
|
85
|
+
*/
|
|
86
|
+
export async function bindSelfKernel(
|
|
87
|
+
kernelUrl: string,
|
|
88
|
+
config: RemoteIdentityConfig,
|
|
89
|
+
): Promise<BoundClientSessionView<FnMap>> {
|
|
90
|
+
return bindSession(kernelUrl, config, buildSelfGrant().grant, () => buildSelfExpr())
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Shared session construction: sign a credential as this function's identity
|
|
95
|
+
* carrying `grant`, bind the session to it, and wire the lazy NEXT-HOP mint.
|
|
96
|
+
*/
|
|
97
|
+
async function bindSession(
|
|
98
|
+
kernelUrl: string,
|
|
99
|
+
config: RemoteIdentityConfig,
|
|
100
|
+
grant: unknown,
|
|
101
|
+
nextHopDelegation: () => UnresolvedIdentityExpr,
|
|
102
|
+
): Promise<BoundClientSessionView<FnMap>> {
|
|
103
|
+
const credential = await signCredential(
|
|
70
104
|
{ grant },
|
|
71
105
|
{
|
|
72
106
|
issuer: config.issuer,
|
|
@@ -83,15 +117,21 @@ export async function bindKernel(
|
|
|
83
117
|
schema: getRegistry(kernelUrl),
|
|
84
118
|
pool: getPool(kernelUrl),
|
|
85
119
|
delegation: {
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
//
|
|
120
|
+
// NEXT-HOP mint: each hop mints AS ITSELF. The anchor is this function's
|
|
121
|
+
// identity NODE id (resolved via whoami — `@` only accepts node ids, not
|
|
122
|
+
// paths), so `self.id === auth.principal` holds by construction. The
|
|
123
|
+
// minted delegation carries the session's authority expression (composed
|
|
124
|
+
// for delegated sessions, self-only for selfKernel): the next worker
|
|
125
|
+
// sees WHO called it while inheriting exactly that authority.
|
|
126
|
+
// `skipDelegation` keeps the whoami + mint from re-entering this
|
|
127
|
+
// closure — both target the kernel (same origin), so no delegation is
|
|
128
|
+
// needed.
|
|
90
129
|
mint: async (audience) => {
|
|
130
|
+
const selfId = await resolveSelfId(session, credential, kernelUrl, config)
|
|
91
131
|
const envelope = await session.call(
|
|
92
|
-
`@${
|
|
93
|
-
{ audience, delegation:
|
|
94
|
-
{ credential
|
|
132
|
+
`@${selfId}::mintDelegationCredential`,
|
|
133
|
+
{ audience, delegation: nextHopDelegation(), ttl: DELEGATION_TTL_SECONDS },
|
|
134
|
+
{ credential, skipDelegation: true },
|
|
95
135
|
)
|
|
96
136
|
if (typeof envelope !== 'string') {
|
|
97
137
|
throw new Error(
|
|
@@ -103,5 +143,57 @@ export async function bindKernel(
|
|
|
103
143
|
ttl: DELEGATION_TTL_SECONDS,
|
|
104
144
|
},
|
|
105
145
|
})
|
|
106
|
-
return session.as(
|
|
146
|
+
return session.as(credential)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Build the `selfKernel` accessor handed to remote-function handlers.
|
|
151
|
+
* Resolves the kernel URL from the explicit argument or `deps.KERNEL_URL`
|
|
152
|
+
* (a public request carries no credential, so the parent kernel cannot be
|
|
153
|
+
* inferred — it must be configured).
|
|
154
|
+
*/
|
|
155
|
+
export function makeSelfKernel(
|
|
156
|
+
identity: RemoteIdentityConfig,
|
|
157
|
+
deps: unknown,
|
|
158
|
+
): (kernelUrl?: string) => Promise<BoundClientSessionView<FnMap>> {
|
|
159
|
+
return async (kernelUrl?: string) => {
|
|
160
|
+
const url = kernelUrl ?? (deps as { KERNEL_URL?: unknown } | null | undefined)?.KERNEL_URL
|
|
161
|
+
if (typeof url !== 'string' || url.length === 0) {
|
|
162
|
+
throw new Error(
|
|
163
|
+
'selfKernel: no kernel URL — pass one explicitly or set KERNEL_URL in the worker env ' +
|
|
164
|
+
'(managed deploys set it automatically).',
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
return bindSelfKernel(url, identity)
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Function-identity node ids, cached per (kernel, issuer, subject). Sessions
|
|
172
|
+
// are per-request, but a function's identity node is stable for the worker's
|
|
173
|
+
// lifetime — one whoami per function, not one per redirect.
|
|
174
|
+
const selfIds = new Map<string, string>()
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Resolve THIS function's identity node id on the parent kernel via whoami,
|
|
178
|
+
* authenticated with the composed credential (whose principal IS the function).
|
|
179
|
+
*/
|
|
180
|
+
async function resolveSelfId(
|
|
181
|
+
session: ClientSession<FnMap>,
|
|
182
|
+
credential: string,
|
|
183
|
+
kernelUrl: string,
|
|
184
|
+
config: RemoteIdentityConfig,
|
|
185
|
+
): Promise<string> {
|
|
186
|
+
const key = `${kernelUrl}|${config.issuer}|${config.subject}`
|
|
187
|
+
const cached = selfIds.get(key)
|
|
188
|
+
if (cached) return cached
|
|
189
|
+
const me = (await session.call(WHOAMI_PATH, {}, { credential, skipDelegation: true })) as {
|
|
190
|
+
id?: string
|
|
191
|
+
} | null
|
|
192
|
+
if (!me?.id) {
|
|
193
|
+
throw new Error(
|
|
194
|
+
`whoami returned no identity node for ${config.subject} — cannot anchor the next-hop delegation mint`,
|
|
195
|
+
)
|
|
196
|
+
}
|
|
197
|
+
selfIds.set(key, me.id)
|
|
198
|
+
return me.id
|
|
107
199
|
}
|
|
@@ -48,6 +48,16 @@ export type RemoteFunctionContext<TParams, TDeps = unknown> = {
|
|
|
48
48
|
* `Identity.mintDelegationCredential` + the target method's grants.
|
|
49
49
|
*/
|
|
50
50
|
callRemote: CallRemoteFn
|
|
51
|
+
/**
|
|
52
|
+
* Acquire a kernel session authenticated as THIS FUNCTION'S OWN identity —
|
|
53
|
+
* authority = the function's own grants only, no caller delegation. The
|
|
54
|
+
* webhook seam: when an `auth: 'public'` upstream can't carry an Astrale
|
|
55
|
+
* token (HMAC-signature webhooks, Stripe-style), VERIFY THE UPSTREAM'S
|
|
56
|
+
* SIGNATURE FIRST, then act on the graph as yourself. `kernelUrl` defaults
|
|
57
|
+
* to `deps.KERNEL_URL` (set automatically on managed deploys); pass it
|
|
58
|
+
* explicitly for other targets.
|
|
59
|
+
*/
|
|
60
|
+
selfKernel: (kernelUrl?: string) => Promise<BoundClientSessionView<FnMap>>
|
|
51
61
|
}
|
|
52
62
|
|
|
53
63
|
export type RemoteFunctionDef<TParams = unknown, TResult = unknown, TDeps = unknown> = {
|
|
@@ -39,6 +39,7 @@ import type { ViewDef } from '../define/view'
|
|
|
39
39
|
import type { CallRemoteFn } from '../dispatch/call-remote'
|
|
40
40
|
import type { AuxIdentityMap } from '../dispatch/identity'
|
|
41
41
|
|
|
42
|
+
import { makeSelfKernel } from '../auth/kernel-client'
|
|
42
43
|
import { resolveInboundAuth } from '../auth/resolve'
|
|
43
44
|
import { runAuthorize } from '../dispatch/authorize'
|
|
44
45
|
import { makeCallRemote } from '../dispatch/call-remote'
|
|
@@ -124,12 +125,13 @@ export function mountAuxiliaryRoutes<TDeps>(config: AuxiliaryRoutesConfig<TDeps>
|
|
|
124
125
|
identity,
|
|
125
126
|
corsHeaders,
|
|
126
127
|
run: async ({ c, auth, kernel, callRemote }) => {
|
|
128
|
+
const selfKernel = makeSelfKernel(identity, deps)
|
|
127
129
|
const rawBody: unknown = await c.req.json().catch(() => ({}))
|
|
128
130
|
const validation = validateParams(def.inputSchema, rawBody)
|
|
129
131
|
if (!validation.ok) {
|
|
130
132
|
throw new SdkValidationError(validation.issues as SdkValidationError['issues'])
|
|
131
133
|
}
|
|
132
|
-
const ctx = { params: validation.data, c, auth, deps, kernel, callRemote }
|
|
134
|
+
const ctx = { params: validation.data, c, auth, deps, kernel, callRemote, selfKernel }
|
|
133
135
|
if (def.authorize) await runAuthorize(def.authorize, ctx)
|
|
134
136
|
const result = await def.execute(ctx)
|
|
135
137
|
const outValidation = validateResult(def.outputSchema, result)
|
package/src/server/start.ts
CHANGED
|
@@ -11,7 +11,11 @@ import type { Hono } from 'hono'
|
|
|
11
11
|
import type { RemoteServerHandle } from './handle'
|
|
12
12
|
|
|
13
13
|
export async function startNodeServer(app: Hono, port = 3000): Promise<RemoteServerHandle> {
|
|
14
|
-
|
|
14
|
+
// Opaque specifier: the `./server` barrel re-exports this module, so worker
|
|
15
|
+
// bundles (wrangler/esbuild) traverse it even though they never call it. A
|
|
16
|
+
// literal import() would make them resolve the optional peer and fail.
|
|
17
|
+
const nodeServerModule = '@hono/node-server'
|
|
18
|
+
const { serve } = (await import(nodeServerModule)) as typeof import('@hono/node-server')
|
|
15
19
|
// oxlint-disable-next-line no-explicit-any
|
|
16
20
|
const server = serve({ fetch: app.fetch, port }) as any
|
|
17
21
|
|