@appport/sdk 1.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 (387) hide show
  1. package/LICENSE +126 -0
  2. package/README.md +39 -0
  3. package/dist/index.d.ts +14 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +14 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/node.d.ts +3 -0
  8. package/dist/node.d.ts.map +1 -0
  9. package/dist/node.js +3 -0
  10. package/dist/node.js.map +1 -0
  11. package/node_modules/@appport/authorization/README.md +28 -0
  12. package/node_modules/@appport/authorization/dist/index.d.ts +94 -0
  13. package/node_modules/@appport/authorization/dist/index.d.ts.map +1 -0
  14. package/node_modules/@appport/authorization/dist/index.js +131 -0
  15. package/node_modules/@appport/authorization/dist/index.js.map +1 -0
  16. package/node_modules/@appport/authorization/package.json +28 -0
  17. package/node_modules/@appport/client/README.md +35 -0
  18. package/node_modules/@appport/client/dist/channel.d.ts +14 -0
  19. package/node_modules/@appport/client/dist/channel.d.ts.map +1 -0
  20. package/node_modules/@appport/client/dist/channel.js +58 -0
  21. package/node_modules/@appport/client/dist/channel.js.map +1 -0
  22. package/node_modules/@appport/client/dist/client.d.ts +61 -0
  23. package/node_modules/@appport/client/dist/client.d.ts.map +1 -0
  24. package/node_modules/@appport/client/dist/client.js +214 -0
  25. package/node_modules/@appport/client/dist/client.js.map +1 -0
  26. package/node_modules/@appport/client/dist/contract.d.ts +55 -0
  27. package/node_modules/@appport/client/dist/contract.d.ts.map +1 -0
  28. package/node_modules/@appport/client/dist/contract.js +12 -0
  29. package/node_modules/@appport/client/dist/contract.js.map +1 -0
  30. package/node_modules/@appport/client/dist/discovery.d.ts +17 -0
  31. package/node_modules/@appport/client/dist/discovery.d.ts.map +1 -0
  32. package/node_modules/@appport/client/dist/discovery.js +56 -0
  33. package/node_modules/@appport/client/dist/discovery.js.map +1 -0
  34. package/node_modules/@appport/client/dist/duplex.d.ts +25 -0
  35. package/node_modules/@appport/client/dist/duplex.d.ts.map +1 -0
  36. package/node_modules/@appport/client/dist/duplex.js +194 -0
  37. package/node_modules/@appport/client/dist/duplex.js.map +1 -0
  38. package/node_modules/@appport/client/dist/index.d.ts +13 -0
  39. package/node_modules/@appport/client/dist/index.d.ts.map +1 -0
  40. package/node_modules/@appport/client/dist/index.js +13 -0
  41. package/node_modules/@appport/client/dist/index.js.map +1 -0
  42. package/node_modules/@appport/client/dist/transport.d.ts +42 -0
  43. package/node_modules/@appport/client/dist/transport.d.ts.map +1 -0
  44. package/node_modules/@appport/client/dist/transport.js +2 -0
  45. package/node_modules/@appport/client/dist/transport.js.map +1 -0
  46. package/node_modules/@appport/client/package.json +32 -0
  47. package/node_modules/@appport/core/README.md +91 -0
  48. package/node_modules/@appport/core/dist/appboundry-contract.d.ts +80 -0
  49. package/node_modules/@appport/core/dist/appboundry-contract.d.ts.map +1 -0
  50. package/node_modules/@appport/core/dist/appboundry-contract.js +160 -0
  51. package/node_modules/@appport/core/dist/appboundry-contract.js.map +1 -0
  52. package/node_modules/@appport/core/dist/application-implementation.d.ts +125 -0
  53. package/node_modules/@appport/core/dist/application-implementation.d.ts.map +1 -0
  54. package/node_modules/@appport/core/dist/application-implementation.js +220 -0
  55. package/node_modules/@appport/core/dist/application-implementation.js.map +1 -0
  56. package/node_modules/@appport/core/dist/application-lifecycle.d.ts +150 -0
  57. package/node_modules/@appport/core/dist/application-lifecycle.d.ts.map +1 -0
  58. package/node_modules/@appport/core/dist/application-lifecycle.js +70 -0
  59. package/node_modules/@appport/core/dist/application-lifecycle.js.map +1 -0
  60. package/node_modules/@appport/core/dist/application-source.d.ts +109 -0
  61. package/node_modules/@appport/core/dist/application-source.d.ts.map +1 -0
  62. package/node_modules/@appport/core/dist/application-source.js +186 -0
  63. package/node_modules/@appport/core/dist/application-source.js.map +1 -0
  64. package/node_modules/@appport/core/dist/application.d.ts +122 -0
  65. package/node_modules/@appport/core/dist/application.d.ts.map +1 -0
  66. package/node_modules/@appport/core/dist/application.js +515 -0
  67. package/node_modules/@appport/core/dist/application.js.map +1 -0
  68. package/node_modules/@appport/core/dist/artifact.d.ts +395 -0
  69. package/node_modules/@appport/core/dist/artifact.d.ts.map +1 -0
  70. package/node_modules/@appport/core/dist/artifact.js +392 -0
  71. package/node_modules/@appport/core/dist/artifact.js.map +1 -0
  72. package/node_modules/@appport/core/dist/assembly.d.ts +237 -0
  73. package/node_modules/@appport/core/dist/assembly.d.ts.map +1 -0
  74. package/node_modules/@appport/core/dist/assembly.js +458 -0
  75. package/node_modules/@appport/core/dist/assembly.js.map +1 -0
  76. package/node_modules/@appport/core/dist/authority-attestation.d.ts +34 -0
  77. package/node_modules/@appport/core/dist/authority-attestation.d.ts.map +1 -0
  78. package/node_modules/@appport/core/dist/authority-attestation.js +72 -0
  79. package/node_modules/@appport/core/dist/authority-attestation.js.map +1 -0
  80. package/node_modules/@appport/core/dist/authorization-grant.d.ts +107 -0
  81. package/node_modules/@appport/core/dist/authorization-grant.d.ts.map +1 -0
  82. package/node_modules/@appport/core/dist/authorization-grant.js +131 -0
  83. package/node_modules/@appport/core/dist/authorization-grant.js.map +1 -0
  84. package/node_modules/@appport/core/dist/binding.d.ts +294 -0
  85. package/node_modules/@appport/core/dist/binding.d.ts.map +1 -0
  86. package/node_modules/@appport/core/dist/binding.js +263 -0
  87. package/node_modules/@appport/core/dist/binding.js.map +1 -0
  88. package/node_modules/@appport/core/dist/builtins.d.ts +18 -0
  89. package/node_modules/@appport/core/dist/builtins.d.ts.map +1 -0
  90. package/node_modules/@appport/core/dist/builtins.js +38 -0
  91. package/node_modules/@appport/core/dist/builtins.js.map +1 -0
  92. package/node_modules/@appport/core/dist/capability.d.ts +94 -0
  93. package/node_modules/@appport/core/dist/capability.d.ts.map +1 -0
  94. package/node_modules/@appport/core/dist/capability.js +85 -0
  95. package/node_modules/@appport/core/dist/capability.js.map +1 -0
  96. package/node_modules/@appport/core/dist/concurrency.d.ts +16 -0
  97. package/node_modules/@appport/core/dist/concurrency.d.ts.map +1 -0
  98. package/node_modules/@appport/core/dist/concurrency.js +46 -0
  99. package/node_modules/@appport/core/dist/concurrency.js.map +1 -0
  100. package/node_modules/@appport/core/dist/context.d.ts +59 -0
  101. package/node_modules/@appport/core/dist/context.d.ts.map +1 -0
  102. package/node_modules/@appport/core/dist/context.js +14 -0
  103. package/node_modules/@appport/core/dist/context.js.map +1 -0
  104. package/node_modules/@appport/core/dist/contract-artifact.d.ts +15 -0
  105. package/node_modules/@appport/core/dist/contract-artifact.d.ts.map +1 -0
  106. package/node_modules/@appport/core/dist/contract-artifact.js +152 -0
  107. package/node_modules/@appport/core/dist/contract-artifact.js.map +1 -0
  108. package/node_modules/@appport/core/dist/contract-attestation.d.ts +68 -0
  109. package/node_modules/@appport/core/dist/contract-attestation.d.ts.map +1 -0
  110. package/node_modules/@appport/core/dist/contract-attestation.js +76 -0
  111. package/node_modules/@appport/core/dist/contract-attestation.js.map +1 -0
  112. package/node_modules/@appport/core/dist/crash-injection.d.ts +3 -0
  113. package/node_modules/@appport/core/dist/crash-injection.d.ts.map +1 -0
  114. package/node_modules/@appport/core/dist/crash-injection.js +8 -0
  115. package/node_modules/@appport/core/dist/crash-injection.js.map +1 -0
  116. package/node_modules/@appport/core/dist/events.d.ts +33 -0
  117. package/node_modules/@appport/core/dist/events.d.ts.map +1 -0
  118. package/node_modules/@appport/core/dist/events.js +79 -0
  119. package/node_modules/@appport/core/dist/events.js.map +1 -0
  120. package/node_modules/@appport/core/dist/execution-barrier.d.ts +13 -0
  121. package/node_modules/@appport/core/dist/execution-barrier.d.ts.map +1 -0
  122. package/node_modules/@appport/core/dist/execution-barrier.js +33 -0
  123. package/node_modules/@appport/core/dist/execution-barrier.js.map +1 -0
  124. package/node_modules/@appport/core/dist/execution-ledger.d.ts +81 -0
  125. package/node_modules/@appport/core/dist/execution-ledger.d.ts.map +1 -0
  126. package/node_modules/@appport/core/dist/execution-ledger.js +173 -0
  127. package/node_modules/@appport/core/dist/execution-ledger.js.map +1 -0
  128. package/node_modules/@appport/core/dist/execution.d.ts +387 -0
  129. package/node_modules/@appport/core/dist/execution.d.ts.map +1 -0
  130. package/node_modules/@appport/core/dist/execution.js +165 -0
  131. package/node_modules/@appport/core/dist/execution.js.map +1 -0
  132. package/node_modules/@appport/core/dist/idempotency.d.ts +36 -0
  133. package/node_modules/@appport/core/dist/idempotency.d.ts.map +1 -0
  134. package/node_modules/@appport/core/dist/idempotency.js +36 -0
  135. package/node_modules/@appport/core/dist/idempotency.js.map +1 -0
  136. package/node_modules/@appport/core/dist/implementation.d.ts +110 -0
  137. package/node_modules/@appport/core/dist/implementation.d.ts.map +1 -0
  138. package/node_modules/@appport/core/dist/implementation.js +65 -0
  139. package/node_modules/@appport/core/dist/implementation.js.map +1 -0
  140. package/node_modules/@appport/core/dist/index.d.ts +44 -0
  141. package/node_modules/@appport/core/dist/index.d.ts.map +1 -0
  142. package/node_modules/@appport/core/dist/index.js +44 -0
  143. package/node_modules/@appport/core/dist/index.js.map +1 -0
  144. package/node_modules/@appport/core/dist/invocation.d.ts +253 -0
  145. package/node_modules/@appport/core/dist/invocation.d.ts.map +1 -0
  146. package/node_modules/@appport/core/dist/invocation.js +258 -0
  147. package/node_modules/@appport/core/dist/invocation.js.map +1 -0
  148. package/node_modules/@appport/core/dist/manifest.d.ts +157 -0
  149. package/node_modules/@appport/core/dist/manifest.d.ts.map +1 -0
  150. package/node_modules/@appport/core/dist/manifest.js +255 -0
  151. package/node_modules/@appport/core/dist/manifest.js.map +1 -0
  152. package/node_modules/@appport/core/dist/memory-application-data-store.d.ts +19 -0
  153. package/node_modules/@appport/core/dist/memory-application-data-store.d.ts.map +1 -0
  154. package/node_modules/@appport/core/dist/memory-application-data-store.js +161 -0
  155. package/node_modules/@appport/core/dist/memory-application-data-store.js.map +1 -0
  156. package/node_modules/@appport/core/dist/operations.d.ts +61 -0
  157. package/node_modules/@appport/core/dist/operations.d.ts.map +1 -0
  158. package/node_modules/@appport/core/dist/operations.js +210 -0
  159. package/node_modules/@appport/core/dist/operations.js.map +1 -0
  160. package/node_modules/@appport/core/dist/public.d.ts +19 -0
  161. package/node_modules/@appport/core/dist/public.d.ts.map +1 -0
  162. package/node_modules/@appport/core/dist/public.js +18 -0
  163. package/node_modules/@appport/core/dist/public.js.map +1 -0
  164. package/node_modules/@appport/core/dist/registration.d.ts +165 -0
  165. package/node_modules/@appport/core/dist/registration.d.ts.map +1 -0
  166. package/node_modules/@appport/core/dist/registration.js +253 -0
  167. package/node_modules/@appport/core/dist/registration.js.map +1 -0
  168. package/node_modules/@appport/core/dist/registry.d.ts +29 -0
  169. package/node_modules/@appport/core/dist/registry.d.ts.map +1 -0
  170. package/node_modules/@appport/core/dist/registry.js +148 -0
  171. package/node_modules/@appport/core/dist/registry.js.map +1 -0
  172. package/node_modules/@appport/core/dist/repository-connection.d.ts +100 -0
  173. package/node_modules/@appport/core/dist/repository-connection.d.ts.map +1 -0
  174. package/node_modules/@appport/core/dist/repository-connection.js +57 -0
  175. package/node_modules/@appport/core/dist/repository-connection.js.map +1 -0
  176. package/node_modules/@appport/core/dist/resolver.d.ts +130 -0
  177. package/node_modules/@appport/core/dist/resolver.d.ts.map +1 -0
  178. package/node_modules/@appport/core/dist/resolver.js +252 -0
  179. package/node_modules/@appport/core/dist/resolver.js.map +1 -0
  180. package/node_modules/@appport/core/dist/runtime-manifest.d.ts +68 -0
  181. package/node_modules/@appport/core/dist/runtime-manifest.d.ts.map +1 -0
  182. package/node_modules/@appport/core/dist/runtime-manifest.js +84 -0
  183. package/node_modules/@appport/core/dist/runtime-manifest.js.map +1 -0
  184. package/node_modules/@appport/core/dist/sanitize.d.ts +14 -0
  185. package/node_modules/@appport/core/dist/sanitize.d.ts.map +1 -0
  186. package/node_modules/@appport/core/dist/sanitize.js +49 -0
  187. package/node_modules/@appport/core/dist/sanitize.js.map +1 -0
  188. package/node_modules/@appport/core/dist/server-internal.d.ts +5 -0
  189. package/node_modules/@appport/core/dist/server-internal.d.ts.map +1 -0
  190. package/node_modules/@appport/core/dist/server-internal.js +4 -0
  191. package/node_modules/@appport/core/dist/server-internal.js.map +1 -0
  192. package/node_modules/@appport/core/dist/sessions.d.ts +29 -0
  193. package/node_modules/@appport/core/dist/sessions.d.ts.map +1 -0
  194. package/node_modules/@appport/core/dist/sessions.js +39 -0
  195. package/node_modules/@appport/core/dist/sessions.js.map +1 -0
  196. package/node_modules/@appport/core/dist/sha256.d.ts +3 -0
  197. package/node_modules/@appport/core/dist/sha256.d.ts.map +1 -0
  198. package/node_modules/@appport/core/dist/sha256.js +46 -0
  199. package/node_modules/@appport/core/dist/sha256.js.map +1 -0
  200. package/node_modules/@appport/core/dist/source-verification.d.ts +53 -0
  201. package/node_modules/@appport/core/dist/source-verification.d.ts.map +1 -0
  202. package/node_modules/@appport/core/dist/source-verification.js +92 -0
  203. package/node_modules/@appport/core/dist/source-verification.js.map +1 -0
  204. package/node_modules/@appport/core/dist/state-context.d.ts +312 -0
  205. package/node_modules/@appport/core/dist/state-context.d.ts.map +1 -0
  206. package/node_modules/@appport/core/dist/state-context.js +100 -0
  207. package/node_modules/@appport/core/dist/state-context.js.map +1 -0
  208. package/node_modules/@appport/core/dist/state.d.ts +96 -0
  209. package/node_modules/@appport/core/dist/state.d.ts.map +1 -0
  210. package/node_modules/@appport/core/dist/state.js +89 -0
  211. package/node_modules/@appport/core/dist/state.js.map +1 -0
  212. package/node_modules/@appport/core/dist/streams.d.ts +38 -0
  213. package/node_modules/@appport/core/dist/streams.d.ts.map +1 -0
  214. package/node_modules/@appport/core/dist/streams.js +123 -0
  215. package/node_modules/@appport/core/dist/streams.js.map +1 -0
  216. package/node_modules/@appport/core/dist/telemetry.d.ts +42 -0
  217. package/node_modules/@appport/core/dist/telemetry.d.ts.map +1 -0
  218. package/node_modules/@appport/core/dist/telemetry.js +32 -0
  219. package/node_modules/@appport/core/dist/telemetry.js.map +1 -0
  220. package/node_modules/@appport/core/dist/wasm-engine.d.ts +22 -0
  221. package/node_modules/@appport/core/dist/wasm-engine.d.ts.map +1 -0
  222. package/node_modules/@appport/core/dist/wasm-engine.js +367 -0
  223. package/node_modules/@appport/core/dist/wasm-engine.js.map +1 -0
  224. package/node_modules/@appport/core/package.json +58 -0
  225. package/node_modules/@appport/mobile/README.md +10 -0
  226. package/node_modules/@appport/mobile/dist/index.d.ts +66 -0
  227. package/node_modules/@appport/mobile/dist/index.d.ts.map +1 -0
  228. package/node_modules/@appport/mobile/dist/index.js +182 -0
  229. package/node_modules/@appport/mobile/dist/index.js.map +1 -0
  230. package/node_modules/@appport/mobile/package.json +33 -0
  231. package/node_modules/@appport/protocol/README.md +41 -0
  232. package/node_modules/@appport/protocol/dist/blob.d.ts +46 -0
  233. package/node_modules/@appport/protocol/dist/blob.d.ts.map +1 -0
  234. package/node_modules/@appport/protocol/dist/blob.js +23 -0
  235. package/node_modules/@appport/protocol/dist/blob.js.map +1 -0
  236. package/node_modules/@appport/protocol/dist/compatibility.d.ts +25 -0
  237. package/node_modules/@appport/protocol/dist/compatibility.d.ts.map +1 -0
  238. package/node_modules/@appport/protocol/dist/compatibility.js +189 -0
  239. package/node_modules/@appport/protocol/dist/compatibility.js.map +1 -0
  240. package/node_modules/@appport/protocol/dist/envelopes.d.ts +175 -0
  241. package/node_modules/@appport/protocol/dist/envelopes.d.ts.map +1 -0
  242. package/node_modules/@appport/protocol/dist/envelopes.js +97 -0
  243. package/node_modules/@appport/protocol/dist/envelopes.js.map +1 -0
  244. package/node_modules/@appport/protocol/dist/errors.d.ts +74 -0
  245. package/node_modules/@appport/protocol/dist/errors.d.ts.map +1 -0
  246. package/node_modules/@appport/protocol/dist/errors.js +91 -0
  247. package/node_modules/@appport/protocol/dist/errors.js.map +1 -0
  248. package/node_modules/@appport/protocol/dist/ids.d.ts +12 -0
  249. package/node_modules/@appport/protocol/dist/ids.d.ts.map +1 -0
  250. package/node_modules/@appport/protocol/dist/ids.js +50 -0
  251. package/node_modules/@appport/protocol/dist/ids.js.map +1 -0
  252. package/node_modules/@appport/protocol/dist/index.d.ts +20 -0
  253. package/node_modules/@appport/protocol/dist/index.d.ts.map +1 -0
  254. package/node_modules/@appport/protocol/dist/index.js +20 -0
  255. package/node_modules/@appport/protocol/dist/index.js.map +1 -0
  256. package/node_modules/@appport/protocol/dist/jsonschema.d.ts +50 -0
  257. package/node_modules/@appport/protocol/dist/jsonschema.d.ts.map +1 -0
  258. package/node_modules/@appport/protocol/dist/jsonschema.js +6 -0
  259. package/node_modules/@appport/protocol/dist/jsonschema.js.map +1 -0
  260. package/node_modules/@appport/protocol/dist/manifest.d.ts +131 -0
  261. package/node_modules/@appport/protocol/dist/manifest.d.ts.map +1 -0
  262. package/node_modules/@appport/protocol/dist/manifest.js +20 -0
  263. package/node_modules/@appport/protocol/dist/manifest.js.map +1 -0
  264. package/node_modules/@appport/protocol/dist/names.d.ts +26 -0
  265. package/node_modules/@appport/protocol/dist/names.d.ts.map +1 -0
  266. package/node_modules/@appport/protocol/dist/names.js +85 -0
  267. package/node_modules/@appport/protocol/dist/names.js.map +1 -0
  268. package/node_modules/@appport/protocol/dist/operations.d.ts +34 -0
  269. package/node_modules/@appport/protocol/dist/operations.d.ts.map +1 -0
  270. package/node_modules/@appport/protocol/dist/operations.js +9 -0
  271. package/node_modules/@appport/protocol/dist/operations.js.map +1 -0
  272. package/node_modules/@appport/protocol/dist/session.d.ts +27 -0
  273. package/node_modules/@appport/protocol/dist/session.d.ts.map +1 -0
  274. package/node_modules/@appport/protocol/dist/session.js +7 -0
  275. package/node_modules/@appport/protocol/dist/session.js.map +1 -0
  276. package/node_modules/@appport/protocol/dist/validate.d.ts +37 -0
  277. package/node_modules/@appport/protocol/dist/validate.d.ts.map +1 -0
  278. package/node_modules/@appport/protocol/dist/validate.js +321 -0
  279. package/node_modules/@appport/protocol/dist/validate.js.map +1 -0
  280. package/node_modules/@appport/protocol/dist/version.d.ts +27 -0
  281. package/node_modules/@appport/protocol/dist/version.d.ts.map +1 -0
  282. package/node_modules/@appport/protocol/dist/version.js +26 -0
  283. package/node_modules/@appport/protocol/dist/version.js.map +1 -0
  284. package/node_modules/@appport/protocol/package.json +25 -0
  285. package/node_modules/@appport/schema/README.md +32 -0
  286. package/node_modules/@appport/schema/dist/builder.d.ts +85 -0
  287. package/node_modules/@appport/schema/dist/builder.d.ts.map +1 -0
  288. package/node_modules/@appport/schema/dist/builder.js +278 -0
  289. package/node_modules/@appport/schema/dist/builder.js.map +1 -0
  290. package/node_modules/@appport/schema/dist/from-json-schema.d.ts +12 -0
  291. package/node_modules/@appport/schema/dist/from-json-schema.d.ts.map +1 -0
  292. package/node_modules/@appport/schema/dist/from-json-schema.js +186 -0
  293. package/node_modules/@appport/schema/dist/from-json-schema.js.map +1 -0
  294. package/node_modules/@appport/schema/dist/index.d.ts +23 -0
  295. package/node_modules/@appport/schema/dist/index.d.ts.map +1 -0
  296. package/node_modules/@appport/schema/dist/index.js +22 -0
  297. package/node_modules/@appport/schema/dist/index.js.map +1 -0
  298. package/node_modules/@appport/schema/dist/standard.d.ts +46 -0
  299. package/node_modules/@appport/schema/dist/standard.d.ts.map +1 -0
  300. package/node_modules/@appport/schema/dist/standard.js +42 -0
  301. package/node_modules/@appport/schema/dist/standard.js.map +1 -0
  302. package/node_modules/@appport/schema/dist/types.d.ts +40 -0
  303. package/node_modules/@appport/schema/dist/types.d.ts.map +1 -0
  304. package/node_modules/@appport/schema/dist/types.js +19 -0
  305. package/node_modules/@appport/schema/dist/types.js.map +1 -0
  306. package/node_modules/@appport/schema/package.json +28 -0
  307. package/node_modules/@appport/server/README.md +39 -0
  308. package/node_modules/@appport/server/dist/connection.d.ts +45 -0
  309. package/node_modules/@appport/server/dist/connection.d.ts.map +1 -0
  310. package/node_modules/@appport/server/dist/connection.js +217 -0
  311. package/node_modules/@appport/server/dist/connection.js.map +1 -0
  312. package/node_modules/@appport/server/dist/fetch.d.ts +10 -0
  313. package/node_modules/@appport/server/dist/fetch.d.ts.map +1 -0
  314. package/node_modules/@appport/server/dist/fetch.js +50 -0
  315. package/node_modules/@appport/server/dist/fetch.js.map +1 -0
  316. package/node_modules/@appport/server/dist/http.d.ts +80 -0
  317. package/node_modules/@appport/server/dist/http.d.ts.map +1 -0
  318. package/node_modules/@appport/server/dist/http.js +306 -0
  319. package/node_modules/@appport/server/dist/http.js.map +1 -0
  320. package/node_modules/@appport/server/dist/index.d.ts +11 -0
  321. package/node_modules/@appport/server/dist/index.d.ts.map +1 -0
  322. package/node_modules/@appport/server/dist/index.js +11 -0
  323. package/node_modules/@appport/server/dist/index.js.map +1 -0
  324. package/node_modules/@appport/server/dist/node-entry.d.ts +4 -0
  325. package/node_modules/@appport/server/dist/node-entry.d.ts.map +1 -0
  326. package/node_modules/@appport/server/dist/node-entry.js +4 -0
  327. package/node_modules/@appport/server/dist/node-entry.js.map +1 -0
  328. package/node_modules/@appport/server/dist/node.d.ts +45 -0
  329. package/node_modules/@appport/server/dist/node.d.ts.map +1 -0
  330. package/node_modules/@appport/server/dist/node.js +190 -0
  331. package/node_modules/@appport/server/dist/node.js.map +1 -0
  332. package/node_modules/@appport/server/dist/server.d.ts +83 -0
  333. package/node_modules/@appport/server/dist/server.d.ts.map +1 -0
  334. package/node_modules/@appport/server/dist/server.js +114 -0
  335. package/node_modules/@appport/server/dist/server.js.map +1 -0
  336. package/node_modules/@appport/server/dist/websocket.d.ts +25 -0
  337. package/node_modules/@appport/server/dist/websocket.d.ts.map +1 -0
  338. package/node_modules/@appport/server/dist/websocket.js +221 -0
  339. package/node_modules/@appport/server/dist/websocket.js.map +1 -0
  340. package/node_modules/@appport/server/package.json +34 -0
  341. package/node_modules/@appport/transport-electron/README.md +56 -0
  342. package/node_modules/@appport/transport-electron/dist/index.d.ts +11 -0
  343. package/node_modules/@appport/transport-electron/dist/index.d.ts.map +1 -0
  344. package/node_modules/@appport/transport-electron/dist/index.js +11 -0
  345. package/node_modules/@appport/transport-electron/dist/index.js.map +1 -0
  346. package/node_modules/@appport/transport-electron/dist/main.d.ts +31 -0
  347. package/node_modules/@appport/transport-electron/dist/main.d.ts.map +1 -0
  348. package/node_modules/@appport/transport-electron/dist/main.js +61 -0
  349. package/node_modules/@appport/transport-electron/dist/main.js.map +1 -0
  350. package/node_modules/@appport/transport-electron/dist/preload.d.ts +22 -0
  351. package/node_modules/@appport/transport-electron/dist/preload.d.ts.map +1 -0
  352. package/node_modules/@appport/transport-electron/dist/preload.js +29 -0
  353. package/node_modules/@appport/transport-electron/dist/preload.js.map +1 -0
  354. package/node_modules/@appport/transport-electron/dist/renderer.d.ts +16 -0
  355. package/node_modules/@appport/transport-electron/dist/renderer.d.ts.map +1 -0
  356. package/node_modules/@appport/transport-electron/dist/renderer.js +36 -0
  357. package/node_modules/@appport/transport-electron/dist/renderer.js.map +1 -0
  358. package/node_modules/@appport/transport-electron/dist/types.d.ts +49 -0
  359. package/node_modules/@appport/transport-electron/dist/types.d.ts.map +1 -0
  360. package/node_modules/@appport/transport-electron/dist/types.js +5 -0
  361. package/node_modules/@appport/transport-electron/dist/types.js.map +1 -0
  362. package/node_modules/@appport/transport-electron/package.json +46 -0
  363. package/node_modules/@appport/transport-http/README.md +24 -0
  364. package/node_modules/@appport/transport-http/dist/index.d.ts +18 -0
  365. package/node_modules/@appport/transport-http/dist/index.d.ts.map +1 -0
  366. package/node_modules/@appport/transport-http/dist/index.js +223 -0
  367. package/node_modules/@appport/transport-http/dist/index.js.map +1 -0
  368. package/node_modules/@appport/transport-http/package.json +29 -0
  369. package/node_modules/@appport/transport-inprocess/README.md +24 -0
  370. package/node_modules/@appport/transport-inprocess/dist/index.d.ts +16 -0
  371. package/node_modules/@appport/transport-inprocess/dist/index.d.ts.map +1 -0
  372. package/node_modules/@appport/transport-inprocess/dist/index.js +30 -0
  373. package/node_modules/@appport/transport-inprocess/dist/index.js.map +1 -0
  374. package/node_modules/@appport/transport-inprocess/package.json +30 -0
  375. package/node_modules/@appport/transport-tauri/README.md +45 -0
  376. package/node_modules/@appport/transport-tauri/dist/index.d.ts +23 -0
  377. package/node_modules/@appport/transport-tauri/dist/index.d.ts.map +1 -0
  378. package/node_modules/@appport/transport-tauri/dist/index.js +44 -0
  379. package/node_modules/@appport/transport-tauri/dist/index.js.map +1 -0
  380. package/node_modules/@appport/transport-tauri/package.json +29 -0
  381. package/node_modules/@appport/transport-websocket/README.md +22 -0
  382. package/node_modules/@appport/transport-websocket/dist/index.d.ts +26 -0
  383. package/node_modules/@appport/transport-websocket/dist/index.d.ts.map +1 -0
  384. package/node_modules/@appport/transport-websocket/dist/index.js +72 -0
  385. package/node_modules/@appport/transport-websocket/dist/index.js.map +1 -0
  386. package/node_modules/@appport/transport-websocket/package.json +29 -0
  387. package/package.json +79 -0
