@astrale-os/kernel-client 0.6.0-beta.85 → 0.6.0-beta.86
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/auth.d.ts +2 -8
- package/dist/auth/credential.d.ts +1 -7
- package/dist/session/admission.js +3 -3
- package/dist/session/bound.d.ts +1 -1
- package/dist/session/bound.js +1 -1
- package/dist/session/exchange/exchange.d.ts +1 -7
- package/dist/session/exchange/exchange.js +0 -4
- package/dist/session/exchange/index.d.ts +1 -1
- package/dist/session/exchange/index.js +1 -1
- package/dist/session/exchange/presentation.js +1 -2
- package/dist/session/routing/cache.js +1 -9
- package/dist/session/session.d.ts +6 -2
- package/dist/session/session.js +9 -5
- package/dist/session/session.typecheck.js +4 -1
- package/dist/session/views/catalog.d.ts +10 -2
- package/dist/session/views/catalog.js +36 -19
- package/dist/session/views/index.d.ts +1 -1
- package/dist/session/views/index.js +1 -1
- package/dist/session/views/resolve.d.ts +6 -4
- package/dist/session/views/resolve.js +14 -6
- package/dist/transport/http/transport.js +2 -3
- package/package.json +5 -5
package/dist/auth/auth.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Identity, Authentication, IdentityId, MintedCredential, RegisterResult
|
|
1
|
+
import type { Identity, Authentication, IdentityId, MintedCredential, RegisterResult } from '@astrale-os/kernel-core/auth';
|
|
2
2
|
import type { NodePath, PathLike } from '@astrale-os/kernel-core/path';
|
|
3
3
|
import type { Key } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
4
4
|
import type { Call, Input } from '../client/index.js';
|
|
@@ -13,13 +13,7 @@ export interface FunctionAdmission {
|
|
|
13
13
|
readonly callable: Key.Callable;
|
|
14
14
|
readonly receiver?: NodePath;
|
|
15
15
|
}
|
|
16
|
-
export
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated Ignored. Admission always delegates the session caller unchanged (`self`); the
|
|
19
|
-
* Kernel refuses any other attenuation.
|
|
20
|
-
*/
|
|
21
|
-
readonly attenuation?: UnresolvedIdentityExpr;
|
|
22
|
-
}
|
|
16
|
+
export type AdmissionOptions = RequestOptions;
|
|
23
17
|
export interface AuthApi {
|
|
24
18
|
/** Check access and input without executing an installed remote callable. */
|
|
25
19
|
admit(call: Call, options?: AdmissionOptions): Promise<FunctionAdmission>;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { IdentityId, MintedCredential
|
|
1
|
+
import type { IdentityId, MintedCredential } from '@astrale-os/kernel-core/auth';
|
|
2
2
|
import type { NodePath } from '@astrale-os/kernel-core/path';
|
|
3
3
|
import type { RequestOptions } from '../transport/index.js';
|
|
4
4
|
import type { AuthCall } from './auth.js';
|
|
5
5
|
export interface MintOptions {
|
|
6
6
|
readonly audience?: string;
|
|
7
7
|
readonly ttlSeconds: number;
|
|
8
|
-
readonly grant?: UnresolvedGrant;
|
|
9
8
|
}
|
|
10
9
|
export interface ImpersonateOptions extends MintOptions {
|
|
11
10
|
readonly identity: IdentityId;
|
|
@@ -13,11 +12,6 @@ export interface ImpersonateOptions extends MintOptions {
|
|
|
13
12
|
export interface DelegateOptions {
|
|
14
13
|
readonly audience: string;
|
|
15
14
|
readonly ttlSeconds: number;
|
|
16
|
-
/**
|
|
17
|
-
* Sent only when present; the Kernel reads absence as self. A Kernel whose `Identity.delegate`
|
|
18
|
-
* still requires it rejects the omission.
|
|
19
|
-
*/
|
|
20
|
-
readonly attenuation?: UnresolvedIdentityExpr;
|
|
21
15
|
}
|
|
22
16
|
export declare const IDENTITY_IMPERSONATE_PATH: NodePath;
|
|
23
17
|
export declare const IDENTITY_MINT_PATH: NodePath;
|
|
@@ -5,7 +5,7 @@ import { function as functions } from '@astrale-os/kernel-core/schema/kernel/sys
|
|
|
5
5
|
import { Key } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
6
6
|
import { ClientError } from '../errors/index.js';
|
|
7
7
|
import { runSessionOperation, sessionTransportOptions } from './context/index.js';
|
|
8
|
-
import { callableOrigin, exchangeDomainCredential, installedIssuer, isAuthority,
|
|
8
|
+
import { callableOrigin, exchangeDomainCredential, installedIssuer, isAuthority, } from './exchange/index.js';
|
|
9
9
|
import { matchesCallable } from './reference.js';
|
|
10
10
|
import { requireResultKind, resolveAuth } from './routing/index.js';
|
|
11
11
|
const ADMIT = Path.staticMethod(Path.project(functions.admit.owner), functions.admit.name);
|
|
@@ -25,8 +25,8 @@ export async function admitFunction(dependencies, call, operation) {
|
|
|
25
25
|
if (domain === undefined) {
|
|
26
26
|
throw new ClientError('Function admission through token exchange requires a remote Domain.');
|
|
27
27
|
}
|
|
28
|
-
// The Kernel preserves the session caller
|
|
29
|
-
const exchanged = await exchangeDomainCredential(dependencies, effective, { issuer: domain, ttlSeconds: effective.delegate.ttlSeconds
|
|
28
|
+
// The Kernel preserves the session caller when issuing the delegation.
|
|
29
|
+
const exchanged = await exchangeDomainCredential(dependencies, effective, { issuer: domain, ttlSeconds: effective.delegate.ttlSeconds }, operation);
|
|
30
30
|
const result = await runSessionOperation(operation, () => dependencies
|
|
31
31
|
.source()
|
|
32
32
|
.as(exchanged.credential)
|
package/dist/session/bound.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface BoundSessionSource {
|
|
|
19
19
|
invoke: ClientSession['invoke'];
|
|
20
20
|
stream(call: Call, options?: SessionRequestOptions): Promise<Stream>;
|
|
21
21
|
binary(call: Call, options?: SessionRequestOptions): Promise<Binary>;
|
|
22
|
-
viewsFor(
|
|
22
|
+
viewsFor(domain: Parameters<ClientSession['viewsFor']>[0], options?: SessionControlOptions): Promise<ViewCatalog>;
|
|
23
23
|
}
|
|
24
24
|
export interface BoundSessionControls {
|
|
25
25
|
readonly signal: AbortSignal;
|
package/dist/session/bound.js
CHANGED
|
@@ -28,7 +28,7 @@ export function bindSession(source, controls) {
|
|
|
28
28
|
const upload = (input, options) => uploadSource(input, mergeOptions(options, admittedControls));
|
|
29
29
|
const download = (location, options) => downloadSource(location, controlOptions(options, admittedControls));
|
|
30
30
|
const content = Object.freeze({ upload, download });
|
|
31
|
-
const viewsFor = (
|
|
31
|
+
const viewsFor = (domain, options) => viewsForSource(domain, controlOptions(options, admittedControls));
|
|
32
32
|
const install = (request, options) => schemaSource.install(request, controlOptions(options, admittedControls));
|
|
33
33
|
const uninstall = (request, options) => schemaSource.uninstall(request, controlOptions(options, admittedControls));
|
|
34
34
|
const inspect = (origin, options) => schemaSource.inspect(origin, controlOptions(options, admittedControls));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MintedCredential
|
|
1
|
+
import type { MintedCredential } from '@astrale-os/kernel-core/auth';
|
|
2
2
|
import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
3
3
|
import type { Client } from '../../client/index.js';
|
|
4
4
|
import type { SchemaOptions } from '../../schema/schema.js';
|
|
@@ -29,18 +29,12 @@ export interface DomainExchangeRequest {
|
|
|
29
29
|
readonly issuer: IssuerId;
|
|
30
30
|
/** Requested delegation lifetime; the source credential's remaining lifetime bounds it. */
|
|
31
31
|
readonly ttlSeconds: number;
|
|
32
|
-
readonly attenuation: UnresolvedIdentityExpr;
|
|
33
32
|
/**
|
|
34
33
|
* Lifetime the returned credential must exceed. A source that bounds the delegation within it is
|
|
35
34
|
* exhausted rather than exchanged.
|
|
36
35
|
*/
|
|
37
36
|
readonly coverageMs?: number;
|
|
38
37
|
}
|
|
39
|
-
/** The attenuation that delegates the source caller's own identity. */
|
|
40
|
-
export declare const SELF_ATTENUATION: Readonly<{
|
|
41
|
-
readonly kind: 'identity';
|
|
42
|
-
readonly self: true;
|
|
43
|
-
}>;
|
|
44
38
|
/**
|
|
45
39
|
* Delegate the source caller to one Domain issuer and redeem that delegation at the issuer's
|
|
46
40
|
* advertised endpoint for the Domain's credential to the source Kernel.
|
|
@@ -4,8 +4,6 @@ import { delegationCoverageMs } from '../credential/index.js';
|
|
|
4
4
|
import { resolveAuth } from '../routing/index.js';
|
|
5
5
|
import { redeem, tokenEndpoint } from './issuer.js';
|
|
6
6
|
import { delegationTtl, isAuthority, renewing, sourceCaller, sourceExhausted } from './source.js';
|
|
7
|
-
/** The attenuation that delegates the source caller's own identity. */
|
|
8
|
-
export const SELF_ATTENUATION = Object.freeze({ kind: 'identity', self: true });
|
|
9
7
|
/**
|
|
10
8
|
* Delegate the source caller to one Domain issuer and redeem that delegation at the issuer's
|
|
11
9
|
* advertised endpoint for the Domain's credential to the source Kernel.
|
|
@@ -22,7 +20,6 @@ export async function exchangeDomainCredential(dependencies, source, request, op
|
|
|
22
20
|
const delegation = await credentialApi(caller.call).delegate(principal, {
|
|
23
21
|
audience: request.issuer,
|
|
24
22
|
ttlSeconds,
|
|
25
|
-
attenuation: request.attenuation,
|
|
26
23
|
});
|
|
27
24
|
const credential = await redeem(dependencies, request.issuer, endpoint, delegation, operation);
|
|
28
25
|
// A Domain credential never outlives its source, so only a fresher source can lengthen it.
|
|
@@ -47,7 +44,6 @@ export async function acquireDomainCredential(dependencies, request, operation)
|
|
|
47
44
|
const exchange = (source) => exchangeDomainCredential(dependencies, source, {
|
|
48
45
|
issuer: request.issuer,
|
|
49
46
|
ttlSeconds: request.ttlSeconds,
|
|
50
|
-
attenuation: SELF_ATTENUATION,
|
|
51
47
|
...(request.ttlSeconds * 1_000 > coverageMs ? { coverageMs } : {}),
|
|
52
48
|
}, operation);
|
|
53
49
|
const source = await resolveAuth(auth, call, operation);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { callableOrigin, installedIssuer } from './domain.js';
|
|
2
|
-
export { acquireDomainCredential, exchangeDomainCredential,
|
|
2
|
+
export { acquireDomainCredential, exchangeDomainCredential, type DomainCredential, type DomainExchangeRequest, type ExchangeDependencies, } from './exchange.js';
|
|
3
3
|
export { admitExchangeOptions, admitExchangeRequest, type ExchangeRequest, type SessionExchangeOptions, type SessionExchangeRequest, } from './options.js';
|
|
4
4
|
export { createSessionExchange, type SessionExchange } from './presentation.js';
|
|
5
5
|
export { isAuthority } from './source.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { callableOrigin, installedIssuer } from './domain.js';
|
|
2
|
-
export { acquireDomainCredential, exchangeDomainCredential,
|
|
2
|
+
export { acquireDomainCredential, exchangeDomainCredential, } from './exchange.js';
|
|
3
3
|
export { admitExchangeOptions, admitExchangeRequest, } from './options.js';
|
|
4
4
|
export { createSessionExchange } from './presentation.js';
|
|
5
5
|
export { isAuthority } from './source.js';
|
|
@@ -2,7 +2,7 @@ import { ClientError } from '../../errors/index.js';
|
|
|
2
2
|
import { runSessionOperation } from '../context/index.js';
|
|
3
3
|
import { createSessionCredentialProvider, delegationCoverageMs } from '../credential/index.js';
|
|
4
4
|
import { createInstallations, declaringOrigin, isKernelOrigin } from './domain.js';
|
|
5
|
-
import { exchangeDomainCredential
|
|
5
|
+
import { exchangeDomainCredential } from './exchange.js';
|
|
6
6
|
import { MAXIMUM_EXCHANGE_SOURCES } from './limits.js';
|
|
7
7
|
import { isAuthority, renewing } from './source.js';
|
|
8
8
|
/**
|
|
@@ -51,7 +51,6 @@ export function createSessionExchange(dependencies, options) {
|
|
|
51
51
|
mint: (signal) => exchangeDomainCredential(dependencies, source, {
|
|
52
52
|
issuer: domain,
|
|
53
53
|
ttlSeconds: options.ttlSeconds,
|
|
54
|
-
attenuation: SELF_ATTENUATION,
|
|
55
54
|
coverageMs,
|
|
56
55
|
}, dependencies.operation(signal)),
|
|
57
56
|
});
|
|
@@ -271,15 +271,7 @@ function encodeBase64Url(input) {
|
|
|
271
271
|
return globalThis.btoa(binary).replace(/\+/gu, '-').replace(/\//gu, '_').replace(/=+$/gu, '');
|
|
272
272
|
}
|
|
273
273
|
function canonicalDelegate(input) {
|
|
274
|
-
return JSON.stringify({
|
|
275
|
-
ttlSeconds: input.ttlSeconds,
|
|
276
|
-
...(input.attenuation === undefined ? {} : { attenuation: canonicalExpr(input.attenuation) }),
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
function canonicalExpr(input) {
|
|
280
|
-
return 'self' in input
|
|
281
|
-
? { kind: 'identity', self: true }
|
|
282
|
-
: { kind: 'identity', credential: input.credential };
|
|
274
|
+
return JSON.stringify({ ttlSeconds: input.ttlSeconds });
|
|
283
275
|
}
|
|
284
276
|
async function digestText(input) {
|
|
285
277
|
const webCrypto = typeof crypto === 'undefined' ? undefined : crypto;
|
|
@@ -69,7 +69,7 @@ export declare class ClientSession {
|
|
|
69
69
|
private readonly routes;
|
|
70
70
|
private readonly exchangeDependencies;
|
|
71
71
|
private readonly callExchange?;
|
|
72
|
-
private readonly
|
|
72
|
+
private readonly admitDomainViews;
|
|
73
73
|
private closed;
|
|
74
74
|
constructor(options: ClientSessionOptions);
|
|
75
75
|
/** Bind one admitted DSL Domain to authenticated graph projection and Method dispatch. */
|
|
@@ -93,7 +93,11 @@ export declare class ClientSession {
|
|
|
93
93
|
*/
|
|
94
94
|
publication(options?: SessionControlOptions): Promise<publication.Publication>;
|
|
95
95
|
snapshot(options?: SessionControlOptions): Promise<SessionSnapshot>;
|
|
96
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Resolve the View catalog of one installed Domain. Only an exact Domain Path `/:<origin>` is
|
|
98
|
+
* accepted; any other Path rejects with a TypeError before the call.
|
|
99
|
+
*/
|
|
100
|
+
viewsFor(domain: PathLike, options?: SessionControlOptions): Promise<ViewCatalog>;
|
|
97
101
|
dispatch(call: Call, options?: SessionRequestOptions): Promise<Result>;
|
|
98
102
|
dispatch(call: Call, options: SessionRequestOptionsWithBody): Promise<Result>;
|
|
99
103
|
call(call: Call, options?: SessionRequestOptions): Promise<Input>;
|
package/dist/session/session.js
CHANGED
|
@@ -17,7 +17,7 @@ import { createSessionDiscovery } from './discovery/index.js';
|
|
|
17
17
|
import { acquireDomainCredential, admitExchangeOptions, admitExchangeRequest, createSessionExchange, } from './exchange/index.js';
|
|
18
18
|
import { admitReference } from './reference.js';
|
|
19
19
|
import { admitEnvelopeTransport, admitInvocationOptions, admitSessionAuth, requireResultKind, RouteCache, SessionDispatcher, } from './routing/index.js';
|
|
20
|
-
import {
|
|
20
|
+
import { domainViewCatalog, resolveViewsFor } from './views/index.js';
|
|
21
21
|
const DEFAULT_SESSION_POLICY = Object.freeze({ maximumRouteAgeMs: 60_000 });
|
|
22
22
|
/** Caller-owned discovery and redirect-following conversation with one exact source Kernel. */
|
|
23
23
|
export class ClientSession {
|
|
@@ -34,14 +34,14 @@ export class ClientSession {
|
|
|
34
34
|
routes;
|
|
35
35
|
exchangeDependencies;
|
|
36
36
|
callExchange;
|
|
37
|
-
|
|
37
|
+
admitDomainViews;
|
|
38
38
|
closed = false;
|
|
39
39
|
constructor(options) {
|
|
40
40
|
if (options === null || typeof options !== 'object') {
|
|
41
41
|
throw new TypeError('ClientSession options are invalid.');
|
|
42
42
|
}
|
|
43
43
|
const policy = admitPolicy(options.policy);
|
|
44
|
-
this.
|
|
44
|
+
this.admitDomainViews = (input, domain) => domainViewCatalog(input, domain, policy);
|
|
45
45
|
this.kernel = admitKernel(options.kernel, policy.allowInsecureHttp === true);
|
|
46
46
|
const sourceEndpoint = kernelInvocationEndpoint(this.kernel);
|
|
47
47
|
const fetch = options.fetch ?? globalThis.fetch;
|
|
@@ -173,9 +173,13 @@ export class ClientSession {
|
|
|
173
173
|
snapshot(options) {
|
|
174
174
|
return this.discovery.snapshot(this.operation(admitControlOptions(options)));
|
|
175
175
|
}
|
|
176
|
-
|
|
176
|
+
/**
|
|
177
|
+
* Resolve the View catalog of one installed Domain. Only an exact Domain Path `/:<origin>` is
|
|
178
|
+
* accepted; any other Path rejects with a TypeError before the call.
|
|
179
|
+
*/
|
|
180
|
+
viewsFor(domain, options) {
|
|
177
181
|
this.requireOpen();
|
|
178
|
-
return resolveViewsFor(async (call, operation) => requireResultKind('value', await this.dispatcher.dispatch(call, {}, operation)).value, this.
|
|
182
|
+
return resolveViewsFor(async (call, operation) => requireResultKind('value', await this.dispatcher.dispatch(call, {}, operation)).value, this.admitDomainViews, domain, this.operation(admitControlOptions(options)));
|
|
179
183
|
}
|
|
180
184
|
dispatch(call, options) {
|
|
181
185
|
return this.dispatchWith(call, options);
|
|
@@ -20,8 +20,11 @@ void observedPublication;
|
|
|
20
20
|
const admitted = session.auth.admit({
|
|
21
21
|
target: Path.parse('/:example.test:function.write'),
|
|
22
22
|
input: {},
|
|
23
|
-
},
|
|
23
|
+
}, control);
|
|
24
24
|
void admitted;
|
|
25
|
+
void session.auth.admit({ target: Path.parse('/:example.test:function.write'), input: {} },
|
|
26
|
+
// @ts-expect-error Admission carries no authority expression.
|
|
27
|
+
{ attenuation: { kind: 'identity', self: true } });
|
|
25
28
|
// @ts-expect-error Admission belongs to Auth, not the top-level Session.
|
|
26
29
|
void session.admit({ target: Path.parse('/:example.test:function.write'), input: {} });
|
|
27
30
|
const credentials = createSessionCredentialProvider({
|
|
@@ -9,7 +9,15 @@ export interface ViewCatalog {
|
|
|
9
9
|
readonly entrypoint?: ResolvedView;
|
|
10
10
|
readonly views: readonly ResolvedView[];
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Every View targets its owning Domain. A legacy Class-targeted declaration that an earlier DSL
|
|
14
|
+
* persisted is ignored here, exactly as Runtime View resolution ignores it.
|
|
15
|
+
*/
|
|
12
16
|
export declare function rootViewCatalog(publication: publication.Publication, artifact: bundle.Bundle, policy: Readonly<SessionPolicy>): ViewCatalog;
|
|
13
17
|
export declare function catalogFromKeys(root: ViewCatalog, keys: readonly Key.View[]): ViewCatalog;
|
|
14
|
-
/**
|
|
15
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Re-admit one Runtime-resolved Domain View catalog at the Client trust boundary. Only Views that
|
|
20
|
+
* the requested Domain declares for itself are kept, so an earlier Kernel that still resolved Class
|
|
21
|
+
* targets can never widen the per-Domain catalog.
|
|
22
|
+
*/
|
|
23
|
+
export declare function domainViewCatalog(input: unknown, domain: Key.Origin, policy: Readonly<SessionPolicy>): ViewCatalog;
|
|
@@ -2,34 +2,46 @@ import { acceptViewResolution, } from '@astrale-os/kernel-core/schema/kernel/sys
|
|
|
2
2
|
import { Key as ViewKey } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
3
3
|
import { ClientError } from '../../errors/index.js';
|
|
4
4
|
import { allowEndpoint } from '../context/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* Every View targets its owning Domain. A legacy Class-targeted declaration that an earlier DSL
|
|
7
|
+
* persisted is ignored here, exactly as Runtime View resolution ignores it.
|
|
8
|
+
*/
|
|
5
9
|
export function rootViewCatalog(publication, artifact, policy) {
|
|
10
|
+
const legacy = new Set();
|
|
6
11
|
const views = publication.bindings.views
|
|
7
|
-
.
|
|
12
|
+
.flatMap((binding) => {
|
|
8
13
|
allowEndpoint(binding.href, policy);
|
|
9
14
|
const declaration = artifact.root.views[viewName(binding.view)];
|
|
10
15
|
if (declaration === undefined) {
|
|
11
16
|
throw new ClientError('Published View has no verified root declaration.');
|
|
12
17
|
}
|
|
18
|
+
if (declaration.target.kind !== 'domain') {
|
|
19
|
+
legacy.add(binding.view);
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
13
22
|
const { ref: _ref, ...viewDeclaration } = declaration;
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
return [
|
|
24
|
+
Object.freeze({
|
|
25
|
+
key: binding.view,
|
|
26
|
+
declaration: Object.freeze(viewDeclaration),
|
|
27
|
+
href: binding.href,
|
|
28
|
+
handshake: binding.handshake,
|
|
29
|
+
...(binding.iframe === undefined ? {} : { iframe: binding.iframe }),
|
|
30
|
+
...(binding.host === undefined ? {} : { host: binding.host }),
|
|
31
|
+
issuer: publication.identity.issuer,
|
|
32
|
+
etag: publication.etag,
|
|
33
|
+
revision: publication.schema.revision,
|
|
34
|
+
}),
|
|
35
|
+
];
|
|
25
36
|
})
|
|
26
37
|
.sort((left, right) => compareKeys(left.key, right.key));
|
|
27
38
|
const catalogViews = Object.freeze(views);
|
|
28
39
|
const entrypointRef = publication.manifest?.entrypoint;
|
|
29
|
-
const
|
|
40
|
+
const entrypointKey = entrypointRef === undefined ? undefined : ViewKey.of(entrypointRef);
|
|
41
|
+
const entrypoint = entrypointKey === undefined || legacy.has(entrypointKey)
|
|
30
42
|
? undefined
|
|
31
|
-
: catalogViews.find(({ key }) => key ===
|
|
32
|
-
if (
|
|
43
|
+
: catalogViews.find(({ key }) => key === entrypointKey);
|
|
44
|
+
if (entrypointKey !== undefined && !legacy.has(entrypointKey) && entrypoint === undefined) {
|
|
33
45
|
throw new ClientError('Published View entrypoint has no verified Publication binding.');
|
|
34
46
|
}
|
|
35
47
|
return Object.freeze({
|
|
@@ -47,8 +59,12 @@ export function catalogFromKeys(root, keys) {
|
|
|
47
59
|
views,
|
|
48
60
|
});
|
|
49
61
|
}
|
|
50
|
-
/**
|
|
51
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Re-admit one Runtime-resolved Domain View catalog at the Client trust boundary. Only Views that
|
|
64
|
+
* the requested Domain declares for itself are kept, so an earlier Kernel that still resolved Class
|
|
65
|
+
* targets can never widen the per-Domain catalog.
|
|
66
|
+
*/
|
|
67
|
+
export function domainViewCatalog(input, domain, policy) {
|
|
52
68
|
let resolution;
|
|
53
69
|
try {
|
|
54
70
|
resolution = acceptViewResolution(input);
|
|
@@ -56,9 +72,10 @@ export function targetViewCatalog(input, policy) {
|
|
|
56
72
|
catch (cause) {
|
|
57
73
|
throw new ClientError('Resolved View catalog is invalid.', { cause });
|
|
58
74
|
}
|
|
59
|
-
|
|
75
|
+
const views = resolution.views.filter((view) => view.declaration.target.kind === 'domain' && ViewKey.origin(view.key) === domain);
|
|
76
|
+
for (const view of views)
|
|
60
77
|
allowEndpoint(view.href, policy);
|
|
61
|
-
return Object.freeze({ views:
|
|
78
|
+
return Object.freeze({ views: Object.freeze(views) });
|
|
62
79
|
}
|
|
63
80
|
function compareKeys(left, right) {
|
|
64
81
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { catalogFromKeys,
|
|
1
|
+
export { catalogFromKeys, domainViewCatalog, rootViewCatalog, type ResolvedView, type ViewCatalog, } from './catalog.js';
|
|
2
2
|
export { resolveViewsFor, type ViewCatalogAdmission, type ViewInvoker } from './resolve.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { catalogFromKeys,
|
|
1
|
+
export { catalogFromKeys, domainViewCatalog, rootViewCatalog, } from './catalog.js';
|
|
2
2
|
export { resolveViewsFor } from './resolve.js';
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { PathLike } from '@astrale-os/kernel-core/path';
|
|
2
|
+
import type { Key } from '@astrale-os/kernel-dsl/v1';
|
|
2
3
|
import type { Call, Input } from '../../client/index.js';
|
|
3
4
|
import type { SessionOperation } from '../context/index.js';
|
|
4
5
|
import type { ViewCatalog } from './catalog.js';
|
|
5
6
|
export type ViewInvoker = (call: Call, operation: SessionOperation) => Promise<Input>;
|
|
6
|
-
export type ViewCatalogAdmission = (input: unknown) => ViewCatalog;
|
|
7
|
+
export type ViewCatalogAdmission = (input: unknown, domain: Key.Origin) => ViewCatalog;
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
9
|
+
* Resolve the per-Domain View catalog through the canonical source Kernel call, then admit its
|
|
10
|
+
* installed-Publication projection. Every View targets its owning Domain, so only an exact Domain
|
|
11
|
+
* Path `/:<origin>` is meaningful; any other Path is refused before the call.
|
|
10
12
|
*/
|
|
11
|
-
export declare function resolveViewsFor(invoke: ViewInvoker, admitCatalog: ViewCatalogAdmission,
|
|
13
|
+
export declare function resolveViewsFor(invoke: ViewInvoker, admitCatalog: ViewCatalogAdmission, domain: PathLike, operation: SessionOperation): Promise<ViewCatalog>;
|
|
@@ -2,12 +2,20 @@ import { Path } from '@astrale-os/kernel-core/path';
|
|
|
2
2
|
import { view } from '@astrale-os/kernel-core/schema/kernel/syscalls/references';
|
|
3
3
|
import { call } from '../../client/index.js';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Resolve the per-Domain View catalog through the canonical source Kernel call, then admit its
|
|
6
|
+
* installed-Publication projection. Every View targets its owning Domain, so only an exact Domain
|
|
7
|
+
* Path `/:<origin>` is meaningful; any other Path is refused before the call.
|
|
7
8
|
*/
|
|
8
|
-
export async function resolveViewsFor(invoke, admitCatalog,
|
|
9
|
-
const
|
|
9
|
+
export async function resolveViewsFor(invoke, admitCatalog, domain, operation) {
|
|
10
|
+
const origin = domainOrigin(domain);
|
|
10
11
|
const owner = Path.project(view.resolve.owner);
|
|
11
|
-
const
|
|
12
|
-
return admitCatalog(await invoke(call(
|
|
12
|
+
const resolve = Path.staticMethod(owner, view.resolve.name);
|
|
13
|
+
return admitCatalog(await invoke(call(resolve, { target: Path.domain(origin).raw }), operation), origin);
|
|
14
|
+
}
|
|
15
|
+
function domainOrigin(input) {
|
|
16
|
+
const { anchor, steps } = Path.from(input).ast;
|
|
17
|
+
if (anchor.kind !== 'domain' || steps.length !== 0) {
|
|
18
|
+
throw new TypeError('View catalog requires a Domain Path /:<origin>; Views never target a Node.');
|
|
19
|
+
}
|
|
20
|
+
return anchor.origin;
|
|
13
21
|
}
|
|
@@ -230,9 +230,8 @@ export class HttpTransport {
|
|
|
230
230
|
// An intermediary may rewrite Content-Length (for example when it compresses the body), so
|
|
231
231
|
// only the protocol length counts.
|
|
232
232
|
const length = response.headers.get(protocol.http.BINARY_LENGTH_FIELD);
|
|
233
|
-
const expectedBytes = length === null ? undefined :
|
|
234
|
-
if (length !== null &&
|
|
235
|
-
(!/^(?:0|[1-9][0-9]*)$/u.test(length) || !Number.isSafeInteger(expectedBytes))) {
|
|
233
|
+
const expectedBytes = length === null ? undefined : protocol.http.decodeBinaryLength(length);
|
|
234
|
+
if (length !== null && expectedBytes === undefined) {
|
|
236
235
|
throw new ProtocolError(`streaming binary has an invalid ${protocol.http.BINARY_LENGTH_FIELD}.`);
|
|
237
236
|
}
|
|
238
237
|
if (expectedBytes !== undefined && expectedBytes > this.maximumResponseBytes) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrale-os/kernel-client",
|
|
3
|
-
"version": "0.6.0-beta.
|
|
3
|
+
"version": "0.6.0-beta.86",
|
|
4
4
|
"description": "Universal Client — protocol-first, transport-agnostic",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astrale",
|
|
@@ -65,13 +65,13 @@
|
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@astrale-os/kernel-core": "0.9.0-beta.
|
|
69
|
-
"@astrale-os/kernel-dsl": "0.2.0-beta.
|
|
70
|
-
"@astrale-os/kernel-protocol": "0.5.0-beta.
|
|
68
|
+
"@astrale-os/kernel-core": "0.9.0-beta.65",
|
|
69
|
+
"@astrale-os/kernel-dsl": "0.2.0-beta.47",
|
|
70
|
+
"@astrale-os/kernel-protocol": "0.5.0-beta.71",
|
|
71
71
|
"@tanstack/pacer": "0.20.1"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@astrale-os/kernel-server": "0.5.0-beta.
|
|
74
|
+
"@astrale-os/kernel-server": "0.5.0-beta.73",
|
|
75
75
|
"@astrale/typescript-config": "npm:@jsr/astrale__typescript-config@~1.1.0",
|
|
76
76
|
"@types/node": "^22.0.0",
|
|
77
77
|
"typescript": "7.0.2",
|