@astrale-os/kernel-core 0.9.0-beta.45 → 0.9.0-beta.47

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.
Files changed (26) hide show
  1. package/dist/schema/callables/view.d.ts +14 -0
  2. package/dist/schema/domain/domain.d.ts +569 -122
  3. package/dist/schema/identity/identity.d.ts +17 -0
  4. package/dist/schema/kernel/schema.d.ts +944 -448
  5. package/dist/schema/kernel/schema.js +1 -0
  6. package/dist/schema/kernel/syscalls/contracts/impersonate.d.ts +7 -0
  7. package/dist/schema/kernel/syscalls/contracts/impersonate.js +4 -0
  8. package/dist/schema/kernel/syscalls/contracts/index.d.ts +1 -0
  9. package/dist/schema/kernel/syscalls/contracts/index.js +1 -0
  10. package/dist/schema/kernel/syscalls/contracts/view-host-requirements.d.ts +17 -0
  11. package/dist/schema/kernel/syscalls/contracts/view-host-requirements.js +40 -0
  12. package/dist/schema/kernel/syscalls/contracts/view-resolve.d.ts +7 -0
  13. package/dist/schema/kernel/syscalls/contracts/view-resolve.js +2 -0
  14. package/dist/schema/kernel/syscalls/declarations/impersonate.d.ts +10 -0
  15. package/dist/schema/kernel/syscalls/declarations/impersonate.js +12 -0
  16. package/dist/schema/kernel/syscalls/declarations/index.d.ts +39 -23
  17. package/dist/schema/kernel/syscalls/declarations/index.js +2 -0
  18. package/dist/schema/kernel/syscalls/declarations/view-resolve.d.ts +7 -0
  19. package/dist/schema/kernel/syscalls/descriptors/identity.d.ts +16 -0
  20. package/dist/schema/kernel/syscalls/descriptors/identity.js +1 -0
  21. package/dist/schema/kernel/syscalls/descriptors/results/view-resolution.d.ts +3 -1
  22. package/dist/schema/kernel/syscalls/descriptors/results/view-resolution.js +4 -0
  23. package/dist/schema/kernel/syscalls/descriptors/view.d.ts +7 -0
  24. package/dist/schema/kernel/syscalls/references/identity.d.ts +9 -0
  25. package/dist/schema/kernel/syscalls/references/identity.js +1 -0
  26. package/package.json +2 -2
@@ -76,6 +76,7 @@ export const KernelRootFunctions = Object.freeze([
76
76
  K.functions.uninstall,
77
77
  K.functions.journal,
78
78
  K.classes.Identity.static.methods.whois,
79
+ K.classes.Identity.static.methods.impersonate,
79
80
  K.classes.View.static.methods.resolve,
80
81
  ].sort((left, right) => (left.key < right.key ? -1 : left.key > right.key ? 1 : 0)));
81
82
  export { AuthorityOperationOrder, AuthorityOperations, operationOf } from '../authority/index.js';
@@ -0,0 +1,7 @@
1
+ export declare const impersonateInput: import("zod").ZodObject<{
2
+ audience: import("zod").ZodOptional<import("zod").ZodString>;
3
+ ttlSeconds: import("zod").ZodNumber;
4
+ grant: import("zod").ZodOptional<import("zod").ZodUnknown>;
5
+ identity: import("zod").ZodString;
6
+ }, import("zod/v4/core").$strict>;
7
+ export declare const impersonateOutput: import("zod").ZodString;
@@ -0,0 +1,4 @@
1
+ import { string } from 'zod';
2
+ import { mintInput, mintOutput } from './mint.js';
3
+ export const impersonateInput = mintInput.extend({ identity: string().min(1) });
4
+ export const impersonateOutput = mintOutput;
@@ -4,6 +4,7 @@ export { delegateInput, delegateOutput } from './delegate.js';
4
4
  export { installInput, installReceipt, type DomainRequest, type InstallInput, type InstallReceipt, } from './install.js';
5
5
  export { introspectInput } from './introspect.js';
6
6
  export { journalInput, journalOutput } from './journal.js';
7
+ export { impersonateInput, impersonateOutput } from './impersonate.js';
7
8
  export { mintInput, mintOutput } from './mint.js';
