@swal/edge-mesh 0.0.0-stage → 0.1.0

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 (464) hide show
  1. package/LICENSE +128 -0
  2. package/NOTICE +37 -0
  3. package/README.md +470 -2
  4. package/dist/adapters/gpu-agent/index.d.ts +61 -0
  5. package/dist/adapters/gpu-agent/index.d.ts.map +1 -0
  6. package/dist/adapters/gpu-agent/index.js +364 -0
  7. package/dist/adapters/gpu-agent/index.js.map +1 -0
  8. package/dist/adapters/maloca-salud/citas-distribuidas.d.ts +19 -0
  9. package/dist/adapters/maloca-salud/citas-distribuidas.d.ts.map +1 -0
  10. package/dist/adapters/maloca-salud/citas-distribuidas.js +51 -0
  11. package/dist/adapters/maloca-salud/citas-distribuidas.js.map +1 -0
  12. package/dist/adapters/maloca-salud/eps-bridge.d.ts +15 -0
  13. package/dist/adapters/maloca-salud/eps-bridge.d.ts.map +1 -0
  14. package/dist/adapters/maloca-salud/eps-bridge.js +27 -0
  15. package/dist/adapters/maloca-salud/eps-bridge.js.map +1 -0
  16. package/dist/adapters/maloca-salud/patient-profile.d.ts +20 -0
  17. package/dist/adapters/maloca-salud/patient-profile.d.ts.map +1 -0
  18. package/dist/adapters/maloca-salud/patient-profile.js +36 -0
  19. package/dist/adapters/maloca-salud/patient-profile.js.map +1 -0
  20. package/dist/adapters/maloca-salud/types.d.ts +40 -0
  21. package/dist/adapters/maloca-salud/types.d.ts.map +1 -0
  22. package/dist/adapters/maloca-salud/types.js +2 -0
  23. package/dist/adapters/maloca-salud/types.js.map +1 -0
  24. package/dist/adapters/maloca-veeduria/contract-bridge.d.ts +31 -0
  25. package/dist/adapters/maloca-veeduria/contract-bridge.d.ts.map +1 -0
  26. package/dist/adapters/maloca-veeduria/contract-bridge.js +103 -0
  27. package/dist/adapters/maloca-veeduria/contract-bridge.js.map +1 -0
  28. package/dist/adapters/maloca-veeduria/evidentia-veeduria.d.ts +14 -0
  29. package/dist/adapters/maloca-veeduria/evidentia-veeduria.d.ts.map +1 -0
  30. package/dist/adapters/maloca-veeduria/evidentia-veeduria.js +40 -0
  31. package/dist/adapters/maloca-veeduria/evidentia-veeduria.js.map +1 -0
  32. package/dist/adapters/maloca-veeduria/licitante-profile.d.ts +21 -0
  33. package/dist/adapters/maloca-veeduria/licitante-profile.d.ts.map +1 -0
  34. package/dist/adapters/maloca-veeduria/licitante-profile.js +58 -0
  35. package/dist/adapters/maloca-veeduria/licitante-profile.js.map +1 -0
  36. package/dist/adapters/maloca-veeduria/types.d.ts +30 -0
  37. package/dist/adapters/maloca-veeduria/types.d.ts.map +1 -0
  38. package/dist/adapters/maloca-veeduria/types.js +2 -0
  39. package/dist/adapters/maloca-veeduria/types.js.map +1 -0
  40. package/dist/adapters/maloca-xavier/agent-profile.d.ts +32 -0
  41. package/dist/adapters/maloca-xavier/agent-profile.d.ts.map +1 -0
  42. package/dist/adapters/maloca-xavier/agent-profile.js +56 -0
  43. package/dist/adapters/maloca-xavier/agent-profile.js.map +1 -0
  44. package/dist/adapters/maloca-xavier/codegraph-bridge.d.ts +27 -0
  45. package/dist/adapters/maloca-xavier/codegraph-bridge.d.ts.map +1 -0
  46. package/dist/adapters/maloca-xavier/codegraph-bridge.js +58 -0
  47. package/dist/adapters/maloca-xavier/codegraph-bridge.js.map +1 -0
  48. package/dist/adapters/maloca-xavier/llm-router.d.ts +25 -0
  49. package/dist/adapters/maloca-xavier/llm-router.d.ts.map +1 -0
  50. package/dist/adapters/maloca-xavier/llm-router.js +58 -0
  51. package/dist/adapters/maloca-xavier/llm-router.js.map +1 -0
  52. package/dist/authz/index.d.ts +81 -0
  53. package/dist/authz/index.d.ts.map +1 -0
  54. package/dist/authz/index.js +271 -0
  55. package/dist/authz/index.js.map +1 -0
  56. package/dist/chat/index.d.ts +138 -0
  57. package/dist/chat/index.d.ts.map +1 -0
  58. package/dist/chat/index.js +394 -0
  59. package/dist/chat/index.js.map +1 -0
  60. package/dist/chat/offline-queue.d.ts +32 -0
  61. package/dist/chat/offline-queue.d.ts.map +1 -0
  62. package/dist/chat/offline-queue.js +93 -0
  63. package/dist/chat/offline-queue.js.map +1 -0
  64. package/dist/core/DefaultEdgeMeshNode.d.ts +17 -0
  65. package/dist/core/DefaultEdgeMeshNode.d.ts.map +1 -0
  66. package/dist/core/DefaultEdgeMeshNode.js +57 -0
  67. package/dist/core/DefaultEdgeMeshNode.js.map +1 -0
  68. package/dist/core/node.d.ts +26 -0
  69. package/dist/core/node.d.ts.map +1 -0
  70. package/dist/core/node.js +16 -0
  71. package/dist/core/node.js.map +1 -0
  72. package/dist/edge-mesh.d.ts +139 -0
  73. package/dist/edge-mesh.d.ts.map +1 -0
  74. package/dist/edge-mesh.js +1146 -0
  75. package/dist/edge-mesh.js.map +1 -0
  76. package/dist/gos/GosBridge.d.ts +49 -0
  77. package/dist/gos/GosBridge.d.ts.map +1 -0
  78. package/dist/gos/GosBridge.js +133 -0
  79. package/dist/gos/GosBridge.js.map +1 -0
  80. package/dist/governance/authority.d.ts +44 -0
  81. package/dist/governance/authority.d.ts.map +1 -0
  82. package/dist/governance/authority.js +123 -0
  83. package/dist/governance/authority.js.map +1 -0
  84. package/dist/governance/index.d.ts +66 -0
  85. package/dist/governance/index.d.ts.map +1 -0
  86. package/dist/governance/index.js +210 -0
  87. package/dist/governance/index.js.map +1 -0
  88. package/dist/governance/merge.d.ts +31 -0
  89. package/dist/governance/merge.d.ts.map +1 -0
  90. package/dist/governance/merge.js +167 -0
  91. package/dist/governance/merge.js.map +1 -0
  92. package/dist/identity/index.d.ts +199 -0
  93. package/dist/identity/index.d.ts.map +1 -0
  94. package/dist/identity/index.js +415 -0
  95. package/dist/identity/index.js.map +1 -0
  96. package/dist/index.d.ts +71 -0
  97. package/dist/index.d.ts.map +1 -0
  98. package/dist/index.js +56 -0
  99. package/dist/index.js.map +1 -0
  100. package/dist/maloca/backoffice.d.ts +31 -0
  101. package/dist/maloca/backoffice.d.ts.map +1 -0
  102. package/dist/maloca/backoffice.js +40 -0
  103. package/dist/maloca/backoffice.js.map +1 -0
  104. package/dist/maloca/event-bus.d.ts +60 -0
  105. package/dist/maloca/event-bus.d.ts.map +1 -0
  106. package/dist/maloca/event-bus.js +175 -0
  107. package/dist/maloca/event-bus.js.map +1 -0
  108. package/dist/maloca/evidentia.d.ts +136 -0
  109. package/dist/maloca/evidentia.d.ts.map +1 -0
  110. package/dist/maloca/evidentia.js +447 -0
  111. package/dist/maloca/evidentia.js.map +1 -0
  112. package/dist/maloca/gateway/api.d.ts +146 -0
  113. package/dist/maloca/gateway/api.d.ts.map +1 -0
  114. package/dist/maloca/gateway/api.js +228 -0
  115. package/dist/maloca/gateway/api.js.map +1 -0
  116. package/dist/maloca/gateway/auth.d.ts +20 -0
  117. package/dist/maloca/gateway/auth.d.ts.map +1 -0
  118. package/dist/maloca/gateway/auth.js +115 -0
  119. package/dist/maloca/gateway/auth.js.map +1 -0
  120. package/dist/maloca/gateway/dashboard.d.ts +42 -0
  121. package/dist/maloca/gateway/dashboard.d.ts.map +1 -0
  122. package/dist/maloca/gateway/dashboard.js +67 -0
  123. package/dist/maloca/gateway/dashboard.js.map +1 -0
  124. package/dist/maloca/gateway/websocket.d.ts +34 -0
  125. package/dist/maloca/gateway/websocket.d.ts.map +1 -0
  126. package/dist/maloca/gateway/websocket.js +71 -0
  127. package/dist/maloca/gateway/websocket.js.map +1 -0
  128. package/dist/maloca/karma.d.ts +165 -0
  129. package/dist/maloca/karma.d.ts.map +1 -0
  130. package/dist/maloca/karma.js +307 -0
  131. package/dist/maloca/karma.js.map +1 -0
  132. package/dist/maloca/kernel.d.ts +20 -0
  133. package/dist/maloca/kernel.d.ts.map +1 -0
  134. package/dist/maloca/kernel.js +76 -0
  135. package/dist/maloca/kernel.js.map +1 -0
  136. package/dist/maloca/metadata.d.ts +30 -0
  137. package/dist/maloca/metadata.d.ts.map +1 -0
  138. package/dist/maloca/metadata.js +80 -0
  139. package/dist/maloca/metadata.js.map +1 -0
  140. package/dist/maloca/perfil.d.ts +57 -0
  141. package/dist/maloca/perfil.d.ts.map +1 -0
  142. package/dist/maloca/perfil.js +113 -0
  143. package/dist/maloca/perfil.js.map +1 -0
  144. package/dist/maloca/plugin-registry.d.ts +27 -0
  145. package/dist/maloca/plugin-registry.d.ts.map +1 -0
  146. package/dist/maloca/plugin-registry.js +76 -0
  147. package/dist/maloca/plugin-registry.js.map +1 -0
  148. package/dist/maloca/polygon-bridge.d.ts +63 -0
  149. package/dist/maloca/polygon-bridge.d.ts.map +1 -0
  150. package/dist/maloca/polygon-bridge.js +198 -0
  151. package/dist/maloca/polygon-bridge.js.map +1 -0
  152. package/dist/maloca/types.d.ts +44 -0
  153. package/dist/maloca/types.d.ts.map +1 -0
  154. package/dist/maloca/types.js +2 -0
  155. package/dist/maloca/types.js.map +1 -0
  156. package/dist/medico/aval.d.ts +149 -0
  157. package/dist/medico/aval.d.ts.map +1 -0
  158. package/dist/medico/aval.js +281 -0
  159. package/dist/medico/aval.js.map +1 -0
  160. package/dist/medico/canonica.d.ts +96 -0
  161. package/dist/medico/canonica.d.ts.map +1 -0
  162. package/dist/medico/canonica.js +148 -0
  163. package/dist/medico/canonica.js.map +1 -0
  164. package/dist/medico/credencial.d.ts +160 -0
  165. package/dist/medico/credencial.d.ts.map +1 -0
  166. package/dist/medico/credencial.js +240 -0
  167. package/dist/medico/credencial.js.map +1 -0
  168. package/dist/medico/index.d.ts +36 -0
  169. package/dist/medico/index.d.ts.map +1 -0
  170. package/dist/medico/index.js +39 -0
  171. package/dist/medico/index.js.map +1 -0
  172. package/dist/medico/malla.d.ts +218 -0
  173. package/dist/medico/malla.d.ts.map +1 -0
  174. package/dist/medico/malla.js +347 -0
  175. package/dist/medico/malla.js.map +1 -0
  176. package/dist/medico/registro-profesional.d.ts +84 -0
  177. package/dist/medico/registro-profesional.d.ts.map +1 -0
  178. package/dist/medico/registro-profesional.js +135 -0
  179. package/dist/medico/registro-profesional.js.map +1 -0
  180. package/dist/medico/registro.d.ts +149 -0
  181. package/dist/medico/registro.d.ts.map +1 -0
  182. package/dist/medico/registro.js +173 -0
  183. package/dist/medico/registro.js.map +1 -0
  184. package/dist/medico/types.d.ts +287 -0
  185. package/dist/medico/types.d.ts.map +1 -0
  186. package/dist/medico/types.js +135 -0
  187. package/dist/medico/types.js.map +1 -0
  188. package/dist/medico/verificacion-registro.d.ts +300 -0
  189. package/dist/medico/verificacion-registro.d.ts.map +1 -0
  190. package/dist/medico/verificacion-registro.js +319 -0
  191. package/dist/medico/verificacion-registro.js.map +1 -0
  192. package/dist/mesh/index.d.ts +457 -0
  193. package/dist/mesh/index.d.ts.map +1 -0
  194. package/dist/mesh/index.js +929 -0
  195. package/dist/mesh/index.js.map +1 -0
  196. package/dist/namespaces/encrypted-plugin.d.ts +56 -0
  197. package/dist/namespaces/encrypted-plugin.d.ts.map +1 -0
  198. package/dist/namespaces/encrypted-plugin.js +173 -0
  199. package/dist/namespaces/encrypted-plugin.js.map +1 -0
  200. package/dist/namespaces/index.d.ts +52 -0
  201. package/dist/namespaces/index.d.ts.map +1 -0
  202. package/dist/namespaces/index.js +134 -0
  203. package/dist/namespaces/index.js.map +1 -0
  204. package/dist/namespaces/ivn-proofs.d.ts +54 -0
  205. package/dist/namespaces/ivn-proofs.d.ts.map +1 -0
  206. package/dist/namespaces/ivn-proofs.js +162 -0
  207. package/dist/namespaces/ivn-proofs.js.map +1 -0
  208. package/dist/namespaces/offers-gossip.d.ts +95 -0
  209. package/dist/namespaces/offers-gossip.d.ts.map +1 -0
  210. package/dist/namespaces/offers-gossip.js +213 -0
  211. package/dist/namespaces/offers-gossip.js.map +1 -0
  212. package/dist/node-memory/idb-store.d.ts +22 -0
  213. package/dist/node-memory/idb-store.d.ts.map +1 -0
  214. package/dist/node-memory/idb-store.js +154 -0
  215. package/dist/node-memory/idb-store.js.map +1 -0
  216. package/dist/node-memory/index.d.ts +14 -0
  217. package/dist/node-memory/index.d.ts.map +1 -0
  218. package/dist/node-memory/index.js +159 -0
  219. package/dist/node-memory/index.js.map +1 -0
  220. package/dist/node-memory/sync-flush.d.ts +11 -0
  221. package/dist/node-memory/sync-flush.d.ts.map +1 -0
  222. package/dist/node-memory/sync-flush.js +37 -0
  223. package/dist/node-memory/sync-flush.js.map +1 -0
  224. package/dist/node-memory/types.d.ts +34 -0
  225. package/dist/node-memory/types.d.ts.map +1 -0
  226. package/dist/node-memory/types.js +2 -0
  227. package/dist/node-memory/types.js.map +1 -0
  228. package/dist/node-memory/xavier-store.d.ts +12 -0
  229. package/dist/node-memory/xavier-store.d.ts.map +1 -0
  230. package/dist/node-memory/xavier-store.js +75 -0
  231. package/dist/node-memory/xavier-store.js.map +1 -0
  232. package/dist/op-log/index.d.ts +49 -0
  233. package/dist/op-log/index.d.ts.map +1 -0
  234. package/dist/op-log/index.js +190 -0
  235. package/dist/op-log/index.js.map +1 -0
  236. package/dist/presence/health.d.ts +54 -0
  237. package/dist/presence/health.d.ts.map +1 -0
  238. package/dist/presence/health.js +139 -0
  239. package/dist/presence/health.js.map +1 -0
  240. package/dist/presence/index.d.ts +85 -0
  241. package/dist/presence/index.d.ts.map +1 -0
  242. package/dist/presence/index.js +255 -0
  243. package/dist/presence/index.js.map +1 -0
  244. package/dist/presence/peer-health.d.ts +40 -0
  245. package/dist/presence/peer-health.d.ts.map +1 -0
  246. package/dist/presence/peer-health.js +118 -0
  247. package/dist/presence/peer-health.js.map +1 -0
  248. package/dist/protocol/canonical.d.ts +10 -0
  249. package/dist/protocol/canonical.d.ts.map +1 -0
  250. package/dist/protocol/canonical.js +32 -0
  251. package/dist/protocol/canonical.js.map +1 -0
  252. package/dist/protocol/crypto.d.ts +299 -0
  253. package/dist/protocol/crypto.d.ts.map +1 -0
  254. package/dist/protocol/crypto.js +739 -0
  255. package/dist/protocol/crypto.js.map +1 -0
  256. package/dist/protocol/index.d.ts +30 -0
  257. package/dist/protocol/index.d.ts.map +1 -0
  258. package/dist/protocol/index.js +116 -0
  259. package/dist/protocol/index.js.map +1 -0
  260. package/dist/protocol/utils.d.ts +5 -0
  261. package/dist/protocol/utils.d.ts.map +1 -0
  262. package/dist/protocol/utils.js +27 -0
  263. package/dist/protocol/utils.js.map +1 -0
  264. package/dist/salones/manager.d.ts +100 -0
  265. package/dist/salones/manager.d.ts.map +1 -0
  266. package/dist/salones/manager.js +240 -0
  267. package/dist/salones/manager.js.map +1 -0
  268. package/dist/security/rate-limiter.d.ts +13 -0
  269. package/dist/security/rate-limiter.d.ts.map +1 -0
  270. package/dist/security/rate-limiter.js +32 -0
  271. package/dist/security/rate-limiter.js.map +1 -0
  272. package/dist/snapshot/index.d.ts +90 -0
  273. package/dist/snapshot/index.d.ts.map +1 -0
  274. package/dist/snapshot/index.js +189 -0
  275. package/dist/snapshot/index.js.map +1 -0
  276. package/dist/storage/index.d.ts +49 -0
  277. package/dist/storage/index.d.ts.map +1 -0
  278. package/dist/storage/index.js +176 -0
  279. package/dist/storage/index.js.map +1 -0
  280. package/dist/storage/optimizer.d.ts +28 -0
  281. package/dist/storage/optimizer.d.ts.map +1 -0
  282. package/dist/storage/optimizer.js +50 -0
  283. package/dist/storage/optimizer.js.map +1 -0
  284. package/dist/storage/ydoc-persistence.d.ts +27 -0
  285. package/dist/storage/ydoc-persistence.d.ts.map +1 -0
  286. package/dist/storage/ydoc-persistence.js +128 -0
  287. package/dist/storage/ydoc-persistence.js.map +1 -0
  288. package/dist/sync/ChunkSyncManager.d.ts +41 -0
  289. package/dist/sync/ChunkSyncManager.d.ts.map +1 -0
  290. package/dist/sync/ChunkSyncManager.js +115 -0
  291. package/dist/sync/ChunkSyncManager.js.map +1 -0
  292. package/dist/sync/conflict-resolver.d.ts +33 -0
  293. package/dist/sync/conflict-resolver.d.ts.map +1 -0
  294. package/dist/sync/conflict-resolver.js +54 -0
  295. package/dist/sync/conflict-resolver.js.map +1 -0
  296. package/dist/sync/engine.d.ts +168 -0
  297. package/dist/sync/engine.d.ts.map +1 -0
  298. package/dist/sync/engine.js +315 -0
  299. package/dist/sync/engine.js.map +1 -0
  300. package/dist/sync/index.d.ts +3 -0
  301. package/dist/sync/index.d.ts.map +1 -0
  302. package/dist/sync/index.js +3 -0
  303. package/dist/sync/index.js.map +1 -0
  304. package/dist/transport/TorTransportAdapter.d.ts +70 -0
  305. package/dist/transport/TorTransportAdapter.d.ts.map +1 -0
  306. package/dist/transport/TorTransportAdapter.js +192 -0
  307. package/dist/transport/TorTransportAdapter.js.map +1 -0
  308. package/dist/transport/memory.d.ts +31 -0
  309. package/dist/transport/memory.d.ts.map +1 -0
  310. package/dist/transport/memory.js +114 -0
  311. package/dist/transport/memory.js.map +1 -0
  312. package/dist/transport/peerjs.d.ts +45 -0
  313. package/dist/transport/peerjs.d.ts.map +1 -0
  314. package/dist/transport/peerjs.js +301 -0
  315. package/dist/transport/peerjs.js.map +1 -0
  316. package/dist/transport/pqc-handshake.d.ts +72 -0
  317. package/dist/transport/pqc-handshake.d.ts.map +1 -0
  318. package/dist/transport/pqc-handshake.js +129 -0
  319. package/dist/transport/pqc-handshake.js.map +1 -0
  320. package/dist/transport/relay-config.d.ts +11 -0
  321. package/dist/transport/relay-config.d.ts.map +1 -0
  322. package/dist/transport/relay-config.js +48 -0
  323. package/dist/transport/relay-config.js.map +1 -0
  324. package/dist/transport/relay-server.d.ts +37 -0
  325. package/dist/transport/relay-server.d.ts.map +1 -0
  326. package/dist/transport/relay-server.js +230 -0
  327. package/dist/transport/relay-server.js.map +1 -0
  328. package/dist/transport/tor.d.ts +47 -0
  329. package/dist/transport/tor.d.ts.map +1 -0
  330. package/dist/transport/tor.js +158 -0
  331. package/dist/transport/tor.js.map +1 -0
  332. package/dist/transport/types.d.ts +34 -0
  333. package/dist/transport/types.d.ts.map +1 -0
  334. package/dist/transport/types.js +2 -0
  335. package/dist/transport/types.js.map +1 -0
  336. package/dist/types/index.d.ts +293 -0
  337. package/dist/types/index.d.ts.map +1 -0
  338. package/dist/types/index.js +73 -0
  339. package/dist/types/index.js.map +1 -0
  340. package/dist/web/admission.d.ts +24 -0
  341. package/dist/web/admission.d.ts.map +1 -0
  342. package/dist/web/admission.js +41 -0
  343. package/dist/web/admission.js.map +1 -0
  344. package/dist/web/crypto.d.ts +18 -0
  345. package/dist/web/crypto.d.ts.map +1 -0
  346. package/dist/web/crypto.js +78 -0
  347. package/dist/web/crypto.js.map +1 -0
  348. package/dist/web/exchange.d.ts +23 -0
  349. package/dist/web/exchange.d.ts.map +1 -0
  350. package/dist/web/exchange.js +54 -0
  351. package/dist/web/exchange.js.map +1 -0
  352. package/dist/web/fragment.d.ts +58 -0
  353. package/dist/web/fragment.d.ts.map +1 -0
  354. package/dist/web/fragment.js +198 -0
  355. package/dist/web/fragment.js.map +1 -0
  356. package/dist/web/index.d.ts +25 -0
  357. package/dist/web/index.d.ts.map +1 -0
  358. package/dist/web/index.js +14 -0
  359. package/dist/web/index.js.map +1 -0
  360. package/dist/web/merge/index.d.ts +104 -0
  361. package/dist/web/merge/index.d.ts.map +1 -0
  362. package/dist/web/merge/index.js +236 -0
  363. package/dist/web/merge/index.js.map +1 -0
  364. package/dist/web/oplog/hlc.d.ts +19 -0
  365. package/dist/web/oplog/hlc.d.ts.map +1 -0
  366. package/dist/web/oplog/hlc.js +39 -0
  367. package/dist/web/oplog/hlc.js.map +1 -0
  368. package/dist/web/oplog/index.d.ts +10 -0
  369. package/dist/web/oplog/index.d.ts.map +1 -0
  370. package/dist/web/oplog/index.js +6 -0
  371. package/dist/web/oplog/index.js.map +1 -0
  372. package/dist/web/oplog/log.d.ts +182 -0
  373. package/dist/web/oplog/log.d.ts.map +1 -0
  374. package/dist/web/oplog/log.js +693 -0
  375. package/dist/web/oplog/log.js.map +1 -0
  376. package/dist/web/oplog/store.d.ts +40 -0
  377. package/dist/web/oplog/store.d.ts.map +1 -0
  378. package/dist/web/oplog/store.js +85 -0
  379. package/dist/web/oplog/store.js.map +1 -0
  380. package/dist/web/oplog/sync.d.ts +54 -0
  381. package/dist/web/oplog/sync.d.ts.map +1 -0
  382. package/dist/web/oplog/sync.js +162 -0
  383. package/dist/web/oplog/sync.js.map +1 -0
  384. package/dist/web/oplog/types.d.ts +119 -0
  385. package/dist/web/oplog/types.d.ts.map +1 -0
  386. package/dist/web/oplog/types.js +2 -0
  387. package/dist/web/oplog/types.js.map +1 -0
  388. package/dist/web/pairing.d.ts +186 -0
  389. package/dist/web/pairing.d.ts.map +1 -0
  390. package/dist/web/pairing.js +395 -0
  391. package/dist/web/pairing.js.map +1 -0
  392. package/dist/web/pq.d.ts +36 -0
  393. package/dist/web/pq.d.ts.map +1 -0
  394. package/dist/web/pq.js +59 -0
  395. package/dist/web/pq.js.map +1 -0
  396. package/dist/web/provider.d.ts +188 -0
  397. package/dist/web/provider.d.ts.map +1 -0
  398. package/dist/web/provider.js +2042 -0
  399. package/dist/web/provider.js.map +1 -0
  400. package/dist/web/rooms.d.ts +20 -0
  401. package/dist/web/rooms.d.ts.map +1 -0
  402. package/dist/web/rooms.js +51 -0
  403. package/dist/web/rooms.js.map +1 -0
  404. package/dist/web/rotation.d.ts +73 -0
  405. package/dist/web/rotation.d.ts.map +1 -0
  406. package/dist/web/rotation.js +130 -0
  407. package/dist/web/rotation.js.map +1 -0
  408. package/dist/web/secstate.d.ts +213 -0
  409. package/dist/web/secstate.d.ts.map +1 -0
  410. package/dist/web/secstate.js +789 -0
  411. package/dist/web/secstate.js.map +1 -0
  412. package/dist/web/store.d.ts +9 -0
  413. package/dist/web/store.d.ts.map +1 -0
  414. package/dist/web/store.js +32 -0
  415. package/dist/web/store.js.map +1 -0
  416. package/dist/web/transports/loopback.d.ts +11 -0
  417. package/dist/web/transports/loopback.d.ts.map +1 -0
  418. package/dist/web/transports/loopback.js +97 -0
  419. package/dist/web/transports/loopback.js.map +1 -0
  420. package/dist/web/transports/qr-sdp.d.ts +27 -0
  421. package/dist/web/transports/qr-sdp.d.ts.map +1 -0
  422. package/dist/web/transports/qr-sdp.js +131 -0
  423. package/dist/web/transports/qr-sdp.js.map +1 -0
  424. package/dist/web/transports/ws.d.ts +12 -0
  425. package/dist/web/transports/ws.d.ts.map +1 -0
  426. package/dist/web/transports/ws.js +139 -0
  427. package/dist/web/transports/ws.js.map +1 -0
  428. package/dist/web/trust/canonical.d.ts +8 -0
  429. package/dist/web/trust/canonical.d.ts.map +1 -0
  430. package/dist/web/trust/canonical.js +27 -0
  431. package/dist/web/trust/canonical.js.map +1 -0
  432. package/dist/web/trust/docs.d.ts +51 -0
  433. package/dist/web/trust/docs.d.ts.map +1 -0
  434. package/dist/web/trust/docs.js +170 -0
  435. package/dist/web/trust/docs.js.map +1 -0
  436. package/dist/web/trust/index.d.ts +10 -0
  437. package/dist/web/trust/index.d.ts.map +1 -0
  438. package/dist/web/trust/index.js +7 -0
  439. package/dist/web/trust/index.js.map +1 -0
  440. package/dist/web/trust/keys.d.ts +37 -0
  441. package/dist/web/trust/keys.d.ts.map +1 -0
  442. package/dist/web/trust/keys.js +75 -0
  443. package/dist/web/trust/keys.js.map +1 -0
  444. package/dist/web/trust/store.d.ts +150 -0
  445. package/dist/web/trust/store.d.ts.map +1 -0
  446. package/dist/web/trust/store.js +587 -0
  447. package/dist/web/trust/store.js.map +1 -0
  448. package/dist/web/trust/types.d.ts +134 -0
  449. package/dist/web/trust/types.d.ts.map +1 -0
  450. package/dist/web/trust/types.js +4 -0
  451. package/dist/web/trust/types.js.map +1 -0
  452. package/dist/web/types.d.ts +115 -0
  453. package/dist/web/types.d.ts.map +1 -0
  454. package/dist/web/types.js +2 -0
  455. package/dist/web/types.js.map +1 -0
  456. package/dist/web/util.d.ts +12 -0
  457. package/dist/web/util.d.ts.map +1 -0
  458. package/dist/web/util.js +54 -0
  459. package/dist/web/util.js.map +1 -0
  460. package/dist/web/webrtc.d.ts +35 -0
  461. package/dist/web/webrtc.d.ts.map +1 -0
  462. package/dist/web/webrtc.js +304 -0
  463. package/dist/web/webrtc.js.map +1 -0
  464. package/package.json +138 -4
@@ -0,0 +1,300 @@
1
+ /**
2
+ * Foundation verification: from "well-formed credential" to "accredited".
3
+ *
4
+ * ─── WHAT THE PREVIOUS PHASE ALREADY SOLVED, AND WHAT IT DID NOT ─────────────
5
+ *
6
+ * `./credencial.ts` verifies FORM: ISO country, `idLicencia` is a SHA-256 hex,
7
+ * `vigenteHasta` present and not lapsed, signature over the canonical bytes. A
8
+ * credential can pass all of that and still be a forgery — a well-formed object
9
+ * that no authority ever issued. Nothing before this file asked the substrate
10
+ * question: *does this licence exist?*
11
+ *
12
+ * `./registro.ts` answers part of it, with the right fail-closed primitive
13
+ * (normalize → SHA-256 → country-scoped membership). What it cannot answer, by
14
+ * construction, is state: its `InstantaneaRegistroPais` is a `Set<string>` of
15
+ * hashes, and a set has one relation — *present* or *absent*. A `Set` cannot say
16
+ * "present, suspended", so a licence the Ministry suspended in March keeps
17
+ * matching a snapshot taken in January, forever.
18
+ *
19
+ * ─── THE THIRD DEFECT, WHICH IS THE ONE THAT ADDS NOVEL VALUE ───────────────
20
+ *
21
+ * `InstantaneaRegistroPais` also carries no expiry and no version per entry, so
22
+ * `{ estado: 'activa' }` would be enough — and that is exactly the
23
+ * OrionHealth `expired`-never-returned defect wearing a different hat. A state
24
+ * that is only ever `ACTIVA` because nothing can express anything else is not a
25
+ * state machine, it is a comment.
26
+ *
27
+ * So the registry here is an array of {@link EntradaRegistroLicencia}: country,
28
+ * licence hash, issuer-signed `vigenteHasta`, and an explicit
29
+ * {@link EstadoLicenciaRegistro}. All three states are reachable and two of them
30
+ * refuse. That is the whole point of this file.
31
+ *
32
+ * ─── WHY THE LOOKUP IS AN INJECTED FUNCTION ────────────────────────────────
33
+ *
34
+ * {@link FuenteAcreditacion.consultar} takes a `{ pais, hashLicencia }` and
35
+ * returns an entry or `undefined`. No fetch, no filesystem, no `Date.now()`:
36
+ * the transport is Phase 3's decision (a gossiped, hash-compared snapshot), and
37
+ * until then a fixture *is* the network. Because the seam is data in / data
38
+ * out, every state below is reachable from a test with no I/O at all.
39
+ *
40
+ * ─── WHY A MISSING COUNTRY REFUSES ────────────────────────────────────────
41
+ *
42
+ * OrionHealth returns `LicenseVerificationResult.unknown` when a country's
43
+ * registry is empty and treats it as "not refused". Here an unlisted country is
44
+ * `pais_no_soportado` and a supported country with an empty registry is
45
+ * `licencia_no_encontrada` — both `accesoPermitido: false`, and the type has no
46
+ * member meaning "we could not check this, carry on". An accreditation whose
47
+ * failure mode is a bypass is not a verification scheme.
48
+ *
49
+ * Pure: no clock read, no randomness, no I/O. `ahora` is always injected, which
50
+ * is what makes the refusal reasons reproducible — same inputs, same `motivo`,
51
+ * byte for byte, forever.
52
+ */
53
+ import { MOTIVO_RECHAZO_CREDENCIAL, type MotivoRechazoCredencial } from "./credencial.js";
54
+ import { MOTIVO_RECHAZO_REGISTRO, type MotivoRechazoRegistro } from "./registro-profesional.js";
55
+ import type { CredencialMedica, MetodoVerificacion } from "./types.js";
56
+ /**
57
+ * The life cycle of a licence *as the registry sees it*.
58
+ *
59
+ * Declared as a closed three-member union so the intermediate and terminal
60
+ * states are first-class. OrionHealth has the same two non-active states in its
61
+ * enum and returns neither one, because list membership cannot express them;
62
+ * here `suspendida` and `revocada` are not decoration — each one is a distinct,
63
+ * named refusal returned by {@link acreditarContraRegistro}.
64
+ *
65
+ * A value outside this union is refused as {@link MOTIVO_RECHAZO_CONSULTA_REGISTRO.ESTADO_REGISTRO_INVALIDO}.
66
+ * Unknown is never treated as active.
67
+ */
68
+ export declare const ESTADO_LICENCIA: {
69
+ readonly ACTIVA: "activa";
70
+ readonly SUSPENDIDA: "suspendida";
71
+ readonly REVOCADA: "revocada";
72
+ };
73
+ export type EstadoLicencia = (typeof ESTADO_LICENCIA)[keyof typeof ESTADO_LICENCIA];
74
+ /**
75
+ * One licence, as held by one country registry snapshot.
76
+ *
77
+ * Membership is no longer a bare hash: the entry states *what* the registry says
78
+ * about the licence and *until when*, so a suspended or lapsed licence cannot be
79
+ * represented as a good one. `pais` is mandatory so a transport bug that answers
80
+ * a `CO` query with an `ES` entry is detectable
81
+ * ({@link MOTIVO_RECHAZO_CONSULTA_REGISTRO.ENTRADA_DE_OTRO_PAIS}).
82
+ */
83
+ export interface EntradaRegistroLicencia {
84
+ /** ISO 3166-1 alpha-2, upper case. Must equal the credential's `pais`. */
85
+ readonly pais: string;
86
+ /** `sha256(normalize(numeroLicencia))`. Never the number: that is PII (Ley 1581/2012). */
87
+ readonly hashLicencia: string;
88
+ /**
89
+ * Registry-stated validity window, ms epoch. Independent of the credential's
90
+ * own `vigenteHasta`: both must hold, so a credential claiming a longer
91
+ * licence than the registry grants is refused rather than believed.
92
+ */
93
+ readonly vigenteHasta: number;
94
+ readonly estado: EstadoLicencia;
95
+ /** Issuing authority, when the snapshot carries it. Checked when both sides do. */
96
+ readonly autoridad?: string;
97
+ /** Specialty slug, when the entry describes a specialty licence. */
98
+ readonly especialidad?: string;
99
+ }
100
+ /** Sync or async, so a Phase 3 transport may fetch without changing the contract. */
101
+ type Awaitable<T> = T | Promise<T>;
102
+ /** The query a transport receives. Hash only — the licence number never travels. */
103
+ export interface ConsultaRegistroLicencia {
104
+ readonly pais: string;
105
+ readonly hashLicencia: string;
106
+ }
107
+ /**
108
+ * The injected lookup: given a country and a licence hash, produce the registry's
109
+ * entry, or `undefined` when the registry does not hold it.
110
+ *
111
+ * Returning `undefined` is "not in the registry". Throwing is not interpreted as
112
+ * absence: it becomes {@link MOTIVO_RECHAZO_CONSULTA_REGISTRO.CONSULTA_FALLIDA},
113
+ * still fail-closed, because a transport error must never be laundered into a
114
+ * plain miss that some future caller might treat as benign.
115
+ */
116
+ export type ConsultarEntradaRegistro = (consulta: ConsultaRegistroLicencia) => Awaitable<EntradaRegistroLicencia | undefined>;
117
+ /**
118
+ * The Phase 3 extension point.
119
+ *
120
+ * Everything the verification needs from the outside world arrives through this
121
+ * interface, so swapping an in-memory fixture for a replicated snapshot is a
122
+ * constructor change in a later phase and not a change to any rule in this file.
123
+ */
124
+ export interface FuenteAcreditacion {
125
+ /**
126
+ * Countries this source can speak for. Empty ⇒ nothing is verifiable, and
127
+ * every credential is refused as `pais_no_soportado`.
128
+ *
129
+ * Separate from the registry's own contents on purpose: "we do not carry
130
+ * Colombia" is a different operational fact from "your licence is not in
131
+ * Colombia's registry", and conflating them is how an unsupported country
132
+ * becomes a silent bypass.
133
+ */
134
+ readonly paisesSoportados: readonly string[];
135
+ /** Version of the snapshot backing `pais`, for the audit trail. */
136
+ versionRegistro(pais: string): string | undefined;
137
+ /** The lookup itself. Injected; this module performs no I/O. */
138
+ consultar(consulta: ConsultaRegistroLicencia): Awaitable<EntradaRegistroLicencia | undefined>;
139
+ }
140
+ /**
141
+ * Refusals specific to consulting a registry.
142
+ *
143
+ * Additive to the two existing reason sets rather than a parallel system:
144
+ * {@link MotivoRechazoAcreditacion} is the union of this, `MOTIVO_RECHAZO_CREDENCIAL`
145
+ * and `MOTIVO_RECHAZO_REGISTRO`, and a credential that fails form is reported
146
+ * with the *credential's own* reason, so a caller reading
147
+ * `motivo === MOTIVO_RECHAZO_CREDENCIAL.SIN_VIGENCIA` keeps working unchanged.
148
+ */
149
+ export declare const MOTIVO_RECHAZO_CONSULTA_REGISTRO: {
150
+ /** The credential itself failed `validarCredencial`; see `detalle` for its reason. */
151
+ readonly CREDENCIAL_MAL_FORMADA: "credencial_mal_formada";
152
+ /** No source speaks for this country. Fail closed, never "unknown". */
153
+ readonly PAIS_NO_SOPORTADO: "pais_no_soportado";
154
+ /** The source supports the country but holds no snapshot for it. */
155
+ readonly PAIS_SIN_REGISTRO: "pais_sin_registro";
156
+ /** Country supported, snapshot present, licence absent. */
157
+ readonly LICENCIA_NO_ENCONTRADA: "licencia_no_encontrada";
158
+ /** The registry says the licence is suspended. */
159
+ readonly LICENCIA_SUSPENDIDA: "licencia_suspendida";
160
+ /** The registry says the licence is revoked. Terminal. */
161
+ readonly LICENCIA_REVOCADA: "licencia_revocada";
162
+ /** `vigenteHasta <= ahora` on the registry entry, or on the credential, or the
163
+ * credential claims a longer window than the registry grants. */
164
+ readonly LICENCIA_CADUCADA: "licencia_caducada";
165
+ /** The entry answered a query for another country. Transport or source bug. */
166
+ readonly ENTRADA_DE_OTRO_PAIS: "entrada_de_otro_pais";
167
+ /** `estado` outside {@link ESTADO_LICENCIA}. Unknown is never active. */
168
+ readonly ESTADO_REGISTRO_INVALIDO: "estado_registro_invalido";
169
+ /** `vigenteHasta` absent or not a finite number on the entry. */
170
+ readonly VIGENCIA_REGISTRO_INVALIDA: "vigencia_registro_invalida";
171
+ /** The specialty the credential claims is not the specialty the registry holds. */
172
+ readonly ESPECIALIDAD_NO_REGISTRADA: "especialidad_no_registada";
173
+ /** The issuing authority disagrees with the registry's. */
174
+ readonly AUTORIDAD_NO_REGISTRADA: "autoridad_no_registada";
175
+ /** `consultar` threw. Fail closed, and distinguishable from a plain miss. */
176
+ readonly CONSULTA_FALLIDA: "consulta_fallida";
177
+ /** A verification class this phase does not implement. See the strategies below. */
178
+ readonly METODO_NO_IMPLEMENTADO: "metodo_no_implementado";
179
+ };
180
+ export type MotivoRechazoConsultaRegistro = (typeof MOTIVO_RECHAZO_CONSULTA_REGISTRO)[keyof typeof MOTIVO_RECHAZO_CONSULTA_REGISTRO];
181
+ /**
182
+ * Every reason a foundation verification can fail.
183
+ *
184
+ * The union, not a new vocabulary: shape failures surface as
185
+ * `MOTIVO_RECHAZO_CREDENCIAL.*`, whole-record problems as
186
+ * `MOTIVO_RECHAZO_REGISTRO.*`, and registry findings as
187
+ * `MOTIVO_RECHAZO_CONSULTA_REGISTRO.*`.
188
+ */
189
+ export type MotivoRechazoAcreditacion = MotivoRechazoConsultaRegistro | MotivoRechazoCredencial | MotivoRechazoRegistro;
190
+ /** The audit record of a successful verification. */
191
+ export interface MetodoVerificacionAplicado {
192
+ readonly clase: "registro_por_pais";
193
+ readonly pais: string;
194
+ readonly versionRegistro: string;
195
+ }
196
+ export type ResultadoAcreditacion = {
197
+ readonly ok: true;
198
+ readonly credencial: CredencialMedica;
199
+ /** The registry entry the verification stood on. */
200
+ readonly entrada: EntradaRegistroLicencia;
201
+ /**
202
+ * How it was checked, on the face of the result. An accreditation without
203
+ * proof of method is a claim, not a verification (`docs/medico/modelo-datos.md` §4.2).
204
+ */
205
+ readonly metodoVerificacion: MetodoVerificacionAplicado;
206
+ /** Injected clock value, so the trail carries no hidden `Date.now()`. */
207
+ readonly verificadoEn: number;
208
+ } | {
209
+ readonly ok: false;
210
+ readonly motivo: MotivoRechazoAcreditacion;
211
+ readonly detalle: string;
212
+ /** Always `false`. There is no state here meaning "unverified but proceed". */
213
+ readonly accesoPermitido: false;
214
+ };
215
+ /**
216
+ * Build the `metodoVerificacion` that records "I checked this against the
217
+ * country registry".
218
+ *
219
+ * One construction site: the success path below stamps its audit trail with
220
+ * this, so the shape a verification returns and the shape an `Aval` must carry
221
+ * cannot drift apart.
222
+ *
223
+ * `versionRegistro` is mandatory on the wire (`docs/medico/modelo-datos.md` §4.2):
224
+ * a stale snapshot that cannot be named cannot be reasoned about, and an
225
+ * unnameable one is refused by `validarAval` in `./aval.ts`.
226
+ */
227
+ export declare function metodoRegistroPorPais(pais: string, versionRegistro: string): MetodoVerificacionAplicado;
228
+ /**
229
+ * Verify a credential against a real registry entry.
230
+ *
231
+ * Checks run cheap-to-expensive and in a fixed order, so the same inputs always
232
+ * produce the same `motivo`: form, then country support, then snapshot presence,
233
+ * then lookup, then the entry's own state and window, then the claims the
234
+ * credential makes about that entry. No branch is random, no branch reads a
235
+ * clock that was not injected, and no branch can widen access.
236
+ *
237
+ * @param credencial - a credential already built. Its shape is re-checked here so
238
+ * the foundation path cannot be entered with a hand-rolled object.
239
+ * @param fuente - the injected registry. Phase 3 supplies the real transport.
240
+ * @param ahora - injected clock (ms epoch), used against both `vigenteHasta` fields.
241
+ */
242
+ export declare function acreditarContraRegistro(credencial: CredencialMedica, fuente: FuenteAcreditacion, ahora: number): Promise<ResultadoAcreditacion>;
243
+ /**
244
+ * A verification strategy — the seam Phase 3 fills with peer attestation and
245
+ * quorum revocation.
246
+ *
247
+ * Declared here, implemented by exactly one member today. The point of the
248
+ * interface is that adding `avalado_por_pares` or `revocacion_por_quorum` is a
249
+ * new implementation of *this* type, never a new branch inside
250
+ * {@link acreditarContraRegistro}.
251
+ */
252
+ export interface EstrategiaAcreditacion {
253
+ /** The `MetodoVerificacion` class this strategy produces. */
254
+ readonly clase: MetodoVerificacion["clase"];
255
+ acreditar(credencial: CredencialMedica, fuente: FuenteAcreditacion, ahora: number): Promise<ResultadoAcreditacion>;
256
+ }
257
+ /** The only implemented strategy: verification of foundation, by country registry. */
258
+ export declare const ESTRATEGIA_REGISTRO_POR_PAIS: EstrategiaAcreditacion;
259
+ /**
260
+ * Classes declared by `docs/medico/modelo-datos.md` §4.2 that this phase does
261
+ * not implement. Listed so the gap is explicit rather than inferred from a
262
+ * missing export.
263
+ */
264
+ export declare const CLASES_NO_IMPLEMENTADAS: readonly ["colegio_directo", "testimonio_directo", "supervision"];
265
+ /**
266
+ * Dispatch to a strategy by its verification class.
267
+ *
268
+ * Fails closed with {@link MOTIVO_RECHAZO_CONSULTA_REGISTRO.METODO_NO_IMPLEMENTADO}
269
+ * for a class with no strategy today, so "not built yet" can never be read as
270
+ * "nothing to check". Peer attestation and quorum revocation arrive here, as
271
+ * implementations of {@link EstrategiaAcreditacion}, in Phase 3.
272
+ */
273
+ export declare function acreditarCon(clase: MetodoVerificacion["clase"], credencial: CredencialMedica, fuente: FuenteAcreditacion, ahora: number): Promise<ResultadoAcreditacion>;
274
+ /**
275
+ * An in-memory registry. Pure data, no I/O — the fixture a test supplies and the
276
+ * stand-in Phase 3 replaces with a replicated, append-only snapshot.
277
+ */
278
+ export declare class RegistroLicenciasEnMemoria implements FuenteAcreditacion {
279
+ private readonly entradasPorPais;
280
+ private readonly versiones;
281
+ private readonly soportados;
282
+ /**
283
+ * @param entradas - the registry contents. Anything whose `estado` is not in
284
+ * {@link ESTADO_LICENCIA} is kept verbatim, so a test can prove such an
285
+ * entry is refused rather than normalised away by the fixture.
286
+ * @param opciones.versionRegistro - snapshot version, per country or shared.
287
+ * @param opciones.paisesSoportados - countries this source speaks for. Defaults
288
+ * to the countries actually present in `entradas`.
289
+ */
290
+ constructor(entradas?: readonly EntradaRegistroLicencia[], opciones?: {
291
+ readonly versionRegistro?: string | Readonly<Record<string, string>>;
292
+ readonly paisesSoportados?: readonly string[];
293
+ });
294
+ get paisesSoportados(): readonly string[];
295
+ versionRegistro(pais: string): string | undefined;
296
+ consultar({ pais, hashLicencia, }: ConsultaRegistroLicencia): EntradaRegistroLicencia | undefined;
297
+ }
298
+ /** Reasons this module can produce, re-exported so callers need one import. */
299
+ export { MOTIVO_RECHAZO_CREDENCIAL, MOTIVO_RECHAZO_REGISTRO };
300
+ //# sourceMappingURL=verificacion-registro.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verificacion-registro.d.ts","sourceRoot":"","sources":["../../src/medico/verificacion-registro.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,OAAO,EACN,yBAAyB,EACzB,KAAK,uBAAuB,EAE5B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,uBAAuB,EACvB,KAAK,qBAAqB,EAC1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEvE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe;aAC3B,MAAM,EAAE,QAAQ;aAChB,UAAU,EAAE,YAAY;aACxB,QAAQ,EAAE,UAAU;CACX,CAAC;AAEX,MAAM,MAAM,cAAc,GACzB,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAExD;;;;;;;;GAQG;AACH,MAAM,WAAW,uBAAuB;IACvC,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0FAA0F;IAC1F,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;;;;OAIG;I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EAAE,MAAM,CAAC,CAAC,CAAC;QACrE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;KACzC,EAoBN;IAED,IAAI,gBAAgB,IAAI,SAAS,MAAM,EAAE,CAExC;IAED,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEhD;IAED,SAAS,CAAC,EACT,IAAI,EACJ,YAAY,GACZ,EAAE,wBAAwB,GAAG,uBAAuB,GAAG,SAAS,CAIhE;CACD;AAED,+EAA+E;AAC/E,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,CAAC"}
@@ -0,0 +1,319 @@
1
+ /**
2
+ * Foundation verification: from "well-formed credential" to "accredited".
3
+ *
4
+ * ─── WHAT THE PREVIOUS PHASE ALREADY SOLVED, AND WHAT IT DID NOT ─────────────
5
+ *
6
+ * `./credencial.ts` verifies FORM: ISO country, `idLicencia` is a SHA-256 hex,
7
+ * `vigenteHasta` present and not lapsed, signature over the canonical bytes. A
8
+ * credential can pass all of that and still be a forgery — a well-formed object
9
+ * that no authority ever issued. Nothing before this file asked the substrate
10
+ * question: *does this licence exist?*
11
+ *
12
+ * `./registro.ts` answers part of it, with the right fail-closed primitive
13
+ * (normalize → SHA-256 → country-scoped membership). What it cannot answer, by
14
+ * construction, is state: its `InstantaneaRegistroPais` is a `Set<string>` of
15
+ * hashes, and a set has one relation — *present* or *absent*. A `Set` cannot say
16
+ * "present, suspended", so a licence the Ministry suspended in March keeps
17
+ * matching a snapshot taken in January, forever.
18
+ *
19
+ * ─── THE THIRD DEFECT, WHICH IS THE ONE THAT ADDS NOVEL VALUE ───────────────
20
+ *
21
+ * `InstantaneaRegistroPais` also carries no expiry and no version per entry, so
22
+ * `{ estado: 'activa' }` would be enough — and that is exactly the
23
+ * OrionHealth `expired`-never-returned defect wearing a different hat. A state
24
+ * that is only ever `ACTIVA` because nothing can express anything else is not a
25
+ * state machine, it is a comment.
26
+ *
27
+ * So the registry here is an array of {@link EntradaRegistroLicencia}: country,
28
+ * licence hash, issuer-signed `vigenteHasta`, and an explicit
29
+ * {@link EstadoLicenciaRegistro}. All three states are reachable and two of them
30
+ * refuse. That is the whole point of this file.
31
+ *
32
+ * ─── WHY THE LOOKUP IS AN INJECTED FUNCTION ────────────────────────────────
33
+ *
34
+ * {@link FuenteAcreditacion.consultar} takes a `{ pais, hashLicencia }` and
35
+ * returns an entry or `undefined`. No fetch, no filesystem, no `Date.now()`:
36
+ * the transport is Phase 3's decision (a gossiped, hash-compared snapshot), and
37
+ * until then a fixture *is* the network. Because the seam is data in / data
38
+ * out, every state below is reachable from a test with no I/O at all.
39
+ *
40
+ * ─── WHY A MISSING COUNTRY REFUSES ────────────────────────────────────────
41
+ *
42
+ * OrionHealth returns `LicenseVerificationResult.unknown` when a country's
43
+ * registry is empty and treats it as "not refused". Here an unlisted country is
44
+ * `pais_no_soportado` and a supported country with an empty registry is
45
+ * `licencia_no_encontrada` — both `accesoPermitido: false`, and the type has no
46
+ * member meaning "we could not check this, carry on". An accreditation whose
47
+ * failure mode is a bypass is not a verification scheme.
48
+ *
49
+ * Pure: no clock read, no randomness, no I/O. `ahora` is always injected, which
50
+ * is what makes the refusal reasons reproducible — same inputs, same `motivo`,
51
+ * byte for byte, forever.
52
+ */
53
+ import { MOTIVO_RECHAZO_CREDENCIAL, validarCredencial, } from "./credencial.js";
54
+ import { MOTIVO_RECHAZO_REGISTRO, } from "./registro-profesional.js";
55
+ /**
56
+ * The life cycle of a licence *as the registry sees it*.
57
+ *
58
+ * Declared as a closed three-member union so the intermediate and terminal
59
+ * states are first-class. OrionHealth has the same two non-active states in its
60
+ * enum and returns neither one, because list membership cannot express them;
61
+ * here `suspendida` and `revocada` are not decoration — each one is a distinct,
62
+ * named refusal returned by {@link acreditarContraRegistro}.
63
+ *
64
+ * A value outside this union is refused as {@link MOTIVO_RECHAZO_CONSULTA_REGISTRO.ESTADO_REGISTRO_INVALIDO}.
65
+ * Unknown is never treated as active.
66
+ */
67
+ export const ESTADO_LICENCIA = {
68
+ ACTIVA: "activa",
69
+ SUSPENDIDA: "suspendida",
70
+ REVOCADA: "revocada",
71
+ };
72
+ /**
73
+ * Refusals specific to consulting a registry.
74
+ *
75
+ * Additive to the two existing reason sets rather than a parallel system:
76
+ * {@link MotivoRechazoAcreditacion} is the union of this, `MOTIVO_RECHAZO_CREDENCIAL`
77
+ * and `MOTIVO_RECHAZO_REGISTRO`, and a credential that fails form is reported
78
+ * with the *credential's own* reason, so a caller reading
79
+ * `motivo === MOTIVO_RECHAZO_CREDENCIAL.SIN_VIGENCIA` keeps working unchanged.
80
+ */
81
+ export const MOTIVO_RECHAZO_CONSULTA_REGISTRO = {
82
+ /** The credential itself failed `validarCredencial`; see `detalle` for its reason. */
83
+ CREDENCIAL_MAL_FORMADA: "credencial_mal_formada",
84
+ /** No source speaks for this country. Fail closed, never "unknown". */
85
+ PAIS_NO_SOPORTADO: "pais_no_soportado",
86
+ /** The source supports the country but holds no snapshot for it. */
87
+ PAIS_SIN_REGISTRO: "pais_sin_registro",
88
+ /** Country supported, snapshot present, licence absent. */
89
+ LICENCIA_NO_ENCONTRADA: "licencia_no_encontrada",
90
+ /** The registry says the licence is suspended. */
91
+ LICENCIA_SUSPENDIDA: "licencia_suspendida",
92
+ /** The registry says the licence is revoked. Terminal. */
93
+ LICENCIA_REVOCADA: "licencia_revocada",
94
+ /** `vigenteHasta <= ahora` on the registry entry, or on the credential, or the
95
+ * credential claims a longer window than the registry grants. */
96
+ LICENCIA_CADUCADA: "licencia_caducada",
97
+ /** The entry answered a query for another country. Transport or source bug. */
98
+ ENTRADA_DE_OTRO_PAIS: "entrada_de_otro_pais",
99
+ /** `estado` outside {@link ESTADO_LICENCIA}. Unknown is never active. */
100
+ ESTADO_REGISTRO_INVALIDO: "estado_registro_invalido",
101
+ /** `vigenteHasta` absent or not a finite number on the entry. */
102
+ VIGENCIA_REGISTRO_INVALIDA: "vigencia_registro_invalida",
103
+ /** The specialty the credential claims is not the specialty the registry holds. */
104
+ ESPECIALIDAD_NO_REGISTRADA: "especialidad_no_registada",
105
+ /** The issuing authority disagrees with the registry's. */
106
+ AUTORIDAD_NO_REGISTRADA: "autoridad_no_registada",
107
+ /** `consultar` threw. Fail closed, and distinguishable from a plain miss. */
108
+ CONSULTA_FALLIDA: "consulta_fallida",
109
+ /** A verification class this phase does not implement. See the strategies below. */
110
+ METODO_NO_IMPLEMENTADO: "metodo_no_implementado",
111
+ };
112
+ function fallo(motivo, detalle) {
113
+ return { ok: false, motivo, detalle, accesoPermitido: false };
114
+ }
115
+ /**
116
+ * Build the `metodoVerificacion` that records "I checked this against the
117
+ * country registry".
118
+ *
119
+ * One construction site: the success path below stamps its audit trail with
120
+ * this, so the shape a verification returns and the shape an `Aval` must carry
121
+ * cannot drift apart.
122
+ *
123
+ * `versionRegistro` is mandatory on the wire (`docs/medico/modelo-datos.md` §4.2):
124
+ * a stale snapshot that cannot be named cannot be reasoned about, and an
125
+ * unnameable one is refused by `validarAval` in `./aval.ts`.
126
+ */
127
+ export function metodoRegistroPorPais(pais, versionRegistro) {
128
+ return {
129
+ clase: "registro_por_pais",
130
+ pais: pais.toUpperCase(),
131
+ versionRegistro,
132
+ };
133
+ }
134
+ const RE_PAIS_ALFA2 = /^[A-Z]{2}$/;
135
+ const RE_HEX64 = /^[0-9a-f]{64}$/;
136
+ /**
137
+ * Verify a credential against a real registry entry.
138
+ *
139
+ * Checks run cheap-to-expensive and in a fixed order, so the same inputs always
140
+ * produce the same `motivo`: form, then country support, then snapshot presence,
141
+ * then lookup, then the entry's own state and window, then the claims the
142
+ * credential makes about that entry. No branch is random, no branch reads a
143
+ * clock that was not injected, and no branch can widen access.
144
+ *
145
+ * @param credencial - a credential already built. Its shape is re-checked here so
146
+ * the foundation path cannot be entered with a hand-rolled object.
147
+ * @param fuente - the injected registry. Phase 3 supplies the real transport.
148
+ * @param ahora - injected clock (ms epoch), used against both `vigenteHasta` fields.
149
+ */
150
+ export async function acreditarContraRegistro(credencial, fuente, ahora) {
151
+ // ── 1. Form, first: never spend a lookup on a malformed object ──
152
+ const forma = validarCredencial(credencial, ahora);
153
+ if (!forma.ok) {
154
+ // The credential's own reason is preserved so callers of `validarCredencial`
155
+ // keep working; `motivo` stays inside the one vocabulary.
156
+ return fallo(MOTIVO_RECHAZO_CONSULTA_REGISTRO.CREDENCIAL_MAL_FORMADA, `forma inválida (${forma.motivo}): ${forma.detalle}`);
157
+ }
158
+ const pais = credencial.pais.toUpperCase();
159
+ // ── 2. Country support: fail closed, the OrionHealth `unknown` branch ──
160
+ if (!Array.isArray(fuente.paisesSoportados) ||
161
+ !fuente.paisesSoportados.some((p) => p.toUpperCase() === pais)) {
162
+ return fallo(MOTIVO_RECHAZO_CONSULTA_REGISTRO.PAIS_NO_SOPORTADO, `ninguna fuente sostiene '${pais}': no hay registro contra el cual verificar, y no verificar no es perdonar`);
163
+ }
164
+ // ── 3. The country is supported: there must still be a snapshot behind it ──
165
+ const version = fuente.versionRegistro(pais);
166
+ if (!version) {
167
+ return fallo(MOTIVO_RECHAZO_CONSULTA_REGISTRO.PAIS_SIN_REGISTRO, `'${pais}' está soportado pero no hay instantánea cargada`);
168
+ }
169
+ // ── 4. The lookup. A throwing transport is a failure, not a miss ──
170
+ let entrada;
171
+ try {
172
+ entrada = await fuente.consultar({
173
+ pais,
174
+ hashLicencia: credencial.idLicencia,
175
+ });
176
+ }
177
+ catch (error) {
178
+ return fallo(MOTIVO_RECHAZO_CONSULTA_REGISTRO.CONSULTA_FALLIDA, `la consulta al registro falló: ${error instanceof Error ? error.message : String(error)}`);
179
+ }
180
+ if (!entrada) {
181
+ return fallo(MOTIVO_RECHAZO_CONSULTA_REGISTRO.LICENCIA_NO_ENCONTRADA, `hash de licencia no presente en el registro '${pais}' (versión ${version})`);
182
+ }
183
+ // ── 5. The entry must be well formed itself ──
184
+ if (typeof entrada.pais !== "string" || !RE_PAIS_ALFA2.test(entrada.pais)) {
185
+ return fallo(MOTIVO_RECHAZO_CONSULTA_REGISTRO.ENTRADA_DE_OTRO_PAIS, `la entrada declara un país inválido: ${String(entrada.pais)}`);
186
+ }
187
+ if (entrada.pais.toUpperCase() !== pais) {
188
+ return fallo(MOTIVO_RECHAZO_CONSULTA_REGISTRO.ENTRADA_DE_OTRO_PAIS, `la entrada responde a una consulta de '${pais}' con una de '${entrada.pais}'`);
189
+ }
190
+ if (typeof entrada.hashLicencia !== "string" ||
191
+ !RE_HEX64.test(entrada.hashLicencia)) {
192
+ return fallo(MOTIVO_RECHAZO_CONSULTA_REGISTRO.VIGENCIA_REGISTRO_INVALIDA, "la entrada no declara un hash de licencia válido");
193
+ }
194
+ if (typeof entrada.vigenteHasta !== "number" ||
195
+ !Number.isFinite(entrada.vigenteHasta) ||
196
+ entrada.vigenteHasta <= 0) {
197
+ return fallo(MOTIVO_RECHAZO_CONSULTA_REGISTRO.VIGENCIA_REGISTRO_INVALIDA, `la entrada no declara una vigencia válida: ${String(entrada.vigenteHasta)}`);
198
+ }
199
+ if (!Object.values(ESTADO_LICENCIA).includes(entrada.estado)) {
200
+ // An unrecognised state is refused, never optimistically read as `activa`.
201
+ return fallo(MOTIVO_RECHAZO_CONSULTA_REGISTRO.ESTADO_REGISTRO_INVALIDO, `estado de licencia desconocido: ${String(entrada.estado)}`);
202
+ }
203
+ // ── 6. State. Both non-active states refuse — no "valid with warnings" ──
204
+ if (entrada.estado === ESTADO_LICENCIA.REVOCADA) {
205
+ return fallo(MOTIVO_RECHAZO_CONSULTA_REGISTRO.LICENCIA_REVOCADA, `el registro de '${pais}' declara la licencia revocada: no admite avisos`);
206
+ }
207
+ if (entrada.estado === ESTADO_LICENCIA.SUSPENDIDA) {
208
+ return fallo(MOTIVO_RECHAZO_CONSULTA_REGISTRO.LICENCIA_SUSPENDIDA, `el registro de '${pais}' declara la licencia suspendida: no admite avisos`);
209
+ }
210
+ // ── 7. Windows. Two independent ones, and the credential may not exceed the registry ──
211
+ // `vigenteHasta` is exclusive in both places, matching `validarCredencial`.
212
+ if (credencial.vigenteHasta <= ahora) {
213
+ return fallo(MOTIVO_RECHAZO_CONSULTA_REGISTRO.LICENCIA_CADUCADA, `la credencial caducó antes de ${ahora} (vigente hasta ${credencial.vigenteHasta})`);
214
+ }
215
+ if (entrada.vigenteHasta <= ahora) {
216
+ return fallo(MOTIVO_RECHAZO_CONSULTA_REGISTRO.LICENCIA_CADUCADA, `el registro da la licencia por vencida (vigente hasta ${entrada.vigenteHasta}, ahora ${ahora})`);
217
+ }
218
+ if (credencial.vigenteHasta > entrada.vigenteHasta) {
219
+ return fallo(MOTIVO_RECHAZO_CONSULTA_REGISTRO.LICENCIA_CADUCADA, `la credencial reclama vigencia hasta ${credencial.vigenteHasta} pero el registro solo hasta ${entrada.vigenteHasta}`);
220
+ }
221
+ // ── 8. The claims the credential makes about that entry ──
222
+ if (entrada.especialidad !== undefined &&
223
+ credencial.especialidad !== entrada.especialidad) {
224
+ return fallo(MOTIVO_RECHAZO_CONSULTA_REGISTRO.ESPECIALIDAD_NO_REGISTRADA, `la entrada registra '${entrada.especialidad}' y la credencial reclama '${String(credencial.especialidad)}'`);
225
+ }
226
+ if (entrada.autoridad !== undefined &&
227
+ credencial.autoridad !== entrada.autoridad) {
228
+ return fallo(MOTIVO_RECHAZO_CONSULTA_REGISTRO.AUTORIDAD_NO_REGISTRADA, `la entrada registra '${entrada.autoridad}' y la credencial declara '${credencial.autoridad}'`);
229
+ }
230
+ return {
231
+ ok: true,
232
+ credencial,
233
+ entrada,
234
+ metodoVerificacion: metodoRegistroPorPais(pais, version),
235
+ verificadoEn: ahora,
236
+ };
237
+ }
238
+ /** The only implemented strategy: verification of foundation, by country registry. */
239
+ export const ESTRATEGIA_REGISTRO_POR_PAIS = {
240
+ clase: "registro_por_pais",
241
+ acreditar: acreditarContraRegistro,
242
+ };
243
+ /**
244
+ * Classes declared by `docs/medico/modelo-datos.md` §4.2 that this phase does
245
+ * not implement. Listed so the gap is explicit rather than inferred from a
246
+ * missing export.
247
+ */
248
+ export const CLASES_NO_IMPLEMENTADAS = [
249
+ "colegio_directo",
250
+ "testimonio_directo",
251
+ "supervision",
252
+ ];
253
+ /**
254
+ * Dispatch to a strategy by its verification class.
255
+ *
256
+ * Fails closed with {@link MOTIVO_RECHAZO_CONSULTA_REGISTRO.METODO_NO_IMPLEMENTADO}
257
+ * for a class with no strategy today, so "not built yet" can never be read as
258
+ * "nothing to check". Peer attestation and quorum revocation arrive here, as
259
+ * implementations of {@link EstrategiaAcreditacion}, in Phase 3.
260
+ */
261
+ export async function acreditarCon(clase, credencial, fuente, ahora) {
262
+ if (clase === ESTRATEGIA_REGISTRO_POR_PAIS.clase) {
263
+ return ESTRATEGIA_REGISTRO_POR_PAIS.acreditar(credencial, fuente, ahora);
264
+ }
265
+ return fallo(MOTIVO_RECHAZO_CONSULTA_REGISTRO.METODO_NO_IMPLEMENTADO, `la clase de verificación '${clase}' todavía no tiene estrategia en esta fase`);
266
+ }
267
+ /**
268
+ * An in-memory registry. Pure data, no I/O — the fixture a test supplies and the
269
+ * stand-in Phase 3 replaces with a replicated, append-only snapshot.
270
+ */
271
+ export class RegistroLicenciasEnMemoria {
272
+ entradasPorPais = new Map();
273
+ versiones = new Map();
274
+ soportados;
275
+ /**
276
+ * @param entradas - the registry contents. Anything whose `estado` is not in
277
+ * {@link ESTADO_LICENCIA} is kept verbatim, so a test can prove such an
278
+ * entry is refused rather than normalised away by the fixture.
279
+ * @param opciones.versionRegistro - snapshot version, per country or shared.
280
+ * @param opciones.paisesSoportados - countries this source speaks for. Defaults
281
+ * to the countries actually present in `entradas`.
282
+ */
283
+ constructor(entradas = [], opciones = {}) {
284
+ for (const entrada of entradas) {
285
+ const clave = entrada?.pais?.toUpperCase?.() ?? "";
286
+ if (clave === "")
287
+ continue;
288
+ const lista = this.entradasPorPais.get(clave);
289
+ if (lista)
290
+ lista.push(entrada);
291
+ else
292
+ this.entradasPorPais.set(clave, [entrada]);
293
+ }
294
+ const version = opciones.versionRegistro;
295
+ for (const pais of this.entradasPorPais.keys()) {
296
+ const propia = typeof version === "string" ? version : version?.[pais];
297
+ // An empty registry still has a version, so "supported but no snapshot" is
298
+ // distinguishable from "empty snapshot" — both refuse, for different reasons.
299
+ this.versiones.set(pais, propia ?? `${pais}-v0`);
300
+ }
301
+ const declarados = opciones.paisesSoportados?.map((p) => p.toUpperCase());
302
+ this.soportados = new Set(declarados ?? [...this.entradasPorPais.keys()]);
303
+ }
304
+ get paisesSoportados() {
305
+ return [...this.soportados];
306
+ }
307
+ versionRegistro(pais) {
308
+ return this.versiones.get(pais.toUpperCase());
309
+ }
310
+ consultar({ pais, hashLicencia, }) {
311
+ const lista = this.entradasPorPais.get(pais.toUpperCase());
312
+ if (!lista)
313
+ return undefined;
314
+ return lista.find((e) => e.hashLicencia === hashLicencia);
315
+ }
316
+ }
317
+ /** Reasons this module can produce, re-exported so callers need one import. */
318
+ export { MOTIVO_RECHAZO_CREDENCIAL, MOTIVO_RECHAZO_REGISTRO };
319
+ //# sourceMappingURL=verificacion-registro.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verificacion-registro.js","sourceRoot":"","sources":["../../src/medico/verificacion-registro.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,OAAO,EACN,yBAAyB,EAEzB,iBAAiB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,uBAAuB,GAEvB,MAAM,2BAA2B,CAAC;AAGnC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC9B,MAAM,EAAE,QAAQ;IAChB,UAAU,EAAE,YAAY;IACxB,QAAQ,EAAE,UAAU;CACX,CAAC;AAkFX;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG;IAC/C,sFAAsF;IACtF,sBAAsB,EAAE,wBAAwB;IAChD,uEAAuE;IACvE,iBAAiB,EAAE,mBAAmB;IACtC,oEAAoE;IACpE,i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