@brud/kernel 0.0.0-stage → 0.0.1

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 (278) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +63 -2
  3. package/dist/index.d.ts +15 -0
  4. package/dist/index.js +13 -0
  5. package/dist/serviceModules/events.d.ts +1 -0
  6. package/dist/serviceModules/events.js +1 -0
  7. package/dist/serviceModules/exposedApiRegistry.d.ts +1 -0
  8. package/dist/serviceModules/exposedApiRegistry.js +1 -0
  9. package/dist/serviceModules/identityRegistry.d.ts +1 -0
  10. package/dist/serviceModules/identityRegistry.js +1 -0
  11. package/dist/serviceModules/interception.d.ts +1 -0
  12. package/dist/serviceModules/interception.js +1 -0
  13. package/dist/serviceModules/parser.d.ts +1 -0
  14. package/dist/serviceModules/parser.js +1 -0
  15. package/dist/serviceModules/router.d.ts +1 -0
  16. package/dist/serviceModules/router.js +1 -0
  17. package/dist/serviceModules/wasmCage.d.ts +1 -0
  18. package/dist/serviceModules/wasmCage.js +1 -0
  19. package/dist/services/Events/contracts/IEventsService.d.ts +64 -0
  20. package/dist/services/Events/contracts/IEventsService.js +1 -0
  21. package/dist/services/Events/contracts/errors.d.ts +31 -0
  22. package/dist/services/Events/contracts/errors.js +40 -0
  23. package/dist/services/Events/contracts/index.d.ts +3 -0
  24. package/dist/services/Events/contracts/index.js +3 -0
  25. package/dist/services/Events/contracts/tokens.d.ts +2 -0
  26. package/dist/services/Events/contracts/tokens.js +2 -0
  27. package/dist/services/Events/descriptor/EventsDescriptor.d.ts +9 -0
  28. package/dist/services/Events/descriptor/EventsDescriptor.js +56 -0
  29. package/dist/services/Events/descriptor/tokens.d.ts +1 -0
  30. package/dist/services/Events/descriptor/tokens.js +1 -0
  31. package/dist/services/Events/index.d.ts +4 -0
  32. package/dist/services/Events/index.js +4 -0
  33. package/dist/services/Events/orchestrator/EventsService.d.ts +51 -0
  34. package/dist/services/Events/orchestrator/EventsService.js +339 -0
  35. package/dist/services/Events/orchestrator/index.d.ts +2 -0
  36. package/dist/services/Events/orchestrator/index.js +2 -0
  37. package/dist/services/Events/orchestrator/limits.d.ts +22 -0
  38. package/dist/services/Events/orchestrator/limits.js +33 -0
  39. package/dist/services/Events/serviceModule.d.ts +2 -0
  40. package/dist/services/Events/serviceModule.js +5 -0
  41. package/dist/services/ExposedApiRegistry/contracts/IExposedApiRegistry.d.ts +44 -0
  42. package/dist/services/ExposedApiRegistry/contracts/IExposedApiRegistry.js +1 -0
  43. package/dist/services/ExposedApiRegistry/contracts/errors.d.ts +132 -0
  44. package/dist/services/ExposedApiRegistry/contracts/errors.js +195 -0
  45. package/dist/services/ExposedApiRegistry/contracts/index.d.ts +9 -0
  46. package/dist/services/ExposedApiRegistry/contracts/index.js +4 -0
  47. package/dist/services/ExposedApiRegistry/contracts/policy.d.ts +90 -0
  48. package/dist/services/ExposedApiRegistry/contracts/policy.js +169 -0
  49. package/dist/services/ExposedApiRegistry/contracts/registrant.d.ts +37 -0
  50. package/dist/services/ExposedApiRegistry/contracts/registrant.js +36 -0
  51. package/dist/services/ExposedApiRegistry/contracts/types.d.ts +112 -0
  52. package/dist/services/ExposedApiRegistry/contracts/types.js +73 -0
  53. package/dist/services/ExposedApiRegistry/descriptor/ExposedApiRegistryDescriptor.d.ts +44 -0
  54. package/dist/services/ExposedApiRegistry/descriptor/ExposedApiRegistryDescriptor.js +58 -0
  55. package/dist/services/ExposedApiRegistry/descriptor/tokens.d.ts +8 -0
  56. package/dist/services/ExposedApiRegistry/descriptor/tokens.js +8 -0
  57. package/dist/services/ExposedApiRegistry/index.d.ts +6 -0
  58. package/dist/services/ExposedApiRegistry/index.js +5 -0
  59. package/dist/services/ExposedApiRegistry/orchestrator/ExposedApiRegistryService.d.ts +61 -0
  60. package/dist/services/ExposedApiRegistry/orchestrator/ExposedApiRegistryService.js +407 -0
  61. package/dist/services/ExposedApiRegistry/orchestrator/index.d.ts +2 -0
  62. package/dist/services/ExposedApiRegistry/orchestrator/index.js +1 -0
  63. package/dist/services/ExposedApiRegistry/serviceModule.d.ts +10 -0
  64. package/dist/services/ExposedApiRegistry/serviceModule.js +20 -0
  65. package/dist/services/ExposedApiRegistry/storage/protection.d.ts +21 -0
  66. package/dist/services/ExposedApiRegistry/storage/protection.js +35 -0
  67. package/dist/services/ExposedApiRegistry/storage/scopeRecord.d.ts +45 -0
  68. package/dist/services/ExposedApiRegistry/storage/scopeRecord.js +178 -0
  69. package/dist/services/IdentityRegistry/contracts/errors.d.ts +88 -0
  70. package/dist/services/IdentityRegistry/contracts/errors.js +128 -0
  71. package/dist/services/IdentityRegistry/contracts/index.d.ts +5 -0
  72. package/dist/services/IdentityRegistry/contracts/index.js +3 -0
  73. package/dist/services/IdentityRegistry/contracts/types.d.ts +77 -0
  74. package/dist/services/IdentityRegistry/contracts/types.js +18 -0
  75. package/dist/services/IdentityRegistry/descriptor/descriptor.d.ts +36 -0
  76. package/dist/services/IdentityRegistry/descriptor/descriptor.js +44 -0
  77. package/dist/services/IdentityRegistry/descriptor/tokens.d.ts +8 -0
  78. package/dist/services/IdentityRegistry/descriptor/tokens.js +8 -0
  79. package/dist/services/IdentityRegistry/index.d.ts +11 -0
  80. package/dist/services/IdentityRegistry/index.js +6 -0
  81. package/dist/services/IdentityRegistry/orchestrator/IdentityRegistryService.d.ts +47 -0
  82. package/dist/services/IdentityRegistry/orchestrator/IdentityRegistryService.js +240 -0
  83. package/dist/services/IdentityRegistry/serviceModule.d.ts +10 -0
  84. package/dist/services/IdentityRegistry/serviceModule.js +24 -0
  85. package/dist/services/IdentityRegistry/storage/registryDocument.d.ts +55 -0
  86. package/dist/services/IdentityRegistry/storage/registryDocument.js +235 -0
  87. package/dist/services/Interception/contracts/IInterceptionService.d.ts +65 -0
  88. package/dist/services/Interception/contracts/IInterceptionService.js +1 -0
  89. package/dist/services/Interception/contracts/errors.d.ts +26 -0
  90. package/dist/services/Interception/contracts/errors.js +35 -0
  91. package/dist/services/Interception/contracts/index.d.ts +3 -0
  92. package/dist/services/Interception/contracts/index.js +3 -0
  93. package/dist/services/Interception/contracts/tokens.d.ts +2 -0
  94. package/dist/services/Interception/contracts/tokens.js +2 -0
  95. package/dist/services/Interception/descriptor/InterceptionDescriptor.d.ts +9 -0
  96. package/dist/services/Interception/descriptor/InterceptionDescriptor.js +49 -0
  97. package/dist/services/Interception/descriptor/tokens.d.ts +1 -0
  98. package/dist/services/Interception/descriptor/tokens.js +1 -0
  99. package/dist/services/Interception/index.d.ts +4 -0
  100. package/dist/services/Interception/index.js +4 -0
  101. package/dist/services/Interception/orchestrator/InterceptionService.d.ts +32 -0
  102. package/dist/services/Interception/orchestrator/InterceptionService.js +180 -0
  103. package/dist/services/Interception/orchestrator/index.d.ts +1 -0
  104. package/dist/services/Interception/orchestrator/index.js +1 -0
  105. package/dist/services/Interception/serviceModule.d.ts +2 -0
  106. package/dist/services/Interception/serviceModule.js +5 -0
  107. package/dist/services/Parser/contracts/IParserService.d.ts +21 -0
  108. package/dist/services/Parser/contracts/IParserService.js +1 -0
  109. package/dist/services/Parser/contracts/errors.d.ts +25 -0
  110. package/dist/services/Parser/contracts/errors.js +33 -0
  111. package/dist/services/Parser/contracts/index.d.ts +4 -0
  112. package/dist/services/Parser/contracts/index.js +1 -0
  113. package/dist/services/Parser/contracts/types.d.ts +42 -0
  114. package/dist/services/Parser/contracts/types.js +1 -0
  115. package/dist/services/Parser/descriptor/ParserDescriptor.d.ts +23 -0
  116. package/dist/services/Parser/descriptor/ParserDescriptor.js +50 -0
  117. package/dist/services/Parser/descriptor/tokens.d.ts +8 -0
  118. package/dist/services/Parser/descriptor/tokens.js +8 -0
  119. package/dist/services/Parser/index.d.ts +8 -0
  120. package/dist/services/Parser/index.js +8 -0
  121. package/dist/services/Parser/orchestrator/ParserService.d.ts +20 -0
  122. package/dist/services/Parser/orchestrator/ParserService.js +105 -0
  123. package/dist/services/Parser/orchestrator/index.d.ts +1 -0
  124. package/dist/services/Parser/orchestrator/index.js +1 -0
  125. package/dist/services/Parser/parser/indexSynthesis.d.ts +11 -0
  126. package/dist/services/Parser/parser/indexSynthesis.js +13 -0
  127. package/dist/services/Parser/parser/parameters.d.ts +14 -0
  128. package/dist/services/Parser/parser/parameters.js +89 -0
  129. package/dist/services/Parser/parser/scanner.d.ts +48 -0
  130. package/dist/services/Parser/parser/scanner.js +156 -0
  131. package/dist/services/Parser/parser/syntax.d.ts +30 -0
  132. package/dist/services/Parser/parser/syntax.js +34 -0
  133. package/dist/services/Parser/serviceModule.d.ts +2 -0
  134. package/dist/services/Parser/serviceModule.js +5 -0
  135. package/dist/services/Router/bootOptions.d.ts +2 -0
  136. package/dist/services/Router/bootOptions.js +2 -0
  137. package/dist/services/Router/contracts/IRouterService.d.ts +43 -0
  138. package/dist/services/Router/contracts/IRouterService.js +1 -0
  139. package/dist/services/Router/contracts/caller.d.ts +6 -0
  140. package/dist/services/Router/contracts/caller.js +6 -0
  141. package/dist/services/Router/contracts/errors.d.ts +56 -0
  142. package/dist/services/Router/contracts/errors.js +75 -0
  143. package/dist/services/Router/contracts/index.d.ts +8 -0
  144. package/dist/services/Router/contracts/index.js +4 -0
  145. package/dist/services/Router/contracts/kind.d.ts +7 -0
  146. package/dist/services/Router/contracts/kind.js +10 -0
  147. package/dist/services/Router/contracts/registrant.d.ts +23 -0
  148. package/dist/services/Router/contracts/registrant.js +13 -0
  149. package/dist/services/Router/contracts/types.d.ts +90 -0
  150. package/dist/services/Router/contracts/types.js +1 -0
  151. package/dist/services/Router/descriptor/RouterDescriptor.d.ts +32 -0
  152. package/dist/services/Router/descriptor/RouterDescriptor.js +92 -0
  153. package/dist/services/Router/descriptor/tokens.d.ts +9 -0
  154. package/dist/services/Router/descriptor/tokens.js +9 -0
  155. package/dist/services/Router/index.d.ts +4 -0
  156. package/dist/services/Router/index.js +4 -0
  157. package/dist/services/Router/orchestrator/RouterService.d.ts +74 -0
  158. package/dist/services/Router/orchestrator/RouterService.js +332 -0
  159. package/dist/services/Router/orchestrator/index.d.ts +2 -0
  160. package/dist/services/Router/orchestrator/index.js +1 -0
  161. package/dist/services/Router/serviceModule.d.ts +4 -0
  162. package/dist/services/Router/serviceModule.js +22 -0
  163. package/dist/services/WasmCage/index.d.ts +7 -0
  164. package/dist/services/WasmCage/index.js +4 -0
  165. package/dist/services/WasmCage/scripts/prepin.d.ts +1 -0
  166. package/dist/services/WasmCage/scripts/prepin.js +38 -0
  167. package/dist/services/WasmCage/serviceModule.d.ts +12 -0
  168. package/dist/services/WasmCage/serviceModule.js +18 -0
  169. package/dist/services/WasmCage/src/caged.d.ts +104 -0
  170. package/dist/services/WasmCage/src/caged.js +381 -0
  171. package/dist/services/WasmCage/src/descriptor.d.ts +47 -0
  172. package/dist/services/WasmCage/src/descriptor.js +56 -0
  173. package/dist/services/WasmCage/src/native.d.ts +29 -0
  174. package/dist/services/WasmCage/src/native.js +66 -0
  175. package/dist/services/WasmCage/src/nativeDigests.d.ts +9 -0
  176. package/dist/services/WasmCage/src/nativeDigests.js +15 -0
  177. package/dist/services/WasmCage/src/package.d.ts +36 -0
  178. package/dist/services/WasmCage/src/package.js +122 -0
  179. package/dist/services/shared/canonicalJson.d.ts +29 -0
  180. package/dist/services/shared/canonicalJson.js +93 -0
  181. package/dist/services/shared/documentStore.d.ts +16 -0
  182. package/dist/services/shared/documentStore.js +98 -0
  183. package/dist/src/bootstrap/bootKernelInternal.d.ts +18 -0
  184. package/dist/src/bootstrap/bootKernelInternal.js +420 -0
  185. package/dist/src/bootstrap/bootTypes.d.ts +89 -0
  186. package/dist/src/bootstrap/bootTypes.js +1 -0
  187. package/dist/src/bootstrap/config/index.d.ts +3 -0
  188. package/dist/src/bootstrap/config/index.js +2 -0
  189. package/dist/src/bootstrap/config/integrity.d.ts +34 -0
  190. package/dist/src/bootstrap/config/integrity.js +79 -0
  191. package/dist/src/bootstrap/config/parse.d.ts +15 -0
  192. package/dist/src/bootstrap/config/parse.js +81 -0
  193. package/dist/src/bootstrap/config/pathWriteGuard.d.ts +20 -0
  194. package/dist/src/bootstrap/config/pathWriteGuard.js +349 -0
  195. package/dist/src/bootstrap/config/types.d.ts +41 -0
  196. package/dist/src/bootstrap/config/types.js +15 -0
  197. package/dist/src/bootstrap/hardcore.d.ts +212 -0
  198. package/dist/src/bootstrap/hardcore.js +312 -0
  199. package/dist/src/bootstrap/hardcoreServices.d.ts +10 -0
  200. package/dist/src/bootstrap/hardcoreServices.js +258 -0
  201. package/dist/src/bootstrap/index.d.ts +8 -0
  202. package/dist/src/bootstrap/index.js +5 -0
  203. package/dist/src/bootstrap/packageRequirements.d.ts +26 -0
  204. package/dist/src/bootstrap/packageRequirements.js +52 -0
  205. package/dist/src/contracts/accessBroker.d.ts +53 -0
  206. package/dist/src/contracts/accessBroker.js +1 -0
  207. package/dist/src/contracts/brudOperation.d.ts +20 -0
  208. package/dist/src/contracts/brudOperation.js +20 -0
  209. package/dist/src/contracts/callChain.d.ts +161 -0
  210. package/dist/src/contracts/callChain.js +19 -0
  211. package/dist/src/contracts/capability.d.ts +26 -0
  212. package/dist/src/contracts/capability.js +26 -0
  213. package/dist/src/contracts/container.d.ts +17 -0
  214. package/dist/src/contracts/container.js +8 -0
  215. package/dist/src/contracts/context.d.ts +19 -0
  216. package/dist/src/contracts/context.js +1 -0
  217. package/dist/src/contracts/contextContract.d.ts +129 -0
  218. package/dist/src/contracts/contextContract.js +285 -0
  219. package/dist/src/contracts/dispatchView.d.ts +21 -0
  220. package/dist/src/contracts/dispatchView.js +1 -0
  221. package/dist/src/contracts/handler.d.ts +28 -0
  222. package/dist/src/contracts/handler.js +1 -0
  223. package/dist/src/contracts/index.d.ts +25 -0
  224. package/dist/src/contracts/index.js +8 -0
  225. package/dist/src/contracts/kernel.d.ts +60 -0
  226. package/dist/src/contracts/kernel.js +1 -0
  227. package/dist/src/contracts/lifecycle.d.ts +59 -0
  228. package/dist/src/contracts/lifecycle.js +1 -0
  229. package/dist/src/contracts/manifest.d.ts +145 -0
  230. package/dist/src/contracts/manifest.js +295 -0
  231. package/dist/src/contracts/pipeline.d.ts +8 -0
  232. package/dist/src/contracts/pipeline.js +1 -0
  233. package/dist/src/contracts/policy.d.ts +75 -0
  234. package/dist/src/contracts/policy.js +77 -0
  235. package/dist/src/contracts/registry.d.ts +7 -0
  236. package/dist/src/contracts/registry.js +1 -0
  237. package/dist/src/contracts/serviceDescriptor.d.ts +67 -0
  238. package/dist/src/contracts/serviceDescriptor.js +1 -0
  239. package/dist/src/contracts/serviceToken.d.ts +36 -0
  240. package/dist/src/contracts/serviceToken.js +16 -0
  241. package/dist/src/engine/BrudKernel.d.ts +118 -0
  242. package/dist/src/engine/BrudKernel.js +366 -0
  243. package/dist/src/engine/ExecutionPipeline.d.ts +13 -0
  244. package/dist/src/engine/ExecutionPipeline.js +62 -0
  245. package/dist/src/engine/KernelAccessBroker.d.ts +47 -0
  246. package/dist/src/engine/KernelAccessBroker.js +107 -0
  247. package/dist/src/engine/KernelRegistry.d.ts +14 -0
  248. package/dist/src/engine/KernelRegistry.js +33 -0
  249. package/dist/src/engine/OperationRegistry.d.ts +9 -0
  250. package/dist/src/engine/OperationRegistry.js +18 -0
  251. package/dist/src/engine/ServiceContainer.d.ts +13 -0
  252. package/dist/src/engine/ServiceContainer.js +53 -0
  253. package/dist/src/engine/callChain.d.ts +68 -0
  254. package/dist/src/engine/callChain.js +180 -0
  255. package/dist/src/engine/dag.d.ts +2 -0
  256. package/dist/src/engine/dag.js +34 -0
  257. package/dist/src/engine/errors.d.ts +26 -0
  258. package/dist/src/engine/errors.js +52 -0
  259. package/dist/src/engine/index.d.ts +11 -0
  260. package/dist/src/engine/index.js +8 -0
  261. package/dist/src/engine/state.d.ts +1 -0
  262. package/dist/src/engine/state.js +1 -0
  263. package/dist/src/validation/jsonSchema/compile.d.ts +8 -0
  264. package/dist/src/validation/jsonSchema/compile.js +386 -0
  265. package/dist/src/validation/jsonSchema/index.d.ts +3 -0
  266. package/dist/src/validation/jsonSchema/index.js +2 -0
  267. package/dist/src/validation/jsonSchema/jsonValue.d.ts +29 -0
  268. package/dist/src/validation/jsonSchema/jsonValue.js +190 -0
  269. package/dist/src/validation/jsonSchema/pattern.d.ts +28 -0
  270. package/dist/src/validation/jsonSchema/pattern.js +155 -0
  271. package/dist/src/validation/jsonSchema/types.d.ts +71 -0
  272. package/dist/src/validation/jsonSchema/types.js +15 -0
  273. package/package.json +59 -4
  274. package/services/WasmCage/native/brud-wasm-cage.darwin-arm64.node +0 -0
  275. package/services/WasmCage/native/brud-wasm-cage.darwin-x64.node +0 -0
  276. package/services/WasmCage/native/brud-wasm-cage.linux-arm64-gnu.node +0 -0
  277. package/services/WasmCage/native/brud-wasm-cage.linux-x64-gnu.node +0 -0
  278. package/services/WasmCage/native/brud-wasm-cage.win32-x64-msvc.node +0 -0