@@ -0,0 +1,253 @@
1
+ /**
2
+ * Application Registry: FeltDB-backed application state management
3
+ *
4
+ * Handles registration, lookup, listing, and state persistence of
5
+ * tracked applications. Integrates with FeltDB via the adapter pattern.
6
+ *
7
+ * The registry is the authoritative source for:
8
+ * - Application identity and manifests
9
+ * - Fingerprints and verification state
10
+ * - Application lifecycle and revisions
11
+ * - Application discovery
12
+ */
13
+ import { createApplicationState, markApplicationActive, retireApplication, updateApplicationState } from "./state.js";
14
+ import { fingerprintManifest } from "./manifest.js";
15
+ /**
16
+ * In-memory application state store.
17
+ *
18
+ * Useful for testing and development without a persistent backend.
19
+ */
20
+ export class MemoryApplicationStateStore {
21
+ #states = new Map();
22
+ async get(id) {
23
+ return this.#states.get(id);
24
+ }
25
+ async put(state) {
26
+ this.#states.set(state.id, state);
27
+ }
28
+ async delete(id) {
29
+ this.#states.delete(id);
30
+ }
31
+ async list(options) {
32
+ let results = [...this.#states.values()];
33
+ if (options?.prefix) {
34
+ results = results.filter((s) => s.id.startsWith(options.prefix));
35
+ }
36
+ // Deterministic ordering by application ID
37
+ results.sort((a, b) => a.id.localeCompare(b.id));
38
+ if (options?.limit) {
39
+ results = results.slice(0, options.limit);
40
+ }
41
+ return results;
42
+ }
43
+ }
44
+ /**
45
+ * Application registry: manages registration, lookup, and tracking of
46
+ * applications via a persistent store.
47
+ *
48
+ * The registry enforces:
49
+ * - Only verified applications can be registered
50
+ * - Fingerprint verification for idempotency
51
+ * - No implementation persistence
52
+ * - Manifest as canonical contract
53
+ */
54
+ export class ApplicationRegistry {
55
+ #store;
56
+ constructor(store) {
57
+ this.#store = store;
58
+ }
59
+ /**
60
+ * Register a verified application.
61
+ *
62
+ * @param options - Identity, manifest, fingerprint, and verification state
63
+ * @returns The registered application state
64
+ *
65
+ * Throws if application is not verified or if registration is invalid.
66
+ */
67
+ async register(options) {
68
+ // Only verified applications can be registered
69
+ if (!options.verification.ready) {
70
+ throw new Error(`Cannot register application "${options.identity.id}": application is not verified. ` +
71
+ `Fix verification errors and try again.`);
72
+ }
73
+ const id = options.identity.id;
74
+ const existing = await this.#store.get(id);
75
+ // Idempotency: if application already registered with same fingerprint, return existing
76
+ if (existing) {
77
+ if (existing.fingerprint === options.fingerprint) {
78
+ // Idempotent: same contract, return existing state
79
+ return existing;
80
+ }
81
+ // Different contract: update to new revision
82
+ const updated = updateApplicationState(existing, {
83
+ manifest: options.manifest,
84
+ fingerprint: options.fingerprint,
85
+ verification: options.verification,
86
+ status: options.status
87
+ });
88
+ await this.#store.put(updated);
89
+ return updated;
90
+ }
91
+ // New registration: create initial state
92
+ const state = createApplicationState(options, 1);
93
+ await this.#store.put(state);
94
+ return state;
95
+ }
96
+ /**
97
+ * Register an application, validating manifest and fingerprint match.
98
+ *
99
+ * This is the same as {@link register} but additionally validates that
100
+ * the provided fingerprint matches the manifest hash.
101
+ *
102
+ * @throws If fingerprint does not match manifest
103
+ */
104
+ async registerWithValidation(options) {
105
+ const expectedFingerprint = fingerprintManifest(options.manifest);
106
+ if (options.fingerprint !== expectedFingerprint) {
107
+ throw new Error(`Registration validation failed: fingerprint mismatch for "${options.identity.id}". ` +
108
+ `Expected: ${expectedFingerprint}, got: ${options.fingerprint}`);
109
+ }
110
+ return this.register(options);
111
+ }
112
+ /**
113
+ * Retrieve a registered application by ID.
114
+ *
115
+ * @returns The application state, or undefined if not registered
116
+ */
117
+ async get(id) {
118
+ return this.#store.get(id);
119
+ }
120
+ /**
121
+ * Check if an application is registered.
122
+ */
123
+ async has(id) {
124
+ const state = await this.#store.get(id);
125
+ return state !== undefined;
126
+ }
127
+ /**
128
+ * List all registered applications.
129
+ *
130
+ * @param options - Query options (prefix, limit)
131
+ * @returns Array of registered application states
132
+ */
133
+ async list(options) {
134
+ return this.#store.list(options);
135
+ }
136
+ /**
137
+ * Find applications by name.
138
+ *
139
+ * Returns all versions of an application with the given name (deterministically sorted by ID).
140
+ */
141
+ async findByName(name) {
142
+ const all = await this.#store.list();
143
+ const results = all.filter((s) => s.name === name);
144
+ // Deterministic ordering by application ID
145
+ results.sort((a, b) => a.id.localeCompare(b.id));
146
+ return results;
147
+ }
148
+ /**
149
+ * Find the latest version of an application by name.
150
+ *
151
+ * Returns undefined if no application with this name is registered.
152
+ */
153
+ async getLatestByName(name) {
154
+ const all = await this.findByName(name);
155
+ if (all.length === 0)
156
+ return undefined;
157
+ // Sort by semantic version (simple comparison - assumes valid semver)
158
+ all.sort((a, b) => {
159
+ const aParts = a.version.split(".").map((p) => parseInt(p, 10));
160
+ const bParts = b.version.split(".").map((p) => parseInt(p, 10));
161
+ for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {
162
+ const aVal = aParts[i] ?? 0;
163
+ const bVal = bParts[i] ?? 0;
164
+ if (aVal !== bVal)
165
+ return bVal - aVal;
166
+ }
167
+ return 0;
168
+ });
169
+ return all[0];
170
+ }
171
+ /**
172
+ * Delete a registered application.
173
+ *
174
+ * This marks an application as no longer tracked. The state is
175
+ * permanently removed from storage.
176
+ */
177
+ async delete(id) {
178
+ await this.#store.delete(id);
179
+ }
180
+ /** Persist an authoritative activation transition. */
181
+ async activate(id) {
182
+ const state = await this.#store.get(id);
183
+ if (!state)
184
+ throw new Error(`Cannot activate unknown application "${id}"`);
185
+ if (state.status === "retired")
186
+ throw new Error(`Cannot activate retired application "${id}"`);
187
+ const active = markApplicationActive(state);
188
+ await this.#store.put(active);
189
+ return active;
190
+ }
191
+ /** Retire without deleting identity, contract, state, or history. */
192
+ async retire(id) {
193
+ const state = await this.#store.get(id);
194
+ if (!state)
195
+ throw new Error(`Cannot retire unknown application "${id}"`);
196
+ const retired = retireApplication(state);
197
+ await this.#store.put(retired);
198
+ return retired;
199
+ }
200
+ /**
201
+ * Find an application by its manifest fingerprint.
202
+ *
203
+ * @param fingerprint - SHA256 fingerprint of the manifest
204
+ * @returns Array of applications with matching fingerprint (deterministically sorted by ID)
205
+ *
206
+ * Note: Applications should have unique fingerprints in practice, but this method
207
+ * returns an array for consistency with other discovery methods.
208
+ */
209
+ async findByFingerprint(fingerprint) {
210
+ const all = await this.#store.list();
211
+ const results = all.filter((state) => state.fingerprint === fingerprint);
212
+ // Deterministic ordering by application ID
213
+ results.sort((a, b) => a.id.localeCompare(b.id));
214
+ return results;
215
+ }
216
+ /**
217
+ * Find applications that provide a given capability.
218
+ *
219
+ * @param name - Capability name (e.g., "invoices.read")
220
+ * @param version - Optional specific capability version. If omitted, matches any version of the capability.
221
+ * @returns Array of applications providing this capability (deterministically sorted by ID)
222
+ */
223
+ async findByCapability(name, version) {
224
+ const all = await this.#store.list();
225
+ const results = all.filter((state) => state.status !== "retired" && (() => {
226
+ return state.manifest.provides.some((cap) => {
227
+ return cap.name === name && (version === undefined || cap.version === version);
228
+ });
229
+ })());
230
+ // Deterministic ordering by application ID
231
+ results.sort((a, b) => a.id.localeCompare(b.id));
232
+ return results;
233
+ }
234
+ /**
235
+ * Find applications that require a given capability.
236
+ *
237
+ * @param name - Capability name (e.g., "invoices.read")
238
+ * @param version - Optional specific capability version. If omitted, matches any version of the requirement.
239
+ * @returns Array of applications requiring this capability (deterministically sorted by ID)
240
+ */
241
+ async findByRequirement(name, version) {
242
+ const all = await this.#store.list();
243
+ const results = all.filter((state) => {
244
+ return state.manifest.requires.some((req) => {
245
+ return req.name === name && (version === undefined || req.version === version);
246
+ });
247
+ });
248
+ // Deterministic ordering by application ID
249
+ results.sort((a, b) => a.id.localeCompare(b.id));
250
+ return results;
251
+ }
252
+ }
253
+ //# sourceMappingURL=registration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registration.js","sourceRoot":"","sources":["../src/registration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEtH,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAuCpD;;;;GAIG;AACH,MAAM,OAAO,2BAA2B;IAC7B,OAAO,GAAG,IAAI,GAAG,EAA4B,CAAC;IAEvD,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,KAAuB;QAC/B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAA6C;QACtD,IAAI,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QACzC,IAAI,OAAO,EAAE,MAAM,EAAE,CAAC;YACpB,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,MAAO,CAAC,CAAC,CAAC;QACpE,CAAC;QACD,2CAA2C;QAC3C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CA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,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACnC,OAAO,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;gBAC1C,OAAO,GAAG,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,GAAG,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;YACjF,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,2CAA2C;QAC3C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACjD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
@@ -0,0 +1,29 @@
1
+ import { type AppPortManifest, type ApplicationDescriptor, type CapabilityManifestEntry, type EventManifestEntry, type TransportDescriptor } from "@appport/protocol";
2
+ import type { AnyCapability, AnyEvent, CapabilityDefinition, EventDefinition } from "./capability.js";
3
+ /**
4
+ * The capability registry: the authoritative set of capabilities and events an
5
+ * application exposes, and the source of its manifest (§30).
6
+ */
7
+ export declare class CapabilityRegistry {
8
+ #private;
9
+ register<Input, Output>(input: CapabilityDefinition<Input, Output>): this;
10
+ registerEvent<Payload>(input: EventDefinition<Payload>): this;
11
+ has(name: string, version?: number): boolean;
12
+ /** Resolves a capability, or throws the correct protocol error (§15). */
13
+ resolve(name: string, version: number): AnyCapability;
14
+ getEvent(name: string, version?: number): AnyEvent | undefined;
15
+ capabilities(): AnyCapability[];
16
+ events(): AnyEvent[];
17
+ capabilityNames(): string[];
18
+ /** Renders the manifest entries for every registered capability. */
19
+ capabilityEntries(): CapabilityManifestEntry[];
20
+ eventEntries(): EventManifestEntry[];
21
+ /** Builds the full application manifest (§30). */
22
+ manifest(options: {
23
+ application: ApplicationDescriptor;
24
+ transports?: TransportDescriptor[];
25
+ extensions?: string[];
26
+ conformance?: AppPortManifest["conformance"];
27
+ }): AppPortManifest;
28
+ }
29
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAE5B,KAAK,kBAAkB,EAEvB,KAAK,mBAAmB,EAGzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEtG;;;GAGG;AACH,qBAAa,kBAAkB;;IAI7B,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,IAAI;IAiBzE,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,IAAI;IAW7D,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO;IAM5C,yEAAyE;IACzE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa;IAUrD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAU9D,YAAY,IAAI,aAAa,EAAE;IAI/B,MAAM,IAAI,QAAQ,EAAE;IAIpB,eAAe,IAAI,MAAM,EAAE;IAI3B,oEAAoE;IACpE,iBAAiB,IAAI,uBAAuB,EAAE;IAoC9C,YAAY,IAAI,kBAAkB,EAAE;IA0BpC,kDAAkD;IAClD,QAAQ,CAAC,OAAO,EAAE;QAChB,WAAW,EAAE,qBAAqB,CAAC;QACnC,UAAU,CAAC,EAAE,mBAAmB,EAAE,CAAC;QACnC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QACtB,WAAW,CAAC,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;KAC9C,GAAG,eAAe;CAiBpB"}
@@ -0,0 +1,148 @@
1
+ import { errors, CONFORMANCE_LEVELS, PROTOCOL_ID } from "@appport/protocol";
2
+ /**
3
+ * The capability registry: the authoritative set of capabilities and events an
4
+ * application exposes, and the source of its manifest (§30).
5
+ */
6
+ export class CapabilityRegistry {
7
+ #capabilities = new Map();
8
+ #events = new Map();
9
+ register(input) {
10
+ const definition = input;
11
+ const versions = this.#capabilities.get(definition.name) ?? new Map();
12
+ if (versions.has(definition.version)) {
13
+ throw errors.conflict(`Capability ${definition.name}@${definition.version} is already registered`);
14
+ }
15
+ const existing = [...versions.values()][0];
16
+ if (existing && existing.kind !== definition.kind) {
17
+ throw errors.conflict(`Capability ${definition.name} cannot mix "${existing.kind}" and "${definition.kind}" versions`);
18
+ }
19
+ versions.set(definition.version, definition);
20
+ this.#capabilities.set(definition.name, versions);
21
+ return this;
22
+ }
23
+ registerEvent(input) {
24
+ const definition = input;
25
+ const versions = this.#events.get(definition.name) ?? new Map();
26
+ if (versions.has(definition.version)) {
27
+ throw errors.conflict(`Event ${definition.name}@${definition.version} is already registered`);
28
+ }
29
+ versions.set(definition.version, definition);
30
+ this.#events.set(definition.name, versions);
31
+ return this;
32
+ }
33
+ has(name, version) {
34
+ const versions = this.#capabilities.get(name);
35
+ if (!versions)
36
+ return false;
37
+ return version === undefined ? versions.size > 0 : versions.has(version);
38
+ }
39
+ /** Resolves a capability, or throws the correct protocol error (§15). */
40
+ resolve(name, version) {
41
+ const versions = this.#capabilities.get(name);
42
+ if (!versions || versions.size === 0)
43
+ throw errors.unknownCapability(name);
44
+ const definition = versions.get(version);
45
+ if (!definition) {
46
+ throw errors.unsupportedCapabilityVersion(name, version, [...versions.keys()].sort((a, b) => a - b));
47
+ }
48
+ return definition;
49
+ }
50
+ getEvent(name, version) {
51
+ const versions = this.#events.get(name);
52
+ if (!versions || versions.size === 0)
53
+ return undefined;
54
+ if (version === undefined) {
55
+ const latest = Math.max(...versions.keys());
56
+ return versions.get(latest);
57
+ }
58
+ return versions.get(version);
59
+ }
60
+ capabilities() {
61
+ return [...this.#capabilities.values()].flatMap((versions) => [...versions.values()]);
62
+ }
63
+ events() {
64
+ return [...this.#events.values()].flatMap((versions) => [...versions.values()]);
65
+ }
66
+ capabilityNames() {
67
+ return [...this.#capabilities.keys()].sort();
68
+ }
69
+ /** Renders the manifest entries for every registered capability. */
70
+ capabilityEntries() {
71
+ const entries = [];
72
+ for (const [name, versions] of [...this.#capabilities.entries()].sort(([a], [b]) => a.localeCompare(b))) {
73
+ const definitions = [...versions.values()]
74
+ .sort((a, b) => a.version - b.version)
75
+ .map((definition) => ({
76
+ version: definition.version,
77
+ ...(definition.description ? { description: definition.description } : {}),
78
+ kind: definition.kind,
79
+ inputSchema: definition.input.toJSONSchema(),
80
+ outputSchema: definition.output.toJSONSchema(),
81
+ authorization: [...definition.authorization],
82
+ idempotency: definition.idempotency,
83
+ concurrency: definition.concurrency,
84
+ ...(definition.timeoutMs !== undefined ? { timeoutMs: definition.timeoutMs } : {}),
85
+ ...(definition.deprecated ? { deprecated: true } : {}),
86
+ ...(definition.emits.length ? { emits: [...definition.emits] } : {})
87
+ }));
88
+ const preferred = [...definitions].reverse().find((entry) => !entry.deprecated) ?? definitions[definitions.length - 1];
89
+ entries.push({
90
+ name,
91
+ versions: definitions.map((entry) => entry.version),
92
+ latestVersion: preferred.version,
93
+ ...(preferred.description ? { description: preferred.description } : {}),
94
+ kind: preferred.kind,
95
+ inputSchema: preferred.inputSchema,
96
+ outputSchema: preferred.outputSchema,
97
+ authorization: preferred.authorization,
98
+ ...(preferred.idempotency ? { idempotency: preferred.idempotency } : {}),
99
+ ...(preferred.concurrency ? { concurrency: preferred.concurrency } : {}),
100
+ definitions
101
+ });
102
+ }
103
+ return entries;
104
+ }
105
+ eventEntries() {
106
+ const entries = [];
107
+ for (const [name, versions] of [...this.#events.entries()].sort(([a], [b]) => a.localeCompare(b))) {
108
+ const definitions = [...versions.values()]
109
+ .sort((a, b) => a.version - b.version)
110
+ .map((definition) => ({
111
+ version: definition.version,
112
+ ...(definition.description ? { description: definition.description } : {}),
113
+ payloadSchema: definition.payload.toJSONSchema(),
114
+ authorization: [...definition.authorization],
115
+ ...(definition.deprecated ? { deprecated: true } : {})
116
+ }));
117
+ const preferred = [...definitions].reverse().find((entry) => !entry.deprecated) ?? definitions[definitions.length - 1];
118
+ entries.push({
119
+ name,
120
+ versions: definitions.map((entry) => entry.version),
121
+ latestVersion: preferred.version,
122
+ ...(preferred.description ? { description: preferred.description } : {}),
123
+ payloadSchema: preferred.payloadSchema,
124
+ authorization: preferred.authorization,
125
+ definitions
126
+ });
127
+ }
128
+ return entries;
129
+ }
130
+ /** Builds the full application manifest (§30). */
131
+ manifest(options) {
132
+ const capabilities = this.capabilityEntries();
133
+ const events = this.eventEntries();
134
+ const hasStreams = capabilities.some((entry) => entry.kind === "stream");
135
+ const conformance = options.conformance ??
136
+ (hasStreams ? CONFORMANCE_LEVELS.streams : events.length > 0 ? CONFORMANCE_LEVELS.events : CONFORMANCE_LEVELS.core);
137
+ return {
138
+ protocol: PROTOCOL_ID,
139
+ application: options.application,
140
+ capabilities,
141
+ events,
142
+ transports: options.transports ?? [],
143
+ conformance,
144
+ ...(options.extensions?.length ? { extensions: options.extensions } : {})
145
+ };
146
+ }
147
+ }
148
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EAQN,kBAAkB,EAClB,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAG3B;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IACpB,aAAa,GAAG,IAAI,GAAG,EAAsC,CAAC;IAC9D,OAAO,GAAG,IAAI,GAAG,EAAiC,CAAC;IAE5D,QAAQ,CAAgB,KAA0C;QAChE,MAAM,UAAU,GA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CAAC,iBAAiB,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QACnC,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;QACzE,MAAM,WAAW,GACf,OAAO,CAAC,WAAW;YACnB,CAAC,UAAU,CAAC,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACtH,OAAO;YACL,QAAQ,EAAE,WAAW;YACrB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,YAAY;YACZ,MAAM;YACN,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE;YACpC,WAAW;YACX,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1E,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,100 @@
1
+ import { type ApplicationManifest } from "./manifest.js";
2
+ export type RepositoryConnectionMethod = "github" | "git-ci" | "local";
3
+ export type RepositoryConnectionStatus = "CONNECTED" | "MISMATCHED" | "DISCONNECTED";
4
+ export interface RepositoryIdentity {
5
+ readonly provider: "github" | "git" | "local";
6
+ readonly repositoryId?: string;
7
+ readonly owner?: string;
8
+ readonly name?: string;
9
+ readonly remoteUrl: string;
10
+ }
11
+ export interface ImplementedCapability {
12
+ readonly name: string;
13
+ readonly version: number;
14
+ }
15
+ export interface CapabilityImplementationAttestation {
16
+ readonly implementationId: string;
17
+ readonly sourceConnectionId: string;
18
+ readonly capabilityName: string;
19
+ readonly capabilityVersion: number;
20
+ }
21
+ export interface RepositoryObservation {
22
+ readonly repository: RepositoryIdentity;
23
+ readonly ref: string;
24
+ readonly commitSha?: string;
25
+ readonly manifest: ApplicationManifest;
26
+ readonly implementedCapabilities?: readonly ImplementedCapability[];
27
+ }
28
+ export interface RepositoryVerification {
29
+ readonly verificationId: string;
30
+ readonly verifiedAt: string;
31
+ readonly observedFingerprint: string;
32
+ readonly authoritativeFingerprint: string;
33
+ readonly identityMatches: boolean;
34
+ readonly contractMatches: boolean;
35
+ readonly reasons: readonly string[];
36
+ }
37
+ export interface RepositoryConnectionEvent {
38
+ readonly eventId: string;
39
+ readonly sequence: number;
40
+ readonly type: "CONNECTED" | "VERIFICATION_FAILED" | "REVERIFIED" | "DISCONNECTED";
41
+ readonly occurredAt: string;
42
+ readonly status: RepositoryConnectionStatus;
43
+ readonly observedFingerprint: string;
44
+ }
45
+ export interface RepositoryConnectionRecord {
46
+ readonly connectionId: string;
47
+ readonly applicationId: string;
48
+ readonly method: RepositoryConnectionMethod;
49
+ readonly status: RepositoryConnectionStatus;
50
+ readonly sequence: number;
51
+ readonly repository: RepositoryIdentity;
52
+ readonly ref: string;
53
+ readonly commitSha?: string;
54
+ readonly implementations: readonly CapabilityImplementationAttestation[];
55
+ readonly contractFingerprint: string;
56
+ readonly observedFingerprint: string;
57
+ readonly lastVerifiedAt: string;
58
+ readonly verification: RepositoryVerification;
59
+ readonly history: readonly RepositoryConnectionEvent[];
60
+ }
61
+ export interface RepositoryConnectionStore {
62
+ get(applicationId: string, connectionId: string): Promise<RepositoryConnectionRecord | undefined>;
63
+ put(record: RepositoryConnectionRecord, expectedSequence?: number): Promise<void>;
64
+ list(applicationId?: string): Promise<RepositoryConnectionRecord[]>;
65
+ }
66
+ export interface AuthoritativeApplicationContract {
67
+ get(applicationId: string): Promise<{
68
+ fingerprint: string;
69
+ manifest: ApplicationManifest;
70
+ } | undefined>;
71
+ }
72
+ export declare class RepositoryConnectionConflictError extends Error {
73
+ constructor(id: string);
74
+ }
75
+ export declare class MemoryRepositoryConnectionStore implements RepositoryConnectionStore {
76
+ #private;
77
+ get(applicationId: string, connectionId: string): Promise<RepositoryConnectionRecord | undefined>;
78
+ put(record: RepositoryConnectionRecord, expected?: number): Promise<void>;
79
+ list(applicationId?: string): Promise<RepositoryConnectionRecord[]>;
80
+ }
81
+ /** Manufactures connection facts only after comparing repository evidence with authority. */
82
+ export declare class RepositoryConnectionOperations {
83
+ private readonly store;
84
+ private readonly authority;
85
+ private readonly now;
86
+ constructor(store: RepositoryConnectionStore, authority: AuthoritativeApplicationContract, now?: () => string);
87
+ connect(applicationId: string, method: RepositoryConnectionMethod, observation: RepositoryObservation): Promise<RepositoryConnectionRecord>;
88
+ verify(applicationId: string, connectionId: string, observation: RepositoryObservation): Promise<RepositoryConnectionRecord>;
89
+ disconnect(applicationId: string, connectionId: string): Promise<RepositoryConnectionRecord>;
90
+ get: (applicationId: string, connectionId: string) => Promise<RepositoryConnectionRecord | undefined>;
91
+ list: (applicationId?: string) => Promise<RepositoryConnectionRecord[]>;
92
+ private check;
93
+ private verification;
94
+ private event;
95
+ private required;
96
+ private validateRepository;
97
+ private implementations;
98
+ private implementation;
99
+ }
100
+ //# sourceMappingURL=repository-connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository-connection.d.ts","sourceRoot":"","sources":["../src/repository-connection.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE9E,MAAM,MAAM,0BAA0B,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AACvE,MAAM,MAAM,0BAA0B,GAAG,WAAW,GAAG,YAAY,GAAG,cAAc,CAAC;AACrF,MAAM,WAAW,kBAAkB;IAAG,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAC;IAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ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epositoryConnectionConflictError extends Error {
4
+ constructor(id) { super(`Concurrent repository connection update rejected for "${id}"`); this.name = "RepositoryConnectionConflictError"; }
5
+ }
6
+ export class MemoryRepositoryConnectionStore {
7
+ #records = new Map();
8
+ async get(applicationId, connectionId) { const value = this.#records.get(`${applicationId}:${connectionId}`); return value && structuredClone(value); }
9
+ async put(record, expected) { const key = `${record.applicationId}:${record.connectionId}`, current = this.#records.get(key); if (current?.sequence !== expected)
10
+ throw new RepositoryConnectionConflictError(record.connectionId); this.#records.set(key, structuredClone(record)); }
11
+ async list(applicationId) { return [...this.#records.values()].filter(item => !applicationId || item.applicationId === applicationId).map(item => structuredClone(item)); }
12
+ }
13
+ /** Manufactures connection facts only after comparing repository evidence with authority. */
14
+ export class RepositoryConnectionOperations {
15
+ store;
16
+ authority;
17
+ now;
18
+ constructor(store, authority, now = () => new Date().toISOString()) {
19
+ this.store = store;
20
+ this.authority = authority;
21
+ this.now = now;
22
+ }
23
+ async connect(applicationId, method, observation) {
24
+ this.validateRepository(method, observation.repository);
25
+ const implementedCapabilities = this.implementations(observation), checked = await this.check(applicationId, observation.manifest, implementedCapabilities), at = this.now(), connectionId = `conn_${randomUUID()}`, status = checked.reasons.length ? "MISMATCHED" : "CONNECTED";
26
+ const implementations = status === "CONNECTED" ? implementedCapabilities.map(item => this.implementation(connectionId, item)) : [], verification = this.verification(checked, at), record = { connectionId, applicationId, method, status, sequence: 1, repository: structuredClone(observation.repository), ref: observation.ref, ...(observation.commitSha ? { commitSha: observation.commitSha } : {}), implementations, contractFingerprint: checked.authoritativeFingerprint, observedFingerprint: checked.observedFingerprint, lastVerifiedAt: at, verification, history: [this.event(1, status === "CONNECTED" ? "CONNECTED" : "VERIFICATION_FAILED", status, checked.observedFingerprint, at)] };
27
+ await this.store.put(record);
28
+ return record;
29
+ }
30
+ async verify(applicationId, connectionId, observation) {
31
+ const current = await this.required(applicationId, connectionId);
32
+ if (current.status === "DISCONNECTED")
33
+ throw new Error("A disconnected repository must be reconnected with a new connection");
34
+ if (JSON.stringify(current.repository) !== JSON.stringify(observation.repository))
35
+ throw new Error("Verification cannot change repository identity");
36
+ const implementedCapabilities = this.implementations(observation), checked = await this.check(applicationId, observation.manifest, implementedCapabilities), at = this.now(), status = checked.reasons.length ? "MISMATCHED" : "CONNECTED", sequence = current.sequence + 1;
37
+ const implementations = status === "CONNECTED" ? implementedCapabilities.map(item => current.implementations.find(existing => existing.capabilityName === item.name && existing.capabilityVersion === item.version) ?? this.implementation(connectionId, item)) : [], next = { ...current, status, sequence, ref: observation.ref, ...(observation.commitSha ? { commitSha: observation.commitSha } : {}), implementations, contractFingerprint: checked.authoritativeFingerprint, observedFingerprint: checked.observedFingerprint, lastVerifiedAt: at, verification: this.verification(checked, at), history: [...current.history, this.event(sequence, status === "CONNECTED" ? "REVERIFIED" : "VERIFICATION_FAILED", status, checked.observedFingerprint, at)] };
38
+ await this.store.put(next, current.sequence);
39
+ return next;
40
+ }
41
+ async disconnect(applicationId, connectionId) { const current = await this.required(applicationId, connectionId); if (current.status === "DISCONNECTED")
42
+ return current; const at = this.now(), sequence = current.sequence + 1, next = { ...current, status: "DISCONNECTED", sequence, history: [...current.history, this.event(sequence, "DISCONNECTED", "DISCONNECTED", current.observedFingerprint, at)] }; await this.store.put(next, current.sequence); return next; }
43
+ get = (applicationId, connectionId) => this.store.get(applicationId, connectionId);
44
+ list = (applicationId) => this.store.list(applicationId);
45
+ async check(applicationId, manifest, implementations) { const authoritative = await this.authority.get(applicationId); if (!authoritative)
46
+ throw new Error(`Unknown application "${applicationId}"`); const observedFingerprint = fingerprintManifest(manifest), identityMatches = manifest.application.id === applicationId, contractMatches = observedFingerprint === authoritative.fingerprint, declared = new Set(authoritative.manifest.provides.map(item => `${item.name}@${item.version}`)), invalid = implementations.filter(item => !declared.has(`${item.name}@${item.version}`)), reasons = [...(!identityMatches ? ["Application identity does not match"] : []), ...(!contractMatches ? ["Contract fingerprint does not match"] : []), ...(invalid.length ? [`Implementation claims are outside the application contract: ${invalid.map(item => `${item.name}@${item.version}`).join(", ")}`] : [])]; return { authoritativeFingerprint: authoritative.fingerprint, observedFingerprint, identityMatches, contractMatches: contractMatches && invalid.length === 0, reasons }; }
47
+ verification(checked, at) { return { verificationId: `verify_${randomUUID()}`, verifiedAt: at, ...checked }; }
48
+ event(sequence, type, status, observedFingerprint, occurredAt) { return { eventId: `repo_${randomUUID()}`, sequence, type, occurredAt, status, observedFingerprint }; }
49
+ async required(applicationId, connectionId) { const value = await this.store.get(applicationId, connectionId); if (!value)
50
+ throw new Error(`Unknown repository connection "${connectionId}"`); return value; }
51
+ validateRepository(method, repository) { if (!repository.remoteUrl || !repository.remoteUrl.trim())
52
+ throw new Error("Repository remoteUrl is required"); if (method === "github" && (repository.provider !== "github" || !repository.repositoryId))
53
+ throw new Error("GitHub connections require authenticated repository identity"); }
54
+ implementations(observation) { const values = observation.implementedCapabilities ?? observation.manifest.provides.map(({ name, version }) => ({ name, version })), unique = new Map(values.map(item => [`${item.name}@${item.version}`, { name: item.name, version: item.version }])); return [...unique.values()].sort((a, b) => a.name.localeCompare(b.name) || a.version - b.version); }
55
+ implementation(connectionId, capability) { return { implementationId: `impl_${randomUUID()}`, sourceConnectionId: connectionId, capabilityName: capability.name, capabilityVersion: capability.version }; }
56
+ }
57
+ //# sourceMappingURL=repository-connection.js.map