@mdbase-dev/sdk 0.0.0-stage → 0.1.0-beta.153

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 (900) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +844 -2
  3. package/dist/account-key.d.ts +176 -0
  4. package/dist/account-key.js +409 -0
  5. package/dist/account-key.js.map +1 -0
  6. package/dist/account.d.ts +11 -0
  7. package/dist/account.js +9 -0
  8. package/dist/account.js.map +1 -0
  9. package/dist/app-grant/client.d.ts +209 -0
  10. package/dist/app-grant/client.js +930 -0
  11. package/dist/app-grant/client.js.map +1 -0
  12. package/dist/app-grant/grant-store.d.ts +77 -0
  13. package/dist/app-grant/grant-store.js +201 -0
  14. package/dist/app-grant/grant-store.js.map +1 -0
  15. package/dist/app-grant/index.d.ts +11 -0
  16. package/dist/app-grant/index.js +10 -0
  17. package/dist/app-grant/index.js.map +1 -0
  18. package/dist/app-grant/native-completion.d.ts +22 -0
  19. package/dist/app-grant/native-completion.js +63 -0
  20. package/dist/app-grant/native-completion.js.map +1 -0
  21. package/dist/app-grant/people.d.ts +10 -0
  22. package/dist/app-grant/people.js +84 -0
  23. package/dist/app-grant/people.js.map +1 -0
  24. package/dist/app-grant/setup-attempt.d.ts +12 -0
  25. package/dist/app-grant/setup-attempt.js +62 -0
  26. package/dist/app-grant/setup-attempt.js.map +1 -0
  27. package/dist/app-grant/setup-producer.d.ts +31 -0
  28. package/dist/app-grant/setup-producer.js +65 -0
  29. package/dist/app-grant/setup-producer.js.map +1 -0
  30. package/dist/app-grant/setup.d.ts +11 -0
  31. package/dist/app-grant/setup.js +222 -0
  32. package/dist/app-grant/setup.js.map +1 -0
  33. package/dist/app-host/app-environment.d.ts +27 -0
  34. package/dist/app-host/app-environment.js +48 -0
  35. package/dist/app-host/app-environment.js.map +1 -0
  36. package/dist/app-host/app-origin.d.ts +7 -0
  37. package/dist/app-host/app-origin.js +48 -0
  38. package/dist/app-host/app-origin.js.map +1 -0
  39. package/dist/app-host/bases-pages.d.ts +29 -0
  40. package/dist/app-host/bases-pages.js +42 -0
  41. package/dist/app-host/bases-pages.js.map +1 -0
  42. package/dist/app-host/bases-wire.d.ts +159 -0
  43. package/dist/app-host/bases-wire.js +376 -0
  44. package/dist/app-host/bases-wire.js.map +1 -0
  45. package/dist/app-host/browser-direct-access.d.ts +18 -0
  46. package/dist/app-host/browser-direct-access.js +17 -0
  47. package/dist/app-host/browser-direct-access.js.map +1 -0
  48. package/dist/app-host/cloud-copy-bootstrap.d.ts +127 -0
  49. package/dist/app-host/cloud-copy-bootstrap.js +606 -0
  50. package/dist/app-host/cloud-copy-bootstrap.js.map +1 -0
  51. package/dist/app-host/cloud-copy-host.d.ts +248 -0
  52. package/dist/app-host/cloud-copy-host.js +1028 -0
  53. package/dist/app-host/cloud-copy-host.js.map +1 -0
  54. package/dist/app-host/cloud-copy-persistence-idb.d.ts +33 -0
  55. package/dist/app-host/cloud-copy-persistence-idb.js +255 -0
  56. package/dist/app-host/cloud-copy-persistence-idb.js.map +1 -0
  57. package/dist/app-host/cloud-copy-persistence.d.ts +57 -0
  58. package/dist/app-host/cloud-copy-persistence.js +341 -0
  59. package/dist/app-host/cloud-copy-persistence.js.map +1 -0
  60. package/dist/app-host/collection-control.d.ts +111 -0
  61. package/dist/app-host/collection-control.js +604 -0
  62. package/dist/app-host/collection-control.js.map +1 -0
  63. package/dist/app-host/collection-delete.d.ts +7 -0
  64. package/dist/app-host/collection-delete.js +54 -0
  65. package/dist/app-host/collection-delete.js.map +1 -0
  66. package/dist/app-host/collection-display-name.d.ts +2 -0
  67. package/dist/app-host/collection-display-name.js +22 -0
  68. package/dist/app-host/collection-display-name.js.map +1 -0
  69. package/dist/app-host/collection-join-ledger.d.ts +52 -0
  70. package/dist/app-host/collection-join-ledger.js +208 -0
  71. package/dist/app-host/collection-join-ledger.js.map +1 -0
  72. package/dist/app-host/collection-people.d.ts +32 -0
  73. package/dist/app-host/collection-people.js +119 -0
  74. package/dist/app-host/collection-people.js.map +1 -0
  75. package/dist/app-host/collection-readiness.d.ts +119 -0
  76. package/dist/app-host/collection-readiness.js +649 -0
  77. package/dist/app-host/collection-readiness.js.map +1 -0
  78. package/dist/app-host/collection-setup-journal.d.ts +59 -0
  79. package/dist/app-host/collection-setup-journal.js +813 -0
  80. package/dist/app-host/collection-setup-journal.js.map +1 -0
  81. package/dist/app-host/collection-setup-types.d.ts +155 -0
  82. package/dist/app-host/collection-setup-types.js +10 -0
  83. package/dist/app-host/collection-setup-types.js.map +1 -0
  84. package/dist/app-host/cp-authority.d.ts +65 -0
  85. package/dist/app-host/cp-authority.js +243 -0
  86. package/dist/app-host/cp-authority.js.map +1 -0
  87. package/dist/app-host/cp-people.d.ts +23 -0
  88. package/dist/app-host/cp-people.js +145 -0
  89. package/dist/app-host/cp-people.js.map +1 -0
  90. package/dist/app-host/cp-problem.d.ts +34 -0
  91. package/dist/app-host/cp-problem.js +114 -0
  92. package/dist/app-host/cp-problem.js.map +1 -0
  93. package/dist/app-host/device-key-custody.d.ts +51 -0
  94. package/dist/app-host/device-key-custody.js +128 -0
  95. package/dist/app-host/device-key-custody.js.map +1 -0
  96. package/dist/app-host/device-key-idb.d.ts +31 -0
  97. package/dist/app-host/device-key-idb.js +176 -0
  98. package/dist/app-host/device-key-idb.js.map +1 -0
  99. package/dist/app-host/device-key-provider.d.ts +33 -0
  100. package/dist/app-host/device-key-provider.js +181 -0
  101. package/dist/app-host/device-key-provider.js.map +1 -0
  102. package/dist/app-host/device-registration.d.ts +51 -0
  103. package/dist/app-host/device-registration.js +180 -0
  104. package/dist/app-host/device-registration.js.map +1 -0
  105. package/dist/app-host/foreground-wake.d.ts +43 -0
  106. package/dist/app-host/foreground-wake.js +113 -0
  107. package/dist/app-host/foreground-wake.js.map +1 -0
  108. package/dist/app-host/handover.d.ts +27 -0
  109. package/dist/app-host/handover.js +82 -0
  110. package/dist/app-host/handover.js.map +1 -0
  111. package/dist/app-host/http-log.d.ts +96 -0
  112. package/dist/app-host/http-log.js +608 -0
  113. package/dist/app-host/http-log.js.map +1 -0
  114. package/dist/app-host/index.d.ts +63 -0
  115. package/dist/app-host/index.js +33 -0
  116. package/dist/app-host/index.js.map +1 -0
  117. package/dist/app-host/initial-sync.d.ts +22 -0
  118. package/dist/app-host/initial-sync.js +41 -0
  119. package/dist/app-host/initial-sync.js.map +1 -0
  120. package/dist/app-host/installation-sign-in.d.ts +319 -0
  121. package/dist/app-host/installation-sign-in.js +1231 -0
  122. package/dist/app-host/installation-sign-in.js.map +1 -0
  123. package/dist/app-host/installation-store.d.ts +56 -0
  124. package/dist/app-host/installation-store.js +285 -0
  125. package/dist/app-host/installation-store.js.map +1 -0
  126. package/dist/app-host/ledger-rows.d.ts +3 -0
  127. package/dist/app-host/ledger-rows.js +23 -0
  128. package/dist/app-host/ledger-rows.js.map +1 -0
  129. package/dist/app-host/local-facade.d.ts +24 -0
  130. package/dist/app-host/local-facade.js +361 -0
  131. package/dist/app-host/local-facade.js.map +1 -0
  132. package/dist/app-host/log-pump.d.ts +124 -0
  133. package/dist/app-host/log-pump.js +326 -0
  134. package/dist/app-host/log-pump.js.map +1 -0
  135. package/dist/app-host/log-push.d.ts +90 -0
  136. package/dist/app-host/log-push.js +376 -0
  137. package/dist/app-host/log-push.js.map +1 -0
  138. package/dist/app-host/log-token-cache.d.ts +28 -0
  139. package/dist/app-host/log-token-cache.js +104 -0
  140. package/dist/app-host/log-token-cache.js.map +1 -0
  141. package/dist/app-host/native-sign-in.d.ts +27 -0
  142. package/dist/app-host/native-sign-in.js +12 -0
  143. package/dist/app-host/native-sign-in.js.map +1 -0
  144. package/dist/app-host/noise-custody.d.ts +62 -0
  145. package/dist/app-host/noise-custody.js +238 -0
  146. package/dist/app-host/noise-custody.js.map +1 -0
  147. package/dist/app-host/noise-idb.d.ts +33 -0
  148. package/dist/app-host/noise-idb.js +199 -0
  149. package/dist/app-host/noise-idb.js.map +1 -0
  150. package/dist/app-host/open-wait.d.ts +3 -0
  151. package/dist/app-host/open-wait.js +17 -0
  152. package/dist/app-host/open-wait.js.map +1 -0
  153. package/dist/app-host/opening-progress.d.ts +3 -0
  154. package/dist/app-host/opening-progress.js +5 -0
  155. package/dist/app-host/opening-progress.js.map +1 -0
  156. package/dist/app-host/owner.d.ts +103 -0
  157. package/dist/app-host/owner.js +262 -0
  158. package/dist/app-host/owner.js.map +1 -0
  159. package/dist/app-host/private-bootstrap.d.ts +78 -0
  160. package/dist/app-host/private-bootstrap.js +230 -0
  161. package/dist/app-host/private-bootstrap.js.map +1 -0
  162. package/dist/app-host/private-persistence-idb.d.ts +32 -0
  163. package/dist/app-host/private-persistence-idb.js +188 -0
  164. package/dist/app-host/private-persistence-idb.js.map +1 -0
  165. package/dist/app-host/private-persistence.d.ts +55 -0
  166. package/dist/app-host/private-persistence.js +257 -0
  167. package/dist/app-host/private-persistence.js.map +1 -0
  168. package/dist/app-host/scoped-sign-in-session.d.ts +49 -0
  169. package/dist/app-host/scoped-sign-in-session.js +243 -0
  170. package/dist/app-host/scoped-sign-in-session.js.map +1 -0
  171. package/dist/app-host/setup-engine.d.ts +14 -0
  172. package/dist/app-host/setup-engine.js +73 -0
  173. package/dist/app-host/setup-engine.js.map +1 -0
  174. package/dist/app-host/sign-out-erase.d.ts +37 -0
  175. package/dist/app-host/sign-out-erase.js +139 -0
  176. package/dist/app-host/sign-out-erase.js.map +1 -0
  177. package/dist/app-host/status.d.ts +62 -0
  178. package/dist/app-host/status.js +43 -0
  179. package/dist/app-host/status.js.map +1 -0
  180. package/dist/app-host/storage-probe.d.ts +46 -0
  181. package/dist/app-host/storage-probe.js +63 -0
  182. package/dist/app-host/storage-probe.js.map +1 -0
  183. package/dist/app-host/timer-port.d.ts +29 -0
  184. package/dist/app-host/timer-port.js +483 -0
  185. package/dist/app-host/timer-port.js.map +1 -0
  186. package/dist/app-host/wasm-runtime.d.ts +302 -0
  187. package/dist/app-host/wasm-runtime.js +1050 -0
  188. package/dist/app-host/wasm-runtime.js.map +1 -0
  189. package/dist/app-host/web-collection.d.ts +78 -0
  190. package/dist/app-host/web-collection.js +671 -0
  191. package/dist/app-host/web-collection.js.map +1 -0
  192. package/dist/app-host/web-sign-in-problem.d.ts +17 -0
  193. package/dist/app-host/web-sign-in-problem.js +59 -0
  194. package/dist/app-host/web-sign-in-problem.js.map +1 -0
  195. package/dist/app-host/web-sign-in-session.d.ts +367 -0
  196. package/dist/app-host/web-sign-in-session.js +1258 -0
  197. package/dist/app-host/web-sign-in-session.js.map +1 -0
  198. package/dist/app-storage/app-binary-index.d.ts +33 -0
  199. package/dist/app-storage/app-binary-index.js +274 -0
  200. package/dist/app-storage/app-binary-index.js.map +1 -0
  201. package/dist/app-storage/app-sqlite-index.d.ts +40 -0
  202. package/dist/app-storage/app-sqlite-index.js +102 -0
  203. package/dist/app-storage/app-sqlite-index.js.map +1 -0
  204. package/dist/app-storage/collection-sql.d.ts +39 -0
  205. package/dist/app-storage/collection-sql.js +93 -0
  206. package/dist/app-storage/collection-sql.js.map +1 -0
  207. package/dist/app-storage/index.d.ts +10 -0
  208. package/dist/app-storage/index.js +7 -0
  209. package/dist/app-storage/index.js.map +1 -0
  210. package/dist/app-storage/sqlite-index.d.ts +95 -0
  211. package/dist/app-storage/sqlite-index.js +280 -0
  212. package/dist/app-storage/sqlite-index.js.map +1 -0
  213. package/dist/application/asset-loader.d.ts +22 -0
  214. package/dist/application/asset-loader.js +130 -0
  215. package/dist/application/asset-loader.js.map +1 -0
  216. package/dist/application/asset-pins.json +24 -0
  217. package/dist/application/browser-capabilities.d.ts +48 -0
  218. package/dist/application/browser-capabilities.js +87 -0
  219. package/dist/application/browser-capabilities.js.map +1 -0
  220. package/dist/application/browser-selection.d.ts +58 -0
  221. package/dist/application/browser-selection.js +160 -0
  222. package/dist/application/browser-selection.js.map +1 -0
  223. package/dist/application/capabilities.d.ts +20 -0
  224. package/dist/application/capabilities.js +22 -0
  225. package/dist/application/capabilities.js.map +1 -0
  226. package/dist/application/collection-selection.d.ts +147 -0
  227. package/dist/application/collection-selection.js +351 -0
  228. package/dist/application/collection-selection.js.map +1 -0
  229. package/dist/application/configuration.d.ts +52 -0
  230. package/dist/application/configuration.js +568 -0
  231. package/dist/application/configuration.js.map +1 -0
  232. package/dist/application/declaration.d.ts +51 -0
  233. package/dist/application/declaration.js +100 -0
  234. package/dist/application/declaration.js.map +1 -0
  235. package/dist/application/entry.d.ts +343 -0
  236. package/dist/application/entry.js +945 -0
  237. package/dist/application/entry.js.map +1 -0
  238. package/dist/application/file-access.d.ts +55 -0
  239. package/dist/application/file-access.js +93 -0
  240. package/dist/application/file-access.js.map +1 -0
  241. package/dist/application/file-readiness.d.ts +16 -0
  242. package/dist/application/file-readiness.js +53 -0
  243. package/dist/application/file-readiness.js.map +1 -0
  244. package/dist/application/forgotten.d.ts +15 -0
  245. package/dist/application/forgotten.js +70 -0
  246. package/dist/application/forgotten.js.map +1 -0
  247. package/dist/application/front-door.d.ts +68 -0
  248. package/dist/application/front-door.js +66 -0
  249. package/dist/application/front-door.js.map +1 -0
  250. package/dist/application/local-build.d.ts +5 -0
  251. package/dist/application/local-build.js +22 -0
  252. package/dist/application/local-build.js.map +1 -0
  253. package/dist/application/manifest.d.ts +16 -0
  254. package/dist/application/manifest.js +31 -0
  255. package/dist/application/manifest.js.map +1 -0
  256. package/dist/application/native-assets.d.ts +25 -0
  257. package/dist/application/native-assets.js +29 -0
  258. package/dist/application/native-assets.js.map +1 -0
  259. package/dist/application/native-authorization-rpc.d.ts +23 -0
  260. package/dist/application/native-authorization-rpc.js +54 -0
  261. package/dist/application/native-authorization-rpc.js.map +1 -0
  262. package/dist/application/notification-readiness.d.ts +33 -0
  263. package/dist/application/notification-readiness.js +222 -0
  264. package/dist/application/notification-readiness.js.map +1 -0
  265. package/dist/application/packaged-assets.d.ts +5 -0
  266. package/dist/application/packaged-assets.js +55 -0
  267. package/dist/application/packaged-assets.js.map +1 -0
  268. package/dist/application/packaged-trust.d.ts +5 -0
  269. package/dist/application/packaged-trust.js +10 -0
  270. package/dist/application/packaged-trust.js.map +1 -0
  271. package/dist/application/people-readiness.d.ts +23 -0
  272. package/dist/application/people-readiness.js +213 -0
  273. package/dist/application/people-readiness.js.map +1 -0
  274. package/dist/application/phase.d.ts +108 -0
  275. package/dist/application/phase.js +113 -0
  276. package/dist/application/phase.js.map +1 -0
  277. package/dist/application/portal-reservation.d.ts +38 -0
  278. package/dist/application/portal-reservation.js +183 -0
  279. package/dist/application/portal-reservation.js.map +1 -0
  280. package/dist/application/private-collections.d.ts +114 -0
  281. package/dist/application/private-collections.js +415 -0
  282. package/dist/application/private-collections.js.map +1 -0
  283. package/dist/application/readiness.d.ts +59 -0
  284. package/dist/application/readiness.js +223 -0
  285. package/dist/application/readiness.js.map +1 -0
  286. package/dist/application/registration-refusal.d.ts +16 -0
  287. package/dist/application/registration-refusal.js +41 -0
  288. package/dist/application/registration-refusal.js.map +1 -0
  289. package/dist/application/registration.d.ts +26 -0
  290. package/dist/application/registration.js +372 -0
  291. package/dist/application/registration.js.map +1 -0
  292. package/dist/application/return-url.d.ts +1 -0
  293. package/dist/application/return-url.js +40 -0
  294. package/dist/application/return-url.js.map +1 -0
  295. package/dist/application/runtime.d.ts +107 -0
  296. package/dist/application/runtime.js +379 -0
  297. package/dist/application/runtime.js.map +1 -0
  298. package/dist/application/scope.d.ts +34 -0
  299. package/dist/application/scope.js +164 -0
  300. package/dist/application/scope.js.map +1 -0
  301. package/dist/application/session-hint.d.ts +21 -0
  302. package/dist/application/session-hint.js +87 -0
  303. package/dist/application/session-hint.js.map +1 -0
  304. package/dist/application/setup.d.ts +105 -0
  305. package/dist/application/setup.js +137 -0
  306. package/dist/application/setup.js.map +1 -0
  307. package/dist/application/sign-out.d.ts +17 -0
  308. package/dist/application/sign-out.js +28 -0
  309. package/dist/application/sign-out.js.map +1 -0
  310. package/dist/application/storage-scope.d.ts +8 -0
  311. package/dist/application/storage-scope.js +15 -0
  312. package/dist/application/storage-scope.js.map +1 -0
  313. package/dist/application/tabs.d.ts +98 -0
  314. package/dist/application/tabs.js +407 -0
  315. package/dist/application/tabs.js.map +1 -0
  316. package/dist/application/timer-criteria.d.ts +5 -0
  317. package/dist/application/timer-criteria.js +15 -0
  318. package/dist/application/timer-criteria.js.map +1 -0
  319. package/dist/application/ui-connections.d.ts +35 -0
  320. package/dist/application/ui-connections.js +129 -0
  321. package/dist/application/ui-connections.js.map +1 -0
  322. package/dist/application/worker-client.d.ts +59 -0
  323. package/dist/application/worker-client.js +381 -0
  324. package/dist/application/worker-client.js.map +1 -0
  325. package/dist/application/worker-host.d.ts +84 -0
  326. package/dist/application/worker-host.js +547 -0
  327. package/dist/application/worker-host.js.map +1 -0
  328. package/dist/application/worker-protocol.d.ts +40 -0
  329. package/dist/application/worker-protocol.js +83 -0
  330. package/dist/application/worker-protocol.js.map +1 -0
  331. package/dist/application/worker-session.d.ts +45 -0
  332. package/dist/application/worker-session.js +37 -0
  333. package/dist/application/worker-session.js.map +1 -0
  334. package/dist/application/worker.d.ts +1 -0
  335. package/dist/application/worker.js +34835 -0
  336. package/dist/application/worker.js.map +1 -0
  337. package/dist/attachment-wire.d.ts +15 -0
  338. package/dist/attachment-wire.js +47 -0
  339. package/dist/attachment-wire.js.map +1 -0
  340. package/dist/browser/mdbase-sdk.js +49398 -0
  341. package/dist/browser/mdbase-sdk.min.js +130 -0
  342. package/dist/browser.d.ts +4 -0
  343. package/dist/browser.js +5 -0
  344. package/dist/browser.js.map +1 -0
  345. package/dist/cbor.d.ts +52 -0
  346. package/dist/cbor.js +480 -0
  347. package/dist/cbor.js.map +1 -0
  348. package/dist/client.d.ts +658 -0
  349. package/dist/client.js +1966 -0
  350. package/dist/client.js.map +1 -0
  351. package/dist/codec.d.ts +82 -0
  352. package/dist/codec.js +388 -0
  353. package/dist/codec.js.map +1 -0
  354. package/dist/collection-availability.d.ts +34 -0
  355. package/dist/collection-availability.js +63 -0
  356. package/dist/collection-availability.js.map +1 -0
  357. package/dist/contract-query.d.ts +31 -0
  358. package/dist/contract-query.js +13 -0
  359. package/dist/contract-query.js.map +1 -0
  360. package/dist/contract-records.d.ts +51 -0
  361. package/dist/contract-records.js +14 -0
  362. package/dist/contract-records.js.map +1 -0
  363. package/dist/describe-error.d.ts +61 -0
  364. package/dist/describe-error.js +452 -0
  365. package/dist/describe-error.js.map +1 -0
  366. package/dist/errors.d.ts +65 -0
  367. package/dist/errors.js +94 -0
  368. package/dist/errors.js.map +1 -0
  369. package/dist/files.d.ts +147 -0
  370. package/dist/files.js +537 -0
  371. package/dist/files.js.map +1 -0
  372. package/dist/holds.d.ts +74 -0
  373. package/dist/holds.js +118 -0
  374. package/dist/holds.js.map +1 -0
  375. package/dist/index.d.ts +36 -0
  376. package/dist/index.js +22 -0
  377. package/dist/index.js.map +1 -0
  378. package/dist/keys.d.ts +40 -0
  379. package/dist/keys.js +181 -0
  380. package/dist/keys.js.map +1 -0
  381. package/dist/live.d.ts +38 -0
  382. package/dist/live.js +82 -0
  383. package/dist/live.js.map +1 -0
  384. package/dist/local-build.d.ts +13 -0
  385. package/dist/local-build.js +47 -0
  386. package/dist/local-build.js.map +1 -0
  387. package/dist/native/provenance.json +23 -0
  388. package/dist/native/runtime.wasm +0 -0
  389. package/dist/native/sqlite3.d.ts +5 -0
  390. package/dist/native/sqlite3.js +17392 -0
  391. package/dist/native/sqlite3.js.map +1 -0
  392. package/dist/native/sqlite3.wasm +0 -0
  393. package/dist/node.d.ts +63 -0
  394. package/dist/node.js +255 -0
  395. package/dist/node.js.map +1 -0
  396. package/dist/notifications.d.ts +95 -0
  397. package/dist/notifications.js +226 -0
  398. package/dist/notifications.js.map +1 -0
  399. package/dist/offline-shell-build.d.ts +25 -0
  400. package/dist/offline-shell-build.js +78 -0
  401. package/dist/offline-shell-build.js.map +1 -0
  402. package/dist/offline-shell-worker.d.ts +46 -0
  403. package/dist/offline-shell-worker.js +115 -0
  404. package/dist/offline-shell-worker.js.map +1 -0
  405. package/dist/people.d.ts +82 -0
  406. package/dist/people.js +199 -0
  407. package/dist/people.js.map +1 -0
  408. package/dist/presence.d.ts +21 -0
  409. package/dist/presence.js +109 -0
  410. package/dist/presence.js.map +1 -0
  411. package/dist/private-account.d.ts +197 -0
  412. package/dist/private-account.js +510 -0
  413. package/dist/private-account.js.map +1 -0
  414. package/dist/private.d.ts +55 -0
  415. package/dist/private.js +69 -0
  416. package/dist/private.js.map +1 -0
  417. package/dist/read-helpers.d.ts +32 -0
  418. package/dist/read-helpers.js +181 -0
  419. package/dist/read-helpers.js.map +1 -0
  420. package/dist/records/session.d.ts +60 -0
  421. package/dist/records/session.js +534 -0
  422. package/dist/records/session.js.map +1 -0
  423. package/dist/records/types.d.ts +76 -0
  424. package/dist/records/types.js +2 -0
  425. package/dist/records/types.js.map +1 -0
  426. package/dist/records/witness.d.ts +19 -0
  427. package/dist/records/witness.js +64 -0
  428. package/dist/records/witness.js.map +1 -0
  429. package/dist/records.d.ts +23 -0
  430. package/dist/records.js +234 -0
  431. package/dist/records.js.map +1 -0
  432. package/dist/runtime/wasm.d.ts +69 -0
  433. package/dist/runtime/wasm.js +274 -0
  434. package/dist/runtime/wasm.js.map +1 -0
  435. package/dist/runtime-wire.d.ts +71 -0
  436. package/dist/runtime-wire.js +71 -0
  437. package/dist/runtime-wire.js.map +1 -0
  438. package/dist/saved-views.d.ts +29 -0
  439. package/dist/saved-views.js +171 -0
  440. package/dist/saved-views.js.map +1 -0
  441. package/dist/semver.d.ts +22 -0
  442. package/dist/semver.js +63 -0
  443. package/dist/semver.js.map +1 -0
  444. package/dist/session.d.ts +65 -0
  445. package/dist/session.js +332 -0
  446. package/dist/session.js.map +1 -0
  447. package/dist/status.d.ts +46 -0
  448. package/dist/status.js +59 -0
  449. package/dist/status.js.map +1 -0
  450. package/dist/strength.d.ts +12 -0
  451. package/dist/strength.js +194 -0
  452. package/dist/strength.js.map +1 -0
  453. package/dist/testing/application.d.ts +59 -0
  454. package/dist/testing/application.js +230 -0
  455. package/dist/testing/application.js.map +1 -0
  456. package/dist/testing/index.d.ts +10 -0
  457. package/dist/testing/index.js +6 -0
  458. package/dist/testing/index.js.map +1 -0
  459. package/dist/testing/memory-contracts.d.ts +40 -0
  460. package/dist/testing/memory-contracts.js +127 -0
  461. package/dist/testing/memory-contracts.js.map +1 -0
  462. package/dist/testing/memory-replica.d.ts +191 -0
  463. package/dist/testing/memory-replica.js +1465 -0
  464. package/dist/testing/memory-replica.js.map +1 -0
  465. package/dist/testing/noise-server.d.ts +11 -0
  466. package/dist/testing/noise-server.js +65 -0
  467. package/dist/testing/noise-server.js.map +1 -0
  468. package/dist/testing/test-app.d.ts +93 -0
  469. package/dist/testing/test-app.js +140 -0
  470. package/dist/testing/test-app.js.map +1 -0
  471. package/dist/thin-client.d.ts +67 -0
  472. package/dist/thin-client.js +42 -0
  473. package/dist/thin-client.js.map +1 -0
  474. package/dist/timers.d.ts +158 -0
  475. package/dist/timers.js +258 -0
  476. package/dist/timers.js.map +1 -0
  477. package/dist/transport/bases-rpc.d.ts +15 -0
  478. package/dist/transport/bases-rpc.js +61 -0
  479. package/dist/transport/bases-rpc.js.map +1 -0
  480. package/dist/transport/control-route.d.ts +34 -0
  481. package/dist/transport/control-route.js +84 -0
  482. package/dist/transport/control-route.js.map +1 -0
  483. package/dist/transport/inprocess.d.ts +13 -0
  484. package/dist/transport/inprocess.js +37 -0
  485. package/dist/transport/inprocess.js.map +1 -0
  486. package/dist/transport/local-link.d.ts +53 -0
  487. package/dist/transport/local-link.js +66 -0
  488. package/dist/transport/local-link.js.map +1 -0
  489. package/dist/transport/next-relay.d.ts +64 -0
  490. package/dist/transport/next-relay.js +222 -0
  491. package/dist/transport/next-relay.js.map +1 -0
  492. package/dist/transport/noise-session.d.ts +88 -0
  493. package/dist/transport/noise-session.js +264 -0
  494. package/dist/transport/noise-session.js.map +1 -0
  495. package/dist/transport/noise.d.ts +102 -0
  496. package/dist/transport/noise.js +307 -0
  497. package/dist/transport/noise.js.map +1 -0
  498. package/dist/transport/original-session.d.ts +6 -0
  499. package/dist/transport/original-session.js +6 -0
  500. package/dist/transport/original-session.js.map +1 -0
  501. package/dist/transport/port.d.ts +67 -0
  502. package/dist/transport/port.js +184 -0
  503. package/dist/transport/port.js.map +1 -0
  504. package/dist/transport/read-fence-policy.d.ts +3 -0
  505. package/dist/transport/read-fence-policy.js +11 -0
  506. package/dist/transport/read-fence-policy.js.map +1 -0
  507. package/dist/transport/relay-close.d.ts +31 -0
  508. package/dist/transport/relay-close.js +23 -0
  509. package/dist/transport/relay-close.js.map +1 -0
  510. package/dist/transport/relay-pipe.d.ts +15 -0
  511. package/dist/transport/relay-pipe.js +190 -0
  512. package/dist/transport/relay-pipe.js.map +1 -0
  513. package/dist/transport/relay.d.ts +36 -0
  514. package/dist/transport/relay.js +45 -0
  515. package/dist/transport/relay.js.map +1 -0
  516. package/dist/type-packs.d.ts +124 -0
  517. package/dist/type-packs.js +188 -0
  518. package/dist/type-packs.js.map +1 -0
  519. package/dist/validation.d.ts +30 -0
  520. package/dist/validation.js +125 -0
  521. package/dist/validation.js.map +1 -0
  522. package/dist/values.d.ts +37 -0
  523. package/dist/values.js +133 -0
  524. package/dist/values.js.map +1 -0
  525. package/dist/view-sources.d.ts +31 -0
  526. package/dist/view-sources.js +78 -0
  527. package/dist/view-sources.js.map +1 -0
  528. package/dist/wire.d.ts +857 -0
  529. package/dist/wire.js +915 -0
  530. package/dist/wire.js.map +1 -0
  531. package/dist/witness.d.ts +7 -0
  532. package/dist/witness.js +82 -0
  533. package/dist/witness.js.map +1 -0
  534. package/dist/write-ledger.d.ts +41 -0
  535. package/dist/write-ledger.js +184 -0
  536. package/dist/write-ledger.js.map +1 -0
  537. package/node_modules/@mdbase-dev/connect-protocol/dist/application-authorization.d.ts +32 -0
  538. package/node_modules/@mdbase-dev/connect-protocol/dist/application-authorization.js +207 -0
  539. package/node_modules/@mdbase-dev/connect-protocol/dist/application-contract.d.ts +23 -0
  540. package/node_modules/@mdbase-dev/connect-protocol/dist/application-contract.js +76 -0
  541. package/node_modules/@mdbase-dev/connect-protocol/dist/application-declaration.d.ts +120 -0
  542. package/node_modules/@mdbase-dev/connect-protocol/dist/application-declaration.js +1 -0
  543. package/node_modules/@mdbase-dev/connect-protocol/dist/authorization-errors.d.ts +34 -0
  544. package/node_modules/@mdbase-dev/connect-protocol/dist/authorization-errors.js +52 -0
  545. package/node_modules/@mdbase-dev/connect-protocol/dist/capabilities.d.ts +73 -0
  546. package/node_modules/@mdbase-dev/connect-protocol/dist/capabilities.js +92 -0
  547. package/node_modules/@mdbase-dev/connect-protocol/dist/change-events.generated.d.ts +48 -0
  548. package/node_modules/@mdbase-dev/connect-protocol/dist/change-events.generated.js +18 -0
  549. package/node_modules/@mdbase-dev/connect-protocol/dist/collection-setup.d.ts +93 -0
  550. package/node_modules/@mdbase-dev/connect-protocol/dist/collection-setup.js +7 -0
  551. package/node_modules/@mdbase-dev/connect-protocol/dist/compatibility.d.ts +37 -0
  552. package/node_modules/@mdbase-dev/connect-protocol/dist/compatibility.js +65 -0
  553. package/node_modules/@mdbase-dev/connect-protocol/dist/connect-problems.generated.d.ts +1533 -0
  554. package/node_modules/@mdbase-dev/connect-protocol/dist/connect-problems.generated.js +598 -0
  555. package/node_modules/@mdbase-dev/connect-protocol/dist/files.d.ts +288 -0
  556. package/node_modules/@mdbase-dev/connect-protocol/dist/files.js +426 -0
  557. package/node_modules/@mdbase-dev/connect-protocol/dist/index.d.ts +723 -0
  558. package/node_modules/@mdbase-dev/connect-protocol/dist/index.js +104 -0
  559. package/node_modules/@mdbase-dev/connect-protocol/dist/manifest-validators.generated.d.ts +13 -0
  560. package/node_modules/@mdbase-dev/connect-protocol/dist/manifest-validators.generated.js +7940 -0
  561. package/node_modules/@mdbase-dev/connect-protocol/dist/manifest.d.ts +72 -0
  562. package/node_modules/@mdbase-dev/connect-protocol/dist/manifest.js +643 -0
  563. package/node_modules/@mdbase-dev/connect-protocol/dist/mutation-fingerprint.d.ts +6 -0
  564. package/node_modules/@mdbase-dev/connect-protocol/dist/mutation-fingerprint.js +116 -0
  565. package/node_modules/@mdbase-dev/connect-protocol/dist/next-authorization.d.ts +30 -0
  566. package/node_modules/@mdbase-dev/connect-protocol/dist/next-authorization.js +90 -0
  567. package/node_modules/@mdbase-dev/connect-protocol/dist/operations.d.ts +15 -0
  568. package/node_modules/@mdbase-dev/connect-protocol/dist/operations.js +196 -0
  569. package/node_modules/@mdbase-dev/connect-protocol/dist/people.d.ts +33 -0
  570. package/node_modules/@mdbase-dev/connect-protocol/dist/people.js +26 -0
  571. package/node_modules/@mdbase-dev/connect-protocol/dist/records.d.ts +108 -0
  572. package/node_modules/@mdbase-dev/connect-protocol/dist/records.js +3 -0
  573. package/node_modules/@mdbase-dev/connect-protocol/dist/type-packs.d.ts +154 -0
  574. package/node_modules/@mdbase-dev/connect-protocol/dist/type-packs.js +30 -0
  575. package/node_modules/@mdbase-dev/connect-protocol/package.json +49 -0
  576. package/node_modules/@mdbase-dev/connect-protocol/schemas/application-capability-catalog.v1.json +40 -0
  577. package/node_modules/@mdbase-dev/connect-protocol/schemas/application-capability-catalog.v2.json +68 -0
  578. package/node_modules/@mdbase-dev/connect-protocol/schemas/catalog.json +17 -0
  579. package/node_modules/@mdbase-dev/connect-protocol/schemas/change-events.v1.json +48 -0
  580. package/node_modules/@mdbase-dev/connect-protocol/schemas/connect-problem.v1.schema.json +5665 -0
  581. package/node_modules/@mdbase-dev/connect-protocol/schemas/connect-problems.v1.catalog.json +373 -0
  582. package/node_modules/@mdbase-dev/connect-protocol/schemas/connect-protocol.v1.schema.json +901 -0
  583. package/node_modules/@mdbase-dev/connect-protocol/schemas/data-contract.schema.json +163 -0
  584. package/node_modules/@mdbase-dev/connect-protocol/schemas/encrypted-relay.v1.schema.json +63 -0
  585. package/node_modules/@mdbase-dev/connect-protocol/schemas/encrypted-relay.v2.schema.json +63 -0
  586. package/node_modules/@mdbase-dev/connect-protocol/schemas/encrypted-relay.v3.schema.json +64 -0
  587. package/node_modules/@mdbase-dev/connect-protocol/schemas/files.v1.schema.json +551 -0
  588. package/node_modules/@mdbase-dev/connect-protocol/schemas/interop/v0.1/action-cancellation.schema.json +6 -0
  589. package/node_modules/@mdbase-dev/connect-protocol/schemas/interop/v0.1/action-invocation.schema.json +6 -0
  590. package/node_modules/@mdbase-dev/connect-protocol/schemas/interop/v0.1/action-outcome.schema.json +6 -0
  591. package/node_modules/@mdbase-dev/connect-protocol/schemas/interop/v0.1/action-provider-declaration.schema.json +6 -0
  592. package/node_modules/@mdbase-dev/connect-protocol/schemas/interop/v0.1/action-request.schema.json +6 -0
  593. package/node_modules/@mdbase-dev/connect-protocol/schemas/interop/v0.1/conformance-claim.schema.json +6 -0
  594. package/node_modules/@mdbase-dev/connect-protocol/schemas/interop/v0.1/event-source-declaration.schema.json +6 -0
  595. package/node_modules/@mdbase-dev/connect-protocol/schemas/interop/v0.1/event.schema.json +6 -0
  596. package/node_modules/@mdbase-dev/connect-protocol/schemas/interop/v0.1/profile.schema.json +456 -0
  597. package/node_modules/@mdbase-dev/connect-protocol/schemas/mdbase-app.legacy-v1.schema.json +430 -0
  598. package/node_modules/@mdbase-dev/connect-protocol/schemas/mdbase-app.schema.json +437 -0
  599. package/node_modules/@mdbase-dev/connect-protocol/schemas/mdbase-query.v0.3.schema.json +176 -0
  600. package/node_modules/@mdbase-dev/connect-protocol/schemas/next-trust.v1.schema.json +54 -0
  601. package/node_modules/@mdbase-dev/connect-protocol/schemas/notification-webhook.v1.schema.json +56 -0
  602. package/node_modules/@mdbase-dev/connect-protocol/schemas/operation-catalog.v1.json +43 -0
  603. package/node_modules/@mdbase-dev/connect-protocol/schemas/operation-mutation-classification.v1.json +554 -0
  604. package/node_modules/@mdbase-dev/connect-protocol/schemas/sync.v1.schema.json +483 -0
  605. package/node_modules/@noble/hashes/LICENSE +21 -0
  606. package/node_modules/@noble/hashes/README.md +478 -0
  607. package/node_modules/@noble/hashes/_blake.d.ts +20 -0
  608. package/node_modules/@noble/hashes/_blake.js +59 -0
  609. package/node_modules/@noble/hashes/_md.d.ts +95 -0
  610. package/node_modules/@noble/hashes/_md.js +209 -0
  611. package/node_modules/@noble/hashes/_u64.d.ts +36 -0
  612. package/node_modules/@noble/hashes/_u64.js +77 -0
  613. package/node_modules/@noble/hashes/argon2.d.ts +148 -0
  614. package/node_modules/@noble/hashes/argon2.js +577 -0
  615. package/node_modules/@noble/hashes/blake1.d.ts +162 -0
  616. package/node_modules/@noble/hashes/blake1.js +630 -0
  617. package/node_modules/@noble/hashes/blake2.d.ts +203 -0
  618. package/node_modules/@noble/hashes/blake2.js +573 -0
  619. package/node_modules/@noble/hashes/blake3.d.ts +68 -0
  620. package/node_modules/@noble/hashes/blake3.js +310 -0
  621. package/node_modules/@noble/hashes/eskdf.d.ts +91 -0
  622. package/node_modules/@noble/hashes/eskdf.js +225 -0
  623. package/node_modules/@noble/hashes/hkdf.d.ts +70 -0
  624. package/node_modules/@noble/hashes/hkdf.js +152 -0
  625. package/node_modules/@noble/hashes/hmac.d.ts +50 -0
  626. package/node_modules/@noble/hashes/hmac.js +93 -0
  627. package/node_modules/@noble/hashes/index.d.ts +1 -0
  628. package/node_modules/@noble/hashes/index.js +34 -0
  629. package/node_modules/@noble/hashes/legacy.d.ts +107 -0
  630. package/node_modules/@noble/hashes/legacy.js +348 -0
  631. package/node_modules/@noble/hashes/package.json +91 -0
  632. package/node_modules/@noble/hashes/pbkdf2.d.ts +66 -0
  633. package/node_modules/@noble/hashes/pbkdf2.js +176 -0
  634. package/node_modules/@noble/hashes/scrypt.d.ts +98 -0
  635. package/node_modules/@noble/hashes/scrypt.js +304 -0
  636. package/node_modules/@noble/hashes/sha2.d.ts +176 -0
  637. package/node_modules/@noble/hashes/sha2.js +446 -0
  638. package/node_modules/@noble/hashes/sha3-addons.d.ts +533 -0
  639. package/node_modules/@noble/hashes/sha3-addons.js +973 -0
  640. package/node_modules/@noble/hashes/sha3.d.ts +208 -0
  641. package/node_modules/@noble/hashes/sha3.js +475 -0
  642. package/node_modules/@noble/hashes/src/_blake.ts +67 -0
  643. package/node_modules/@noble/hashes/src/_md.ts +227 -0
  644. package/node_modules/@noble/hashes/src/_u64.ts +111 -0
  645. package/node_modules/@noble/hashes/src/argon2.ts +693 -0
  646. package/node_modules/@noble/hashes/src/blake1.ts +677 -0
  647. package/node_modules/@noble/hashes/src/blake2.ts +648 -0
  648. package/node_modules/@noble/hashes/src/blake3.ts +344 -0
  649. package/node_modules/@noble/hashes/src/eskdf.ts +265 -0
  650. package/node_modules/@noble/hashes/src/hkdf.ts +161 -0
  651. package/node_modules/@noble/hashes/src/hmac.ts +130 -0
  652. package/node_modules/@noble/hashes/src/index.ts +33 -0
  653. package/node_modules/@noble/hashes/src/legacy.ts +361 -0
  654. package/node_modules/@noble/hashes/src/pbkdf2.ts +219 -0
  655. package/node_modules/@noble/hashes/src/scrypt.ts +375 -0
  656. package/node_modules/@noble/hashes/src/sha2.ts +486 -0
  657. package/node_modules/@noble/hashes/src/sha3-addons.ts +1157 -0
  658. package/node_modules/@noble/hashes/src/sha3.ts +525 -0
  659. package/node_modules/@noble/hashes/src/utils.ts +978 -0
  660. package/node_modules/@noble/hashes/src/webcrypto.ts +283 -0
  661. package/node_modules/@noble/hashes/utils.d.ts +560 -0
  662. package/node_modules/@noble/hashes/utils.js +687 -0
  663. package/node_modules/@noble/hashes/webcrypto.d.ts +121 -0
  664. package/node_modules/@noble/hashes/webcrypto.js +228 -0
  665. package/node_modules/yaml/LICENSE +13 -0
  666. package/node_modules/yaml/README.md +172 -0
  667. package/node_modules/yaml/bin.mjs +11 -0
  668. package/node_modules/yaml/browser/dist/compose/compose-collection.js +88 -0
  669. package/node_modules/yaml/browser/dist/compose/compose-doc.js +43 -0
  670. package/node_modules/yaml/browser/dist/compose/compose-node.js +109 -0
  671. package/node_modules/yaml/browser/dist/compose/compose-scalar.js +86 -0
  672. package/node_modules/yaml/browser/dist/compose/composer.js +219 -0
  673. package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +115 -0
  674. package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +198 -0
  675. package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +49 -0
  676. package/node_modules/yaml/browser/dist/compose/resolve-end.js +37 -0
  677. package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +207 -0
  678. package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +226 -0
  679. package/node_modules/yaml/browser/dist/compose/resolve-props.js +146 -0
  680. package/node_modules/yaml/browser/dist/compose/util-contains-newline.js +34 -0
  681. package/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +26 -0
  682. package/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +15 -0
  683. package/node_modules/yaml/browser/dist/compose/util-map-includes.js +13 -0
  684. package/node_modules/yaml/browser/dist/doc/Document.js +335 -0
  685. package/node_modules/yaml/browser/dist/doc/anchors.js +71 -0
  686. package/node_modules/yaml/browser/dist/doc/applyReviver.js +55 -0
  687. package/node_modules/yaml/browser/dist/doc/createNode.js +88 -0
  688. package/node_modules/yaml/browser/dist/doc/directives.js +176 -0
  689. package/node_modules/yaml/browser/dist/errors.js +57 -0
  690. package/node_modules/yaml/browser/dist/index.js +17 -0
  691. package/node_modules/yaml/browser/dist/log.js +11 -0
  692. package/node_modules/yaml/browser/dist/nodes/Alias.js +118 -0
  693. package/node_modules/yaml/browser/dist/nodes/Collection.js +147 -0
  694. package/node_modules/yaml/browser/dist/nodes/Node.js +38 -0
  695. package/node_modules/yaml/browser/dist/nodes/Pair.js +36 -0
  696. package/node_modules/yaml/browser/dist/nodes/Scalar.js +24 -0
  697. package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +144 -0
  698. package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +113 -0
  699. package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +63 -0
  700. package/node_modules/yaml/browser/dist/nodes/identity.js +36 -0
  701. package/node_modules/yaml/browser/dist/nodes/toJS.js +37 -0
  702. package/node_modules/yaml/browser/dist/parse/cst-scalar.js +214 -0
  703. package/node_modules/yaml/browser/dist/parse/cst-stringify.js +61 -0
  704. package/node_modules/yaml/browser/dist/parse/cst-visit.js +97 -0
  705. package/node_modules/yaml/browser/dist/parse/cst.js +98 -0
  706. package/node_modules/yaml/browser/dist/parse/lexer.js +721 -0
  707. package/node_modules/yaml/browser/dist/parse/line-counter.js +39 -0
  708. package/node_modules/yaml/browser/dist/parse/parser.js +975 -0
  709. package/node_modules/yaml/browser/dist/public-api.js +102 -0
  710. package/node_modules/yaml/browser/dist/schema/Schema.js +37 -0
  711. package/node_modules/yaml/browser/dist/schema/common/map.js +17 -0
  712. package/node_modules/yaml/browser/dist/schema/common/null.js +15 -0
  713. package/node_modules/yaml/browser/dist/schema/common/seq.js +17 -0
  714. package/node_modules/yaml/browser/dist/schema/common/string.js +14 -0
  715. package/node_modules/yaml/browser/dist/schema/core/bool.js +19 -0
  716. package/node_modules/yaml/browser/dist/schema/core/float.js +43 -0
  717. package/node_modules/yaml/browser/dist/schema/core/int.js +38 -0
  718. package/node_modules/yaml/browser/dist/schema/core/schema.js +23 -0
  719. package/node_modules/yaml/browser/dist/schema/json/schema.js +62 -0
  720. package/node_modules/yaml/browser/dist/schema/tags.js +96 -0
  721. package/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +58 -0
  722. package/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +26 -0
  723. package/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +46 -0
  724. package/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +71 -0
  725. package/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +67 -0
  726. package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +74 -0
  727. package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +78 -0
  728. package/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +39 -0
  729. package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +93 -0
  730. package/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +101 -0
  731. package/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +146 -0
  732. package/node_modules/yaml/browser/dist/stringify/stringify.js +129 -0
  733. package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +153 -0
  734. package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +20 -0
  735. package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +85 -0
  736. package/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +25 -0
  737. package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +150 -0
  738. package/node_modules/yaml/browser/dist/stringify/stringifyString.js +336 -0
  739. package/node_modules/yaml/browser/dist/util.js +11 -0
  740. package/node_modules/yaml/browser/dist/visit.js +233 -0
  741. package/node_modules/yaml/browser/index.js +5 -0
  742. package/node_modules/yaml/browser/package.json +3 -0
  743. package/node_modules/yaml/dist/cli.d.ts +8 -0
  744. package/node_modules/yaml/dist/cli.mjs +201 -0
  745. package/node_modules/yaml/dist/compose/compose-collection.d.ts +11 -0
  746. package/node_modules/yaml/dist/compose/compose-collection.js +90 -0
  747. package/node_modules/yaml/dist/compose/compose-doc.d.ts +7 -0
  748. package/node_modules/yaml/dist/compose/compose-doc.js +45 -0
  749. package/node_modules/yaml/dist/compose/compose-node.d.ts +29 -0
  750. package/node_modules/yaml/dist/compose/compose-node.js +112 -0
  751. package/node_modules/yaml/dist/compose/compose-scalar.d.ts +5 -0
  752. package/node_modules/yaml/dist/compose/compose-scalar.js +88 -0
  753. package/node_modules/yaml/dist/compose/composer.d.ts +63 -0
  754. package/node_modules/yaml/dist/compose/composer.js +224 -0
  755. package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +6 -0
  756. package/node_modules/yaml/dist/compose/resolve-block-map.js +117 -0
  757. package/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +11 -0
  758. package/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
  759. package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +6 -0
  760. package/node_modules/yaml/dist/compose/resolve-block-seq.js +51 -0
  761. package/node_modules/yaml/dist/compose/resolve-end.d.ts +6 -0
  762. package/node_modules/yaml/dist/compose/resolve-end.js +39 -0
  763. package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +7 -0
  764. package/node_modules/yaml/dist/compose/resolve-flow-collection.js +209 -0
  765. package/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +10 -0
  766. package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +228 -0
  767. package/node_modules/yaml/dist/compose/resolve-props.d.ts +23 -0
  768. package/node_modules/yaml/dist/compose/resolve-props.js +148 -0
  769. package/node_modules/yaml/dist/compose/util-contains-newline.d.ts +2 -0
  770. package/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
  771. package/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +2 -0
  772. package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +28 -0
  773. package/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +3 -0
  774. package/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
  775. package/node_modules/yaml/dist/compose/util-map-includes.d.ts +4 -0
  776. package/node_modules/yaml/dist/compose/util-map-includes.js +15 -0
  777. package/node_modules/yaml/dist/doc/Document.d.ts +141 -0
  778. package/node_modules/yaml/dist/doc/Document.js +337 -0
  779. package/node_modules/yaml/dist/doc/anchors.d.ts +24 -0
  780. package/node_modules/yaml/dist/doc/anchors.js +76 -0
  781. package/node_modules/yaml/dist/doc/applyReviver.d.ts +9 -0
  782. package/node_modules/yaml/dist/doc/applyReviver.js +57 -0
  783. package/node_modules/yaml/dist/doc/createNode.d.ts +17 -0
  784. package/node_modules/yaml/dist/doc/createNode.js +90 -0
  785. package/node_modules/yaml/dist/doc/directives.d.ts +49 -0
  786. package/node_modules/yaml/dist/doc/directives.js +178 -0
  787. package/node_modules/yaml/dist/errors.d.ts +21 -0
  788. package/node_modules/yaml/dist/errors.js +62 -0
  789. package/node_modules/yaml/dist/index.d.ts +25 -0
  790. package/node_modules/yaml/dist/index.js +50 -0
  791. package/node_modules/yaml/dist/log.d.ts +3 -0
  792. package/node_modules/yaml/dist/log.js +19 -0
  793. package/node_modules/yaml/dist/nodes/Alias.d.ts +29 -0
  794. package/node_modules/yaml/dist/nodes/Alias.js +120 -0
  795. package/node_modules/yaml/dist/nodes/Collection.d.ts +73 -0
  796. package/node_modules/yaml/dist/nodes/Collection.js +151 -0
  797. package/node_modules/yaml/dist/nodes/Node.d.ts +53 -0
  798. package/node_modules/yaml/dist/nodes/Node.js +40 -0
  799. package/node_modules/yaml/dist/nodes/Pair.d.ts +22 -0
  800. package/node_modules/yaml/dist/nodes/Pair.js +39 -0
  801. package/node_modules/yaml/dist/nodes/Scalar.d.ts +47 -0
  802. package/node_modules/yaml/dist/nodes/Scalar.js +27 -0
  803. package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +53 -0
  804. package/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
  805. package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +60 -0
  806. package/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
  807. package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +4 -0
  808. package/node_modules/yaml/dist/nodes/addPairToJSMap.js +65 -0
  809. package/node_modules/yaml/dist/nodes/identity.d.ts +23 -0
  810. package/node_modules/yaml/dist/nodes/identity.js +53 -0
  811. package/node_modules/yaml/dist/nodes/toJS.d.ts +29 -0
  812. package/node_modules/yaml/dist/nodes/toJS.js +39 -0
  813. package/node_modules/yaml/dist/options.d.ts +350 -0
  814. package/node_modules/yaml/dist/parse/cst-scalar.d.ts +64 -0
  815. package/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
  816. package/node_modules/yaml/dist/parse/cst-stringify.d.ts +8 -0
  817. package/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
  818. package/node_modules/yaml/dist/parse/cst-visit.d.ts +39 -0
  819. package/node_modules/yaml/dist/parse/cst-visit.js +99 -0
  820. package/node_modules/yaml/dist/parse/cst.d.ts +109 -0
  821. package/node_modules/yaml/dist/parse/cst.js +112 -0
  822. package/node_modules/yaml/dist/parse/lexer.d.ts +87 -0
  823. package/node_modules/yaml/dist/parse/lexer.js +723 -0
  824. package/node_modules/yaml/dist/parse/line-counter.d.ts +22 -0
  825. package/node_modules/yaml/dist/parse/line-counter.js +41 -0
  826. package/node_modules/yaml/dist/parse/parser.d.ts +84 -0
  827. package/node_modules/yaml/dist/parse/parser.js +980 -0
  828. package/node_modules/yaml/dist/public-api.d.ts +44 -0
  829. package/node_modules/yaml/dist/public-api.js +107 -0
  830. package/node_modules/yaml/dist/schema/Schema.d.ts +17 -0
  831. package/node_modules/yaml/dist/schema/Schema.js +39 -0
  832. package/node_modules/yaml/dist/schema/common/map.d.ts +2 -0
  833. package/node_modules/yaml/dist/schema/common/map.js +19 -0
  834. package/node_modules/yaml/dist/schema/common/null.d.ts +4 -0
  835. package/node_modules/yaml/dist/schema/common/null.js +17 -0
  836. package/node_modules/yaml/dist/schema/common/seq.d.ts +2 -0
  837. package/node_modules/yaml/dist/schema/common/seq.js +19 -0
  838. package/node_modules/yaml/dist/schema/common/string.d.ts +2 -0
  839. package/node_modules/yaml/dist/schema/common/string.js +16 -0
  840. package/node_modules/yaml/dist/schema/core/bool.d.ts +4 -0
  841. package/node_modules/yaml/dist/schema/core/bool.js +21 -0
  842. package/node_modules/yaml/dist/schema/core/float.d.ts +4 -0
  843. package/node_modules/yaml/dist/schema/core/float.js +47 -0
  844. package/node_modules/yaml/dist/schema/core/int.d.ts +4 -0
  845. package/node_modules/yaml/dist/schema/core/int.js +42 -0
  846. package/node_modules/yaml/dist/schema/core/schema.d.ts +1 -0
  847. package/node_modules/yaml/dist/schema/core/schema.js +25 -0
  848. package/node_modules/yaml/dist/schema/json/schema.d.ts +2 -0
  849. package/node_modules/yaml/dist/schema/json/schema.js +64 -0
  850. package/node_modules/yaml/dist/schema/json-schema.d.ts +69 -0
  851. package/node_modules/yaml/dist/schema/tags.d.ts +48 -0
  852. package/node_modules/yaml/dist/schema/tags.js +99 -0
  853. package/node_modules/yaml/dist/schema/types.d.ts +92 -0
  854. package/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +2 -0
  855. package/node_modules/yaml/dist/schema/yaml-1.1/binary.js +70 -0
  856. package/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +7 -0
  857. package/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
  858. package/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +4 -0
  859. package/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
  860. package/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +5 -0
  861. package/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
  862. package/node_modules/yaml/dist/schema/yaml-1.1/merge.d.ts +9 -0
  863. package/node_modules/yaml/dist/schema/yaml-1.1/merge.js +71 -0
  864. package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +22 -0
  865. package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
  866. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +10 -0
  867. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
  868. package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -0
  869. package/node_modules/yaml/dist/schema/yaml-1.1/schema.js +41 -0
  870. package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +28 -0
  871. package/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
  872. package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +6 -0
  873. package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
  874. package/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +34 -0
  875. package/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
  876. package/node_modules/yaml/dist/stringify/stringify.d.ts +21 -0
  877. package/node_modules/yaml/dist/stringify/stringify.js +132 -0
  878. package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +17 -0
  879. package/node_modules/yaml/dist/stringify/stringifyCollection.js +155 -0
  880. package/node_modules/yaml/dist/stringify/stringifyComment.d.ts +10 -0
  881. package/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
  882. package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +4 -0
  883. package/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
  884. package/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +2 -0
  885. package/node_modules/yaml/dist/stringify/stringifyNumber.js +27 -0
  886. package/node_modules/yaml/dist/stringify/stringifyPair.d.ts +3 -0
  887. package/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
  888. package/node_modules/yaml/dist/stringify/stringifyString.d.ts +9 -0
  889. package/node_modules/yaml/dist/stringify/stringifyString.js +338 -0
  890. package/node_modules/yaml/dist/test-events.d.ts +4 -0
  891. package/node_modules/yaml/dist/test-events.js +134 -0
  892. package/node_modules/yaml/dist/util.d.ts +16 -0
  893. package/node_modules/yaml/dist/util.js +28 -0
  894. package/node_modules/yaml/dist/visit.d.ts +102 -0
  895. package/node_modules/yaml/dist/visit.js +236 -0
  896. package/node_modules/yaml/package.json +97 -0
  897. package/node_modules/yaml/util.js +2 -0
  898. package/package.json +108 -4
  899. package/vendor/mdbase-connect-sdk-e6e66bcd172f.json +13 -0
  900. package/vendor/mdbase-dev-connect-protocol-0.1.0-beta.145-e6e66bcd172f.tgz +0 -0
