@astrale-os/kernel-protocol 0.5.0-beta.51 → 0.5.0-beta.53
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/codecs/msgpack.js
CHANGED
|
@@ -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
|
-
|
|
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,9 +1,11 @@
|
|
|
1
|
+
import { type ViewHostRequirements } from '@astrale-os/kernel-core/schema/kernel/syscalls/view-resolution';
|
|
1
2
|
import { Key } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
2
3
|
export interface ViewBinding {
|
|
3
4
|
readonly view: Key.View;
|
|
4
5
|
readonly href: string;
|
|
5
6
|
readonly handshake: 'shell' | 'none';
|
|
6
7
|
readonly iframe?: IframeRequirements;
|
|
8
|
+
readonly host?: ViewHostRequirements;
|
|
7
9
|
}
|
|
8
10
|
export interface IframeRequirements {
|
|
9
11
|
readonly sandbox?: readonly string[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { acceptViewHostRequirements, } from '@astrale-os/kernel-core/schema/kernel/syscalls/view-resolution';
|
|
1
2
|
import { Key } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
2
3
|
import { absoluteHttpUrl, exact, record } from '../content.js';
|
|
3
4
|
import { fail } from '../error.js';
|
|
@@ -11,7 +12,7 @@ export function canonicalizeViewBinding(input, origin) {
|
|
|
11
12
|
}
|
|
12
13
|
function readViewBinding(input, origin, canonicalize) {
|
|
13
14
|
const value = record(input, 'PUBLICATION_VIEW_INVALID', 'Published View binding is invalid.');
|
|
14
|
-
exact(value, ['view', 'href', 'handshake', 'iframe'], 'PUBLICATION_VIEW_INVALID');
|
|
15
|
+
exact(value, ['view', 'href', 'handshake', 'iframe', 'host'], 'PUBLICATION_VIEW_INVALID');
|
|
15
16
|
let view;
|
|
16
17
|
try {
|
|
17
18
|
view = Key(String(value.view));
|
|
@@ -29,11 +30,21 @@ function readViewBinding(input, origin, canonicalize) {
|
|
|
29
30
|
fail('PUBLICATION_VIEW_INVALID', 'View handshake is invalid.');
|
|
30
31
|
}
|
|
31
32
|
const iframe = admitIframeRequirements(dataValue(value, 'iframe'), value.handshake, canonicalize);
|
|
33
|
+
let host;
|
|
34
|
+
try {
|
|
35
|
+
host = acceptViewHostRequirements(dataValue(value, 'host'), value.handshake, canonicalize);
|
|
36
|
+
}
|
|
37
|
+
catch (cause) {
|
|
38
|
+
if (cause instanceof TypeError)
|
|
39
|
+
return fail('PUBLICATION_VIEW_INVALID', 'View host requirements are invalid.', cause);
|
|
40
|
+
throw cause;
|
|
41
|
+
}
|
|
32
42
|
return Object.freeze({
|
|
33
43
|
view,
|
|
34
44
|
href: absoluteHttpUrl(value.href, true, 'PUBLICATION_VIEW_INVALID'),
|
|
35
45
|
handshake: value.handshake,
|
|
36
46
|
...(iframe === undefined ? {} : { iframe }),
|
|
47
|
+
...(host === undefined ? {} : { host }),
|
|
37
48
|
});
|
|
38
49
|
}
|
|
39
50
|
function admitIframeRequirements(input, handshake, canonicalize) {
|
|
@@ -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.
|
|
3
|
+
"version": "0.5.0-beta.53",
|
|
4
4
|
"description": "Portable Astrale invocation, publication, installation, routing, and issuer protocols",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
"access": "public"
|
|
138
138
|
},
|
|
139
139
|
"dependencies": {
|
|
140
|
-
"@astrale-os/kernel-core": "0.9.0-beta.
|
|
140
|
+
"@astrale-os/kernel-core": "0.9.0-beta.47",
|
|
141
141
|
"@astrale-os/kernel-dsl": "0.2.0-beta.33",
|
|
142
142
|
"@noble/hashes": "2.3.0"
|
|
143
143
|
},
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
"scripts": {
|
|
159
159
|
"build": "tsc",
|
|
160
160
|
"clean": "rm -rf dist",
|
|
161
|
-
"typecheck": "tsc --noEmit",
|
|
161
|
+
"typecheck": "tsc --noEmit && tsc -p tsconfig.workers.json",
|
|
162
162
|
"test": "vitest run",
|
|
163
163
|
"test:file": "vitest run",
|
|
164
164
|
"test:watch": "vitest"
|