8
9
  export { mutateInput, mutateOutput } from './mutate.js';
9
10
  export { registerInput, registerOutput } from './register.js';
@@ -4,6 +4,7 @@ export { delegateInput, delegateOutput } from './delegate.js';
4
4
  export { installInput, installReceipt, } from './install.js';
5
5
  export { introspectInput } from './introspect.js';
6
6
  export { journalInput, journalOutput } from './journal.js';
7
+ export { impersonateInput, impersonateOutput } from './impersonate.js';
7
8
  export { mintInput, mintOutput } from './mint.js';
8
9
  export { mutateInput, mutateOutput } from './mutate.js';
9
10
  export { registerInput, registerOutput } from './register.js';
@@ -0,0 +1,17 @@
1
+ /** Browser effects required by a published Shell View. */
2
+ export interface ViewHostRequirements {
3
+ readonly navigation: {
4
+ readonly external: {
5
+ readonly origins: readonly string[];
6
+ };
7
+ };
8
+ }
9
+ export declare const viewHostRequirements: import("zod").ZodObject<{
10
+ navigation: import("zod").ZodObject<{
11
+ external: import("zod").ZodObject<{
12
+ origins: import("zod").ZodArray<import("zod").ZodString>;
13
+ }, import("zod/v4/core").$strict>;
14
+ }, import("zod/v4/core").$strict>;
15
+ }, import("zod/v4/core").$strict>;
16
+ /** Decode canonical wire requirements; construction also normalizes authored origins. */
17
+ export declare function acceptViewHostRequirements(input: unknown, handshake: 'shell' | 'none', canonicalize?: boolean): ViewHostRequirements | undefined;
@@ -0,0 +1,40 @@
1
+ import * as portable from '@astrale-os/kernel-dsl/value';
2
+ import { array, strictObject, string } from 'zod';
3
+ export const viewHostRequirements = strictObject({
4
+ navigation: strictObject({
5
+ external: strictObject({ origins: array(string()).min(1) }),
6
+ }),
7
+ });
8
+ /** Decode canonical wire requirements; construction also normalizes authored origins. */
9
+ export function acceptViewHostRequirements(input, handshake, canonicalize = false) {
10
+ if (input === undefined)
11
+ return undefined;
12
+ if (handshake !== 'shell')
13
+ throw new TypeError('Host requirements require a Shell handshake.');
14
+ const parsed = viewHostRequirements.safeParse(portable.accept(input));
15
+ if (!parsed.success)
16
+ throw new TypeError('View host requirements are invalid.');
17
+ const origins = parsed.data.navigation.external.origins.map((candidate) => {
18
+ const url = new URL(candidate);
19
+ if (url.protocol !== 'https:' ||
20
+ url.hostname.includes('*') ||
21
+ url.username !== '' ||
22
+ url.password !== '' ||
23
+ url.pathname !== '/' ||
24
+ url.search !== '' ||
25
+ url.hash !== '' ||
26
+ (!canonicalize && url.origin !== candidate))
27
+ throw new TypeError('External navigation requires an exact HTTPS origin.');
28
+ return url.origin;
29
+ });
30
+ const canonical = [...new Set(origins)].sort();
31
+ if (!canonicalize &&
32
+ (canonical.length !== origins.length ||
33
+ canonical.some((origin, index) => origin !== origins[index])))
34
+ throw new TypeError('External navigation origins are not canonical.');
35
+ return Object.freeze({
36
+ navigation: Object.freeze({
37
+ external: Object.freeze({ origins: Object.freeze(canonical) }),
38
+ }),
39
+ });
40
+ }
@@ -27,6 +27,13 @@ export declare const viewResolveOutput: import("zod").ZodObject<{
27
27
  sandbox: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
28
28
  allow: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
29
29
  }, import("zod/v4/core").$strict>>;
30
+ host: import("zod").ZodOptional<import("zod").ZodObject<{
31
+ navigation: import("zod").ZodObject<{
32
+ external: import("zod").ZodObject<{
33
+ origins: import("zod").ZodArray<import("zod").ZodString>;
34
+ }, import("zod/v4/core").$strict>;
35
+ }, import("zod/v4/core").$strict>;
36
+ }, import("zod/v4/core").$strict>>;
30
37
  issuer: import("zod").ZodString;