@@ -0,0 +1,2 @@
1
+ export { ExposedApiRegistryService, EXPOSED_API_NAME_PATTERN, } from './ExposedApiRegistryService.js';
2
+ export type { ExposedApiRegistryDependencies } from './ExposedApiRegistryService.js';
@@ -0,0 +1 @@
1
+ export { ExposedApiRegistryService, EXPOSED_API_NAME_PATTERN, } from './ExposedApiRegistryService.js';
@@ -0,0 +1,10 @@
1
+ import type { KernelServiceModuleContext } from '../../src/bootstrap/bootTypes.js';
2
+ /**
3
+ * Composes the resolution primitive through the standard service-module
4
+ * contract.
5
+ *
6
+ * The module declares only its own namespaced storage field. It publishes no
7
+ * instance: registration is the kernel's, during admission, and every
8
+ * participant reaches `resolve` through the access broker.
9
+ */
10
+ export declare function createService(context: KernelServiceModuleContext): import("../../index.js").ServiceDescriptor<import("./index.js").IExposedApiRegistry, import("./index.js").ExposedApiRegistryService>;
@@ -0,0 +1,20 @@
1
+ import { EXPOSED_API_REGISTRY_CONTEXT_SCOPE, EXPOSED_API_SCOPE_RECORD_PATH_FIELD, createExposedApiRegistryDescriptor, } from './descriptor/ExposedApiRegistryDescriptor.js';
2
+ /**
3
+ * Composes the resolution primitive through the standard service-module
4
+ * contract.
5
+ *
6
+ * The module declares only its own namespaced storage field. It publishes no
7
+ * instance: registration is the kernel's, during admission, and every
8
+ * participant reaches `resolve` through the access broker.
9
+ */
10
+ export function createService(context) {
11
+ context.declareContextFields(EXPOSED_API_REGISTRY_CONTEXT_SCOPE, [
12
+ {
13
+ name: EXPOSED_API_SCOPE_RECORD_PATH_FIELD,
14
+ type: 'string',
15
+ required: false,
16
+ description: 'Absolute path to the protected exposed API scope record.',
17
+ },
18
+ ]);
19
+ return createExposedApiRegistryDescriptor();
20
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Runtime write protection for the exposed API scope record.
3
+ *
4
+ * The scope record may be edited by an operator only while the kernel is
5
+ * stopped. While a kernel holds the path, the file is made read-only and every
6
+ * mutating filesystem entry point is refused before it reaches the host.
7
+ */
8
+ /**
9
+ * Makes an existing scope record read-only for the running kernel.
10
+ *
11
+ * @param storagePath - Absolute scope record file path.
12
+ */
13
+ export declare function protectScopeRecord(storagePath: string): void;
14
+ /**
15
+ * Releases one claim on a protected scope record.
16
+ *
17
+ * @param storagePath - Absolute scope record file path.
18
+ */
19
+ export declare function releaseScopeRecordProtection(storagePath: string): void;
20
+ /** Reports whether a scope record path is currently protected by this process. */
21
+ export declare function isScopeRecordProtected(storagePath: string): boolean;
@@ -0,0 +1,35 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { resolve as resolvePath } from 'node:path';
3
+ import { ExposedApiScopeRecordWriteError } from '../contracts/errors.js';
4
+ import { isPathProtected, protectPath, releasePath, } from '../../../src/bootstrap/config/pathWriteGuard.js';
5
+ /**
6
+ * Runtime write protection for the exposed API scope record.
7
+ *
8
+ * The scope record may be edited by an operator only while the kernel is
9
+ * stopped. While a kernel holds the path, the file is made read-only and every
10
+ * mutating filesystem entry point is refused before it reaches the host.
11
+ */
12
+ /**
13
+ * Makes an existing scope record read-only for the running kernel.
14
+ *
15
+ * @param storagePath - Absolute scope record file path.
16
+ */
17
+ export function protectScopeRecord(storagePath) {
18
+ const resolvedPath = resolvePath(storagePath);
19
+ if (!existsSync(resolvedPath)) {
20
+ return;
21
+ }
22
+ protectPath(resolvedPath, (key, operation) => new ExposedApiScopeRecordWriteError(key, `scope record is protected and cannot be ${operation} while the kernel is running`));
23
+ }
24
+ /**
25
+ * Releases one claim on a protected scope record.
26
+ *
27
+ * @param storagePath - Absolute scope record file path.
28
+ */
29
+ export function releaseScopeRecordProtection(storagePath) {
30
+ releasePath(storagePath);
31
+ }
32
+ /** Reports whether a scope record path is currently protected by this process. */
33
+ export function isScopeRecordProtected(storagePath) {
34
+ return isPathProtected(storagePath);
35
+ }
@@ -0,0 +1,45 @@
1
+ import { type ExposedApiScope, type ExposedApiVersion } from '../contracts/types.js';
2
+ /** Stable format marker for the protected scope record. */
3
+ export declare const EXPOSED_API_SCOPE_RECORD_FORMAT = "brud.exposed-api-scope-record";
4
+ /** Format version the service understands. */
5
+ export declare const EXPOSED_API_SCOPE_RECORD_VERSION = 1;
6
+ /** Maximum accepted API name length in a scope record. */
7
+ export declare const EXPOSED_API_SCOPE_RECORD_MAX_NAME_LENGTH = 1024;
8
+ /** One persisted scope entry. */
9
+ export interface ScopeRecordEntry {
10
+ readonly name: string;
11
+ readonly version: ExposedApiVersion;
12
+ readonly scope: ExposedApiScope;
13
+ }
14
+ export { isScopeRecordProtected, protectScopeRecord, releaseScopeRecordProtection, } from './protection.js';
15
+ /** Builds the deterministic key for one `(name, version)` identity. */
16
+ export declare function scopeRecordIdentityKey(name: string, version: ExposedApiVersion): string;
17
+ /** Rejects a storage path that is not an absolute file path. */
18
+ export declare function assertScopeRecordPath(storagePath: string): string;
19
+ /**
20
+ * Parses and integrity-checks a scope record document.
21
+ *
22
+ * @param raw - Exact file contents.
23
+ * @param storagePath - Absolute path used in diagnostics.
24
+ */
25
+ export declare function parseScopeRecordDocument(raw: string, storagePath: string): readonly ScopeRecordEntry[];
26
+ /**
27
+ * Serializes a scope record document with a fresh integrity digest.
28
+ *
29
+ * @param records - Current records.
30
+ */
31
+ export declare function serializeScopeRecordDocument(records: readonly ScopeRecordEntry[]): string;
32
+ /**
33
+ * Loads and validates a scope record file.
34
+ *
35
+ * @param storagePath - Absolute scope record file path.
36
+ * @returns The records, or `undefined` when the file does not exist yet.
37
+ */
38
+ export declare function loadScopeRecord(storagePath: string): readonly ScopeRecordEntry[] | undefined;
39
+ /**
40
+ * Persists a scope record file atomically.
41
+ *
42
+ * @param storagePath - Absolute scope record file path.
43
+ * @param records - Current records.
44
+ */
45
+ export declare function persistScopeRecord(storagePath: string, records: readonly ScopeRecordEntry[]): void;
@@ -0,0 +1,178 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { ExposedApiScopeRecordCorruptError, ExposedApiScopeRecordPathError, ExposedApiScopeRecordWriteError, } from '../contracts/errors.js';
3
+ import { EXPOSED_API_NAME_PATTERN, isExposedApiScope, isExposedApiVersion, } from '../contracts/types.js';
4
+ import { isPlainRecord } from '../../shared/canonicalJson.js';
5
+ import { assertExactKeys, canonicalDigest, digestsEqual, resolveAbsoluteStoragePath, writeAtomically, } from '../../shared/documentStore.js';
6
+ /** Stable format marker for the protected scope record. */
7
+ export const EXPOSED_API_SCOPE_RECORD_FORMAT = 'brud.exposed-api-scope-record';
8
+ /** Format version the service understands. */
9
+ export const EXPOSED_API_SCOPE_RECORD_VERSION = 1;
10
+ /** Maximum accepted API name length in a scope record. */
11
+ export const EXPOSED_API_SCOPE_RECORD_MAX_NAME_LENGTH = 1_024;
12
+ const DIGEST_ALGORITHM = 'sha256';
13
+ const DIGEST_PATTERN = /^[0-9a-f]{64}$/u;
14
+ const ROOT_KEYS = new Set(['format', 'version', 'records', 'integrity']);
15
+ const INTEGRITY_KEYS = new Set(['algorithm', 'digest']);
16
+ const RECORD_KEYS = new Set(['name', 'version', 'scope']);
17
+ export { isScopeRecordProtected, protectScopeRecord, releaseScopeRecordProtection, } from './protection.js';
18
+ /** Builds the deterministic key for one `(name, version)` identity. */
19
+ export function scopeRecordIdentityKey(name, version) {
20
+ const kind = typeof version === 'number' ? 'major' : 'semver';
21
+ return `${name}\u0000${kind}\u0000${String(version)}`;
22
+ }
23
+ /** Raises a corrupt-storage failure. */
24
+ function corrupt(storagePath, reason) {
25
+ throw new ExposedApiScopeRecordCorruptError(storagePath, reason);
26
+ }
27
+ /** Rejects a storage path that is not an absolute file path. */
28
+ export function assertScopeRecordPath(storagePath) {
29
+ return resolveAbsoluteStoragePath(storagePath, (path) => {
30
+ throw new ExposedApiScopeRecordPathError(path);
31
+ });
32
+ }
33
+ /** Validates one record and returns a frozen copy. */
34
+ function parseRecord(value, index, storagePath) {
35
+ if (!isPlainRecord(value)) {
36
+ corrupt(storagePath, `records[${String(index)}] is not an object`);
37
+ }
38
+ assertExactKeys(value, RECORD_KEYS, storagePath, `records[${String(index)}]`, corrupt);
39
+ const name = value.name;
40
+ if (typeof name !== 'string'
41
+ || name.length === 0
42
+ || name.length > EXPOSED_API_SCOPE_RECORD_MAX_NAME_LENGTH
43
+ || !EXPOSED_API_NAME_PATTERN.test(name)) {
44
+ corrupt(storagePath, `records[${String(index)}].name is invalid`);
45
+ }
46
+ const version = value.version;
47
+ if (!isExposedApiVersion(version)) {
48
+ corrupt(storagePath, `records[${String(index)}].version is invalid`);
49
+ }
50
+ const scope = value.scope;
51
+ if (!isExposedApiScope(scope)) {
52
+ corrupt(storagePath, `records[${String(index)}].scope is invalid`);
53
+ }
54
+ return Object.freeze({ name, version, scope });
55
+ }
56
+ /**
57
+ * Parses and integrity-checks a scope record document.
58
+ *
59
+ * @param raw - Exact file contents.
60
+ * @param storagePath - Absolute path used in diagnostics.
61
+ */
62
+ export function parseScopeRecordDocument(raw, storagePath) {
63
+ let document;
64
+ try {
65
+ document = JSON.parse(raw);
66
+ }
67
+ catch {
68
+ corrupt(storagePath, 'document is not valid JSON');
69
+ }
70
+ if (!isPlainRecord(document)) {
71
+ corrupt(storagePath, 'document root is not an object');
72
+ }
73
+ assertExactKeys(document, ROOT_KEYS, storagePath, 'document', corrupt);
74
+ if (document.format !== EXPOSED_API_SCOPE_RECORD_FORMAT) {
75
+ corrupt(storagePath, 'document format marker is not supported');
76
+ }
77
+ if (document.version !== EXPOSED_API_SCOPE_RECORD_VERSION) {
78
+ corrupt(storagePath, 'document version is not supported');
79
+ }
80
+ if (!Array.isArray(document.records)) {
81
+ corrupt(storagePath, 'records is not an array');
82
+ }
83
+ const records = [];
84
+ const identities = new Set();
85
+ for (let index = 0; index < document.records.length; index += 1) {
86
+ const record = parseRecord(document.records[index], index, storagePath);
87
+ const key = scopeRecordIdentityKey(record.name, record.version);
88
+ if (identities.has(key)) {
89
+ corrupt(storagePath, `duplicate identity at records[${String(index)}]`);
90
+ }
91
+ identities.add(key);
92
+ records.push(record);
93
+ }
94
+ const integrity = document.integrity;
95
+ if (!isPlainRecord(integrity)) {
96
+ corrupt(storagePath, 'integrity is not an object');
97
+ }
98
+ assertExactKeys(integrity, INTEGRITY_KEYS, storagePath, 'integrity', corrupt);
99
+ if (integrity.algorithm !== DIGEST_ALGORITHM) {
100
+ corrupt(storagePath, 'integrity algorithm is not supported');
101
+ }
102
+ const digest = integrity.digest;
103
+ if (typeof digest !== 'string' || !DIGEST_PATTERN.test(digest)) {
104
+ corrupt(storagePath, 'integrity digest is invalid');
105
+ }
106
+ const body = {
107
+ format: EXPOSED_API_SCOPE_RECORD_FORMAT,
108
+ version: EXPOSED_API_SCOPE_RECORD_VERSION,
109
+ records,
110
+ };
111
+ if (!digestsEqual(canonicalDigest(body), digest)) {
112
+ corrupt(storagePath, 'integrity digest mismatch');
113
+ }
114
+ return Object.freeze(records);
115
+ }
116
+ /**
117
+ * Serializes a scope record document with a fresh integrity digest.
118
+ *
119
+ * @param records - Current records.
120
+ */
121
+ export function serializeScopeRecordDocument(records) {
122
+ const ordered = [...records].sort((left, right) => {
123
+ const byName = left.name.localeCompare(right.name);
124
+ if (byName !== 0) {
125
+ return byName;
126
+ }
127
+ return String(left.version).localeCompare(String(right.version));
128
+ });
129
+ const body = {
130
+ format: EXPOSED_API_SCOPE_RECORD_FORMAT,
131
+ version: EXPOSED_API_SCOPE_RECORD_VERSION,
132
+ records: ordered,
133
+ };
134
+ const document = {
135
+ ...body,
136
+ integrity: {
137
+ algorithm: DIGEST_ALGORITHM,
138
+ digest: canonicalDigest(body),
139
+ },
140
+ };
141
+ return `${JSON.stringify(document, null, 2)}\n`;
142
+ }
143
+ /** Writes a scope record through the shared atomic writer. */
144
+ function writeScopeRecordAtomically(storagePath, raw) {
145
+ writeAtomically(storagePath, raw, (path, reason) => new ExposedApiScopeRecordWriteError(path, reason));
146
+ }
147
+ /**
148
+ * Loads and validates a scope record file.
149
+ *
150
+ * @param storagePath - Absolute scope record file path.
151
+ * @returns The records, or `undefined` when the file does not exist yet.
152
+ */
153
+ export function loadScopeRecord(storagePath) {
154
+ const resolvedPath = assertScopeRecordPath(storagePath);
155
+ let raw;
156
+ try {
157
+ raw = readFileSync(resolvedPath, 'utf8');
158
+ }
159
+ catch (error) {
160
+ const code = error.code;
161
+ if (code === 'ENOENT') {
162
+ return undefined;
163
+ }
164
+ throw new ExposedApiScopeRecordCorruptError(resolvedPath, `storage cannot be read${code === undefined ? '' : ` (${code})`}`);
165
+ }
166
+ return parseScopeRecordDocument(raw, resolvedPath);
167
+ }
168
+ /**
169
+ * Persists a scope record file atomically.
170
+ *
171
+ * @param storagePath - Absolute scope record file path.
172
+ * @param records - Current records.
173
+ */
174
+ export function persistScopeRecord(storagePath, records) {
175
+ const resolvedPath = assertScopeRecordPath(storagePath);
176
+ const raw = serializeScopeRecordDocument(records);
177
+ writeScopeRecordAtomically(resolvedPath, raw);
178
+ }
@@ -0,0 +1,88 @@
1
+ /** Stable, machine-readable identity registry failure codes. */
2
+ export type IdentityRegistryErrorCode = 'IDENTITY_REGISTRY_MISSING' | 'IDENTITY_REGISTRY_CORRUPT' | 'IDENTITY_REGISTRY_FROZEN' | 'IDENTITY_REGISTRY_UNKNOWN_TOKEN' | 'IDENTITY_REGISTRY_REVOKED' | 'IDENTITY_REGISTRY_INPUT_INVALID' | 'IDENTITY_REGISTRY_NOT_READY' | 'IDENTITY_REGISTRY_STORAGE_EXISTS' | 'IDENTITY_REGISTRY_PATH_INVALID' | 'IDENTITY_REGISTRY_WRITE_FAILED';
3
+ /** Base class for every identity registry domain failure. */
4
+ export declare abstract class IdentityRegistryError extends Error {
5
+ /** Stable, machine-readable failure code. */
6
+ abstract readonly code: IdentityRegistryErrorCode;
7
+ protected constructor(message: string);
8
+ }
9
+ /**
10
+ * Raised at boot when the configured registry storage file does not exist.
11
+ *
12
+ * The service refuses to regenerate a missing registry because a silent reset
13
+ * would turn an integrity failure into an identity reset.
14
+ */
15
+ export declare class IdentityRegistryMissingError extends IdentityRegistryError {
16
+ readonly code: "IDENTITY_REGISTRY_MISSING";
17
+ /** Absolute storage path the service expected. */
18
+ readonly storagePath: string;
19
+ constructor(storagePath: string);
20
+ }
21
+ /**
22
+ * Raised at boot when the registry storage exists but fails parsing or
23
+ * integrity validation.
24
+ */
25
+ export declare class IdentityRegistryCorruptError extends IdentityRegistryError {
26
+ readonly code: "IDENTITY_REGISTRY_CORRUPT";
27
+ /** Absolute storage path that failed validation. */
28
+ readonly storagePath: string;
29
+ /** Scrubbed reason for the failure. Never includes raw storage content. */
30
+ readonly reason: string;
31
+ constructor(storagePath: string, reason: string);
32
+ }
33
+ /** Raised when an operation attempts to mutate a frozen registry. */
34
+ export declare class IdentityRegistryFrozenError extends IdentityRegistryError {
35
+ readonly code: "IDENTITY_REGISTRY_FROZEN";
36
+ /** Operation that was refused. */
37
+ readonly operation: string;
38
+ constructor(operation: string);
39
+ }
40
+ /** Raised when an operation is attempted before the registry loaded. */
41
+ export declare class IdentityRegistryNotReadyError extends IdentityRegistryError {
42
+ readonly code: "IDENTITY_REGISTRY_NOT_READY";
43
+ /** Operation that was refused. */
44
+ readonly operation: string;
45
+ constructor(operation: string);
46
+ }
47
+ /** Raised when a retire or revoke names a token that is not recorded. */
48
+ export declare class IdentityRegistryUnknownTokenError extends IdentityRegistryError {
49
+ readonly code: "IDENTITY_REGISTRY_UNKNOWN_TOKEN";
50
+ /** Token value that was not found. */
51
+ readonly token: string;
52
+ constructor(token: string);
53
+ }
54
+ /** Raised when a revoked token or binding is used again. */
55
+ export declare class IdentityRegistryRevokedError extends IdentityRegistryError {
56
+ readonly code: "IDENTITY_REGISTRY_REVOKED";
57
+ /** Token whose binding is permanently revoked. */
58
+ readonly token: string;
59
+ constructor(token: string);
60
+ }
61
+ /** Raised when an operation receives an invalid opaque value. */
62
+ export declare class IdentityRegistryInputError extends IdentityRegistryError {
63
+ readonly code: "IDENTITY_REGISTRY_INPUT_INVALID";
64
+ /** Field or operation that failed validation. */
65
+ readonly field: string;
66
+ constructor(field: string, reason: string);
67
+ }
68
+ /** Raised when a storage path is not an absolute file path. */
69
+ export declare class IdentityRegistryPathError extends IdentityRegistryError {
70
+ readonly code: "IDENTITY_REGISTRY_PATH_INVALID";
71
+ /** Rejected path value. */
72
+ readonly storagePath: string;
73
+ constructor(storagePath: string);
74
+ }
75
+ /** Raised when operator provisioning would overwrite an existing registry. */
76
+ export declare class IdentityRegistryStorageExistsError extends IdentityRegistryError {
77
+ readonly code: "IDENTITY_REGISTRY_STORAGE_EXISTS";
78
+ /** Existing storage path. */
79
+ readonly storagePath: string;
80
+ constructor(storagePath: string);
81
+ }
82
+ /** Raised when the registry cannot write its storage file. */
83
+ export declare class IdentityRegistryWriteError extends IdentityRegistryError {
84
+ readonly code: "IDENTITY_REGISTRY_WRITE_FAILED";
85
+ /** Storage path the write targeted. */
86
+ readonly storagePath: string;
87
+ constructor(storagePath: string, reason: string);
88
+ }
@@ -0,0 +1,128 @@
1
+ /** Base class for every identity registry domain failure. */
2
+ export class IdentityRegistryError extends Error {
3
+ constructor(message) {
4
+ super(message);
5
+ this.name = 'IdentityRegistryError';
6
+ }
7
+ }
8
+ /**
9
+ * Raised at boot when the configured registry storage file does not exist.
10
+ *
11
+ * The service refuses to regenerate a missing registry because a silent reset
12
+ * would turn an integrity failure into an identity reset.
13
+ */
14
+ export class IdentityRegistryMissingError extends IdentityRegistryError {
15
+ code = 'IDENTITY_REGISTRY_MISSING';
16
+ /** Absolute storage path the service expected. */
17
+ storagePath;
18
+ constructor(storagePath) {
19
+ super(`Identity registry storage is missing at "${storagePath}". Refusing to start the identity registry instead of regenerating it.`);
20
+ this.name = 'IdentityRegistryMissingError';
21
+ this.storagePath = storagePath;
22
+ }
23
+ }
24
+ /**
25
+ * Raised at boot when the registry storage exists but fails parsing or
26
+ * integrity validation.
27
+ */
28
+ export class IdentityRegistryCorruptError extends IdentityRegistryError {
29
+ code = 'IDENTITY_REGISTRY_CORRUPT';
30
+ /** Absolute storage path that failed validation. */
31
+ storagePath;
32
+ /** Scrubbed reason for the failure. Never includes raw storage content. */
33
+ reason;
34
+ constructor(storagePath, reason) {
35
+ super(`Identity registry storage at "${storagePath}" failed integrity validation: ${reason}. Refusing to start the identity registry.`);
36
+ this.name = 'IdentityRegistryCorruptError';
37
+ this.storagePath = storagePath;
38
+ this.reason = reason;
39
+ }
40
+ }
41
+ /** Raised when an operation attempts to mutate a frozen registry. */
42
+ export class IdentityRegistryFrozenError extends IdentityRegistryError {
43
+ code = 'IDENTITY_REGISTRY_FROZEN';
44
+ /** Operation that was refused. */
45
+ operation;
46
+ constructor(operation) {
47
+ super(`Cannot ${operation} an identity token: the identity registry froze when the kernel reached RUNNING.`);
48
+ this.name = 'IdentityRegistryFrozenError';
49
+ this.operation = operation;
50
+ }
51
+ }
52
+ /** Raised when an operation is attempted before the registry loaded. */
53
+ export class IdentityRegistryNotReadyError extends IdentityRegistryError {
54
+ code = 'IDENTITY_REGISTRY_NOT_READY';
55
+ /** Operation that was refused. */
56
+ operation;
57
+ constructor(operation) {
58
+ super(`Cannot ${operation} an identity token before the identity registry has loaded its storage.`);
59
+ this.name = 'IdentityRegistryNotReadyError';
60
+ this.operation = operation;
61
+ }
62
+ }
63
+ /** Raised when a retire or revoke names a token that is not recorded. */
64
+ export class IdentityRegistryUnknownTokenError extends IdentityRegistryError {
65
+ code = 'IDENTITY_REGISTRY_UNKNOWN_TOKEN';
66
+ /** Token value that was not found. */
67
+ token;
68
+ constructor(token) {
69
+ super(`Identity token "${token}" is not recorded in the identity registry.`);
70
+ this.name = 'IdentityRegistryUnknownTokenError';
71
+ this.token = token;
72
+ }
73
+ }
74
+ /** Raised when a revoked token or binding is used again. */
75
+ export class IdentityRegistryRevokedError extends IdentityRegistryError {
76
+ code = 'IDENTITY_REGISTRY_REVOKED';
77
+ /** Token whose binding is permanently revoked. */
78
+ token;
79
+ constructor(token) {
80
+ super(`Identity token "${token}" is revoked permanently and can never be retired, reissued, or reactivated.`);
81
+ this.name = 'IdentityRegistryRevokedError';
82
+ this.token = token;
83
+ }
84
+ }
85
+ /** Raised when an operation receives an invalid opaque value. */
86
+ export class IdentityRegistryInputError extends IdentityRegistryError {
87
+ code = 'IDENTITY_REGISTRY_INPUT_INVALID';
88
+ /** Field or operation that failed validation. */
89
+ field;
90
+ constructor(field, reason) {
91
+ super(`Invalid identity registry input for ${field}: ${reason}`);
92
+ this.name = 'IdentityRegistryInputError';
93
+ this.field = field;
94
+ }
95
+ }
96
+ /** Raised when a storage path is not an absolute file path. */
97
+ export class IdentityRegistryPathError extends IdentityRegistryError {
98
+ code = 'IDENTITY_REGISTRY_PATH_INVALID';
99
+ /** Rejected path value. */
100
+ storagePath;
101
+ constructor(storagePath) {
102
+ super(`Identity registry storage path must be an absolute file path; received "${storagePath}".`);
103
+ this.name = 'IdentityRegistryPathError';
104
+ this.storagePath = storagePath;
105
+ }
106
+ }
107
+ /** Raised when operator provisioning would overwrite an existing registry. */
108
+ export class IdentityRegistryStorageExistsError extends IdentityRegistryError {
109
+ code = 'IDENTITY_REGISTRY_STORAGE_EXISTS';
110
+ /** Existing storage path. */
111
+ storagePath;
112
+ constructor(storagePath) {
113
+ super(`Identity registry storage already exists at "${storagePath}"; provisioning never overwrites an existing registry.`);
114
+ this.name = 'IdentityRegistryStorageExistsError';
115
+ this.storagePath = storagePath;
116
+ }
117
+ }
118
+ /** Raised when the registry cannot write its storage file. */
119
+ export class IdentityRegistryWriteError extends IdentityRegistryError {
120
+ code = 'IDENTITY_REGISTRY_WRITE_FAILED';
121
+ /** Storage path the write targeted. */
122
+ storagePath;
123
+ constructor(storagePath, reason) {
124
+ super(`Identity registry write failed at "${storagePath}": ${reason}`);
125
+ this.name = 'IdentityRegistryWriteError';
126
+ this.storagePath = storagePath;
127
+ }
128
+ }
@@ -0,0 +1,5 @@
1
+ export type { IdentityBinding, IdentityRecord, IdentityState, IdentityToken, IIdentityRegistry, } from './types.js';
2
+ export { IDENTITY_STATES, isIdentityState } from './types.js';
3
+ export { IdentityRegistryToken } from '../descriptor/tokens.js';
4
+ export { IdentityRegistryCorruptError, IdentityRegistryError, IdentityRegistryFrozenError, IdentityRegistryInputError, IdentityRegistryMissingError, IdentityRegistryNotReadyError, IdentityRegistryPathError, IdentityRegistryRevokedError, IdentityRegistryStorageExistsError, IdentityRegistryUnknownTokenError, IdentityRegistryWriteError, } from './errors.js';
5
+ export type { IdentityRegistryErrorCode } from './errors.js';
@@ -0,0 +1,3 @@
1
+ export { IDENTITY_STATES, isIdentityState } from './types.js';
2
+ export { IdentityRegistryToken } from '../descriptor/tokens.js';
3
+ export { IdentityRegistryCorruptError, IdentityRegistryError, IdentityRegistryFrozenError, IdentityRegistryInputError, IdentityRegistryMissingError, IdentityRegistryNotReadyError, IdentityRegistryPathError, IdentityRegistryRevokedError, IdentityRegistryStorageExistsError, IdentityRegistryUnknownTokenError, IdentityRegistryWriteError, } from './errors.js';
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Public types for the kernel-owned identity registry.
3
+ *
4
+ * The registry records opaque values. It does not interpret a publisher, a
5
+ * content hash, or a metadata record; it stores what the boot-time issuer
6
+ * supplies and returns the same values on resolve.
7
+ */
8
+ /** Opaque token issued by the registry. It is not a credential. */
9
+ export type IdentityToken = string;
10
+ /** Lifecycle state of one recorded identity. */
11
+ export declare const IDENTITY_STATES: readonly ["active", "retired", "revoked"];
12
+ /** Lifecycle state of one recorded identity. */
13
+ export type IdentityState = (typeof IDENTITY_STATES)[number];
14
+ /** Opaque values the boot-time issuer records against a token. */
15
+ export interface IdentityBinding {
16
+ /** Opaque publisher identifier. Never verified or interpreted here. */
17
+ readonly publisher: string;
18
+ /** Opaque content hash. Never verified or interpreted here. */
19
+ readonly contentHash: string;
20
+ /** Opaque JSON metadata record. */
21
+ readonly metadata: Readonly<Record<string, unknown>>;
22
+ }
23
+ /** A token together with the binding it was issued for. */
24
+ export interface IdentityRecord extends IdentityBinding {
25
+ /** Registry-issued opaque token. */
26
+ readonly token: IdentityToken;
27
+ /** Current lifecycle state. */
28
+ readonly state: IdentityState;
29
+ }
30
+ /**
31
+ * Identity registry contract.
32
+ *
33
+ * The four operations are the only mutation and read paths. `issue`, `retire`,
34
+ * and `revoke` are available only during the boot window; the service freezes
35
+ * itself when the kernel reaches `RUNNING`. `resolve` remains available.
36
+ */
37
+ export interface IIdentityRegistry {
38
+ /**
39
+ * Issues a token for an opaque binding, or returns the existing one.
40
+ *
41
+ * The same publisher and content hash always return the same token. A
42
+ * retired binding is reclaimed by reactivating its token. A revoked binding
43
+ * is never reissued.
44
+ *
45
+ * @param binding - Opaque publisher, content hash, and metadata.
46
+ * @returns The active record for the binding.
47
+ */
48
+ issue(binding: IdentityBinding): IdentityRecord;
49
+ /**
50
+ * Resolves a token to its recorded binding.
51
+ *
52
+ * @param token - Opaque token value.
53
+ * @returns The recorded binding, including its lifecycle state, or `null`
54
+ * when the token is unknown.
55
+ */
56
+ resolve(token: IdentityToken): IdentityRecord | null;
57
+ /**
58
+ * Marks a token inactive while preserving its record.
59
+ *
60
+ * @param token - Opaque token value.
61
+ * @returns The retired record.
62
+ */
63
+ retire(token: IdentityToken): IdentityRecord;
64
+ /**
65
+ * Revokes a token permanently. A revoked binding is never reissued.
66
+ *
67
+ * @param token - Opaque token value.
68
+ * @returns The revoked record.
69
+ */
70
+ revoke(token: IdentityToken): IdentityRecord;
71
+ }
72
+ /**
73
+ * Reports whether a value is a supported identity state.
74
+ *
75
+ * @param value - Candidate value.
76
+ */
77
+ export declare function isIdentityState(value: unknown): value is IdentityState;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Public types for the kernel-owned identity registry.
3
+ *
4
+ * The registry records opaque values. It does not interpret a publisher, a
5
+ * content hash, or a metadata record; it stores what the boot-time issuer
6
+ * supplies and returns the same values on resolve.
7
+ */
8
+ /** Lifecycle state of one recorded identity. */
9
+ export const IDENTITY_STATES = ['active', 'retired', 'revoked'];
10
+ /**
11
+ * Reports whether a value is a supported identity state.
12
+ *
13
+ * @param value - Candidate value.
14
+ */
15
+ export function isIdentityState(value) {
16
+ return typeof value === 'string'
17
+ && IDENTITY_STATES.includes(value);
18
+ }