@@ -0,0 +1,1050 @@
1
+ /** Optional first-party app artifact binding. No auth/custody defaults or MemStore fallback. */
2
+ import { decode, encode, encodeSecret } from "../cbor.js";
3
+ import { hashToBytes, uuidToBytes } from "../codec.js";
4
+ import { mdbaseError } from "../errors.js";
5
+ import { WasmRuntime } from "../runtime/wasm.js";
6
+ import { confirmedHead, syncStatus } from "../wire.js";
7
+ import { AppLogPump } from "./log-pump.js";
8
+ import { resourceAssessment, resourceDecisions } from "./collection-control.js";
9
+ import { modelResourcePlan } from "./collection-setup-journal.js";
10
+ /** @internal Bounded resource DATA codec shared with the setup engine. */
11
+ export function resourceJson(value, toCbor, depth = 0, count = { nodes: 0 }) {
12
+ if (depth > 32 || ++count.nodes > 65536)
13
+ throw mdbaseError("invalid_request", "resource DATA exceeds bound");
14
+ if (value === null || typeof value === "boolean" || typeof value === "string"
15
+ || (typeof value === "number" && Number.isFinite(value)))
16
+ return value;
17
+ if (Array.isArray(value))
18
+ return value.map(child => resourceJson(child, toCbor, depth + 1, count));
19
+ const map = toCbor ? value !== null && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype
20
+ ? Object.entries(value) : null : value instanceof Map ? [...value] : null;
21
+ if (!map)
22
+ throw mdbaseError("invalid_request", "invalid resource DATA");
23
+ const result = new Map();
24
+ for (const [key, child] of map) {
25
+ if (typeof key !== "string" || result.has(key))
26
+ throw mdbaseError("invalid_request", "invalid resource DATA");
27
+ result.set(key, resourceJson(child, toCbor, depth + 1, count));
28
+ }
29
+ return toCbor ? result : Object.fromEntries(result);
30
+ }
31
+ export class AppStrictDeviceApprovalError extends Error {
32
+ reason = "strict_device_approval";
33
+ constructor() { super("this account uses strict device approval; add this device from your desktop"); this.name = "AppStrictDeviceApprovalError"; }
34
+ }
35
+ const bad = () => mdbaseError("unavailable", "app runtime unavailable; reopen and reconcile");
36
+ function policyPins(v) {
37
+ if (!(v instanceof Uint8Array) || v.length === 0 || v.length > 64 * 1024)
38
+ throw bad();
39
+ return new Uint8Array(v);
40
+ }
41
+ function uint64(v) {
42
+ if ((typeof v !== "number" || !Number.isSafeInteger(v)) && typeof v !== "bigint")
43
+ throw bad();
44
+ const n = BigInt(v);
45
+ if (n < 0n || n > (1n << 64n) - 1n)
46
+ throw bad();
47
+ return n;
48
+ }
49
+ const equalBytes = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
50
+ function b32(v) { if (!(v instanceof Uint8Array) || v.length !== 32)
51
+ throw bad(); return v; }
52
+ /** One module/database lifetime. Call pump.close() before shutdown/SQL close;
53
+ * terminate Worker before releasing its lease if drain/disposal fails. */
54
+ export class AppWasmRuntime extends WasmRuntime {
55
+ sqlBinding;
56
+ attempted = false;
57
+ active = false;
58
+ retired = false;
59
+ collection = null;
60
+ deviceId = null;
61
+ connectorId = null;
62
+ cpPin = null;
63
+ deviceAttempted = false;
64
+ deviceActive = false;
65
+ deviceRegistered = false;
66
+ devicePin = null;
67
+ installationId = null;
68
+ publicIdentity = null;
69
+ noiseEnvelope = null;
70
+ cloudSource = null;
71
+ cloudCallback = null;
72
+ cloudCollection = null;
73
+ cloudPurpose = null;
74
+ cloudIssued = false;
75
+ privateAttempted = false;
76
+ privateSource = null;
77
+ prospectiveCollection = null;
78
+ privatePurpose = null;
79
+ sasCommitment = null;
80
+ privateEnrolAcknowledged = false;
81
+ endpoint = null;
82
+ logGeneration = 0n;
83
+ pump = null;
84
+ transport = null;
85
+ constructor(x, sqlBinding) {
86
+ super(x);
87
+ this.sqlBinding = sqlBinding;
88
+ }
89
+ get sql() { return this.sqlBinding.sql; }
90
+ get app() { return this.x; }
91
+ static async create(bytes, sql) {
92
+ if (sql.needsRecovery)
93
+ throw bad();
94
+ return this.instantiateApp(bytes, sql);
95
+ }
96
+ /** Device-only module with DENYING SQL import. Collection trust/database is
97
+ * deliberately not required/created while registering a fresh installation. */
98
+ static async createDevice(bytes) { return this.instantiateApp(bytes, null); }
99
+ static async instantiateApp(bytes, sql) {
100
+ const binding = { sql, exports: null, run: null };
101
+ const x = await this.load(bytes, exports => { binding.exports = exports; binding.run = sql?.import(exports) ?? null; return { host_app_sql: (p, n) => binding.run?.(p, n) ?? 0n }; });
102
+ const names = ["rt_app_account_key_unlock", "rt_app_account_key_status", "rt_app_account_key_device_setup", "rt_app_private_collection_pin", "rt_app_private_enrol_restore", "rt_app_private_enrol_commitment", "rt_app_private_create_sign", "rt_app_private_device_enrol_sign", "rt_app_device_open", "rt_app_device_registered", "rt_app_device_adopt", "rt_app_device_retire", "rt_app_cp_enrol_sign", "rt_app_verify_handover", "rt_app_cp_bind_connector", "rt_app_cp_log_token_sign", "rt_app_open", "rt_app_log_bind", "rt_app_log_generation", "rt_app_log_reconnect", "rt_app_log_http_sign", "rt_app_log_calls", "rt_app_log_reply", "rt_app_log_no_response", "rt_app_log_retire", "rt_app_log_push", "rt_app_observations", "rt_app_shutdown"];
103
+ if (!(x.memory instanceof WebAssembly.Memory) || names.some(name => typeof x[name] !== "function"))
104
+ throw bad();
105
+ return new AppWasmRuntime(x, binding);
106
+ }
107
+ /** The app artifact never uses a legacy/config-default MemStore path. */
108
+ open(_config) { throw bad(); }
109
+ fail() { try {
110
+ if (this.active || this.attempted)
111
+ this.sql?.fence();
112
+ }
113
+ finally {
114
+ this.active = false;
115
+ this.deviceActive = false;
116
+ this.discard();
117
+ } }
118
+ guard(f) {
119
+ try {
120
+ return f();
121
+ }
122
+ catch {
123
+ this.fail();
124
+ throw bad();
125
+ }
126
+ }
127
+ /** One attempt. The caller must unwrap keys before this SYNCHRONOUS operation. */
128
+ openAppConsuming(c) {
129
+ let encoded = null;
130
+ try {
131
+ if (this.attempted || this.deviceAttempted || !this.sql || this.sql.needsRecovery)
132
+ throw bad();
133
+ this.attempted = true;
134
+ const endpoint = uint64(c.endpoint);
135
+ if (!Array.isArray(c.trustedRoots) || c.trustedRoots.length < 1 || c.trustedRoots.length > 64 || !Array.isArray(c.trustedSigners) || c.trustedSigners.length > 1_024)
136
+ throw bad();
137
+ if (!Number.isSafeInteger(c.sqliteVersion) || c.sqliteVersion < 0 || c.sqliteVersion > 0xffff_ffff)
138
+ throw bad();
139
+ const state = c.state === "e2e" ? 0 : c.state === "cloud_copy" ? 1 : -1;
140
+ const opened = c.opened === "fresh" ? 0 : c.opened === "existing" ? 1 : c.opened === "unclean" ? 2 : -1;
141
+ if (state < 0 || opened < 0 || typeof c.cloudCopyOptIn !== "boolean" || (state === 1) !== c.cloudCopyOptIn)
142
+ throw bad();
143
+ encoded = encodeSecret(new Map([
144
+ [0, 3], [1, uuidToBytes(c.collection)], [2, uuidToBytes(c.replicaId)], [3, uuidToBytes(c.deviceId)],
145
+ [4, endpoint], [5, c.trustedRoots.map(b32)], [6, c.trustedSigners.map(uuidToBytes)], [7, hashToBytes(c.expectedGenesis)],
146
+ [8, state], [9, c.cloudCopyOptIn], [10, b32(c.signSecretKey)], [11, b32(c.kemSecretKey)], [12, opened], [13, c.sqliteVersion], [16, policyPins(c.policyPins)],
147
+ ]));
148
+ if (encoded.length > 64 * 1024)
149
+ throw bad();
150
+ const error = this.guard(() => this.takeOut(this.app.rt_app_open(...this.put(encoded))));
151
+ if (error.length)
152
+ throw bad();
153
+ this.collection = c.collection;
154
+ this.deviceId = c.deviceId;
155
+ this.endpoint = endpoint;
156
+ this.active = true;
157
+ this.markOpened();
158
+ }
159
+ catch {
160
+ this.retireLog();
161
+ this.fail();
162
+ throw bad();
163
+ }
164
+ finally {
165
+ encoded?.fill(0);
166
+ c.signSecretKey?.fill(0);
167
+ c.kemSecretKey?.fill(0);
168
+ }
169
+ }
170
+ tick() { if (this.active && !this.retired)
171
+ this.guard(() => super.tick()); }
172
+ connect(options = {}) {
173
+ if (!this.active || this.retired || (options.collection !== undefined && (typeof options.collection !== "string" || options.collection.toLowerCase() !== this.collection?.toLowerCase())))
174
+ throw bad();
175
+ const port = super.connect(options), send = port.send.bind(port), close = port.close.bind(port);
176
+ port.send = frame => this.guard(() => send(frame));
177
+ port.close = () => this.guard(() => close());
178
+ return port;
179
+ }
180
+ /** Trusted host READ on its actual held port. Native admission/publication
181
+ * remains authoritative. There is no caller-selected session or MemStore path. */
182
+ executeBases(port, request) {
183
+ return this.readBases(port, request, "execute");
184
+ }
185
+ /** Separate native metadata READ exports; never caller sessions or Query RPC. */
186
+ discoverBases(port, operation, request) {
187
+ if (operation !== "list-views" && operation !== "read-view-source")
188
+ throw bad();
189
+ return this.readBases(port, request, operation);
190
+ }
191
+ readBases(port, request, operation) {
192
+ const session = this.sessionForPort(port);
193
+ const native = operation === "execute" ? this.app.rt_app_bases_execute : operation === "list-views" ? this.app.rt_app_bases_list_views : this.app.rt_app_bases_read_view_source;
194
+ if (!this.active || this.retired || !this.sql || this.sql.needsRecovery || session === null || typeof native !== "function")
195
+ throw bad();
196
+ if (!(request instanceof Uint8Array) || !request.length || request.length > 128 * 1024)
197
+ throw mdbaseError("invalid_request", "Bases request bytes exceed bound");
198
+ const owned = new Uint8Array(request);
199
+ try {
200
+ const out = this.guard(() => {
201
+ const packed = uint64(native.call(this.app, session, ...this.put(owned)));
202
+ const length = Number(packed & 0xffffffffn);
203
+ if (!length || length > (operation === "execute" ? 16 : 1) * 1024 * 1024)
204
+ throw bad();
205
+ return this.takeOut(packed);
206
+ });
207
+ if (!this.active || this.retired || this.sql.needsRecovery || this.sessionForPort(port) !== session) {
208
+ out.fill(0);
209
+ throw bad();
210
+ }
211
+ return out;
212
+ }
213
+ finally {
214
+ owned.fill(0);
215
+ }
216
+ }
217
+ setupResources(port, operation, manifest, expectedDigest, decisions) {
218
+ const session = this.sessionForPort(port), native = this.app.rt_app_resources;
219
+ if (!this.active || this.retired || !this.sql || this.sql.needsRecovery || session === null || typeof native !== "function")
220
+ throw mdbaseError("unavailable", "resource setup unsupported", "resource_setup_unsupported");
221
+ if (operation !== "assess" && operation !== "apply")
222
+ throw bad();
223
+ if (operation === "apply" && (typeof expectedDigest !== "string" || !/^sha256:[0-9a-f]{64}$/.test(expectedDigest)))
224
+ throw bad();
225
+ // A fifth member carries reviewed decisions and asks assess for the review.
226
+ const reviewing = decisions !== undefined;
227
+ const request = [1, operation === "apply" ? 1 : 0, resourceJson(manifest, true), expectedDigest ?? null];
228
+ if (reviewing)
229
+ request.push(resourceJson(resourceDecisions(decisions), true));
230
+ const input = encode(request);
231
+ if (!input.length || input.length > 512 * 1024) {
232
+ input.fill(0);
233
+ throw mdbaseError("invalid_request", "resource DATA exceeds bound");
234
+ }
235
+ let output;
236
+ try {
237
+ output = this.guard(() => {
238
+ const packed = uint64(native.call(this.app, session, ...this.put(input)));
239
+ const length = Number(packed & 0xffffffffn);
240
+ if (!length || length > 512 * 1024)
241
+ throw bad();
242
+ return this.takeOut(packed);
243
+ });
244
+ if (!this.active || this.retired || this.sql.needsRecovery || this.sessionForPort(port) !== session)
245
+ throw bad();
246
+ const response = this.guard(() => decode(output));
247
+ if (!Array.isArray(response) || response.length !== 3 || response[0] !== 1 || typeof response[1] !== "boolean")
248
+ throw bad();
249
+ if (response[1] === false)
250
+ throw mdbaseError("unavailable", "resource setup unavailable", "resource_setup_unavailable");
251
+ const value = resourceJson(response[2], false);
252
+ return operation === "assess" ? resourceAssessment(value, reviewing) : modelResourcePlan(value);
253
+ }
254
+ finally {
255
+ input.fill(0);
256
+ output?.fill(0);
257
+ }
258
+ }
259
+ /** True only when native holds a FINAL rejected receipt for exactly this
260
+ * mutation on the port's own session. Anything else, including errors, is false. */
261
+ resourceRejected(port, mutationId) {
262
+ let bytes = null;
263
+ try {
264
+ const session = this.sessionForPort(port), native = this.app.rt_app_receipt_rejected;
265
+ if (!this.active || this.retired || session === null || typeof native !== "function" || !/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(mutationId))
266
+ return false;
267
+ bytes = uuidToBytes(mutationId);
268
+ const answer = this.guard(() => native.call(this.app, session, ...this.put(bytes)));
269
+ return answer === 1 && this.active && !this.retired && this.sessionForPort(port) === session;
270
+ }
271
+ catch {
272
+ return false;
273
+ }
274
+ finally {
275
+ bytes?.fill(0);
276
+ }
277
+ }
278
+ /** Positive ONLY from native verified-policy signature + retained prefix and
279
+ * live READ session. Ordinary unavailable stays hosted; no saved implication. */
280
+ verifyHandover(port, source, witness) {
281
+ let bytes = null, device = null;
282
+ try {
283
+ const session = this.sessionForPort(port), collection = source.collection, deviceId = source.deviceId;
284
+ if (!this.active || this.retired || session === null || collection !== this.collection || source.isCurrent() !== true || !(witness instanceof Uint8Array) || witness.length > 64 * 1024)
285
+ return null;
286
+ bytes = new Uint8Array(witness);
287
+ device = uuidToBytes(deviceId);
288
+ const out = this.guard(() => this.takeOut(this.app.rt_app_verify_handover(session, ...this.put(device), ...this.put(bytes))));
289
+ if (out.length === 0 || this.sessionForPort(port) !== session || source.isCurrent() !== true || source.collection !== collection || source.deviceId !== deviceId)
290
+ return null;
291
+ const head = this.guard(() => confirmedHead.dec(decode(out)));
292
+ if (head.seq === 0 || [head.chain, head.policyGeneration, head.catalogGeneration].some(h => h === `sha256:${"00".repeat(32)}`))
293
+ return null;
294
+ return head;
295
+ }
296
+ catch {
297
+ return null;
298
+ }
299
+ finally {
300
+ bytes?.fill(0);
301
+ device?.fill(0);
302
+ }
303
+ }
304
+ /** One authenticated connector bootstrap pin before any LS binding. */
305
+ bindCpConnector(pin) {
306
+ let bytes = null;
307
+ try {
308
+ if (!this.active || this.retired || this.pump || this.cpPin || pin.isCurrent() !== true || pin.deviceId !== this.deviceId || pin.collection !== this.collection)
309
+ throw bad();
310
+ const connectorId = pin.connectorId;
311
+ bytes = uuidToBytes(connectorId);
312
+ if (bytes.every(b => b === 0))
313
+ throw bad();
314
+ if (this.guard(() => this.app.rt_app_cp_bind_connector(...this.put(bytes))) !== 1)
315
+ throw bad();
316
+ this.connectorId = connectorId;
317
+ this.cpPin = pin;
318
+ }
319
+ catch {
320
+ throw bad();
321
+ }
322
+ finally {
323
+ bytes?.fill(0);
324
+ }
325
+ }
326
+ deviceCurrent() {
327
+ try {
328
+ const pin = this.devicePin;
329
+ return this.deviceActive && !this.retired && pin !== null && pin.isCurrent() === true && pin.connectorId === this.connectorId && pin.deviceId === this.deviceId && pin.installationId === this.installationId;
330
+ }
331
+ catch {
332
+ return false;
333
+ }
334
+ }
335
+ publicResult(out) {
336
+ if (out.length > 1024)
337
+ throw bad();
338
+ const decoded = decode(out);
339
+ if (!(decoded instanceof Map))
340
+ throw bad();
341
+ const m = decoded;
342
+ if (m.size !== 4 || [0, 1, 2, 3].some(k => !m.has(k)))
343
+ throw bad();
344
+ const publicKey = (k) => { const value = m.get(k); if (!(value instanceof Uint8Array) || value.length !== 32 || value.every(b => b === 0))
345
+ throw bad(); return new Uint8Array(value); };
346
+ return { m, identity: Object.freeze({ signPublicKey: publicKey(0), kemPublicKey: publicKey(1), noisePublicKey: publicKey(2) }) };
347
+ }
348
+ /** Phase1 ONLY; no roots/genesis/Core/SQL/LS/RPC. Async protected outer
349
+ * unwrap precedes this sync native operation. Exactly one fresh/restore
350
+ * attempt, consuming BOTH sign/KEM loans; no caller Noise secret. */
351
+ openDeviceConsuming(c) {
352
+ let encoded = null;
353
+ try {
354
+ if (this.deviceAttempted || this.attempted || this.retired)
355
+ throw bad();
356
+ this.deviceAttempted = true;
357
+ const pin = c.pin;
358
+ this.devicePin = pin;
359
+ this.connectorId = pin.connectorId;
360
+ this.deviceId = pin.deviceId;
361
+ this.installationId = pin.installationId;
362
+ this.deviceActive = true;
363
+ if (!this.deviceCurrent())
364
+ throw bad();
365
+ const ids = [this.connectorId, this.deviceId, this.installationId].map(uuidToBytes);
366
+ if (ids.some(id => id.every(b => b === 0)))
367
+ throw bad();
368
+ const opened = c.opened;
369
+ if (opened.mode !== "fresh" && opened.mode !== "existing")
370
+ throw bad();
371
+ if (opened.mode === "existing" && (!(opened.envelope instanceof Uint8Array) || !opened.envelope.length || opened.envelope.length > 1024))
372
+ throw bad();
373
+ encoded = encodeSecret(new Map([[0, 1], [1, ids[0]], [2, ids[1]], [3, ids[2]], [4, opened.mode === "fresh" ? 0 : 1], [5, b32(c.signSecretKey)], [6, b32(c.kemSecretKey)], [7, opened.mode === "fresh" ? new Uint8Array() : new Uint8Array(opened.envelope)]]));
374
+ const out = this.guard(() => this.takeOut(this.app.rt_app_device_open(...this.put(encoded))));
375
+ if (!out.length || !this.deviceCurrent())
376
+ throw bad();
377
+ const result = this.guard(() => { const { m, identity } = this.publicResult(out); const wrapped = m.get(3); if (!(wrapped instanceof Uint8Array) || !wrapped.length || wrapped.length > 1024)
378
+ throw bad(); return { ...identity, envelope: new Uint8Array(wrapped) }; });
379
+ this.publicIdentity = { signPublicKey: new Uint8Array(result.signPublicKey), kemPublicKey: new Uint8Array(result.kemPublicKey), noisePublicKey: new Uint8Array(result.noisePublicKey) };
380
+ this.noiseEnvelope = new Uint8Array(result.envelope);
381
+ return Object.freeze(result);
382
+ }
383
+ catch {
384
+ this.retireLog();
385
+ throw bad();
386
+ }
387
+ finally {
388
+ encoded?.fill(0);
389
+ c.signSecretKey?.fill(0);
390
+ c.kemSecretKey?.fill(0);
391
+ }
392
+ }
393
+ /** Public binding check for this exact DEVICE-only custody result. Not an
394
+ * account/app grant, collection readiness or independent key attestation. */
395
+ deviceCustodyCurrent(pin, custody) {
396
+ try {
397
+ return this.deviceCurrent() && !this.active && this.publicIdentity !== null && this.noiseEnvelope !== null && pin.isCurrent() === true && pin.connectorId === this.connectorId && pin.deviceId === this.deviceId && pin.installationId === this.installationId && custody.envelope instanceof Uint8Array && custody.envelope.length === this.noiseEnvelope.length && custody.envelope.every((b, i) => b === this.noiseEnvelope[i]) && ["signPublicKey", "kemPublicKey", "noisePublicKey"].every(k => custody[k] instanceof Uint8Array && custody[k].length === 32 && custody[k].every((b, i) => b === this.publicIdentity[k][i]));
398
+ }
399
+ catch {
400
+ return false;
401
+ }
402
+ }
403
+ /** HOST ONLY actual authenticated response/protected stored receipt. Never
404
+ * inferred from ciphertext, same account, persistence or zero pending. */
405
+ acknowledgeDeviceRegistration(receipt) {
406
+ let encoded = null;
407
+ try {
408
+ if (!this.deviceCurrent() || this.active || this.deviceRegistered || !this.publicIdentity || receipt.connectorId !== this.connectorId || receipt.deviceId !== this.deviceId || receipt.installationId !== this.installationId)
409
+ throw bad();
410
+ for (const k of ["signPublicKey", "kemPublicKey", "noisePublicKey"])
411
+ if (b32(receipt[k]).some((b, i) => b !== this.publicIdentity[k][i]))
412
+ throw bad();
413
+ encoded = encodeSecret(new Map([[0, uuidToBytes(receipt.connectorId)], [1, uuidToBytes(receipt.deviceId)], [2, uuidToBytes(receipt.installationId)], [3, new Uint8Array(receipt.signPublicKey)], [4, new Uint8Array(receipt.kemPublicKey)], [5, new Uint8Array(receipt.noisePublicKey)]]));
414
+ if (this.guard(() => this.app.rt_app_device_registered(...this.put(encoded))) !== 1 || !this.deviceCurrent())
415
+ throw bad();
416
+ this.deviceRegistered = true;
417
+ }
418
+ catch {
419
+ this.retireLog();
420
+ throw bad();
421
+ }
422
+ finally {
423
+ encoded?.fill(0);
424
+ }
425
+ }
426
+ /** Once-pinned CLOUD COPY purpose. Requires actual original registration,
427
+ * no private/SAS context and no seed re-loan, roots or SQL effects. */
428
+ prepareCloudCopyCollection(pin) {
429
+ let encoded = null;
430
+ try {
431
+ if (pin.approvalMode === "strict")
432
+ throw new AppStrictDeviceApprovalError();
433
+ if (this.cloudSource || this.privateAttempted || !this.deviceCurrent() || !this.deviceRegistered || this.active || pin.approvalMode !== "password-ak1" || !["create", "join"].includes(pin.purpose))
434
+ throw bad();
435
+ this.cloudSource = pin;
436
+ this.cloudCallback = pin.isCurrent;
437
+ this.cloudCollection = pin.collection;
438
+ this.cloudPurpose = pin.purpose;
439
+ if (!this.cloudCopyCollectionCurrent(pin))
440
+ throw bad();
441
+ const collection = uuidToBytes(pin.collection);
442
+ if (collection.every(v => v === 0))
443
+ throw bad();
444
+ encoded = encodeSecret(new Map([[0, collection], [1, pin.purpose === "create" ? 0 : 1]]));
445
+ if (this.guard(() => this.app.rt_app_cloud_copy_pin(...this.put(encoded))) !== 1 || !this.cloudCopyCollectionCurrent(pin))
446
+ throw bad();
447
+ }
448
+ catch (error) {
449
+ this.retireLog();
450
+ if (error instanceof AppStrictDeviceApprovalError)
451
+ throw error;
452
+ throw bad();
453
+ }
454
+ finally {
455
+ encoded?.fill(0);
456
+ }
457
+ }
458
+ cloudCopyCollectionCurrent(source) {
459
+ try {
460
+ const p = this.cloudSource;
461
+ return this.deviceCurrent() && !this.active && this.deviceRegistered && p !== null && (!source || source === p) && p.isCurrent === this.cloudCallback && p.isCurrent() === true && p.connectorId === this.connectorId && p.deviceId === this.deviceId && p.installationId === this.installationId && p.collection === this.cloudCollection && p.purpose === this.cloudPurpose && p.approvalMode === "password-ak1";
462
+ }
463
+ catch {
464
+ return false;
465
+ }
466
+ }
467
+ /** Fixed native create domain; no configurable digest/subject/signer. */
468
+ signCloudCopyCreate(challenge) { return this.signCloudCopy(challenge, "create"); }
469
+ /** Fixed native join domain; no private enrol/SAS state. */
470
+ signCloudCopyJoin(challenge) { return this.signCloudCopy(challenge, "join"); }
471
+ signCloudCopy(challenge, purpose) {
472
+ let owned = null, signature = null;
473
+ try {
474
+ if (this.cloudIssued || !this.cloudCopyCollectionCurrent() || this.cloudPurpose !== purpose)
475
+ throw bad();
476
+ this.cloudIssued = true;
477
+ owned = new Uint8Array(b32(challenge));
478
+ signature = this.guard(() => this.takeOut(purpose === "create" ? this.app.rt_app_cloud_copy_create_sign(...this.put(owned)) : this.app.rt_app_cloud_copy_join_sign(...this.put(owned))));
479
+ if (signature.length !== 64 || !this.cloudCopyCollectionCurrent())
480
+ throw bad();
481
+ return signature;
482
+ }
483
+ catch {
484
+ signature?.fill(0);
485
+ this.retireLog();
486
+ throw bad();
487
+ }
488
+ finally {
489
+ owned?.fill(0);
490
+ }
491
+ }
492
+ /** Host-only ONCE, registered DEVICE phase. No Core/SQL/readiness; no caller
493
+ * fresh JS commit/secret. Existing must come from exact platform-protected
494
+ * public marker; never regenerate after uncertain enrolment. */
495
+ preparePrivateCollection(pin, opened) {
496
+ let encoded = null, restoredCommit = null;
497
+ try {
498
+ if (pin.approvalMode === "strict")
499
+ throw new AppStrictDeviceApprovalError();
500
+ if (this.cloudSource || this.privateAttempted || !this.deviceCurrent() || !this.deviceRegistered || this.active || pin.approvalMode !== "password-ak1" || !["create", "enrol"].includes(pin.purpose))
501
+ throw bad();
502
+ this.privateAttempted = true;
503
+ this.privateSource = pin;
504
+ this.prospectiveCollection = pin.collection;
505
+ this.privatePurpose = pin.purpose;
506
+ if (!this.privateCollectionCurrent())
507
+ throw bad();
508
+ const collection = uuidToBytes(pin.collection);
509
+ if (collection.every(v => v === 0))
510
+ throw bad();
511
+ if (opened.mode === "fresh") {
512
+ encoded = encodeSecret(new Map([[0, collection], [1, pin.purpose === "create" ? 0 : 1]]));
513
+ if (this.guard(() => this.app.rt_app_private_collection_pin(...this.put(encoded))) !== 1)
514
+ throw bad();
515
+ }
516
+ else if (opened.mode === "existing") {
517
+ const m = opened.marker, p = this.publicIdentity;
518
+ if (pin.purpose !== "enrol" || !p || m.collection !== pin.collection || m.connectorId !== this.connectorId || m.deviceId !== this.deviceId || m.installationId !== this.installationId || typeof m.acknowledged !== "boolean")
519
+ throw bad();
520
+ for (const k of ["signPublicKey", "kemPublicKey", "noisePublicKey"])
521
+ if (!equalBytes(b32(m[k]), p[k]))
522
+ throw bad();
523
+ const commit = new Uint8Array(b32(m.sasCommitment));
524
+ if (commit.every(v => v === 0))
525
+ throw bad();
526
+ restoredCommit = commit;
527
+ encoded = encodeSecret(new Map([[0, 1], [1, collection], [2, uuidToBytes(m.connectorId)], [3, uuidToBytes(m.deviceId)], [4, uuidToBytes(m.installationId)], [5, new Uint8Array(m.signPublicKey)], [6, new Uint8Array(m.kemPublicKey)], [7, new Uint8Array(m.noisePublicKey)], [8, commit], [9, m.acknowledged]]));
528
+ this.privateEnrolAcknowledged = m.acknowledged;
529
+ if (this.guard(() => this.app.rt_app_private_enrol_restore(...this.put(encoded))) !== 1)
530
+ throw bad();
531
+ }
532
+ else
533
+ throw bad();
534
+ if (!this.privateCollectionCurrent())
535
+ throw bad();
536
+ if (pin.purpose === "enrol") {
537
+ const commit = this.guard(() => this.takeOut(this.app.rt_app_private_enrol_commitment()));
538
+ if (commit.length !== 32 || commit.every(v => v === 0) || (restoredCommit !== null && !equalBytes(commit, restoredCommit)))
539
+ throw bad();
540
+ this.sasCommitment = new Uint8Array(commit);
541
+ }
542
+ }
543
+ catch (error) {
544
+ this.retireLog();
545
+ if (error instanceof AppStrictDeviceApprovalError)
546
+ throw error;
547
+ throw bad();
548
+ }
549
+ finally {
550
+ encoded?.fill(0);
551
+ }
552
+ }
553
+ /** Actual acknowledged device public receipt, copied; no new authority. */
554
+ registeredDeviceReceipt() {
555
+ if (!this.deviceCurrent() || !this.deviceRegistered || !this.publicIdentity)
556
+ throw bad();
557
+ const p = this.publicIdentity;
558
+ return Object.freeze({ connectorId: this.connectorId, deviceId: this.deviceId, installationId: this.installationId, signPublicKey: new Uint8Array(p.signPublicKey), kemPublicKey: new Uint8Array(p.kemPublicKey), noisePublicKey: new Uint8Array(p.noisePublicKey) });
559
+ }
560
+ /** Public native-generated/restored marker to protect BEFORE any enrol POST. */
561
+ privateEnrolMarker() {
562
+ if (!this.privateCollectionCurrent() || this.privatePurpose !== "enrol" || !this.sasCommitment || !this.publicIdentity)
563
+ throw bad();
564
+ const p = this.publicIdentity;
565
+ return Object.freeze({ connectorId: this.connectorId, deviceId: this.deviceId, installationId: this.installationId, collection: this.prospectiveCollection, sasCommitment: new Uint8Array(this.sasCommitment), acknowledged: this.privateEnrolAcknowledged, signPublicKey: new Uint8Array(p.signPublicKey), kemPublicKey: new Uint8Array(p.kemPublicKey), noisePublicKey: new Uint8Array(p.noisePublicKey) });
566
+ }
567
+ privateCollectionCurrent(source) {
568
+ try {
569
+ if (source && (source.isCurrent() !== true || source.connectorId !== this.connectorId || source.deviceId !== this.deviceId || source.installationId !== this.installationId || source.collection !== this.prospectiveCollection || source.purpose !== this.privatePurpose || source.approvalMode !== "password-ak1"))
570
+ return false;
571
+ const p = this.privateSource;
572
+ return this.deviceCurrent() && !this.active && this.deviceRegistered && p !== null && p.isCurrent() === true && p.connectorId === this.connectorId && p.deviceId === this.deviceId && p.installationId === this.installationId && p.collection === this.prospectiveCollection && p.purpose === this.privatePurpose && p.approvalMode === "password-ak1";
573
+ }
574
+ catch {
575
+ return false;
576
+ }
577
+ }
578
+ /** Dedicated private-create signature only, no configurable purpose/PK/digest. */
579
+ signPrivateCreate(challenge) {
580
+ let owned = null;
581
+ try {
582
+ if (!this.privateCollectionCurrent() || this.privatePurpose !== "create")
583
+ throw bad();
584
+ owned = new Uint8Array(b32(challenge));
585
+ const sig = this.guard(() => this.takeOut(this.app.rt_app_private_create_sign(...this.put(owned))));
586
+ if (sig.length !== 64 || !this.privateCollectionCurrent())
587
+ throw bad();
588
+ return sig;
589
+ }
590
+ catch {
591
+ this.retireLog();
592
+ throw bad();
593
+ }
594
+ finally {
595
+ owned?.fill(0);
596
+ }
597
+ }
598
+ /** Native public SAS commitment + dedicated enrol signature. No r/state or
599
+ * caller commit; strict approval/Noise handshake is not implemented in v1. */
600
+ signPrivateDeviceEnrol(challenge) {
601
+ let owned = null;
602
+ try {
603
+ if (!this.privateCollectionCurrent() || this.privatePurpose !== "enrol" || !this.sasCommitment || this.privateEnrolAcknowledged)
604
+ throw bad();
605
+ owned = new Uint8Array(b32(challenge));
606
+ const signature = this.guard(() => this.takeOut(this.app.rt_app_private_device_enrol_sign(...this.put(owned))));
607
+ if (signature.length !== 64 || !this.privateCollectionCurrent())
608
+ throw bad();
609
+ return Object.freeze({ signature, sasCommitment: new Uint8Array(this.sasCommitment) });
610
+ }
611
+ catch {
612
+ this.retireLog();
613
+ throw bad();
614
+ }
615
+ finally {
616
+ owned?.fill(0);
617
+ }
618
+ }
619
+ /** Phase2 consumes SAME native owners with genuine collection trust metadata.
620
+ * NO seed re-export/loan/recreation/rebind; device-phase v1 is unchanged. */
621
+ adoptDevice(c, sql) {
622
+ let encoded = null;
623
+ try {
624
+ if (!this.deviceCurrent() || !this.deviceRegistered || this.attempted || this.active || c.deviceId !== this.deviceId)
625
+ throw bad();
626
+ if (this.privateSource && (!this.privateCollectionCurrent() || c.collection !== this.prospectiveCollection))
627
+ throw bad();
628
+ if (this.cloudSource && (!this.cloudCopyCollectionCurrent() || c.collection !== this.cloudCollection || c.state !== "cloud_copy" || c.cloudCopyOptIn !== true))
629
+ throw bad();
630
+ const pins = policyPins(c.policyPins);
631
+ if (sql) {
632
+ if (this.sql || sql.needsRecovery || !this.sqlBinding.exports)
633
+ throw bad();
634
+ this.sqlBinding.sql = sql;
635
+ this.sqlBinding.run = sql.import(this.sqlBinding.exports);
636
+ }
637
+ if (!this.sql || this.sql.needsRecovery)
638
+ throw bad();
639
+ this.attempted = true;
640
+ const endpoint = uint64(c.endpoint), state = c.state === "e2e" ? 0 : c.state === "cloud_copy" ? 1 : -1, opened = c.opened === "fresh" ? 0 : c.opened === "existing" ? 1 : c.opened === "unclean" ? 2 : -1;
641
+ if (state < 0 || opened < 0 || typeof c.cloudCopyOptIn !== "boolean" || (state === 1) !== c.cloudCopyOptIn || !Array.isArray(c.trustedRoots) || c.trustedRoots.length < 1 || c.trustedRoots.length > 64 || !Array.isArray(c.trustedSigners) || c.trustedSigners.length > 1024 || !Number.isSafeInteger(c.sqliteVersion) || c.sqliteVersion < 0 || c.sqliteVersion > 0xffff_ffff)
642
+ throw bad();
643
+ encoded = encodeSecret(new Map([[0, 4], [1, uuidToBytes(c.collection)], [2, uuidToBytes(c.replicaId)], [3, uuidToBytes(c.deviceId)], [4, endpoint], [5, c.trustedRoots.map(b32)], [6, c.trustedSigners.map(uuidToBytes)], [7, hashToBytes(c.expectedGenesis)], [8, state], [9, c.cloudCopyOptIn], [10, null], [11, null], [12, opened], [13, c.sqliteVersion], [14, uuidToBytes(this.connectorId)], [15, uuidToBytes(this.installationId)], [16, pins]]));
644
+ if (encoded.length > 64 * 1024)
645
+ throw bad();
646
+ const error = this.guard(() => this.takeOut(this.app.rt_app_device_adopt(...this.put(encoded))));
647
+ if (error.length || !this.deviceCurrent())
648
+ throw bad();
649
+ this.collection = c.collection;
650
+ this.endpoint = endpoint;
651
+ this.active = true;
652
+ this.markOpened();
653
+ }
654
+ catch {
655
+ this.retireLog();
656
+ this.fail();
657
+ throw bad();
658
+ }
659
+ finally {
660
+ encoded?.fill(0);
661
+ }
662
+ }
663
+ /** Separate fixed cp-enrol transcript over internally protected public keys.
664
+ * Borrowed nonce is independently copied; no key/identity/domain/digest inputs. */
665
+ signCpEnrol(challenge) {
666
+ let owned = null;
667
+ try {
668
+ if (!this.deviceCurrent() || !this.publicIdentity || this.active || this.pump) {
669
+ this.retireLog();
670
+ throw bad();
671
+ }
672
+ owned = new Uint8Array(b32(challenge));
673
+ const out = this.guard(() => this.takeOut(this.app.rt_app_cp_enrol_sign(...this.put(owned))));
674
+ if (!this.deviceCurrent()) {
675
+ this.retireLog();
676
+ throw bad();
677
+ }
678
+ if (!out.length)
679
+ throw bad();
680
+ const { m, identity } = this.guard(() => this.publicResult(out));
681
+ const signature = m.get(3);
682
+ if (!(signature instanceof Uint8Array) || signature.length !== 64 || ["signPublicKey", "kemPublicKey", "noisePublicKey"].some(k => identity[k].some((b, i) => b !== this.publicIdentity[k][i])))
683
+ throw bad();
684
+ return Object.freeze({ ...identity, signature: new Uint8Array(signature) });
685
+ }
686
+ catch {
687
+ this.retireLog();
688
+ throw bad();
689
+ }
690
+ finally {
691
+ owned?.fill(0);
692
+ }
693
+ }
694
+ /** Fixed CP purpose; no method/route/domain/digest or identity override. */
695
+ signCpLogToken(challenge) {
696
+ let owned = null;
697
+ try {
698
+ if (!this.active || this.retired || !this.cpPin)
699
+ throw bad();
700
+ const pin = this.cpPin;
701
+ let current = false;
702
+ try {
703
+ current = pin.isCurrent() === true && pin.connectorId === this.connectorId && pin.deviceId === this.deviceId && pin.collection === this.collection;
704
+ }
705
+ catch { /* unavailable identity is not authorization */ }
706
+ if (!current) {
707
+ this.retireLog();
708
+ throw bad();
709
+ }
710
+ owned = new Uint8Array(b32(challenge));
711
+ const sig = this.guard(() => this.takeOut(this.app.rt_app_cp_log_token_sign(...this.put(owned))));
712
+ if (sig.length !== 64) {
713
+ sig.fill(0);
714
+ throw bad();
715
+ }
716
+ return sig;
717
+ }
718
+ catch {
719
+ throw bad();
720
+ }
721
+ finally {
722
+ owned?.fill(0);
723
+ }
724
+ }
725
+ /** Host supplies a genuinely authenticated immutable transport, not a true flag. */
726
+ bindLogTransport(transport) {
727
+ try {
728
+ if (!this.active || this.retired || this.pump || this.endpoint === null || this.collection === null || transport.isCurrent() !== true || uint64(transport.endpoint) !== this.endpoint || transport.collection !== this.collection)
729
+ throw bad();
730
+ }
731
+ catch {
732
+ throw bad();
733
+ }
734
+ const bytes = uuidToBytes(this.collection);
735
+ if (this.guard(() => this.app.rt_app_log_bind(this.endpoint, ...this.put(bytes))) !== 1)
736
+ throw bad();
737
+ this.logGeneration = this.guard(() => uint64(this.app.rt_app_log_generation()));
738
+ if (this.logGeneration === 0n) {
739
+ this.retireLog();
740
+ throw bad();
741
+ }
742
+ this.pump = new AppLogPump(this, transport, { endpoint: this.endpoint, collection: this.collection });
743
+ this.transport = transport;
744
+ return this.pump;
745
+ }
746
+ /** HOST ONLY quiet foreground wake: asks the native replica to fetch the log
747
+ * head over the CURRENT authenticated session so remote entries are learned.
748
+ * No token, reconnect, status or readiness change; false when unsupported,
749
+ * not bound, already in flight, or unhealthy. Never retires the log; a trap
750
+ * fails the runtime exactly like tick(). */
751
+ requestLogHead() {
752
+ if (!this.active || this.retired || this.pump === null || typeof this.app.rt_app_log_head !== "function")
753
+ return false;
754
+ return this.guard(() => this.app.rt_app_log_head()) === 1;
755
+ }
756
+ /** True when this runtime can sign the push socket's `hello`. */
757
+ get supportsLogPush() { return typeof this.app.rt_app_log_hello_sign === "function"; }
758
+ /** Fixed ls-hello proof for the push socket of the CURRENT log generation
759
+ * (`nonce32 ‖ token`). Null when unsupported or refused; never a generic signer. */
760
+ signLogHello(nonce, token) {
761
+ let owned = null;
762
+ try {
763
+ if (!this.supportsLogPush || !this.active || this.retired || !this.pump || !this.transport || this.logGeneration === 0n || !this.transport.isCurrent())
764
+ return null;
765
+ if (!(nonce instanceof Uint8Array) || nonce.length !== 32 || typeof token !== "string" || token.length === 0 || token.length > 16 * 1024 || /[^\x21-\x7e]/.test(token))
766
+ return null;
767
+ const t = new TextEncoder().encode(token);
768
+ owned = new Uint8Array(32 + t.length);
769
+ owned.set(nonce, 0);
770
+ owned.set(t, 32);
771
+ t.fill(0);
772
+ const generation = this.logGeneration;
773
+ const signature = this.guard(() => this.takeOut(this.app.rt_app_log_hello_sign(generation, ...this.put(owned))));
774
+ if (signature.length !== 64) {
775
+ signature.fill(0);
776
+ return null;
777
+ }
778
+ return signature;
779
+ }
780
+ catch {
781
+ return null;
782
+ }
783
+ finally {
784
+ owned?.fill(0);
785
+ }
786
+ }
787
+ /** HOST ONLY wake AFTER fresh authenticated authority admission: drain/abort
788
+ * original pump before SAME-owner native session/generation replacement. May
789
+ * hang: owner must terminate Worker before releasing lease. Not readiness. */
790
+ async reconnectLogTransport(transport) {
791
+ const original = this.pump, generation = this.logGeneration, check = () => this.active && !this.retired && this.pump === original && original !== null && this.transport === transport && transport.isCurrent() === true && uint64(transport.endpoint) === this.endpoint && transport.collection === this.collection;
792
+ try {
793
+ if (!check())
794
+ throw bad();
795
+ await original.drainForAuthenticatedReconnect();
796
+ if (!check())
797
+ throw bad();
798
+ this.pump = null;
799
+ this.transport = null;
800
+ const bytes = uuidToBytes(this.collection);
801
+ try {
802
+ if (this.guard(() => this.app.rt_app_log_reconnect(this.endpoint, ...this.put(bytes))) !== 1)
803
+ throw bad();
804
+ }
805
+ finally {
806
+ bytes.fill(0);
807
+ }
808
+ this.logGeneration = this.guard(() => uint64(this.app.rt_app_log_generation()));
809
+ if (this.logGeneration <= generation || !transport.isCurrent() || this.retired || !this.active)
810
+ throw bad();
811
+ this.pump = new AppLogPump(this, transport, { endpoint: this.endpoint, collection: this.collection });
812
+ this.transport = transport;
813
+ return this.pump;
814
+ }
815
+ catch {
816
+ this.retireLog();
817
+ throw bad();
818
+ }
819
+ }
820
+ /** Protected fixed-domain authority callback. Rust checks the original exact
821
+ * frame or its associated same-address commit; JS digest is NOT signing input. */
822
+ signLogHttp(proof) {
823
+ let encoded = null;
824
+ try {
825
+ if (!this.active || !this.pump || !this.transport || this.logGeneration === 0n || this.endpoint === null || proof.path !== "/v1/rpc" || proof.collection !== this.collection || uint64(proof.endpoint) !== this.endpoint || !this.transport.isCurrent())
826
+ throw bad();
827
+ if (!(proof.frame instanceof Uint8Array) || proof.frame.length === 0 || proof.frame.length > 16 * 1024 * 1024 || !(proof.nonce instanceof Uint8Array) || proof.nonce.length !== 32 || typeof proof.token !== "string" || proof.token.length === 0 || proof.token.length > 16 * 1024 || /[^\x21-\x7e]/.test(proof.token))
828
+ throw bad();
829
+ encoded = encodeSecret(new Map([[0, proof.frame], [1, proof.token], [2, proof.nonce]]));
830
+ const signature = this.guard(() => this.takeOut(this.app.rt_app_log_http_sign(this.endpoint, this.logGeneration, uint64(proof.originalCallId), ...this.put(encoded))));
831
+ if (signature.length !== 64) {
832
+ signature.fill(0);
833
+ throw bad();
834
+ }
835
+ return signature;
836
+ }
837
+ catch {
838
+ throw bad();
839
+ }
840
+ finally {
841
+ encoded?.fill(0);
842
+ }
843
+ }
844
+ takeLogCalls() {
845
+ if (!this.active || this.retired)
846
+ return [];
847
+ return this.guard(() => {
848
+ const bytes = this.takeOut(this.app.rt_app_log_calls());
849
+ if (!bytes.length)
850
+ return [];
851
+ const records = decode(bytes);
852
+ if (!Array.isArray(records) || records.length > 64)
853
+ throw bad();
854
+ return records.map(record => {
855
+ if (!(record instanceof Map))
856
+ throw bad();
857
+ const fields = record;
858
+ const endpoint = fields.get(0), frame = fields.get(1), sidecar = fields.get(2);
859
+ if (uint64(endpoint) !== this.endpoint || !(frame instanceof Uint8Array) || (sidecar !== undefined && !(sidecar instanceof Uint8Array)))
860
+ throw bad();
861
+ return { endpoint: endpoint, frame, ...(sidecar !== undefined ? { sidecar } : {}) };
862
+ });
863
+ });
864
+ }
865
+ acceptLogReply(id, bytes) {
866
+ if (!this.active || this.retired)
867
+ return false;
868
+ return this.guard(() => this.app.rt_app_log_reply(uint64(id), ...this.put(bytes)) === 1);
869
+ }
870
+ logNoResponse(id) { if (this.active && !this.retired)
871
+ this.guard(() => this.app.rt_app_log_no_response(uint64(id))); }
872
+ retireLog() {
873
+ this.logGeneration = 0n;
874
+ if (this.retired)
875
+ return;
876
+ this.retired = true;
877
+ this.cpPin = null;
878
+ this.connectorId = null;
879
+ this.devicePin = null;
880
+ this.installationId = null;
881
+ this.privateSource = null;
882
+ this.prospectiveCollection = null;
883
+ this.privatePurpose = null;
884
+ this.sasCommitment?.fill(0);
885
+ this.sasCommitment = null;
886
+ this.publicIdentity = null;
887
+ this.noiseEnvelope?.fill(0);
888
+ this.noiseEnvelope = null;
889
+ this.deviceActive = false;
890
+ this.deviceRegistered = false;
891
+ if (this.active)
892
+ this.guard(() => { super.dispose(); this.app.rt_app_log_retire(); });
893
+ else if (this.deviceAttempted)
894
+ this.guard(() => this.app.rt_app_device_retire());
895
+ }
896
+ /** Current authenticated service push only; transport fences its generation. */
897
+ pushLog(bytes) {
898
+ if (!this.active || this.retired || !this.pump || !this.transport)
899
+ return false;
900
+ return this.guard(() => {
901
+ const t = this.transport;
902
+ if (t.isCurrent() !== true || uint64(t.endpoint) !== this.endpoint || t.collection !== this.collection) {
903
+ this.retireLog();
904
+ return false;
905
+ }
906
+ return this.app.rt_app_log_push(...this.put(bytes)) === 1;
907
+ });
908
+ }
909
+ accountKeyCurrent(pin) {
910
+ try {
911
+ return this.active && !this.retired && pin.isCurrent() === true && pin.approvalMode === "password-ak1" && pin.collection === this.collection && pin.deviceId === this.deviceId && pin.connectorId === this.connectorId && pin.installationId === this.installationId && this.devicePin !== null && this.devicePin.isCurrent() === true && this.devicePin.connectorId === this.connectorId && this.devicePin.deviceId === this.deviceId && this.devicePin.installationId === this.installationId;
912
+ }
913
+ catch {
914
+ return false;
915
+ }
916
+ }
917
+ accountKeyState(bytes) {
918
+ const value = decode(bytes);
919
+ if (!(value instanceof Map))
920
+ throw bad();
921
+ const m = value;
922
+ if (m.size !== 2 || !m.has(0) || !m.has(1))
923
+ throw bad();
924
+ const state = m.get(0), reason = m.get(1);
925
+ if (state === 0 || state === 1) {
926
+ if (reason !== null)
927
+ throw bad();
928
+ return Object.freeze({ state: state === 0 ? "pending" : "keyed" });
929
+ }
930
+ const reasons = ["not_private", "not_ready", "not_enrolled", "not_authorized", "device_missing", "enrolment_mismatch", "not_keyed", "no_wrap", "inconsistent", "failed", "outcome_unknown"];
931
+ if (state !== 2 || typeof reason !== "string" || !reasons.includes(reason))
932
+ throw bad();
933
+ return Object.freeze({ state: "refused", reason: reason });
934
+ }
935
+ /** Protected transient R32 loan, consumed/wiped even when refused/trapped.
936
+ * Native derives only this collection; pending/queued is NOT keyed. */
937
+ unlockAccountKeyConsuming(pin, secret) {
938
+ try {
939
+ if (pin.approvalMode === "strict")
940
+ throw new AppStrictDeviceApprovalError();
941
+ if (!this.accountKeyCurrent(pin))
942
+ throw bad();
943
+ b32(secret);
944
+ const state = this.guard(() => this.accountKeyState(this.takeOut(this.app.rt_app_account_key_unlock(...this.put(secret)))));
945
+ if (!this.accountKeyCurrent(pin))
946
+ throw bad();
947
+ return state;
948
+ }
949
+ catch (error) {
950
+ this.retireLog();
951
+ if (error instanceof AppStrictDeviceApprovalError)
952
+ throw error;
953
+ throw bad();
954
+ }
955
+ finally {
956
+ if (secret instanceof Uint8Array)
957
+ secret.fill(0);
958
+ }
959
+ }
960
+ /** Protected R32 setup loan, consumed even when refused/trapped. Only an
961
+ * existing CP-enrolled EXACT recovery device; queued != recovery_keyed, and
962
+ * recovery_keyed != this app keyed/Saved. Ordinary native KEY_GRANT only. */
963
+ setupAccountKeyDeviceConsuming(pin, secret) {
964
+ try {
965
+ if (pin.approvalMode === "strict")
966
+ throw new AppStrictDeviceApprovalError();
967
+ if (!this.accountKeyCurrent(pin))
968
+ throw bad();
969
+ b32(secret);
970
+ const state = this.guard(() => this.accountKeyState(this.takeOut(this.app.rt_app_account_key_device_setup(...this.put(secret)))));
971
+ if (!this.accountKeyCurrent(pin))
972
+ throw bad();
973
+ return state.state === "refused" ? state : Object.freeze({ state: state.state === "keyed" ? "recovery_keyed" : "recovery_pending" });
974
+ }
975
+ catch (error) {
976
+ this.retireLog();
977
+ if (error instanceof AppStrictDeviceApprovalError)
978
+ throw error;
979
+ throw bad();
980
+ }
981
+ finally {
982
+ if (secret instanceof Uint8Array)
983
+ secret.fill(0);
984
+ }
985
+ }
986
+ /** Actual native applied-policy/trust status; not zero-pending/readback/Saved. */
987
+ accountKeyStatus(pin) {
988
+ try {
989
+ if (!this.accountKeyCurrent(pin))
990
+ throw bad();
991
+ const state = this.guard(() => this.accountKeyState(this.takeOut(this.app.rt_app_account_key_status())));
992
+ if (!this.accountKeyCurrent(pin))
993
+ throw bad();
994
+ return state;
995
+ }
996
+ catch {
997
+ this.retireLog();
998
+ throw bad();
999
+ }
1000
+ }
1001
+ observations() {
1002
+ if (!this.active || this.retired)
1003
+ throw bad();
1004
+ return this.guard(() => {
1005
+ const value = decode(this.takeOut(this.app.rt_app_observations()));
1006
+ if (!(value instanceof Map))
1007
+ throw bad();
1008
+ const m = value;
1009
+ for (const k of [1, 2, 3, 4])
1010
+ if (typeof m.get(k) !== "boolean")
1011
+ throw bad();
1012
+ return { status: syncStatus.dec(m.get(0)), keyringRebuilding: m.get(1), keyringRebuildFailed: m.get(2), snapshotInstallAvailable: m.get(3), requiresReopen: m.get(4) };
1013
+ });
1014
+ }
1015
+ /** Drain/abort current generation BEFORE key/runtime/SQL shutdown. May hang;
1016
+ * owner must terminate the Worker before releasing its lease in that case. */
1017
+ async close() {
1018
+ if (this.pump) {
1019
+ await this.pump.close();
1020
+ this.pump = null;
1021
+ this.transport = null;
1022
+ }
1023
+ return this.shutdown();
1024
+ }
1025
+ /** Synchronous clean shutdown only with no undrained pump. Not a saved claim. */
1026
+ shutdown() {
1027
+ if (!this.active) {
1028
+ if (this.deviceAttempted && !this.retired)
1029
+ this.retireLog();
1030
+ this.discard();
1031
+ return false;
1032
+ }
1033
+ if (this.pump) {
1034
+ void this.pump.close().catch(() => { });
1035
+ this.fail();
1036
+ return false;
1037
+ }
1038
+ try {
1039
+ this.retireLog();
1040
+ super.dispose();
1041
+ return this.guard(() => this.app.rt_app_shutdown() === 1) && this.sql !== null && !this.sql.needsRecovery;
1042
+ }
1043
+ finally {
1044
+ this.active = false;
1045
+ this.discard();
1046
+ }
1047
+ }
1048
+ dispose() { this.shutdown(); }
1049
+ }
1050
+ //# sourceMappingURL=wasm-runtime.js.map