31
38
  etag: import("zod").ZodString;
32
39
  revision: import("zod").ZodString;
@@ -1,6 +1,7 @@
1
1
  import { patterns } from '@astrale-os/kernel-dsl/v1/addressing';
2
2
  import { fullMatch } from '@astrale-os/kernel-dsl/v1/value/full-match';
3
3
  import { array, discriminatedUnion, enum as enumeration, literal, strictObject, string } from 'zod';
4
+ import { viewHostRequirements } from './view-host-requirements.js';
4
5
  const definition = strictObject({
5
6
  origin: string().check(fullMatch(patterns.originFullMatch)),
6
7
  kind: literal('class'),
@@ -26,6 +27,7 @@ export const viewResolveOutput = strictObject({
26
27
  href: string().min(1),
27
28
  handshake: enumeration(['shell', 'none']),
28
29
  iframe: iframeRequirements.optional(),
30
+ host: viewHostRequirements.optional(),
29
31
  issuer: string().min(1),
30
32
  etag: string().min(1),
31
33
  revision: string().min(1),
@@ -0,0 +1,10 @@
1
+ import { type builder } from '@astrale-os/kernel-dsl/v1';
2
+ export declare const Impersonate: builder.Method<builder.CallableProjection<{
3
+ audience?: string | undefined;
4
+ ttlSeconds: number;
5
+ grant?: unknown;
6
+ identity: string;
7
+ }, {
8
+ readonly mode: 'value';
9
+ readonly value: string;
10
+ }, "authorized", true, false>>;
@@ -0,0 +1,12 @@
1
+ import { method } from '@astrale-os/kernel-dsl/v1';
2
+ import { impersonateInput, impersonateOutput } from '../contracts/index.js';
3
+ import { usePolicy } from './use-policy.js';
4
+ export const Impersonate = method({
5
+ description: 'Issue a Kernel credential bounded by the active target Identity authority.',
6
+ auth: 'authorized',
7
+ policy: usePolicy(() => Impersonate),
8
+ input: impersonateInput,
9
+ output: impersonateOutput,
10
+ static: true,
11
+ abstract: false,
12
+ });
@@ -379,29 +379,6 @@ export declare const Functions: Readonly<{
379
379
  };
380
380
  })[];
381
381
  operations: ({
382
- op: "edge.update";
383
- edge: {
384
- source: string;
385
- target: string;
386
- class: string;
387
- };
388
- slug: unknown;
389
- props?: {
390
- set: Record<string, unknown>;
391
- unset: string[];
392
- } | undefined;
393
- } | {
394
- op: "edge.update";
395
- edge: {
396
- source: string;
397
- target: string;
398
- class: string;
399
- };
400
- props: {
401
- set: Record<string, unknown>;
402
- unset: string[];
403
- };
404
- } | {
405
382
  op: "node.create";
406
383
  as: string;
407
384
  class: string;
@@ -429,6 +406,29 @@ export declare const Functions: Readonly<{
429
406
  };
430
407
  slug?: unknown;
431
408
  props: Record<string, unknown>;
409
+ } | {
410
+ op: "edge.update";
411
+ edge: {
412
+ source: string;
413
+ target: string;
414
+ class: string;
415
+ };
416
+ slug: unknown;
417
+ props?: {
418
+ set: Record<string, unknown>;
419
+ unset: string[];
420
+ } | undefined;
421
+ } | {
422
+ op: "edge.update";
423
+ edge: {
424
+ source: string;
425
+ target: string;
426
+ class: string;
427
+ };
428
+ props: {
429
+ set: Record<string, unknown>;
430
+ unset: string[];
431
+ };
432
432
  } | {
433
433
  op: "edge.delete";
434
434
  edge: {
@@ -639,6 +639,15 @@ export declare const IdentityMethods: Readonly<{
639
639
  readonly mode: 'value';
640
640
  readonly value: string;
641
641
  }, "authenticated", true, false>>;
642
+ impersonate: builder.Method<builder.CallableProjection<{
643
+ audience?: string | undefined;
644
+ ttlSeconds: number;
645
+ grant?: unknown;
646
+ identity: string;
647
+ }, {
648
+ readonly mode: 'value';
649
+ readonly value: string;
650
+ }, "authorized", true, false>>;
642
651
  }>;
643
652
  export declare const FunctionMethods: Readonly<{
644
653
  admit: builder.Method<builder.CallableProjection<{
@@ -687,6 +696,13 @@ export declare const ViewMethods: Readonly<{
687
696
  sandbox?: string[] | undefined;
688
697
  allow?: string[] | undefined;
689
698
  } | undefined;
699
+ host?: {
700
+ navigation: {
701
+ external: {
702
+ origins: string[];
703
+ };
704
+ };
705
+ } | undefined;
690
706
  issuer: string;
691
707
  etag: string;
692
708
  revision: string;
@@ -1,6 +1,7 @@
1
1
  import { Admit } from './admit.js';
2
2
  import { Can } from './can.js';
3
3
  import { Delegate } from './delegate.js';
4
+ import { Impersonate } from './impersonate.js';
4
5
  import { Install } from './install.js';
5
6
  import { Introspect } from './introspect.js';
6
7
  import { Journal } from './journal.js';
@@ -27,6 +28,7 @@ export const IdentityMethods = Object.freeze({
27
28
  whoami: Whoami,
28
29
  whois: Whois,
29
30
  mint: Mint,
31
+ impersonate: Impersonate,
30
32
  });
31
33
  export const FunctionMethods = Object.freeze({
32
34
  admit: Admit,
@@ -26,6 +26,13 @@ export declare const ViewResolve: builder.Method<builder.CallableProjection<{
26
26
  sandbox?: string[] | undefined;
27
27
  allow?: string[] | undefined;
28
28
  } | undefined;
29
+ host?: {
30
+ navigation: {
31
+ external: {
32
+ origins: string[];
33
+ };
34
+ };
35
+ } | undefined;
29
36
  issuer: string;
30
37
  etag: string;
31
38
  revision: string;
@@ -89,6 +89,22 @@ export declare const whois: import("./model.js").MethodSyscall<Readonly<{
89
89
  readonly name: "whois";
90
90
  readonly executable: true;
91
91
  }>;
92
+ export declare const impersonate: import("./model.js").MethodSyscall<Readonly<{
93
+ origin: 'kernel.astrale.ai';
94
+ kind: 'class';
95
+ name: 'Identity';
96
+ }>, "impersonate", import("@astrale-os/kernel-dsl/v1").ResolvedMethod<{
97
+ audience?: string | undefined;
98
+ ttlSeconds: number;
99
+ grant?: unknown;
100
+ identity: string;
101
+ }, {
102
+ readonly mode: 'value';
103
+ readonly value: string;
104
+ }, true, false, "authorized", import("@astrale-os/kernel-dsl/v1").PolicyCheckExpression<import("@astrale-os/kernel-dsl/v1").PolicyRef, import("@astrale-os/kernel-dsl/v1/language").PolicyCheckObject>, "kernel.astrale.ai:class.Identity.method.impersonate"> & {
105
+ readonly name: "impersonate";
106
+ readonly executable: true;
107
+ }>;
92
108
  export declare const mint: import("./model.js").MethodSyscall<Readonly<{
93
109
  origin: 'kernel.astrale.ai';
94
110
  kind: 'class';
@@ -5,4 +5,5 @@ export const delegate = methodSyscall(references.delegate, K.classes.Identity.st
5
5
  export const can = methodSyscall(references.can, K.classes.Identity.static.methods.can);
6
6
  export const whoami = methodSyscall(references.whoami, K.classes.Identity.static.methods.whoami);
7
7
  export const whois = methodSyscall(references.whois, K.classes.Identity.static.methods.whois);
8
+ export const impersonate = methodSyscall(references.impersonate, K.classes.Identity.static.methods.impersonate);
8
9
  export const mint = methodSyscall(references.mint, K.classes.Identity.static.methods.mint);
@@ -1,12 +1,15 @@
1
1
  import type { Revision, ViewDefinition } from '@astrale-os/kernel-dsl/v1';
2
2
  import type { Key as KeyType } from '@astrale-os/kernel-dsl/v1/addressing';
3
3
  import type { IssuerId } from '../../../../../auth/index.js';
4
+ import { type ViewHostRequirements } from '../../contracts/view-host-requirements.js';
5
+ export { acceptViewHostRequirements, type ViewHostRequirements, } from '../../contracts/view-host-requirements.js';
4
6
  export interface ResolvedView {
5
7
  readonly key: KeyType.View;
6
8
  readonly declaration: ViewDeclaration;
7
9
  readonly href: string;
8
10
  readonly handshake: 'shell' | 'none';
9
11
  readonly iframe?: IframeRequirements;
12
+ readonly host?: ViewHostRequirements;
10
13
  readonly issuer: IssuerId;
11
14
  readonly etag: `sha256:${string}`;
12
15
  readonly revision: Revision;
@@ -22,4 +25,3 @@ export interface ViewResolution {
22
25
  }
23
26
  /** Admit one detached, deeply immutable result of the Kernel View.resolve syscall. */
24
27
  export declare function acceptViewResolution(input: unknown): ViewResolution;
25
- export {};
@@ -2,6 +2,8 @@ import { Key, patterns } from '@astrale-os/kernel-dsl/v1/addressing';
2
2
  import * as portable from '@astrale-os/kernel-dsl/value';
3
3
  import { issuer } from '../../../../../auth/index.js';
4
4
  import { viewResolveOutput } from '../../contracts/index.js';
5
+ import { acceptViewHostRequirements, } from '../../contracts/view-host-requirements.js';
6
+ export { acceptViewHostRequirements, } from '../../contracts/view-host-requirements.js';
5
7
  /** Admit one detached, deeply immutable result of the Kernel View.resolve syscall. */
6
8
  export function acceptViewResolution(input) {
7
9
  const candidate = portable.accept(input);
@@ -24,12 +26,14 @@ export function acceptViewResolution(input) {
24
26
  invalid(`Resolved View ${index} issuer is not canonical.`);
25
27
  const declaration = acceptDeclaration(view.declaration, index);
26
28
  const iframe = acceptIframeRequirements(view.iframe, view.handshake, index);
29
+ const host = acceptViewHostRequirements(view.host, view.handshake);
27
30
  return Object.freeze({
28
31
  key,
29
32
  declaration,
30
33
  href: view.href,
31
34
  handshake: view.handshake,
32
35
  ...(iframe === undefined ? {} : { iframe }),
36
+ ...(host === undefined ? {} : { host }),
33
37
  issuer: view.issuer,
34
38
  etag: digest(view.etag, `Resolved View ${index} ETag`),
35
39
  revision: digest(view.revision, `Resolved View ${index} revision`),
@@ -30,6 +30,13 @@ export declare const resolve: import("./model.js").MethodSyscall<Readonly<{
30
30
  sandbox?: string[] | undefined;
31
31
  allow?: string[] | undefined;
32
32
  } | undefined;
33
+ host?: {
34
+ navigation: {
35
+ external: {
36
+ origins: string[];
37
+ };
38
+ };
39
+ } | undefined;
33
40
  issuer: string;
34
41
  etag: string;
35
42
  revision: string;
@@ -43,3 +43,12 @@ export declare const mint: Readonly<{
43
43
  }>;
44
44
  name: "mint";
45
45
  }>;
46
+ export declare const impersonate: Readonly<{
47
+ kind: 'method';
48
+ owner: Readonly<{
49
+ origin: 'kernel.astrale.ai';
50
+ kind: 'class';
51
+ name: 'Identity';
52
+ }>;
53
+ name: "impersonate";
54
+ }>;
@@ -9,3 +9,4 @@ export const can = methodRef('can');
9
9
  export const whoami = methodRef('whoami');
10
10
  export const whois = methodRef('whois');
11
11
  export const mint = methodRef('mint');
12
+ export const impersonate = methodRef('impersonate');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/kernel-core",
3
- "version": "0.9.0-beta.45",
3
+ "version": "0.9.0-beta.47",
4
4
  "description": "Astrale Kernel Core - Types, Invariants, and Pure Logic",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -186,6 +186,6 @@
186
186
  "test": "vitest run",
187
187
  "test:file": "vitest run",
188
188
  "test:watch": "vitest",
189
- "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.types.json && tsc --noEmit -p schema/.module/tsconfig.json"
189
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.types.json && tsc --noEmit -p schema/.module/tsconfig.json && tsc -p tsconfig.workers.json"
190
190
  }
191
191
  }