@brud/kernel 0.0.0-stage → 0.0.2
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/LICENSE +201 -0
- package/README.md +63 -2
- package/dist/index.d.ts +15 -0
- package/dist/index.js +13 -0
- package/dist/serviceModules/events.d.ts +1 -0
- package/dist/serviceModules/events.js +1 -0
- package/dist/serviceModules/exposedApiRegistry.d.ts +1 -0
- package/dist/serviceModules/exposedApiRegistry.js +1 -0
- package/dist/serviceModules/identityRegistry.d.ts +1 -0
- package/dist/serviceModules/identityRegistry.js +1 -0
- package/dist/serviceModules/interception.d.ts +1 -0
- package/dist/serviceModules/interception.js +1 -0
- package/dist/serviceModules/parser.d.ts +1 -0
- package/dist/serviceModules/parser.js +1 -0
- package/dist/serviceModules/router.d.ts +1 -0
- package/dist/serviceModules/router.js +1 -0
- package/dist/serviceModules/wasmCage.d.ts +1 -0
- package/dist/serviceModules/wasmCage.js +1 -0
- package/dist/services/Events/contracts/IEventsService.d.ts +64 -0
- package/dist/services/Events/contracts/IEventsService.js +1 -0
- package/dist/services/Events/contracts/errors.d.ts +31 -0
- package/dist/services/Events/contracts/errors.js +40 -0
- package/dist/services/Events/contracts/index.d.ts +3 -0
- package/dist/services/Events/contracts/index.js +3 -0
- package/dist/services/Events/contracts/tokens.d.ts +2 -0
- package/dist/services/Events/contracts/tokens.js +2 -0
- package/dist/services/Events/descriptor/EventsDescriptor.d.ts +9 -0
- package/dist/services/Events/descriptor/EventsDescriptor.js +56 -0
- package/dist/services/Events/descriptor/tokens.d.ts +1 -0
- package/dist/services/Events/descriptor/tokens.js +1 -0
- package/dist/services/Events/index.d.ts +4 -0
- package/dist/services/Events/index.js +4 -0
- package/dist/services/Events/orchestrator/EventsService.d.ts +51 -0
- package/dist/services/Events/orchestrator/EventsService.js +339 -0
- package/dist/services/Events/orchestrator/index.d.ts +2 -0
- package/dist/services/Events/orchestrator/index.js +2 -0
- package/dist/services/Events/orchestrator/limits.d.ts +22 -0
- package/dist/services/Events/orchestrator/limits.js +33 -0
- package/dist/services/Events/serviceModule.d.ts +2 -0
- package/dist/services/Events/serviceModule.js +5 -0
- package/dist/services/ExposedApiRegistry/contracts/IExposedApiRegistry.d.ts +56 -0
- package/dist/services/ExposedApiRegistry/contracts/IExposedApiRegistry.js +1 -0
- package/dist/services/ExposedApiRegistry/contracts/errors.d.ts +132 -0
- package/dist/services/ExposedApiRegistry/contracts/errors.js +195 -0
- package/dist/services/ExposedApiRegistry/contracts/index.d.ts +9 -0
- package/dist/services/ExposedApiRegistry/contracts/index.js +4 -0
- package/dist/services/ExposedApiRegistry/contracts/policy.d.ts +90 -0
- package/dist/services/ExposedApiRegistry/contracts/policy.js +169 -0
- package/dist/services/ExposedApiRegistry/contracts/registrant.d.ts +37 -0
- package/dist/services/ExposedApiRegistry/contracts/registrant.js +36 -0
- package/dist/services/ExposedApiRegistry/contracts/types.d.ts +133 -0
- package/dist/services/ExposedApiRegistry/contracts/types.js +73 -0
- package/dist/services/ExposedApiRegistry/descriptor/ExposedApiRegistryDescriptor.d.ts +44 -0
- package/dist/services/ExposedApiRegistry/descriptor/ExposedApiRegistryDescriptor.js +58 -0
- package/dist/services/ExposedApiRegistry/descriptor/tokens.d.ts +8 -0
- package/dist/services/ExposedApiRegistry/descriptor/tokens.js +8 -0
- package/dist/services/ExposedApiRegistry/index.d.ts +6 -0
- package/dist/services/ExposedApiRegistry/index.js +5 -0
- package/dist/services/ExposedApiRegistry/orchestrator/ExposedApiRegistryService.d.ts +68 -0
- package/dist/services/ExposedApiRegistry/orchestrator/ExposedApiRegistryService.js +452 -0
- package/dist/services/ExposedApiRegistry/orchestrator/index.d.ts +2 -0
- package/dist/services/ExposedApiRegistry/orchestrator/index.js +1 -0
- package/dist/services/ExposedApiRegistry/serviceModule.d.ts +10 -0
- package/dist/services/ExposedApiRegistry/serviceModule.js +20 -0
- package/dist/services/ExposedApiRegistry/storage/protection.d.ts +21 -0
- package/dist/services/ExposedApiRegistry/storage/protection.js +35 -0
- package/dist/services/ExposedApiRegistry/storage/scopeRecord.d.ts +45 -0
- package/dist/services/ExposedApiRegistry/storage/scopeRecord.js +178 -0
- package/dist/services/IdentityRegistry/contracts/errors.d.ts +88 -0
- package/dist/services/IdentityRegistry/contracts/errors.js +128 -0
- package/dist/services/IdentityRegistry/contracts/index.d.ts +5 -0
- package/dist/services/IdentityRegistry/contracts/index.js +3 -0
- package/dist/services/IdentityRegistry/contracts/types.d.ts +77 -0
- package/dist/services/IdentityRegistry/contracts/types.js +18 -0
- package/dist/services/IdentityRegistry/descriptor/descriptor.d.ts +36 -0
- package/dist/services/IdentityRegistry/descriptor/descriptor.js +44 -0
- package/dist/services/IdentityRegistry/descriptor/tokens.d.ts +8 -0
- package/dist/services/IdentityRegistry/descriptor/tokens.js +8 -0
- package/dist/services/IdentityRegistry/index.d.ts +11 -0
- package/dist/services/IdentityRegistry/index.js +6 -0
- package/dist/services/IdentityRegistry/orchestrator/IdentityRegistryService.d.ts +47 -0
- package/dist/services/IdentityRegistry/orchestrator/IdentityRegistryService.js +240 -0
- package/dist/services/IdentityRegistry/serviceModule.d.ts +10 -0
- package/dist/services/IdentityRegistry/serviceModule.js +24 -0
- package/dist/services/IdentityRegistry/storage/registryDocument.d.ts +55 -0
- package/dist/services/IdentityRegistry/storage/registryDocument.js +235 -0
- package/dist/services/Interception/contracts/IInterceptionService.d.ts +155 -0
- package/dist/services/Interception/contracts/IInterceptionService.js +12 -0
- package/dist/services/Interception/contracts/errors.d.ts +26 -0
- package/dist/services/Interception/contracts/errors.js +35 -0
- package/dist/services/Interception/contracts/index.d.ts +3 -0
- package/dist/services/Interception/contracts/index.js +3 -0
- package/dist/services/Interception/contracts/tokens.d.ts +2 -0
- package/dist/services/Interception/contracts/tokens.js +2 -0
- package/dist/services/Interception/descriptor/InterceptionDescriptor.d.ts +9 -0
- package/dist/services/Interception/descriptor/InterceptionDescriptor.js +50 -0
- package/dist/services/Interception/descriptor/tokens.d.ts +1 -0
- package/dist/services/Interception/descriptor/tokens.js +1 -0
- package/dist/services/Interception/index.d.ts +4 -0
- package/dist/services/Interception/index.js +4 -0
- package/dist/services/Interception/orchestrator/InterceptionService.d.ts +40 -0
- package/dist/services/Interception/orchestrator/InterceptionService.js +343 -0
- package/dist/services/Interception/orchestrator/index.d.ts +1 -0
- package/dist/services/Interception/orchestrator/index.js +1 -0
- package/dist/services/Interception/serviceModule.d.ts +2 -0
- package/dist/services/Interception/serviceModule.js +5 -0
- package/dist/services/Parser/contracts/IParserService.d.ts +21 -0
- package/dist/services/Parser/contracts/IParserService.js +1 -0
- package/dist/services/Parser/contracts/errors.d.ts +25 -0
- package/dist/services/Parser/contracts/errors.js +33 -0
- package/dist/services/Parser/contracts/index.d.ts +4 -0
- package/dist/services/Parser/contracts/index.js +1 -0
- package/dist/services/Parser/contracts/types.d.ts +42 -0
- package/dist/services/Parser/contracts/types.js +1 -0
- package/dist/services/Parser/descriptor/ParserDescriptor.d.ts +23 -0
- package/dist/services/Parser/descriptor/ParserDescriptor.js +50 -0
- package/dist/services/Parser/descriptor/tokens.d.ts +8 -0
- package/dist/services/Parser/descriptor/tokens.js +8 -0
- package/dist/services/Parser/index.d.ts +8 -0
- package/dist/services/Parser/index.js +8 -0
- package/dist/services/Parser/orchestrator/ParserService.d.ts +20 -0
- package/dist/services/Parser/orchestrator/ParserService.js +105 -0
- package/dist/services/Parser/orchestrator/index.d.ts +1 -0
- package/dist/services/Parser/orchestrator/index.js +1 -0
- package/dist/services/Parser/parser/indexSynthesis.d.ts +11 -0
- package/dist/services/Parser/parser/indexSynthesis.js +13 -0
- package/dist/services/Parser/parser/parameters.d.ts +14 -0
- package/dist/services/Parser/parser/parameters.js +89 -0
- package/dist/services/Parser/parser/scanner.d.ts +48 -0
- package/dist/services/Parser/parser/scanner.js +156 -0
- package/dist/services/Parser/parser/syntax.d.ts +30 -0
- package/dist/services/Parser/parser/syntax.js +34 -0
- package/dist/services/Parser/serviceModule.d.ts +2 -0
- package/dist/services/Parser/serviceModule.js +5 -0
- package/dist/services/Router/bootOptions.d.ts +2 -0
- package/dist/services/Router/bootOptions.js +2 -0
- package/dist/services/Router/contracts/IRouterService.d.ts +43 -0
- package/dist/services/Router/contracts/IRouterService.js +1 -0
- package/dist/services/Router/contracts/caller.d.ts +6 -0
- package/dist/services/Router/contracts/caller.js +6 -0
- package/dist/services/Router/contracts/errors.d.ts +67 -0
- package/dist/services/Router/contracts/errors.js +90 -0
- package/dist/services/Router/contracts/index.d.ts +8 -0
- package/dist/services/Router/contracts/index.js +4 -0
- package/dist/services/Router/contracts/kind.d.ts +7 -0
- package/dist/services/Router/contracts/kind.js +10 -0
- package/dist/services/Router/contracts/registrant.d.ts +23 -0
- package/dist/services/Router/contracts/registrant.js +13 -0
- package/dist/services/Router/contracts/types.d.ts +110 -0
- package/dist/services/Router/contracts/types.js +1 -0
- package/dist/services/Router/descriptor/RouterDescriptor.d.ts +32 -0
- package/dist/services/Router/descriptor/RouterDescriptor.js +92 -0
- package/dist/services/Router/descriptor/tokens.d.ts +9 -0
- package/dist/services/Router/descriptor/tokens.js +9 -0
- package/dist/services/Router/index.d.ts +4 -0
- package/dist/services/Router/index.js +4 -0
- package/dist/services/Router/orchestrator/RouterService.d.ts +93 -0
- package/dist/services/Router/orchestrator/RouterService.js +457 -0
- package/dist/services/Router/orchestrator/index.d.ts +2 -0
- package/dist/services/Router/orchestrator/index.js +1 -0
- package/dist/services/Router/serviceModule.d.ts +4 -0
- package/dist/services/Router/serviceModule.js +22 -0
- package/dist/services/WasmCage/index.d.ts +7 -0
- package/dist/services/WasmCage/index.js +4 -0
- package/dist/services/WasmCage/scripts/prepin.d.ts +1 -0
- package/dist/services/WasmCage/scripts/prepin.js +38 -0
- package/dist/services/WasmCage/serviceModule.d.ts +12 -0
- package/dist/services/WasmCage/serviceModule.js +18 -0
- package/dist/services/WasmCage/src/caged.d.ts +121 -0
- package/dist/services/WasmCage/src/caged.js +460 -0
- package/dist/services/WasmCage/src/descriptor.d.ts +47 -0
- package/dist/services/WasmCage/src/descriptor.js +56 -0
- package/dist/services/WasmCage/src/native.d.ts +29 -0
- package/dist/services/WasmCage/src/native.js +66 -0
- package/dist/services/WasmCage/src/nativeDigests.d.ts +9 -0
- package/dist/services/WasmCage/src/nativeDigests.js +15 -0
- package/dist/services/WasmCage/src/package.d.ts +36 -0
- package/dist/services/WasmCage/src/package.js +122 -0
- package/dist/services/shared/canonicalJson.d.ts +29 -0
- package/dist/services/shared/canonicalJson.js +93 -0
- package/dist/services/shared/documentStore.d.ts +16 -0
- package/dist/services/shared/documentStore.js +98 -0
- package/dist/src/bootstrap/bootKernelInternal.d.ts +19 -0
- package/dist/src/bootstrap/bootKernelInternal.js +633 -0
- package/dist/src/bootstrap/bootTypes.d.ts +113 -0
- package/dist/src/bootstrap/bootTypes.js +1 -0
- package/dist/src/bootstrap/config/index.d.ts +3 -0
- package/dist/src/bootstrap/config/index.js +2 -0
- package/dist/src/bootstrap/config/integrity.d.ts +45 -0
- package/dist/src/bootstrap/config/integrity.js +92 -0
- package/dist/src/bootstrap/config/parse.d.ts +15 -0
- package/dist/src/bootstrap/config/parse.js +81 -0
- package/dist/src/bootstrap/config/pathWriteGuard.d.ts +20 -0
- package/dist/src/bootstrap/config/pathWriteGuard.js +349 -0
- package/dist/src/bootstrap/config/types.d.ts +41 -0
- package/dist/src/bootstrap/config/types.js +15 -0
- package/dist/src/bootstrap/hardcore.d.ts +212 -0
- package/dist/src/bootstrap/hardcore.js +312 -0
- package/dist/src/bootstrap/hardcoreServices.d.ts +10 -0
- package/dist/src/bootstrap/hardcoreServices.js +258 -0
- package/dist/src/bootstrap/index.d.ts +13 -0
- package/dist/src/bootstrap/index.js +7 -0
- package/dist/src/bootstrap/loaded.d.ts +30 -0
- package/dist/src/bootstrap/loaded.js +45 -0
- package/dist/src/bootstrap/packageRequirements.d.ts +26 -0
- package/dist/src/bootstrap/packageRequirements.js +52 -0
- package/dist/src/bootstrap/reload.d.ts +44 -0
- package/dist/src/bootstrap/reload.js +45 -0
- package/dist/src/bootstrap/seal.d.ts +32 -0
- package/dist/src/bootstrap/seal.js +101 -0
- package/dist/src/contracts/accessBroker.d.ts +53 -0
- package/dist/src/contracts/accessBroker.js +1 -0
- package/dist/src/contracts/brudOperation.d.ts +20 -0
- package/dist/src/contracts/brudOperation.js +20 -0
- package/dist/src/contracts/callChain.d.ts +161 -0
- package/dist/src/contracts/callChain.js +19 -0
- package/dist/src/contracts/capability.d.ts +26 -0
- package/dist/src/contracts/capability.js +26 -0
- package/dist/src/contracts/capabilitySet.d.ts +23 -0
- package/dist/src/contracts/capabilitySet.js +72 -0
- package/dist/src/contracts/container.d.ts +17 -0
- package/dist/src/contracts/container.js +8 -0
- package/dist/src/contracts/context.d.ts +19 -0
- package/dist/src/contracts/context.js +1 -0
- package/dist/src/contracts/contextContract.d.ts +132 -0
- package/dist/src/contracts/contextContract.js +274 -0
- package/dist/src/contracts/dispatchView.d.ts +21 -0
- package/dist/src/contracts/dispatchView.js +1 -0
- package/dist/src/contracts/handler.d.ts +21 -0
- package/dist/src/contracts/handler.js +1 -0
- package/dist/src/contracts/index.d.ts +26 -0
- package/dist/src/contracts/index.js +9 -0
- package/dist/src/contracts/kernel.d.ts +60 -0
- package/dist/src/contracts/kernel.js +1 -0
- package/dist/src/contracts/lifecycle.d.ts +59 -0
- package/dist/src/contracts/lifecycle.js +1 -0
- package/dist/src/contracts/manifest.d.ts +180 -0
- package/dist/src/contracts/manifest.js +334 -0
- package/dist/src/contracts/pipeline.d.ts +8 -0
- package/dist/src/contracts/pipeline.js +1 -0
- package/dist/src/contracts/policy.d.ts +75 -0
- package/dist/src/contracts/policy.js +77 -0
- package/dist/src/contracts/registry.d.ts +7 -0
- package/dist/src/contracts/registry.js +1 -0
- package/dist/src/contracts/serviceDescriptor.d.ts +67 -0
- package/dist/src/contracts/serviceDescriptor.js +1 -0
- package/dist/src/contracts/serviceToken.d.ts +36 -0
- package/dist/src/contracts/serviceToken.js +16 -0
- package/dist/src/engine/BrudKernel.d.ts +120 -0
- package/dist/src/engine/BrudKernel.js +395 -0
- package/dist/src/engine/ExecutionPipeline.d.ts +13 -0
- package/dist/src/engine/ExecutionPipeline.js +62 -0
- package/dist/src/engine/KernelAccessBroker.d.ts +47 -0
- package/dist/src/engine/KernelAccessBroker.js +107 -0
- package/dist/src/engine/KernelRegistry.d.ts +14 -0
- package/dist/src/engine/KernelRegistry.js +33 -0
- package/dist/src/engine/OperationRegistry.d.ts +9 -0
- package/dist/src/engine/OperationRegistry.js +18 -0
- package/dist/src/engine/ServiceContainer.d.ts +13 -0
- package/dist/src/engine/ServiceContainer.js +53 -0
- package/dist/src/engine/callChain.d.ts +68 -0
- package/dist/src/engine/callChain.js +175 -0
- package/dist/src/engine/dag.d.ts +2 -0
- package/dist/src/engine/dag.js +34 -0
- package/dist/src/engine/errors.d.ts +26 -0
- package/dist/src/engine/errors.js +52 -0
- package/dist/src/engine/index.d.ts +11 -0
- package/dist/src/engine/index.js +8 -0
- package/dist/src/engine/state.d.ts +1 -0
- package/dist/src/engine/state.js +1 -0
- package/dist/src/validation/jsonSchema/compile.d.ts +8 -0
- package/dist/src/validation/jsonSchema/compile.js +386 -0
- package/dist/src/validation/jsonSchema/index.d.ts +3 -0
- package/dist/src/validation/jsonSchema/index.js +2 -0
- package/dist/src/validation/jsonSchema/jsonValue.d.ts +29 -0
- package/dist/src/validation/jsonSchema/jsonValue.js +190 -0
- package/dist/src/validation/jsonSchema/pattern.d.ts +28 -0
- package/dist/src/validation/jsonSchema/pattern.js +155 -0
- package/dist/src/validation/jsonSchema/types.d.ts +71 -0
- package/dist/src/validation/jsonSchema/types.js +15 -0
- package/package.json +59 -4
- package/services/WasmCage/native/brud-wasm-cage.darwin-arm64.node +0 -0
- package/services/WasmCage/native/brud-wasm-cage.darwin-x64.node +0 -0
- package/services/WasmCage/native/brud-wasm-cage.linux-arm64-gnu.node +0 -0
- package/services/WasmCage/native/brud-wasm-cage.linux-x64-gnu.node +0 -0
- package/services/WasmCage/native/brud-wasm-cage.win32-x64-msvc.node +0 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import type { ExposedApiCaller } from '../../ExposedApiRegistry/contracts/types.js';
|
|
2
|
+
/** The plain caller view an interceptor sees. */
|
|
3
|
+
export interface InterceptedCaller {
|
|
4
|
+
readonly identity: string | null;
|
|
5
|
+
readonly callerClass: string;
|
|
6
|
+
readonly official: boolean;
|
|
7
|
+
readonly capabilities: ReadonlySet<string>;
|
|
8
|
+
readonly origin: string;
|
|
9
|
+
}
|
|
10
|
+
/** The plain, frozen record of one intercepted call. */
|
|
11
|
+
export interface InterceptedCall {
|
|
12
|
+
/** The interception point, `name@major`. */
|
|
13
|
+
readonly target: string;
|
|
14
|
+
/** The method of the target exposure being called. */
|
|
15
|
+
readonly method: string;
|
|
16
|
+
/** The call's arguments (plain JSON values). */
|
|
17
|
+
readonly args: readonly unknown[];
|
|
18
|
+
/** The original caller of the giver's exposure. */
|
|
19
|
+
readonly caller: InterceptedCaller;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* An interceptor's verdict. `modify` replaces the call's arguments (same method,
|
|
23
|
+
* same target); it cannot re-route the call.
|
|
24
|
+
*/
|
|
25
|
+
export type InterceptionVerdict = {
|
|
26
|
+
readonly verdict: 'allow';
|
|
27
|
+
} | {
|
|
28
|
+
readonly verdict: 'block';
|
|
29
|
+
readonly reason: string;
|
|
30
|
+
} | {
|
|
31
|
+
readonly verdict: 'modify';
|
|
32
|
+
readonly args: readonly unknown[];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* What a giver implements on its instance to be called by the interception
|
|
36
|
+
* hardcore. A non-enumerable method, like `provideExposure`: it is reached only
|
|
37
|
+
* through the hardcore (`instanceOf` + `runAs`), never through `resolve`.
|
|
38
|
+
*/
|
|
39
|
+
export interface IInterceptor {
|
|
40
|
+
intercept(call: InterceptedCall): InterceptionVerdict;
|
|
41
|
+
}
|
|
42
|
+
/** A stage of interception. */
|
|
43
|
+
export type InterceptionStage = 'input' | 'output';
|
|
44
|
+
/**
|
|
45
|
+
* Largest values the output stage allows, in bytes of canonical JSON. A point
|
|
46
|
+
* may lower any of them with `outputLimits` and can never raise one.
|
|
47
|
+
*/
|
|
48
|
+
export declare const INTERCEPTION_OUTPUT_CEILINGS: Readonly<{
|
|
49
|
+
/** A giver's result, as shown to interceptors. */
|
|
50
|
+
maxResultBytes: 1048576;
|
|
51
|
+
/** The content of one interceptor's addition. */
|
|
52
|
+
maxAdditionBytes: 65536;
|
|
53
|
+
/** All additions to one result together. */
|
|
54
|
+
maxTotalBytes: 262144;
|
|
55
|
+
}>;
|
|
56
|
+
/** The intercepted call and the giver's result: plain, deep-frozen JSON. */
|
|
57
|
+
export interface InterceptedResult extends InterceptedCall {
|
|
58
|
+
/** What the giver returned. */
|
|
59
|
+
readonly result: unknown;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* An output-stage verdict. An interceptor can only add: there is no way to
|
|
63
|
+
* change, replace or remove the result, or to withhold it.
|
|
64
|
+
*/
|
|
65
|
+
export type InterceptionOutputVerdict = {
|
|
66
|
+
readonly verdict: 'none';
|
|
67
|
+
} | {
|
|
68
|
+
readonly verdict: 'append';
|
|
69
|
+
readonly content: unknown;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* What an interceptor implements on its instance to take part in the output
|
|
73
|
+
* stage (non-enumerable, like `intercept`): reached only through the hardcore.
|
|
74
|
+
*/
|
|
75
|
+
export interface IResultInterceptor {
|
|
76
|
+
interceptResult(call: InterceptedResult): InterceptionOutputVerdict;
|
|
77
|
+
}
|
|
78
|
+
/** One piece of content an interceptor appended, attributed to it. */
|
|
79
|
+
export interface InterceptionAddition {
|
|
80
|
+
/** Service token of the interceptor that appended it. */
|
|
81
|
+
readonly interceptor: string;
|
|
82
|
+
/** The appended plain JSON content. */
|
|
83
|
+
readonly content: unknown;
|
|
84
|
+
}
|
|
85
|
+
/** An output-stage interceptor the kernel skipped, and why. */
|
|
86
|
+
export interface InterceptionSkipped {
|
|
87
|
+
/** Service token of the interceptor that was skipped. */
|
|
88
|
+
readonly interceptor: string;
|
|
89
|
+
/** What it did wrong: it threw, returned anything but an append, or exceeded a limit. */
|
|
90
|
+
readonly reason: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* What a caller of an intercepted exposure receives: the giver's result
|
|
94
|
+
* exactly as returned, the additions in the order the interceptors ran, the
|
|
95
|
+
* interceptors whose contribution was taken, and the interceptors that were
|
|
96
|
+
* skipped because they misbehaved.
|
|
97
|
+
*/
|
|
98
|
+
export interface InterceptionEnvelope {
|
|
99
|
+
readonly result: unknown;
|
|
100
|
+
readonly additions: readonly InterceptionAddition[];
|
|
101
|
+
readonly interceptedBy: readonly string[];
|
|
102
|
+
readonly skipped: readonly InterceptionSkipped[];
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The outcome of the output stage. `applied: false` means the giver returns
|
|
106
|
+
* its result as it always did: no admitted interceptor takes part in the
|
|
107
|
+
* stage, or the result is one the stage cannot carry. An interceptor that
|
|
108
|
+
* misbehaves never withholds the result: it is skipped and listed in
|
|
109
|
+
* `envelope.skipped`. `allowed: false` is returned only when the giver itself
|
|
110
|
+
* called the stage wrongly (it is not the point's owner, the point is
|
|
111
|
+
* unknown, or the arguments are not plain data).
|
|
112
|
+
*/
|
|
113
|
+
export type InterceptionResultOutcome = {
|
|
114
|
+
readonly applied: false;
|
|
115
|
+
} | {
|
|
116
|
+
readonly applied: true;
|
|
117
|
+
readonly allowed: true;
|
|
118
|
+
readonly envelope: InterceptionEnvelope;
|
|
119
|
+
} | {
|
|
120
|
+
readonly applied: true;
|
|
121
|
+
readonly allowed: false;
|
|
122
|
+
readonly reason: string;
|
|
123
|
+
};
|
|
124
|
+
/** Options the giver passes to `evaluate`. */
|
|
125
|
+
export interface InterceptionEvaluateOptions {
|
|
126
|
+
/** The caller view the giver's projection received (delegation by the owner). */
|
|
127
|
+
readonly caller?: ExposedApiCaller;
|
|
128
|
+
}
|
|
129
|
+
/** The combined outcome the giver enforces. */
|
|
130
|
+
export type InterceptionOutcome = {
|
|
131
|
+
readonly allowed: true;
|
|
132
|
+
readonly args: readonly unknown[];
|
|
133
|
+
readonly modifiedBy: readonly string[];
|
|
134
|
+
} | {
|
|
135
|
+
readonly allowed: false;
|
|
136
|
+
readonly reason: string;
|
|
137
|
+
readonly interceptor?: string;
|
|
138
|
+
};
|
|
139
|
+
export interface IInterceptionService {
|
|
140
|
+
/**
|
|
141
|
+
* Runs the admitted interceptors of the giver's interception point, in the
|
|
142
|
+
* giver's order. Only the point's owner may evaluate it.
|
|
143
|
+
*/
|
|
144
|
+
evaluate(target: string, method: string, args: readonly unknown[], options?: InterceptionEvaluateOptions): InterceptionOutcome;
|
|
145
|
+
/**
|
|
146
|
+
* Runs the output stage of the giver's interception point on the result the
|
|
147
|
+
* giver produced: each interceptor that declared the output stage may append
|
|
148
|
+
* content, in the giver's order. The result is never changed. Only the
|
|
149
|
+
* point's owner may evaluate it, and `args` are the final arguments of the
|
|
150
|
+
* call (after any input modification). The result must be plain JSON.
|
|
151
|
+
*/
|
|
152
|
+
evaluateResult(target: string, method: string, args: readonly unknown[], result: unknown, options?: InterceptionEvaluateOptions): InterceptionResultOutcome;
|
|
153
|
+
/** The interception points in this composition, as `name@major`. */
|
|
154
|
+
list(): readonly string[];
|
|
155
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Largest values the output stage allows, in bytes of canonical JSON. A point
|
|
3
|
+
* may lower any of them with `outputLimits` and can never raise one.
|
|
4
|
+
*/
|
|
5
|
+
export const INTERCEPTION_OUTPUT_CEILINGS = Object.freeze({
|
|
6
|
+
/** A giver's result, as shown to interceptors. */
|
|
7
|
+
maxResultBytes: 1_048_576,
|
|
8
|
+
/** The content of one interceptor's addition. */
|
|
9
|
+
maxAdditionBytes: 65_536,
|
|
10
|
+
/** All additions to one result together. */
|
|
11
|
+
maxTotalBytes: 262_144,
|
|
12
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Stable, machine-readable codes for interception failures. */
|
|
2
|
+
export type InterceptionErrorCode = 'INTERCEPTION_DECLARATION_INVALID' | 'INTERCEPTION_BLOCKED';
|
|
3
|
+
/** Base class for every interception domain failure. */
|
|
4
|
+
export declare abstract class InterceptionError extends Error {
|
|
5
|
+
/** Stable, machine-readable error code. */
|
|
6
|
+
abstract readonly code: InterceptionErrorCode;
|
|
7
|
+
protected constructor(message: string, options?: ErrorOptions);
|
|
8
|
+
}
|
|
9
|
+
/** Raised at boot when an interception or an interception point is not admissible. */
|
|
10
|
+
export declare class InterceptionDeclarationError extends InterceptionError {
|
|
11
|
+
readonly code: "INTERCEPTION_DECLARATION_INVALID";
|
|
12
|
+
/** Service token of the declaring participant. */
|
|
13
|
+
readonly participant: string;
|
|
14
|
+
constructor(participant: string, reason: string);
|
|
15
|
+
}
|
|
16
|
+
/** Thrown by a giver when the interception outcome blocks the call. */
|
|
17
|
+
export declare class InterceptionBlockedError extends InterceptionError {
|
|
18
|
+
readonly code: "INTERCEPTION_BLOCKED";
|
|
19
|
+
/** The interception point, `name@major`. */
|
|
20
|
+
readonly target: string;
|
|
21
|
+
/** The blocking reason. */
|
|
22
|
+
readonly reason: string;
|
|
23
|
+
/** Service token of the blocking interceptor, when one blocked. */
|
|
24
|
+
readonly interceptor: string | undefined;
|
|
25
|
+
constructor(target: string, reason: string, interceptor?: string);
|
|
26
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Base class for every interception domain failure. */
|
|
2
|
+
export class InterceptionError extends Error {
|
|
3
|
+
constructor(message, options) {
|
|
4
|
+
super(message, options);
|
|
5
|
+
this.name = 'InterceptionError';
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/** Raised at boot when an interception or an interception point is not admissible. */
|
|
9
|
+
export class InterceptionDeclarationError extends InterceptionError {
|
|
10
|
+
code = 'INTERCEPTION_DECLARATION_INVALID';
|
|
11
|
+
/** Service token of the declaring participant. */
|
|
12
|
+
participant;
|
|
13
|
+
constructor(participant, reason) {
|
|
14
|
+
super(`Participant "${participant}": ${reason}`);
|
|
15
|
+
this.name = 'InterceptionDeclarationError';
|
|
16
|
+
this.participant = participant;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Thrown by a giver when the interception outcome blocks the call. */
|
|
20
|
+
export class InterceptionBlockedError extends InterceptionError {
|
|
21
|
+
code = 'INTERCEPTION_BLOCKED';
|
|
22
|
+
/** The interception point, `name@major`. */
|
|
23
|
+
target;
|
|
24
|
+
/** The blocking reason. */
|
|
25
|
+
reason;
|
|
26
|
+
/** Service token of the blocking interceptor, when one blocked. */
|
|
27
|
+
interceptor;
|
|
28
|
+
constructor(target, reason, interceptor) {
|
|
29
|
+
super(`Call to "${target}" was blocked by interception: ${reason}`);
|
|
30
|
+
this.name = 'InterceptionBlockedError';
|
|
31
|
+
this.target = target;
|
|
32
|
+
this.reason = reason;
|
|
33
|
+
this.interceptor = interceptor;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ServiceTier } from '../../../src/contracts/lifecycle.js';
|
|
2
|
+
import type { ServiceDescriptor } from '../../../src/contracts/serviceDescriptor.js';
|
|
3
|
+
import type { IInterceptionService } from '../contracts/IInterceptionService.js';
|
|
4
|
+
import { InterceptionService } from '../orchestrator/index.js';
|
|
5
|
+
export declare const INTERCEPTION_SERVICE_TIER: ServiceTier;
|
|
6
|
+
export declare const INTERCEPTION_CONTRACT_VERSION = "1.0.0";
|
|
7
|
+
export declare const INTERCEPTION_CONTRACT_METHODS: readonly ["evaluate", "evaluateResult", "list"];
|
|
8
|
+
export declare function createInterceptionDescriptor(): ServiceDescriptor<IInterceptionService, InterceptionService>;
|
|
9
|
+
export declare const InterceptionDescriptor: ServiceDescriptor<IInterceptionService, InterceptionService>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { withExposureBindings } from '../../ExposedApiRegistry/contracts/registrant.js';
|
|
2
|
+
import { InterceptionService } from '../orchestrator/index.js';
|
|
3
|
+
import { InterceptionToken } from './tokens.js';
|
|
4
|
+
export const INTERCEPTION_SERVICE_TIER = 'core';
|
|
5
|
+
export const INTERCEPTION_CONTRACT_VERSION = '1.0.0';
|
|
6
|
+
export const INTERCEPTION_CONTRACT_METHODS = ['evaluate', 'evaluateResult', 'list'];
|
|
7
|
+
/**
|
|
8
|
+
* Per-exposure projection bindings. Each projection captures the resolver's
|
|
9
|
+
* caller view at resolve time (the registry runs projection calls as the
|
|
10
|
+
* owner), so `evaluate` knows which giver is asking.
|
|
11
|
+
*/
|
|
12
|
+
function interceptionExposureBindings(instance) {
|
|
13
|
+
return {
|
|
14
|
+
'interception.evaluate@1': {
|
|
15
|
+
projection: (_service, caller) => ({
|
|
16
|
+
evaluate: (target, method, args, options) => instance.evaluateAs(caller, target, method, args, options),
|
|
17
|
+
evaluateResult: (target, method, args, result, options) => instance.evaluateResultAs(caller, target, method, args, result, options),
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
'interception.list@1': { projection: () => ({ list: () => instance.list() }) },
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function createInterceptionDescriptor() {
|
|
24
|
+
return {
|
|
25
|
+
token: InterceptionToken,
|
|
26
|
+
tier: INTERCEPTION_SERVICE_TIER,
|
|
27
|
+
dependencies: [],
|
|
28
|
+
contract: {
|
|
29
|
+
version: INTERCEPTION_CONTRACT_VERSION,
|
|
30
|
+
methods: INTERCEPTION_CONTRACT_METHODS,
|
|
31
|
+
},
|
|
32
|
+
accessPolicy: {
|
|
33
|
+
allowedCallers: ['kernel'],
|
|
34
|
+
},
|
|
35
|
+
manifest: {
|
|
36
|
+
exposures: [
|
|
37
|
+
// `any`: a giver's exposure may be called from any origin, and its
|
|
38
|
+
// binding evaluates in that caller's chain. `evaluate` itself admits
|
|
39
|
+
// only the point's owner.
|
|
40
|
+
{ name: 'interception.evaluate', version: 1, scope: 'any' },
|
|
41
|
+
{ name: 'interception.list', version: 1, scope: 'runtime' },
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
factory: () => {
|
|
45
|
+
const instance = new InterceptionService();
|
|
46
|
+
return withExposureBindings(instance, interceptionExposureBindings(instance));
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export const InterceptionDescriptor = createInterceptionDescriptor();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InterceptionToken } from '../contracts/tokens.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InterceptionToken } from '../contracts/tokens.js';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { AdmittedManifest, KernelCallAuthority } from '../../../src/contracts/index.js';
|
|
2
|
+
import type { ExposedApiCaller } from '../../ExposedApiRegistry/contracts/types.js';
|
|
3
|
+
import { type IInterceptionService, type InterceptionEvaluateOptions, type InterceptionOutcome, type InterceptionResultOutcome } from '../contracts/IInterceptionService.js';
|
|
4
|
+
/** One participant of the composition, as the boot hook hands it over. */
|
|
5
|
+
export interface InterceptionParticipant {
|
|
6
|
+
readonly token: string;
|
|
7
|
+
readonly identity: string | undefined;
|
|
8
|
+
readonly manifest: AdmittedManifest;
|
|
9
|
+
}
|
|
10
|
+
export declare class InterceptionService implements IInterceptionService {
|
|
11
|
+
#private;
|
|
12
|
+
private authority;
|
|
13
|
+
bindAuthority(value: KernelCallAuthority): void;
|
|
14
|
+
/**
|
|
15
|
+
* Builds the interception-point table from the composition's manifests.
|
|
16
|
+
*
|
|
17
|
+
* A point must sit on an exposure its giver declares; every admitted token
|
|
18
|
+
* must be a participant that declares an interception of that point; every
|
|
19
|
+
* declared interception must be admitted by a point. Anything else refuses
|
|
20
|
+
* the boot.
|
|
21
|
+
*/
|
|
22
|
+
registerComposition(participants: readonly InterceptionParticipant[]): void;
|
|
23
|
+
evaluate(target: string, method: string, args: readonly unknown[], options?: InterceptionEvaluateOptions): InterceptionOutcome;
|
|
24
|
+
list(): readonly string[];
|
|
25
|
+
/**
|
|
26
|
+
* Evaluates the point for `resolver`, which must be the point's owner. The
|
|
27
|
+
* interceptors run in the giver's admitted order, each as itself: the first
|
|
28
|
+
* `block` wins; `modify` chains; a throw or an invalid verdict blocks
|
|
29
|
+
* (fail closed).
|
|
30
|
+
*/
|
|
31
|
+
evaluateAs(resolver: ExposedApiCaller | undefined, target: string, method: string, args: readonly unknown[], options?: InterceptionEvaluateOptions): InterceptionOutcome;
|
|
32
|
+
evaluateResult(target: string, method: string, args: readonly unknown[], result: unknown, options?: InterceptionEvaluateOptions): InterceptionResultOutcome;
|
|
33
|
+
/**
|
|
34
|
+
* Runs the output stage for `resolver`, which must be the point's owner. The
|
|
35
|
+
* interceptors that declared the stage run in the giver's admitted order,
|
|
36
|
+
* each as itself and each seeing only the original result; each may append
|
|
37
|
+
* one piece of content and nothing else. Any failure withholds the result.
|
|
38
|
+
*/
|
|
39
|
+
evaluateResultAs(resolver: ExposedApiCaller | undefined, target: string, method: string, args: readonly unknown[], result: unknown, options?: InterceptionEvaluateOptions): InterceptionResultOutcome;
|
|
40
|
+
}
|