@astrale-os/kernel-protocol 0.5.0-beta.50 → 0.5.0-beta.52

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.
@@ -4,7 +4,13 @@ import { CONTENT_TYPE_MSGPACK } from './media-types.js';
4
4
  let library = null;
5
5
  export async function loadMsgpack() {
6
6
  if (library === null) {
7
- const [packing, unpacking] = await Promise.all([import('msgpackr/pack'), import('msgpackr')]);
7
+ // `as string` keeps TypeScript from pulling msgpackr's declarations, which assume
8
+ // `@types/node`, into consumer programs. The assertion is erased on emit, so bundlers
9
+ // still see literal specifiers; a variable would leave them unresolvable.
10
+ const [packing, unpacking] = await Promise.all([
11
+ import('msgpackr/pack'),
12
+ import('msgpackr'),
13
+ ]);
8
14
  library = Object.freeze({ pack: packing.pack, unpack: unpacking.unpack });
9
15
  }
10
16
  return MSGPACK;
@@ -1,7 +1,10 @@
1
1
  import * as bundle from '@astrale-os/kernel-dsl/v1/bundle/transport';
2
2
  import type { BundleDescriptor } from './bundle-descriptor.js';
3
3
  import type { Publication } from './publication.js';
4
+ import * as artifact from '../artifact/index.js';
4
5
  import { verifyBundleBytes } from './bundle-evidence.js';
6
+ /** Resolve immutable bundle bytes beneath the exact serving issuer. */
7
+ export declare function bundleUrl(issuer: string, ref: artifact.Ref): string;
5
8
  export declare function describeBundle(input: bundle.Bundle, href: string): BundleDescriptor;
6
9
  export declare function acceptBundleValue(input: unknown): bundle.Bundle;
7
10
  export declare function decodeBundleValue(publication: Publication, bytes: Uint8Array): bundle.Bundle;
@@ -4,6 +4,12 @@ import { BUNDLE_MEDIA_TYPE } from './bundle-descriptor.js';
4
4
  import { verifyBundleBytes } from './bundle-evidence.js';
5
5
  import { absoluteHttpUrl } from './content.js';
6
6
  import { fail } from './error.js';
7
+ import { url as publicationUrl } from './publication.js';
8
+ /** Resolve immutable bundle bytes beneath the exact serving issuer. */
9
+ export function bundleUrl(issuer, ref) {
10
+ const digest = ref.digest.slice('sha256:'.length);
11
+ return `${publicationUrl(issuer).slice(0, -'domain.json'.length)}bundles/sha256/${digest}.json`;
12
+ }
7
13
  export function describeBundle(input, href) {
8
14
  const bytes = bundle.encode(input);
9
15
  return Object.freeze({
@@ -1,6 +1,6 @@
1
1
  export { MEDIA_TYPE, LEGACY_MEDIA_TYPE, mediaType, PATH, url, seal, accept, encode, type Publication, } from './publication.js';
2
2
  export { acceptBundle, decodeBundle } from './bundle-admission.js';
3
- export { BUNDLE_MEDIA_TYPE, describeBundle, type BundleDescriptor } from './bundle.js';
3
+ export { BUNDLE_MEDIA_TYPE, bundleUrl, describeBundle, type BundleDescriptor } from './bundle.js';
4
4
  export { verifyBundleBytes } from './bundle-evidence.js';
5
5
  export type { Content } from './content.js';
6
6
  export type { Declaration, DeliveryDeclaration } from './declaration.js';
@@ -1,6 +1,6 @@
1
1
  export { MEDIA_TYPE, LEGACY_MEDIA_TYPE, mediaType, PATH, url, seal, accept, encode, } from './publication.js';
2
2
  export { acceptBundle, decodeBundle } from './bundle-admission.js';
3
- export { BUNDLE_MEDIA_TYPE, describeBundle } from './bundle.js';
3
+ export { BUNDLE_MEDIA_TYPE, bundleUrl, describeBundle } from './bundle.js';
4
4
  export { verifyBundleBytes } from './bundle-evidence.js';
5
5
  export { placeDelivery } from './delivery-declaration.js';
6
6
  export { PublicationError } from './error.js';
@@ -1,4 +1,5 @@
1
1
  import * as issuer from '../issuer/index.js';
2
+ import { bundleUrl } from '../publication/bundle.js';
2
3
  import { PATH as PUBLICATION_PATH } from '../publication/publication.js';
3
4
  import { fail } from './error.js';
4
5
  import { templateUrl, templatesOverlap } from './template.js';
@@ -14,8 +15,13 @@ export function rejectReserved(publication, entries) {
14
15
  ...(endpoint.websocket === undefined ? [] : [httpUrlForWebSocket(endpoint.websocket)]),
15
16
  ]),
16
17
  ];
18
+ const addressed = bundleUrl(publication.identity.issuer, publication.schema.bundle.ref);
19
+ const bundlePattern = publication.schema.bundle.href === addressed
20
+ ? `${addressed.slice(0, addressed.lastIndexOf('/') + 1)}{artifact}`
21
+ : undefined;
17
22
  for (const entry of entries) {
18
- const claimed = [...reservedPaths].some((path) => templateClaimsPath(entry.href, path)) ||
23
+ const claimed = (bundlePattern !== undefined && templatesOverlap(entry.href, bundlePattern)) ||
24
+ [...reservedPaths].some((path) => templateClaimsPath(entry.href, path)) ||
19
25
  reservedUrls.some((reserved) => templatesOverlap(entry.href, routeLocation(reserved)));
20
26
  if (claimed) {
21
27
  fail('NATIVE_ROUTE_RESERVED', `Route ${entry.name} claims reserved URL ${templateUrl(entry.href).href}.`);
@@ -2,6 +2,7 @@ import { installReceipt } from '@astrale-os/kernel-core/schema/kernel/syscalls/c
2
2
  import { acceptDomainInfo } from './introspection/index.js';
3
3
  export const MEDIA_TYPE = 'application/vnd.astrale.schema-installation.v1+msgpack';
4
4
  export async function encode(result) {
5
+ // Non-literal specifiers keep msgpackr's Node-typed declarations out of consumers (see codecs/msgpack.ts).
5
6
  const { pack } = await import('msgpackr/pack');
6
7
  return new Uint8Array(pack(accept(result)));
7
8
  }
@@ -13,6 +13,7 @@ export async function encode(input, result) {
13
13
  ? encodeDomainBundle(result)
14
14
  : encodeDomainInfo(result);
15
15
  proveRequestedOrigin(request, result);
16
+ // Non-literal specifiers keep msgpackr's Node-typed declarations out of consumers (see codecs/msgpack.ts).
16
17
  const { pack } = await import('msgpackr/pack');
17
18
  return new Uint8Array(pack(wire));
18
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/kernel-protocol",
3
- "version": "0.5.0-beta.50",
3
+ "version": "0.5.0-beta.52",
4
4
  "description": "Portable Astrale invocation, publication, installation, routing, and issuer protocols",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {