@swal/edge-mesh 0.0.0-stage → 0.1.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 (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 +157 -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 +192 -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 +71 -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 +52 -0
  313. package/dist/transport/peerjs.d.ts.map +1 -0
  314. package/dist/transport/peerjs.js +336 -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 +246 -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 +139 -4
@@ -0,0 +1,160 @@
1
+ /**
2
+ * `CredencialMedica` — construction, signing and validation.
3
+ *
4
+ * ─── VALIDATION FAILS CLOSED ────────────────────────────────────────────────
5
+ *
6
+ * Every refusal in this module returns a named reason and leaves the caller
7
+ * with no way to read "unverified but proceed" out of the result. There is no
8
+ * `unknown`, no tri-state, no boolean-plus-warning. The type system does not
9
+ * offer a value meaning "we could not check this, carry on".
10
+ *
11
+ * That is the whole point. The OrionHealth licence verifier returns
12
+ * `LicenseVerificationResult.unknown` when a country's registry is empty, which
13
+ * is correct for a local lookup UI and wrong here: a mesh node that treats
14
+ * `unknown` as "not refused" turns *an unsupported country* into a bypass. A
15
+ * physician could present a licence from a country with no registry snapshot and
16
+ * be waved through by any node that had not yet downloaded that registry.
17
+ */
18
+ import type { PostQuantumIdentity } from "../identity/index.js";
19
+ import type { NodoId, ParPublico } from "../types/index.js";
20
+ import { type CredencialMedica, type EstadoEmision, type TipoCredencial, VERSION_MODELO } from "./types.js";
21
+ /** Why a credential was refused. Every value here means access stays closed. */
22
+ export declare const MOTIVO_RECHAZO_CREDENCIAL: {
23
+ /** A mandatory field is absent or empty. Names the field. */
24
+ readonly CAMPO_OBLIGATORIO_AUSENTE: "campo_obligatorio_ausente";
25
+ /**
26
+ * `vigenteHasta` absent or not a number. Kept distinct from
27
+ * `CREDENCIAL_CADUCADA` because this is the OrionHealth `expired`-never-returned
28
+ * defect: without an issuer-signed expiry a revoked licence verifies forever.
29
+ */
30
+ readonly SIN_VIGENCIA: "sin_vigencia";
31
+ /** `Date.now() >= vigenteHasta`. */
32
+ readonly CREDENCIAL_CADUCADA: "credencial_caducada";
33
+ /** `vigenteHasta` is in the past at construction time. */
34
+ readonly VIGENCIA_EN_PASADO: "vigencia_en_pasado";
35
+ /** `emitidoEn` is not a plausible epoch-ms value, or is after `vigenteHasta`. */
36
+ readonly EMISION_INVALIDA: "emision_invalida";
37
+ /** `idLicencia` is not a 64-char lower-case hex SHA-256. */
38
+ readonly ID_LICENCIA_MAL_FORMADO: "id_licencia_mal_formado";
39
+ /** `pais` is not ISO 3166-1 alpha-2. */
40
+ readonly PAIS_INVALIDO: "pais_invalido";
41
+ /** `tipo` or `estadoEmision` outside the declared unions. */
42
+ readonly ENUM_INVALIDO: "enum_invalido";
43
+ /** No signature bytes. */
44
+ readonly FIRMA_AUSENTE: "firma_ausente";
45
+ /** Signature does not verify against the issuer's public key. */
46
+ readonly FIRMA_INVALIDA: "firma_invalida";
47
+ /** `estadoEmision: 'autofirmada'` whose `emisor` is not the subject. */
48
+ readonly AUTOEMISION_INCOHERENTE: "autoemision_incoherente";
49
+ };
50
+ export type MotivoRechazoCredencial = (typeof MOTIVO_RECHAZO_CREDENCIAL)[keyof typeof MOTIVO_RECHAZO_CREDENCIAL];
51
+ export type ResultadoValidacionCredencial = {
52
+ readonly ok: true;
53
+ readonly credencial: CredencialMedica;
54
+ } | {
55
+ readonly ok: false;
56
+ readonly motivo: MotivoRechazoCredencial;
57
+ readonly detalle: string;
58
+ /**
59
+ * Always `false`. Present so that a caller destructuring the discriminant
60
+ * cannot accidentally treat a refusal as soft information. There is no
61
+ * state in this module where a credential is "unverified but usable".
62
+ */
63
+ readonly accesoPermitido: false;
64
+ };
65
+ /** Inputs for {@link crearCredencial}. The issuer signs; nothing else does. */
66
+ export interface BorradorCredencial {
67
+ readonly tipo: TipoCredencial;
68
+ /** ISO 3166-1 alpha-2. `CO` for Colombia. */
69
+ readonly pais: string;
70
+ /** `'minsalud-rethus'`, `'colomedico-cm'`. The source of the claim. */
71
+ readonly autoridad: string;
72
+ /** `sha256(normalize(numeroLicencia))`. The raw number must not be passed here. */
73
+ readonly idLicencia: string;
74
+ readonly especialidad?: string;
75
+ /** Seal of the real licence number to a specific verifier, if kept. */
76
+ readonly numeroLicenciaCifrado?: Uint8Array;
77
+ readonly emitidoEn: number;
78
+ /**
79
+ * REQUIRED. Issuer-signed expiry. There is no default and no "derive it from
80
+ * the registry": a membership list cannot express a validity window, so this
81
+ * value has to come from the issuer's signature.
82
+ */
83
+ readonly vigenteHasta: number;
84
+ readonly estadoEmision: EstadoEmision;
85
+ /** Who signs. For `'autofirmada'` this is the subject node itself. */
86
+ readonly emisor: NodoId;
87
+ }
88
+ /**
89
+ * Structural validation, in cheap-to-expensive order. Runs no signature check.
90
+ *
91
+ * Order is deliberate: the malformed-shape refusals cost nothing, so a garbage
92
+ * payload never reaches a post-quantum operation. Same discipline
93
+ * `applyTransaction` in `src/maloca/karma.ts` uses.
94
+ *
95
+ * @param ahora - injected clock (ms epoch). Tests pass a fixed value; the
96
+ * function itself never reads the clock, which is what keeps it pure.
97
+ */
98
+ export declare function validarCredencial(credencial: CredencialMedica, ahora: number): ResultadoValidacionCredencial;
99
+ /**
100
+ * Verify the issuer's signature over the canonical credential bytes.
101
+ *
102
+ * Separate from {@link validarCredencial} so a caller can run the cheap
103
+ * structural checks first and skip a post-quantum verification on garbage.
104
+ * Both are required before a credential counts as evidence; neither is
105
+ * sufficient alone.
106
+ */
107
+ export declare function verificarFirmaCredencial(credencial: CredencialMedica, identidadEmisor: PostQuantumIdentity, parPublico: ParPublico): Promise<boolean>;
108
+ /**
109
+ * Full validation: structure, then signature, then the self-attestation rule.
110
+ *
111
+ * @returns `ok: true` only when the credential is well formed, unexpired and
112
+ * genuinely signed by `emisor`. Any other outcome is `ok: false` with
113
+ * `accesoPermitido: false`. There is no partial credit and no third state.
114
+ */
115
+ export declare function validarCredencialFirmada(credencial: CredencialMedica, identidadEmisor: PostQuantumIdentity, parPublicoEmisor: ParPublico, ahora: number): Promise<ResultadoValidacionCredencial>;
116
+ /**
117
+ * A self-attested credential must be signed by the subject it rides on.
118
+ *
119
+ * Kept separate from {@link validarCredencialFirmada} because a
120
+ * `CredencialMedica` carries no subject field of its own — the binding is
121
+ * `RegistroProfesional.nodoId`, one level up. An `autofirmada` credential whose
122
+ * `emisor` is a different node would let a node borrow someone else's key to
123
+ * look institutionally verified, so the check needs both halves and neither
124
+ * object alone contains them.
125
+ *
126
+ * Only `autofirmada` is constrained this way: an `atestiguada_pares` credential
127
+ * carries the issuing node's own signature, and an `anclada_autoridad` one
128
+ * carries the college's, and both are expected to differ from the subject.
129
+ */
130
+ export declare function validarVinculoEmision(credencial: CredencialMedica, nodoSujeto: NodoId): ResultadoValidacionCredencial;
131
+ /**
132
+ * Build and sign a credential.
133
+ *
134
+ * The `id` is derived from `idLicencia + tipo + pais`, so the same licence with
135
+ * the same type in the same country always yields the same id: the credential is
136
+ * identifiable across nodes without any node choosing a random identifier that
137
+ * two honest nodes would fail to agree on.
138
+ *
139
+ * The signature covers everything except `firma`, over the canonical bytes from
140
+ * `./canonica.ts`.
141
+ */
142
+ export declare function crearCredencial(borrador: BorradorCredencial, identidad: PostQuantumIdentity): Promise<CredencialMedica>;
143
+ /** SHA-256 of the canonical credential bytes. Binds an `Aval` to exact bytes. */
144
+ export declare function hashDeCredencial(credencial: CredencialMedica): Promise<string>;
145
+ /** Hex form of the canonical credential bytes, for logging and debugging. */
146
+ export declare function volcarCredencial(credencial: CredencialMedica): string;
147
+ /**
148
+ * A "certified doctor" per the product promise: `licencia ∧ especialidad`, both
149
+ * with a peer-witnessed or authority-anchored state, both unexpired.
150
+ *
151
+ * Deliberately not a boolean field on the licence. A boolean cannot expire, and
152
+ * specialties are revoked on a different cadence from base licensure.
153
+ *
154
+ * A licensed-but-unspecialised doctor is a legitimate node with a *smaller*
155
+ * capability set, not an impostor (DECISIÓN A.4) — this returns `false`, and the
156
+ * caller decides what a lower tier grants.
157
+ */
158
+ export declare function esMedicoCertificado(credenciales: readonly CredencialMedica[], ahora: number): boolean;
159
+ export { VERSION_MODELO };
160
+ //# sourceMappingURL=credencial.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credencial.d.ts","sourceRoot":"","sources":["../../src/medico/credencial.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAO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jB;AAED,6EAA6E;AAC7E,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,gBAAgB,GAAG,MAAM,CAErE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAClC,YAAY,EAAE,SAAS,gBAAgB,EAAE,EACzC,KAAK,EAAE,MAAM,GACX,OAAO,CAcT;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,240 @@
1
+ /**
2
+ * `CredencialMedica` — construction, signing and validation.
3
+ *
4
+ * ─── VALIDATION FAILS CLOSED ────────────────────────────────────────────────
5
+ *
6
+ * Every refusal in this module returns a named reason and leaves the caller
7
+ * with no way to read "unverified but proceed" out of the result. There is no
8
+ * `unknown`, no tri-state, no boolean-plus-warning. The type system does not
9
+ * offer a value meaning "we could not check this, carry on".
10
+ *
11
+ * That is the whole point. The OrionHealth licence verifier returns
12
+ * `LicenseVerificationResult.unknown` when a country's registry is empty, which
13
+ * is correct for a local lookup UI and wrong here: a mesh node that treats
14
+ * `unknown` as "not refused" turns *an unsupported country* into a bypass. A
15
+ * physician could present a licence from a country with no registry snapshot and
16
+ * be waved through by any node that had not yet downloaded that registry.
17
+ */
18
+ import { bytesAHex, bytesCredencial, hashCredencial, idCredencial, } from "./canonica.js";
19
+ import { CAMPOS_OBLIGATORIOS_CREDENCIAL, ESTADO_EMISION, TIPO_CREDENCIAL, VERSION_MODELO, } from "./types.js";
20
+ /** Why a credential was refused. Every value here means access stays closed. */
21
+ export const MOTIVO_RECHAZO_CREDENCIAL = {
22
+ /** A mandatory field is absent or empty. Names the field. */
23
+ CAMPO_OBLIGATORIO_AUSENTE: "campo_obligatorio_ausente",
24
+ /**
25
+ * `vigenteHasta` absent or not a number. Kept distinct from
26
+ * `CREDENCIAL_CADUCADA` because this is the OrionHealth `expired`-never-returned
27
+ * defect: without an issuer-signed expiry a revoked licence verifies forever.
28
+ */
29
+ SIN_VIGENCIA: "sin_vigencia",
30
+ /** `Date.now() >= vigenteHasta`. */
31
+ CREDENCIAL_CADUCADA: "credencial_caducada",
32
+ /** `vigenteHasta` is in the past at construction time. */
33
+ VIGENCIA_EN_PASADO: "vigencia_en_pasado",
34
+ /** `emitidoEn` is not a plausible epoch-ms value, or is after `vigenteHasta`. */
35
+ EMISION_INVALIDA: "emision_invalida",
36
+ /** `idLicencia` is not a 64-char lower-case hex SHA-256. */
37
+ ID_LICENCIA_MAL_FORMADO: "id_licencia_mal_formado",
38
+ /** `pais` is not ISO 3166-1 alpha-2. */
39
+ PAIS_INVALIDO: "pais_invalido",
40
+ /** `tipo` or `estadoEmision` outside the declared unions. */
41
+ ENUM_INVALIDO: "enum_invalido",
42
+ /** No signature bytes. */
43
+ FIRMA_AUSENTE: "firma_ausente",
44
+ /** Signature does not verify against the issuer's public key. */
45
+ FIRMA_INVALIDA: "firma_invalida",
46
+ /** `estadoEmision: 'autofirmada'` whose `emisor` is not the subject. */
47
+ AUTOEMISION_INCOHERENTE: "autoemision_incoherente",
48
+ };
49
+ const RE_HEX64 = /^[0-9a-f]{64}$/;
50
+ const RE_PAIS_ALFA2 = /^[A-Z]{2}$/;
51
+ function fallo(motivo, detalle) {
52
+ return { ok: false, motivo, detalle, accesoPermitido: false };
53
+ }
54
+ /**
55
+ * Structural validation, in cheap-to-expensive order. Runs no signature check.
56
+ *
57
+ * Order is deliberate: the malformed-shape refusals cost nothing, so a garbage
58
+ * payload never reaches a post-quantum operation. Same discipline
59
+ * `applyTransaction` in `src/maloca/karma.ts` uses.
60
+ *
61
+ * @param ahora - injected clock (ms epoch). Tests pass a fixed value; the
62
+ * function itself never reads the clock, which is what keeps it pure.
63
+ */
64
+ export function validarCredencial(credencial, ahora) {
65
+ if (!credencial || typeof credencial !== "object") {
66
+ return fallo(MOTIVO_RECHAZO_CREDENCIAL.CAMPO_OBLIGATORIO_AUSENTE, "la credencial no es un objeto");
67
+ }
68
+ // ── 1. The five mandatory fields, by name ──
69
+ for (const campo of CAMPOS_OBLIGATORIOS_CREDENCIAL) {
70
+ const valor = credencial[campo];
71
+ if (valor === undefined || valor === null || valor === "") {
72
+ return fallo(MOTIVO_RECHAZO_CREDENCIAL.CAMPO_OBLIGATORIO_AUSENTE, `falta '${campo}'`);
73
+ }
74
+ }
75
+ // ── 2. `vigenteHasta`, the field that closes the OrionHealth defect ──
76
+ // Checked before the enums because its absence is the specific bug this
77
+ // module exists to make impossible, and deserves the most specific reason.
78
+ if (typeof credencial.vigenteHasta !== "number" ||
79
+ !Number.isFinite(credencial.vigenteHasta)) {
80
+ return fallo(MOTIVO_RECHAZO_CREDENCIAL.SIN_VIGENCIA, "vigenteHasta ausente o no numérico: sin vigencia firmada por el emisor, una licencia revocada validaría para siempre");
81
+ }
82
+ if (credencial.vigenteHasta <= 0) {
83
+ return fallo(MOTIVO_RECHAZO_CREDENCIAL.SIN_VIGENCIA, `vigenteHasta inválido: ${credencial.vigenteHasta}`);
84
+ }
85
+ // ── 3. Enums ──
86
+ if (!Object.values(TIPO_CREDENCIAL).includes(credencial.tipo)) {
87
+ return fallo(MOTIVO_RECHAZO_CREDENCIAL.ENUM_INVALIDO, `tipo desconocido: ${String(credencial.tipo)}`);
88
+ }
89
+ if (!Object.values(ESTADO_EMISION).includes(credencial.estadoEmision)) {
90
+ return fallo(MOTIVO_RECHAZO_CREDENCIAL.ENUM_INVALIDO, `estadoEmision desconocido: ${String(credencial.estadoEmision)}`);
91
+ }
92
+ // ── 4. Country: alpha-2, upper case ──
93
+ if (!RE_PAIS_ALFA2.test(credencial.pais)) {
94
+ return fallo(MOTIVO_RECHAZO_CREDENCIAL.PAIS_INVALIDO, `pais debe ser ISO 3166-1 alpha-2 en mayúsculas: ${credencial.pais}`);
95
+ }
96
+ // ── 5. `idLicencia` must be a SHA-256 hex digest, not a licence number ──
97
+ // A raw licence number pasted into this field would be a PII leak and is
98
+ // refused at the boundary rather than at publication time.
99
+ if (!RE_HEX64.test(credencial.idLicencia)) {
100
+ return fallo(MOTIVO_RECHAZO_CREDENCIAL.ID_LICENCIA_MAL_FORMADO, "idLicencia debe ser sha256 hex de 64 caracteres; el número de licencia en claro no se acepta aquí");
101
+ }
102
+ // ── 6. Dates are coherent ──
103
+ if (typeof credencial.emitidoEn !== "number" ||
104
+ !Number.isFinite(credencial.emitidoEn)) {
105
+ return fallo(MOTIVO_RECHAZO_CREDENCIAL.EMISION_INVALIDA, `emitidoEn inválido: ${String(credencial.emitidoEn)}`);
106
+ }
107
+ if (credencial.emitidoEn > credencial.vigenteHasta) {
108
+ return fallo(MOTIVO_RECHAZO_CREDENCIAL.EMISION_INVALIDA, `emitidoEn (${credencial.emitidoEn}) es posterior a vigenteHasta (${credencial.vigenteHasta})`);
109
+ }
110
+ // ── 7. Expiry ──
111
+ if (credencial.vigenteHasta < ahora) {
112
+ return fallo(MOTIVO_RECHAZO_CREDENCIAL.CREDENCIAL_CADUCADA, `credencial caducada: vigente hasta ${credencial.vigenteHasta}, ahora ${ahora}`);
113
+ }
114
+ if (credencial.vigenteHasta === ahora) {
115
+ // `vigenteHasta` is exclusive: at the exact millisecond it lapses, it lapses.
116
+ return fallo(MOTIVO_RECHAZO_CREDENCIAL.CREDENCIAL_CADUCADA, `credencial caducada en el instante exacto de expiración (${ahora})`);
117
+ }
118
+ // ── 8. Signature present ──
119
+ if (!(credencial.firma instanceof Uint8Array) ||
120
+ credencial.firma.length === 0) {
121
+ return fallo(MOTIVO_RECHAZO_CREDENCIAL.FIRMA_AUSENTE, "firma ausente o vacía");
122
+ }
123
+ return { ok: true, credencial };
124
+ }
125
+ /**
126
+ * Verify the issuer's signature over the canonical credential bytes.
127
+ *
128
+ * Separate from {@link validarCredencial} so a caller can run the cheap
129
+ * structural checks first and skip a post-quantum verification on garbage.
130
+ * Both are required before a credential counts as evidence; neither is
131
+ * sufficient alone.
132
+ */
133
+ export async function verificarFirmaCredencial(credencial, identidadEmisor, parPublico) {
134
+ try {
135
+ return await identidadEmisor.verificar(bytesCredencial(credencial), credencial.firma, parPublico);
136
+ }
137
+ catch {
138
+ return false;
139
+ }
140
+ }
141
+ /**
142
+ * Full validation: structure, then signature, then the self-attestation rule.
143
+ *
144
+ * @returns `ok: true` only when the credential is well formed, unexpired and
145
+ * genuinely signed by `emisor`. Any other outcome is `ok: false` with
146
+ * `accesoPermitido: false`. There is no partial credit and no third state.
147
+ */
148
+ export async function validarCredencialFirmada(credencial, identidadEmisor, parPublicoEmisor, ahora) {
149
+ const estructural = validarCredencial(credencial, ahora);
150
+ if (!estructural.ok)
151
+ return estructural;
152
+ if (!(await verificarFirmaCredencial(credencial, identidadEmisor, parPublicoEmisor))) {
153
+ return fallo(MOTIVO_RECHAZO_CREDENCIAL.FIRMA_INVALIDA, `la firma no verifica contra la clave pública de ${credencial.emisor}`);
154
+ }
155
+ return { ok: true, credencial };
156
+ }
157
+ /**
158
+ * A self-attested credential must be signed by the subject it rides on.
159
+ *
160
+ * Kept separate from {@link validarCredencialFirmada} because a
161
+ * `CredencialMedica` carries no subject field of its own — the binding is
162
+ * `RegistroProfesional.nodoId`, one level up. An `autofirmada` credential whose
163
+ * `emisor` is a different node would let a node borrow someone else's key to
164
+ * look institutionally verified, so the check needs both halves and neither
165
+ * object alone contains them.
166
+ *
167
+ * Only `autofirmada` is constrained this way: an `atestiguada_pares` credential
168
+ * carries the issuing node's own signature, and an `anclada_autoridad` one
169
+ * carries the college's, and both are expected to differ from the subject.
170
+ */
171
+ export function validarVinculoEmision(credencial, nodoSujeto) {
172
+ if (credencial.estadoEmision === ESTADO_EMISION.AUTOFIRMADA &&
173
+ credencial.emisor !== nodoSujeto) {
174
+ return fallo(MOTIVO_RECHAZO_CREDENCIAL.AUTOEMISION_INCOHERENTE, `credencial autofirmada por ${credencial.emisor} pero presentada por el sujeto ${nodoSujeto}`);
175
+ }
176
+ return { ok: true, credencial };
177
+ }
178
+ /**
179
+ * Build and sign a credential.
180
+ *
181
+ * The `id` is derived from `idLicencia + tipo + pais`, so the same licence with
182
+ * the same type in the same country always yields the same id: the credential is
183
+ * identifiable across nodes without any node choosing a random identifier that
184
+ * two honest nodes would fail to agree on.
185
+ *
186
+ * The signature covers everything except `firma`, over the canonical bytes from
187
+ * `./canonica.ts`.
188
+ */
189
+ export async function crearCredencial(borrador, identidad) {
190
+ const id = await idCredencial(borrador.idLicencia, borrador.tipo, borrador.pais);
191
+ // Assemble first, then sign the assembly, so what is signed is exactly what
192
+ // travels — including the derived id.
193
+ const sinFirmar = {
194
+ id,
195
+ tipo: borrador.tipo,
196
+ pais: borrador.pais.toUpperCase(),
197
+ autoridad: borrador.autoridad,
198
+ idLicencia: borrador.idLicencia,
199
+ ...(borrador.numeroLicenciaCifrado
200
+ ? { numeroLicenciaCifrado: borrador.numeroLicenciaCifrado }
201
+ : {}),
202
+ ...(borrador.especialidad ? { especialidad: borrador.especialidad } : {}),
203
+ emitidoEn: borrador.emitidoEn,
204
+ vigenteHasta: borrador.vigenteHasta,
205
+ estadoEmision: borrador.estadoEmision,
206
+ firma: new Uint8Array(0),
207
+ emisor: borrador.emisor,
208
+ };
209
+ const firma = await identidad.firmar(bytesCredencial(sinFirmar));
210
+ return { ...sinFirmar, firma };
211
+ }
212
+ /** SHA-256 of the canonical credential bytes. Binds an `Aval` to exact bytes. */
213
+ export function hashDeCredencial(credencial) {
214
+ return hashCredencial(credencial);
215
+ }
216
+ /** Hex form of the canonical credential bytes, for logging and debugging. */
217
+ export function volcarCredencial(credencial) {
218
+ return bytesAHex(bytesCredencial(credencial));
219
+ }
220
+ /**
221
+ * A "certified doctor" per the product promise: `licencia ∧ especialidad`, both
222
+ * with a peer-witnessed or authority-anchored state, both unexpired.
223
+ *
224
+ * Deliberately not a boolean field on the licence. A boolean cannot expire, and
225
+ * specialties are revoked on a different cadence from base licensure.
226
+ *
227
+ * A licensed-but-unspecialised doctor is a legitimate node with a *smaller*
228
+ * capability set, not an impostor (DECISIÓN A.4) — this returns `false`, and the
229
+ * caller decides what a lower tier grants.
230
+ */
231
+ export function esMedicoCertificado(credenciales, ahora) {
232
+ const vigentes = credenciales.filter((c) => validarCredencial(c, ahora).ok);
233
+ const conEmisionFuerte = vigentes.filter((c) => c.estadoEmision === ESTADO_EMISION.ATESTIGUADA_PARES ||
234
+ c.estadoEmision === ESTADO_EMISION.ANCLADA_AUTORIDAD);
235
+ const tieneLicencia = conEmisionFuerte.some((c) => c.tipo === TIPO_CREDENCIAL.LICENCIA);
236
+ const tieneEspecialidad = conEmisionFuerte.some((c) => c.tipo === TIPO_CREDENCIAL.ESPECIALIDAD);
237
+ return tieneLicencia && tieneEspecialidad;
238
+ }
239
+ export { VERSION_MODELO };
240
+ //# sourceMappingURL=credencial.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credencial.js","sourceRoot":"","sources":["../../src/medico/credencial.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,EACN,SAAS,EACT,eAAe,EACf,cAAc,EACd,YAAY,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,8BAA8B,EAE9B,cAAc,EAEd,eAAe,EAEf,cAAc,GACd,MAAM,YAAY,CAAC;AAEpB,gFAAgF;AAChF,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACxC,6DAA6D;IAC7D,yBAAyB,EAAE,2BAA2B;IACtD;;;;OAIG;IACH,YAAY,EAAE,cAAc;IAC5B,oCAAoC;IACpC,mBAAmB,EAAE,qBAAqB;IAC1C,0DAA0D;IAC1D,kBAAkB,EAAE,oBAAoB;IACxC,iFAAiF;IACjF,gBAAgB,EAAE,kBAAkB;IACpC,4DAA4D;IAC5D,uBAAuB,EAAE,yBAAyB;IAClD,wCAAwC;IACxC,aAAa,EAAE,eAAe;IAC9B,6DAA6D;IAC7D,aAAa,EAAE,eAAe;IAC9B,0BAA0B;IAC1B,aAAa,EAAE,eAAe;IAC9B,iEAAiE;IACjE,cAAc,EAAE,gBAAgB;IAChC,wEAAwE;IACxE,uBAAuB,EAAE,yBAAyB;CACzC,CAAC;AA2CX,MAAM,QAAQ,GAAG,gBAAgB,CAAC;AAClC,MAAM,aAA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GAAG,gBAAgB,CAAC,IAAI,CAC9C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe,CAAC,YAAY,CAC9C,CAAC;IACF,OAAO,aAAa,IAAI,iBAAiB,CAAC;AAC3C,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Public surface of the medical layer.
3
+ *
4
+ * ─── SCOPE ──────────────────────────────────────────────────────────────────
5
+ *
6
+ * This directory owns the *data model*, its pure validation and its wire
7
+ * format: the credential type, the endorsement type, the professional record,
8
+ * the fail-closed registry seam, and — since `malla.ts` — the encrypted
9
+ * serialisation that lets a record actually travel. It does not own the mesh
10
+ * integration or the authz decision: `aPayloadGossipMedico` produces the object
11
+ * `MeshManager.transmitirConGossip` takes, but the method itself belongs to
12
+ * `src/mesh/index.ts`, which another owner owns.
13
+ *
14
+ * Layering, per `docs/medico/modelo-datos.md` §0:
15
+ *
16
+ * `types.ts` the four layers as types, no logic
17
+ * `canonica.ts` deterministic bytes + hashing (WebCrypto), no logic
18
+ * `credencial.ts` layer 1: build, sign, validate (fail closed)
19
+ * `aval.ts` layer 2: build, sign, validate, fold, adapt to karma
20
+ * `registro.ts` the registry seam + fail-closed licence lookup
21
+ * `registro-profesional.ts` the aggregate record and its rules
22
+ * `malla.ts` the wire format: seal, sign, verify, gossip adapter
23
+ *
24
+ * Everything is pure: no network, no filesystem, no clock read. `ahora` is always
25
+ * injected, and randomness for an `Aval` nonce is the caller's, so the whole
26
+ * layer is testable with fixtures and no I/O.
27
+ */
28
+ export { aTransaccionKarma, avalCuentaParaPromocion, type BorradorAval, crearAval, idLicenciaDesdeNumero, MOTIVO_RECHAZO_AVAL, type MotivoRechazoAval, OBJETO_QUE_CUENTA, prepararCredencialParaAval, type ResultadoValidacionAval, resumirAvales, validarAval, validarAvalFirmado, verificarFirmaAval, } from "./aval.js";
29
+ export { bytesAHex, bytesAval, bytesCredencial, canonicalBytes, canonicalizarAval, canonicalizarCredencial, canonicalStringify, DOMINIO_ID_CREDENCIAL, hashCredencial, hashLicencia, hexABytes, idAval, idCredencial, normalizarLicencia, sha256, sha256Hex, } from "./canonica.js";
30
+ export { type BorradorCredencial, crearCredencial, esMedicoCertificado, hashDeCredencial, MOTIVO_RECHAZO_CREDENCIAL, type MotivoRechazoCredencial, type ResultadoValidacionCredencial, validarCredencial, validarCredencialFirmada, validarVinculoEmision, verificarFirmaCredencial, volcarCredencial, } from "./credencial.js";
31
+ export { type AvalWire, aPayloadGossipMedico, avalAWire, type CredencialMedicaWire, credencialAWire, type EmisionMedica, emitirAval, emitirCredencial, emitirRegistro, type MetodoVerificacionWire, MOTIVO_RECHAZO_MALLA, type MotivoRechazoMalla, type OpcionesEmitir, type OpcionesRecibir, PAYLOAD_MEDICO_TIPO, type RegistroPaisWire, type ResultadoRecepcion, recibirAval, recibirCredencial, registroAWire, wireAAval, wireACredencial, } from "./malla.js";
32
+ export { ESTADO_VERIFICACION_REGISTRO, type EstadoVerificacionRegistro, type InstantaneaRegistroPais, PAISES_SOPORTADOS, type ResultadoVerificacionRegistro, VerificadorRegistroEnMemoria, type VerificadorRegistroPais, verificarCredencialContraRegistro, verificarHashContraRegistro, verificarLicenciaContraRegistro, } from "./registro.js";
33
+ export { MOTIVO_RECHAZO_REGISTRO, type MotivoRechazoRegistro, type ResultadoValidacionRegistro, recalcularAvalRecibido, validarRegistroProfesional, } from "./registro-profesional.js";
34
+ export { ALCANCE_AVAL, type AlcanceAval, CAMPOS_OBLIGATORIOS_CREDENCIAL, CLASE_VERIFICACION, type ClaseVerificacion, type CredencialMedica, type DeclaracionNodo, ESTADO_EMISION, type Especialidad, type EstadoEmision, type MetodoVerificacion, OBJETO_AVAL, type ObjetoAval, type RegistroProfesional, type ResumenAvales, TIPO_CREDENCIAL, type TipoCredencial, VERSION_MODELO, } from "./types.js";
35
+ export { acreditarCon, acreditarContraRegistro, CLASES_NO_IMPLEMENTADAS, type ConsultaRegistroLicencia, type ConsultarEntradaRegistro, type EntradaRegistroLicencia, ESTADO_LICENCIA, ESTRATEGIA_REGISTRO_POR_PAIS, type EstadoLicencia, type EstrategiaAcreditacion, type FuenteAcreditacion, type MetodoVerificacionAplicado, MOTIVO_RECHAZO_CONSULTA_REGISTRO, type MotivoRechazoAcreditacion, type MotivoRechazoConsultaRegistro, metodoRegistroPorPais, RegistroLicenciasEnMemoria, type ResultadoAcreditacion, } from "./verificacion-registro.js";
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/medico/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EACN,iBAAiB,EACjB,uBAAuB,EACvB,KAAK,YAAY,EACjB,SAAS,EACT,qBAAqB,EACrB,mBAAmB,EACnB,KAAK,iBAAiB,EACtB,iBAAiB,EACjB,0BAA0B,EAC1B,KAAK,uBAAuB,EAC5B,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,kBAAkB,GAClB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,SAAS,EACT,SAAS,EACT,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,SAAS,EACT,MAAM,EACN,YAAY,EACZ,kBAAkB,EAClB,MAAM,EACN,SAAS,GACT,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,KAAK,kBAAkB,EACvB,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,yBAAyB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,EAClC,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,KAAK,QAAQ,EACb,oBAAoB,EACpB,SAAS,EACT,KAAK,oBAAoB,EACzB,eAAe,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C,qBAAqB,EACrB,0BAA0B,EAC1B,KAAK,qBAAqB,GAC1B,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Public surface of the medical layer.
3
+ *
4
+ * ─── SCOPE ──────────────────────────────────────────────────────────────────
5
+ *
6
+ * This directory owns the *data model*, its pure validation and its wire
7
+ * format: the credential type, the endorsement type, the professional record,
8
+ * the fail-closed registry seam, and — since `malla.ts` — the encrypted
9
+ * serialisation that lets a record actually travel. It does not own the mesh
10
+ * integration or the authz decision: `aPayloadGossipMedico` produces the object
11
+ * `MeshManager.transmitirConGossip` takes, but the method itself belongs to
12
+ * `src/mesh/index.ts`, which another owner owns.
13
+ *
14
+ * Layering, per `docs/medico/modelo-datos.md` §0:
15
+ *
16
+ * `types.ts` the four layers as types, no logic
17
+ * `canonica.ts` deterministic bytes + hashing (WebCrypto), no logic
18
+ * `credencial.ts` layer 1: build, sign, validate (fail closed)
19
+ * `aval.ts` layer 2: build, sign, validate, fold, adapt to karma
20
+ * `registro.ts` the registry seam + fail-closed licence lookup
21
+ * `registro-profesional.ts` the aggregate record and its rules
22
+ * `malla.ts` the wire format: seal, sign, verify, gossip adapter
23
+ *
24
+ * Everything is pure: no network, no filesystem, no clock read. `ahora` is always
25
+ * injected, and randomness for an `Aval` nonce is the caller's, so the whole
26
+ * layer is testable with fixtures and no I/O.
27
+ */
28
+ export { aTransaccionKarma, avalCuentaParaPromocion, crearAval, idLicenciaDesdeNumero, MOTIVO_RECHAZO_AVAL, OBJETO_QUE_CUENTA, prepararCredencialParaAval, resumirAvales, validarAval, validarAvalFirmado, verificarFirmaAval, } from "./aval.js";
29
+ export { bytesAHex, bytesAval, bytesCredencial, canonicalBytes, canonicalizarAval, canonicalizarCredencial, canonicalStringify, DOMINIO_ID_CREDENCIAL, hashCredencial, hashLicencia, hexABytes, idAval, idCredencial, normalizarLicencia, sha256, sha256Hex, } from "./canonica.js";
30
+ export { crearCredencial, esMedicoCertificado, hashDeCredencial, MOTIVO_RECHAZO_CREDENCIAL, validarCredencial, validarCredencialFirmada, validarVinculoEmision, verificarFirmaCredencial, volcarCredencial, } from "./credencial.js";
31
+ export { aPayloadGossipMedico, avalAWire, credencialAWire, emitirAval, emitirCredencial, emitirRegistro, MOTIVO_RECHAZO_MALLA, PAYLOAD_MEDICO_TIPO, recibirAval, recibirCredencial, registroAWire, wireAAval, wireACredencial, } from "./malla.js";
32
+ export { ESTADO_VERIFICACION_REGISTRO, PAISES_SOPORTADOS, VerificadorRegistroEnMemoria, verificarCredencialContraRegistro, verificarHashContraRegistro, verificarLicenciaContraRegistro, } from "./registro.js";
33
+ export { MOTIVO_RECHAZO_REGISTRO, recalcularAvalRecibido, validarRegistroProfesional, } from "./registro-profesional.js";
34
+ export { ALCANCE_AVAL, CAMPOS_OBLIGATORIOS_CREDENCIAL, CLASE_VERIFICACION, ESTADO_EMISION, OBJETO_AVAL, TIPO_CREDENCIAL, VERSION_MODELO, } from "./types.js";
35
+ // The foundation-verification layer: credential → accreditation. Re-exported
36
+ // here so the medical layer keeps a single public surface, and so the parallel
37
+ // agent working on the wire protocol imports from the same place.
38
+ export { acreditarCon, acreditarContraRegistro, CLASES_NO_IMPLEMENTADAS, ESTADO_LICENCIA, ESTRATEGIA_REGISTRO_POR_PAIS, MOTIVO_RECHAZO_CONSULTA_REGISTRO, metodoRegistroPorPais, RegistroLicenciasEnMemoria, } from "./verificacion-registro.js";
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/medico/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EACN,iBAAiB,EACjB,uBAAuB,EAEvB,SAAS,EACT,qBAAqB,EACrB,mBAAmB,EAEnB,iBAAiB,EACjB,0BAA0B,EAE1B,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,kBAAkB,GAClB,MAAM,WAAW,CAAC;AACnB,OAAO,EAC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