@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,73 @@
|
|
|
1
|
+
import { CALL_ORIGINS, } from '../../../src/contracts/callChain.js';
|
|
2
|
+
/** API names accept dotted, kebab, and snake segments. */
|
|
3
|
+
export const EXPOSED_API_NAME_PATTERN = /^[A-Za-z][A-Za-z0-9_.-]*$/;
|
|
4
|
+
/** The four reachability scopes, ordered from narrowest to widest. */
|
|
5
|
+
export const EXPOSED_API_SCOPES = ['kernel', 'runtime', 'host', 'any'];
|
|
6
|
+
/** The three root origins a call chain can carry. Assigned by the kernel. */
|
|
7
|
+
export const EXPOSED_API_ORIGINS = CALL_ORIGINS;
|
|
8
|
+
/**
|
|
9
|
+
* Reports whether a value is a supported scope.
|
|
10
|
+
*
|
|
11
|
+
* @param value - Candidate value.
|
|
12
|
+
*/
|
|
13
|
+
export function isExposedApiScope(value) {
|
|
14
|
+
return typeof value === 'string'
|
|
15
|
+
&& EXPOSED_API_SCOPES.includes(value);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Reports whether a value is a supported root origin.
|
|
19
|
+
*
|
|
20
|
+
* @param value - Candidate value.
|
|
21
|
+
*/
|
|
22
|
+
export function isExposedApiOrigin(value) {
|
|
23
|
+
return typeof value === 'string'
|
|
24
|
+
&& EXPOSED_API_ORIGINS.includes(value);
|
|
25
|
+
}
|
|
26
|
+
const SEMANTIC_VERSION_PATTERN = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u;
|
|
27
|
+
/**
|
|
28
|
+
* Reports whether a value is a valid API version.
|
|
29
|
+
*
|
|
30
|
+
* @param value - Candidate value.
|
|
31
|
+
*/
|
|
32
|
+
export function isExposedApiVersion(value) {
|
|
33
|
+
if (typeof value === 'number') {
|
|
34
|
+
return Number.isSafeInteger(value) && value >= 1;
|
|
35
|
+
}
|
|
36
|
+
return typeof value === 'string' && SEMANTIC_VERSION_PATTERN.test(value);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns the order rank of a scope. Higher is wider.
|
|
40
|
+
*
|
|
41
|
+
* @param scope - Supported scope.
|
|
42
|
+
*/
|
|
43
|
+
export function exposedApiScopeRank(scope) {
|
|
44
|
+
return EXPOSED_API_SCOPES.indexOf(scope);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Applies the four-case origin-and-scope rule.
|
|
48
|
+
*
|
|
49
|
+
* @param scope - Scope declared by the API identity.
|
|
50
|
+
* @param origin - Root origin of the call chain.
|
|
51
|
+
*/
|
|
52
|
+
export function exposedApiScopeAllowsOrigin(scope, origin) {
|
|
53
|
+
switch (scope) {
|
|
54
|
+
case 'kernel':
|
|
55
|
+
return origin === 'kernel';
|
|
56
|
+
case 'runtime':
|
|
57
|
+
return origin === 'kernel' || origin === 'runtime';
|
|
58
|
+
case 'host':
|
|
59
|
+
return origin === 'host';
|
|
60
|
+
case 'any':
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Returns the major version of a valid API version.
|
|
66
|
+
*
|
|
67
|
+
* @param version - A valid API version.
|
|
68
|
+
*/
|
|
69
|
+
export function exposedApiMajor(version) {
|
|
70
|
+
return typeof version === 'number'
|
|
71
|
+
? version
|
|
72
|
+
: Number.parseInt(version.split('.')[0] ?? '', 10);
|
|
73
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ServiceTier } from '../../../src/contracts/lifecycle.js';
|
|
2
|
+
import type { ServiceDescriptor } from '../../../src/contracts/serviceDescriptor.js';
|
|
3
|
+
import type { IExposedApiRegistry } from '../contracts/IExposedApiRegistry.js';
|
|
4
|
+
import { ExposedApiRegistryService } from '../orchestrator/index.js';
|
|
5
|
+
/** Tier assigned to the Registry descriptor. */
|
|
6
|
+
export declare const EXPOSED_API_REGISTRY_SERVICE_TIER: ServiceTier;
|
|
7
|
+
/** Namespace owned by the registry in the context contract. */
|
|
8
|
+
export declare const EXPOSED_API_REGISTRY_CONTEXT_SCOPE = "exposedApi";
|
|
9
|
+
/** Contract version declared for the Registry interface. */
|
|
10
|
+
export declare const EXPOSED_API_REGISTRY_CONTRACT_VERSION = "1.0.0";
|
|
11
|
+
/**
|
|
12
|
+
* Methods declared for the Registry interface.
|
|
13
|
+
*
|
|
14
|
+
* `resolve` and `lastRefusal` are open to every participant. `register` is kernel-only: the
|
|
15
|
+
* kernel calls it during admission, and it is never part of the view a
|
|
16
|
+
* participant receives.
|
|
17
|
+
*/
|
|
18
|
+
export declare const EXPOSED_API_REGISTRY_CONTRACT_METHODS: readonly ["lastRefusal", "register", "resolve"];
|
|
19
|
+
/**
|
|
20
|
+
* Optional context field holding the absolute protected scope-record path.
|
|
21
|
+
*
|
|
22
|
+
* This is the registry's own field, declared in its own namespace. Hosts that
|
|
23
|
+
* need cross-boot scope persistence supply it. When it is absent the registry
|
|
24
|
+
* keeps the scope record in memory for one boot.
|
|
25
|
+
*/
|
|
26
|
+
export declare const EXPOSED_API_SCOPE_RECORD_PATH_FIELD = "exposedApi.scopeRecord.path";
|
|
27
|
+
/** Configuration for {@link createExposedApiRegistryDescriptor}. */
|
|
28
|
+
export interface ExposedApiRegistryDescriptorOptions {
|
|
29
|
+
/** Absolute scope-record path used instead of the context field. */
|
|
30
|
+
readonly scopeRecordPath?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Builds the resolution primitive's descriptor.
|
|
34
|
+
*
|
|
35
|
+
* The descriptor carries no caller list and no access policy of its own:
|
|
36
|
+
* `resolve` is open to every participant, and the projection hands every
|
|
37
|
+
* caller only `resolve`. Registration is reachable only by the kernel, which
|
|
38
|
+
* holds the instance during admission.
|
|
39
|
+
*
|
|
40
|
+
* @param options - Storage override.
|
|
41
|
+
*/
|
|
42
|
+
export declare function createExposedApiRegistryDescriptor(options?: ExposedApiRegistryDescriptorOptions): ServiceDescriptor<IExposedApiRegistry, ExposedApiRegistryService>;
|
|
43
|
+
/** Standard Registry descriptor with no overrides. */
|
|
44
|
+
export declare const ExposedApiRegistryDescriptor: ServiceDescriptor<IExposedApiRegistry, ExposedApiRegistryService>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ExposedApiRegistryService } from '../orchestrator/index.js';
|
|
2
|
+
import { ExposedApiRegistryToken } from './tokens.js';
|
|
3
|
+
/** Tier assigned to the Registry descriptor. */
|
|
4
|
+
export const EXPOSED_API_REGISTRY_SERVICE_TIER = 'core';
|
|
5
|
+
/** Namespace owned by the registry in the context contract. */
|
|
6
|
+
export const EXPOSED_API_REGISTRY_CONTEXT_SCOPE = 'exposedApi';
|
|
7
|
+
/** Contract version declared for the Registry interface. */
|
|
8
|
+
export const EXPOSED_API_REGISTRY_CONTRACT_VERSION = '1.0.0';
|
|
9
|
+
/**
|
|
10
|
+
* Methods declared for the Registry interface.
|
|
11
|
+
*
|
|
12
|
+
* `resolve` and `lastRefusal` are open to every participant. `register` is kernel-only: the
|
|
13
|
+
* kernel calls it during admission, and it is never part of the view a
|
|
14
|
+
* participant receives.
|
|
15
|
+
*/
|
|
16
|
+
export const EXPOSED_API_REGISTRY_CONTRACT_METHODS = ['lastRefusal', 'register', 'resolve'];
|
|
17
|
+
/**
|
|
18
|
+
* Optional context field holding the absolute protected scope-record path.
|
|
19
|
+
*
|
|
20
|
+
* This is the registry's own field, declared in its own namespace. Hosts that
|
|
21
|
+
* need cross-boot scope persistence supply it. When it is absent the registry
|
|
22
|
+
* keeps the scope record in memory for one boot.
|
|
23
|
+
*/
|
|
24
|
+
export const EXPOSED_API_SCOPE_RECORD_PATH_FIELD = 'exposedApi.scopeRecord.path';
|
|
25
|
+
/** Reads an optional non-empty string from the registry's own context field. */
|
|
26
|
+
function optionalContextString(options, field) {
|
|
27
|
+
const value = options[field];
|
|
28
|
+
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Builds the resolution primitive's descriptor.
|
|
32
|
+
*
|
|
33
|
+
* The descriptor carries no caller list and no access policy of its own:
|
|
34
|
+
* `resolve` is open to every participant, and the projection hands every
|
|
35
|
+
* caller only `resolve`. Registration is reachable only by the kernel, which
|
|
36
|
+
* holds the instance during admission.
|
|
37
|
+
*
|
|
38
|
+
* @param options - Storage override.
|
|
39
|
+
*/
|
|
40
|
+
export function createExposedApiRegistryDescriptor(options) {
|
|
41
|
+
return {
|
|
42
|
+
token: ExposedApiRegistryToken,
|
|
43
|
+
tier: EXPOSED_API_REGISTRY_SERVICE_TIER,
|
|
44
|
+
dependencies: [],
|
|
45
|
+
contract: {
|
|
46
|
+
version: EXPOSED_API_REGISTRY_CONTRACT_VERSION,
|
|
47
|
+
methods: EXPOSED_API_REGISTRY_CONTRACT_METHODS,
|
|
48
|
+
},
|
|
49
|
+
factory: (context) => {
|
|
50
|
+
const scopeRecordPath = options?.scopeRecordPath
|
|
51
|
+
?? optionalContextString(context.options, EXPOSED_API_SCOPE_RECORD_PATH_FIELD);
|
|
52
|
+
return new ExposedApiRegistryService(scopeRecordPath === undefined ? {} : { scopeRecordPath });
|
|
53
|
+
},
|
|
54
|
+
project: (instance) => instance.publicView,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** Standard Registry descriptor with no overrides. */
|
|
58
|
+
export const ExposedApiRegistryDescriptor = createExposedApiRegistryDescriptor();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IExposedApiRegistry } from '../contracts/IExposedApiRegistry.js';
|
|
2
|
+
/**
|
|
3
|
+
* Kernel service token of the resolution primitive.
|
|
4
|
+
*
|
|
5
|
+
* Every participant reaches `resolve` through this token. Registration is the
|
|
6
|
+
* kernel's own, during admission, and is never reachable through it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const ExposedApiRegistryToken: import("../../../src/contracts/serviceToken.js").ServiceToken<IExposedApiRegistry>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createServiceToken } from '../../../src/contracts/serviceToken.js';
|
|
2
|
+
/**
|
|
3
|
+
* Kernel service token of the resolution primitive.
|
|
4
|
+
*
|
|
5
|
+
* Every participant reaches `resolve` through this token. Registration is the
|
|
6
|
+
* kernel's own, during admission, and is never reachable through it.
|
|
7
|
+
*/
|
|
8
|
+
export const ExposedApiRegistryToken = createServiceToken('brud.core.exposedApiRegistry', 'Resolution primitive for manifest-declared exposures');
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './contracts/index.js';
|
|
2
|
+
export * from './descriptor/ExposedApiRegistryDescriptor.js';
|
|
3
|
+
export * from './descriptor/tokens.js';
|
|
4
|
+
export * from './orchestrator/index.js';
|
|
5
|
+
export { EXPOSED_API_SCOPE_RECORD_FORMAT, EXPOSED_API_SCOPE_RECORD_MAX_NAME_LENGTH, EXPOSED_API_SCOPE_RECORD_VERSION, assertScopeRecordPath, isScopeRecordProtected, loadScopeRecord, parseScopeRecordDocument, persistScopeRecord, protectScopeRecord, releaseScopeRecordProtection, scopeRecordIdentityKey, serializeScopeRecordDocument, } from './storage/scopeRecord.js';
|
|
6
|
+
export type { ScopeRecordEntry } from './storage/scopeRecord.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from './contracts/index.js';
|
|
2
|
+
export * from './descriptor/ExposedApiRegistryDescriptor.js';
|
|
3
|
+
export * from './descriptor/tokens.js';
|
|
4
|
+
export * from './orchestrator/index.js';
|
|
5
|
+
export { EXPOSED_API_SCOPE_RECORD_FORMAT, EXPOSED_API_SCOPE_RECORD_MAX_NAME_LENGTH, EXPOSED_API_SCOPE_RECORD_VERSION, assertScopeRecordPath, isScopeRecordProtected, loadScopeRecord, parseScopeRecordDocument, persistScopeRecord, protectScopeRecord, releaseScopeRecordProtection, scopeRecordIdentityKey, serializeScopeRecordDocument, } from './storage/scopeRecord.js';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { KernelCallAuthority } from '../../../src/contracts/callChain.js';
|
|
2
|
+
import type { IServiceLifecycle } from '../../../src/contracts/lifecycle.js';
|
|
3
|
+
import type { ExposureDeclaration } from '../../../src/contracts/manifest.js';
|
|
4
|
+
import type { IExposedApiAdmission, IExposedApiRegistry } from '../contracts/IExposedApiRegistry.js';
|
|
5
|
+
import { EXPOSED_API_NAME_PATTERN, type ExposedApiRefusal, type ExposedApiResolveOptions } from '../contracts/types.js';
|
|
6
|
+
/** API names accept dotted, kebab, and snake segments. */
|
|
7
|
+
export { EXPOSED_API_NAME_PATTERN };
|
|
8
|
+
/** Collaborators injected into {@link ExposedApiRegistryService}. */
|
|
9
|
+
export interface ExposedApiRegistryDependencies {
|
|
10
|
+
/**
|
|
11
|
+
* Absolute path to the protected per-composition scope record.
|
|
12
|
+
*
|
|
13
|
+
* When omitted, scope is tracked in memory for the lifetime of the service.
|
|
14
|
+
*/
|
|
15
|
+
readonly scopeRecordPath?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The resolution primitive.
|
|
19
|
+
*
|
|
20
|
+
* Holds no participant name, no participant token, no caller identifier, no
|
|
21
|
+
* caller list, and no policy of its own. It stores what each participant's
|
|
22
|
+
* manifest declares, keyed by the owner's kernel-issued identity, and
|
|
23
|
+
* evaluates each giver's declared Layer 1 policy against the kernel-provided
|
|
24
|
+
* execution context.
|
|
25
|
+
*/
|
|
26
|
+
export declare class ExposedApiRegistryService implements IExposedApiRegistry, IExposedApiAdmission, IServiceLifecycle {
|
|
27
|
+
#private;
|
|
28
|
+
/** The only view a participant receives: `resolve` and `lastRefusal`. */
|
|
29
|
+
readonly publicView: IExposedApiRegistry;
|
|
30
|
+
constructor(dependencies?: ExposedApiRegistryDependencies);
|
|
31
|
+
/**
|
|
32
|
+
* Loads and integrity-checks the protected scope record.
|
|
33
|
+
*
|
|
34
|
+
* A missing record is the legitimate first-registration case. A corrupt
|
|
35
|
+
* record refuses boot. An existing record is made read-only for the runtime.
|
|
36
|
+
*/
|
|
37
|
+
initialize(): Promise<void>;
|
|
38
|
+
/** Seals the window and persists the final scope record. */
|
|
39
|
+
onRunning(): Promise<void>;
|
|
40
|
+
/** Releases the protected-path claim and forgets every exposure. */
|
|
41
|
+
dispose(): Promise<void>;
|
|
42
|
+
/** Whether {@link dispose} has run. */
|
|
43
|
+
get isDisposed(): boolean;
|
|
44
|
+
/** Whether the registration window is sealed. */
|
|
45
|
+
get isSealed(): boolean;
|
|
46
|
+
/** Absolute scope-record path, when persistence is configured. */
|
|
47
|
+
get scopeRecordPath(): string | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Attaches the kernel's call authority and the composition's name pins.
|
|
50
|
+
*
|
|
51
|
+
* Called once by the kernel, during admission, before any registration.
|
|
52
|
+
*
|
|
53
|
+
* @param authority - The kernel's call authority.
|
|
54
|
+
* @param ownerPins - Exposure names pinned to an owner identity.
|
|
55
|
+
*/
|
|
56
|
+
attachKernel(authority: KernelCallAuthority, ownerPins: Readonly<Record<string, string>>): void;
|
|
57
|
+
register(owner: string, declaration: ExposureDeclaration): void;
|
|
58
|
+
/** Seals the registration window. Idempotent. Kernel-only. */
|
|
59
|
+
seal(): void;
|
|
60
|
+
resolve<T = unknown>(name: string, options?: ExposedApiResolveOptions): T | null;
|
|
61
|
+
/**
|
|
62
|
+
* Why the most recent `resolve` in the current call frame returned `null`.
|
|
63
|
+
*
|
|
64
|
+
* Reads only the current frame's own record, so no other caller's refusal is
|
|
65
|
+
* visible. Outside any frame the only possible refusal is the absence of one.
|
|
66
|
+
*/
|
|
67
|
+
lastRefusal(): ExposedApiRefusal | null;
|
|
68
|
+
}
|