@weaveprotocol/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (430) hide show
  1. package/README.md +1106 -0
  2. package/dist/elements/auth-styles.d.ts +18 -0
  3. package/dist/elements/auth-styles.d.ts.map +1 -0
  4. package/dist/elements/auth-styles.js +150 -0
  5. package/dist/elements/auth-styles.js.map +1 -0
  6. package/dist/elements/dom.d.ts +28 -0
  7. package/dist/elements/dom.d.ts.map +1 -0
  8. package/dist/elements/dom.js +74 -0
  9. package/dist/elements/dom.js.map +1 -0
  10. package/dist/elements/index.d.ts +13 -0
  11. package/dist/elements/index.d.ts.map +1 -0
  12. package/dist/elements/index.js +11 -0
  13. package/dist/elements/index.js.map +1 -0
  14. package/dist/elements/weave-auth.d.ts +52 -0
  15. package/dist/elements/weave-auth.d.ts.map +1 -0
  16. package/dist/elements/weave-auth.js +427 -0
  17. package/dist/elements/weave-auth.js.map +1 -0
  18. package/dist/identity/account-store.d.ts +113 -0
  19. package/dist/identity/account-store.d.ts.map +1 -0
  20. package/dist/identity/account-store.js +305 -0
  21. package/dist/identity/account-store.js.map +1 -0
  22. package/dist/identity/account-vault.d.ts +199 -0
  23. package/dist/identity/account-vault.d.ts.map +1 -0
  24. package/dist/identity/account-vault.js +251 -0
  25. package/dist/identity/account-vault.js.map +1 -0
  26. package/dist/identity/agent-note.d.ts +19 -0
  27. package/dist/identity/agent-note.d.ts.map +1 -0
  28. package/dist/identity/agent-note.js +29 -0
  29. package/dist/identity/agent-note.js.map +1 -0
  30. package/dist/identity/crypto-p256.d.ts +7 -0
  31. package/dist/identity/crypto-p256.d.ts.map +1 -0
  32. package/dist/identity/crypto-p256.js +84 -0
  33. package/dist/identity/crypto-p256.js.map +1 -0
  34. package/dist/identity/device-key.d.ts +60 -0
  35. package/dist/identity/device-key.d.ts.map +1 -0
  36. package/dist/identity/device-key.js +103 -0
  37. package/dist/identity/device-key.js.map +1 -0
  38. package/dist/identity/did.d.ts +22 -0
  39. package/dist/identity/did.d.ts.map +1 -0
  40. package/dist/identity/did.js +37 -0
  41. package/dist/identity/did.js.map +1 -0
  42. package/dist/identity/folder-account.d.ts +65 -0
  43. package/dist/identity/folder-account.d.ts.map +1 -0
  44. package/dist/identity/folder-account.js +115 -0
  45. package/dist/identity/folder-account.js.map +1 -0
  46. package/dist/identity/identity-manager.d.ts +36 -0
  47. package/dist/identity/identity-manager.d.ts.map +1 -0
  48. package/dist/identity/identity-manager.js +115 -0
  49. package/dist/identity/identity-manager.js.map +1 -0
  50. package/dist/identity/index.d.ts +10 -0
  51. package/dist/identity/index.d.ts.map +1 -0
  52. package/dist/identity/index.js +10 -0
  53. package/dist/identity/index.js.map +1 -0
  54. package/dist/identity/keys.d.ts +24 -0
  55. package/dist/identity/keys.d.ts.map +1 -0
  56. package/dist/identity/keys.js +38 -0
  57. package/dist/identity/keys.js.map +1 -0
  58. package/dist/identity/pairing.d.ts +83 -0
  59. package/dist/identity/pairing.d.ts.map +1 -0
  60. package/dist/identity/pairing.js +120 -0
  61. package/dist/identity/pairing.js.map +1 -0
  62. package/dist/identity/passkey-diagnostics.d.ts +54 -0
  63. package/dist/identity/passkey-diagnostics.d.ts.map +1 -0
  64. package/dist/identity/passkey-diagnostics.js +178 -0
  65. package/dist/identity/passkey-diagnostics.js.map +1 -0
  66. package/dist/identity/recovery-code.d.ts +50 -0
  67. package/dist/identity/recovery-code.d.ts.map +1 -0
  68. package/dist/identity/recovery-code.js +116 -0
  69. package/dist/identity/recovery-code.js.map +1 -0
  70. package/dist/identity/root-signer.d.ts +59 -0
  71. package/dist/identity/root-signer.d.ts.map +1 -0
  72. package/dist/identity/root-signer.js +44 -0
  73. package/dist/identity/root-signer.js.map +1 -0
  74. package/dist/identity/ucan.d.ts +164 -0
  75. package/dist/identity/ucan.d.ts.map +1 -0
  76. package/dist/identity/ucan.js +273 -0
  77. package/dist/identity/ucan.js.map +1 -0
  78. package/dist/identity/webauthn.d.ts +87 -0
  79. package/dist/identity/webauthn.d.ts.map +1 -0
  80. package/dist/identity/webauthn.js +155 -0
  81. package/dist/identity/webauthn.js.map +1 -0
  82. package/dist/index.d.ts +116 -0
  83. package/dist/index.d.ts.map +1 -0
  84. package/dist/index.js +85 -0
  85. package/dist/index.js.map +1 -0
  86. package/dist/network/index.d.ts +17 -0
  87. package/dist/network/index.d.ts.map +1 -0
  88. package/dist/network/index.js +10 -0
  89. package/dist/network/index.js.map +1 -0
  90. package/dist/network/introductions.d.ts +85 -0
  91. package/dist/network/introductions.d.ts.map +1 -0
  92. package/dist/network/introductions.js +94 -0
  93. package/dist/network/introductions.js.map +1 -0
  94. package/dist/network/local-transport.d.ts +22 -0
  95. package/dist/network/local-transport.d.ts.map +1 -0
  96. package/dist/network/local-transport.js +55 -0
  97. package/dist/network/local-transport.js.map +1 -0
  98. package/dist/network/mesh.d.ts +31 -0
  99. package/dist/network/mesh.d.ts.map +1 -0
  100. package/dist/network/mesh.js +332 -0
  101. package/dist/network/mesh.js.map +1 -0
  102. package/dist/network/multi-signaling.d.ts +29 -0
  103. package/dist/network/multi-signaling.d.ts.map +1 -0
  104. package/dist/network/multi-signaling.js +125 -0
  105. package/dist/network/multi-signaling.js.map +1 -0
  106. package/dist/network/network-manager.d.ts +37 -0
  107. package/dist/network/network-manager.d.ts.map +1 -0
  108. package/dist/network/network-manager.js +64 -0
  109. package/dist/network/network-manager.js.map +1 -0
  110. package/dist/network/peer-auth.d.ts +98 -0
  111. package/dist/network/peer-auth.d.ts.map +1 -0
  112. package/dist/network/peer-auth.js +86 -0
  113. package/dist/network/peer-auth.js.map +1 -0
  114. package/dist/network/rtc-transport.d.ts +18 -0
  115. package/dist/network/rtc-transport.d.ts.map +1 -0
  116. package/dist/network/rtc-transport.js +149 -0
  117. package/dist/network/rtc-transport.js.map +1 -0
  118. package/dist/network/signaling.d.ts +40 -0
  119. package/dist/network/signaling.d.ts.map +1 -0
  120. package/dist/network/signaling.js +124 -0
  121. package/dist/network/signaling.js.map +1 -0
  122. package/dist/network/transport.d.ts +50 -0
  123. package/dist/network/transport.d.ts.map +1 -0
  124. package/dist/network/transport.js +13 -0
  125. package/dist/network/transport.js.map +1 -0
  126. package/dist/network/ws-transport.d.ts +42 -0
  127. package/dist/network/ws-transport.d.ts.map +1 -0
  128. package/dist/network/ws-transport.js +194 -0
  129. package/dist/network/ws-transport.js.map +1 -0
  130. package/dist/node/actions.d.ts +62 -0
  131. package/dist/node/actions.d.ts.map +1 -0
  132. package/dist/node/actions.js +500 -0
  133. package/dist/node/actions.js.map +1 -0
  134. package/dist/node/carrier.d.ts +85 -0
  135. package/dist/node/carrier.d.ts.map +1 -0
  136. package/dist/node/carrier.js +192 -0
  137. package/dist/node/carrier.js.map +1 -0
  138. package/dist/node/copy.d.ts +38 -0
  139. package/dist/node/copy.d.ts.map +1 -0
  140. package/dist/node/copy.js +53 -0
  141. package/dist/node/copy.js.map +1 -0
  142. package/dist/node/index.d.ts +16 -0
  143. package/dist/node/index.d.ts.map +1 -0
  144. package/dist/node/index.js +11 -0
  145. package/dist/node/index.js.map +1 -0
  146. package/dist/node/node.d.ts +12 -0
  147. package/dist/node/node.d.ts.map +1 -0
  148. package/dist/node/node.js +872 -0
  149. package/dist/node/node.js.map +1 -0
  150. package/dist/node/space-runtime.d.ts +144 -0
  151. package/dist/node/space-runtime.d.ts.map +1 -0
  152. package/dist/node/space-runtime.js +1221 -0
  153. package/dist/node/space-runtime.js.map +1 -0
  154. package/dist/node/stores.d.ts +45 -0
  155. package/dist/node/stores.d.ts.map +1 -0
  156. package/dist/node/stores.js +31 -0
  157. package/dist/node/stores.js.map +1 -0
  158. package/dist/node/types.d.ts +508 -0
  159. package/dist/node/types.d.ts.map +1 -0
  160. package/dist/node/types.js +2 -0
  161. package/dist/node/types.js.map +1 -0
  162. package/dist/privacy/index.d.ts +4 -0
  163. package/dist/privacy/index.d.ts.map +1 -0
  164. package/dist/privacy/index.js +4 -0
  165. package/dist/privacy/index.js.map +1 -0
  166. package/dist/privacy/key-distribution.d.ts +42 -0
  167. package/dist/privacy/key-distribution.d.ts.map +1 -0
  168. package/dist/privacy/key-distribution.js +50 -0
  169. package/dist/privacy/key-distribution.js.map +1 -0
  170. package/dist/privacy/privacy-guard.d.ts +24 -0
  171. package/dist/privacy/privacy-guard.d.ts.map +1 -0
  172. package/dist/privacy/privacy-guard.js +87 -0
  173. package/dist/privacy/privacy-guard.js.map +1 -0
  174. package/dist/privacy/space-encryption.d.ts +48 -0
  175. package/dist/privacy/space-encryption.d.ts.map +1 -0
  176. package/dist/privacy/space-encryption.js +61 -0
  177. package/dist/privacy/space-encryption.js.map +1 -0
  178. package/dist/query/engine.d.ts +27 -0
  179. package/dist/query/engine.d.ts.map +1 -0
  180. package/dist/query/engine.js +84 -0
  181. package/dist/query/engine.js.map +1 -0
  182. package/dist/query/filter.d.ts +15 -0
  183. package/dist/query/filter.d.ts.map +1 -0
  184. package/dist/query/filter.js +207 -0
  185. package/dist/query/filter.js.map +1 -0
  186. package/dist/query/types.d.ts +144 -0
  187. package/dist/query/types.d.ts.map +1 -0
  188. package/dist/query/types.js +22 -0
  189. package/dist/query/types.js.map +1 -0
  190. package/dist/react/context.d.ts +81 -0
  191. package/dist/react/context.d.ts.map +1 -0
  192. package/dist/react/context.js +95 -0
  193. package/dist/react/context.js.map +1 -0
  194. package/dist/react/index.d.ts +40 -0
  195. package/dist/react/index.d.ts.map +1 -0
  196. package/dist/react/index.js +36 -0
  197. package/dist/react/index.js.map +1 -0
  198. package/dist/react/use-live.d.ts +16 -0
  199. package/dist/react/use-live.d.ts.map +1 -0
  200. package/dist/react/use-live.js +55 -0
  201. package/dist/react/use-live.js.map +1 -0
  202. package/dist/react/use-query.d.ts +17 -0
  203. package/dist/react/use-query.d.ts.map +1 -0
  204. package/dist/react/use-query.js +23 -0
  205. package/dist/react/use-query.js.map +1 -0
  206. package/dist/react/use-space.d.ts +29 -0
  207. package/dist/react/use-space.d.ts.map +1 -0
  208. package/dist/react/use-space.js +48 -0
  209. package/dist/react/use-space.js.map +1 -0
  210. package/dist/react/use-spaces.d.ts +19 -0
  211. package/dist/react/use-spaces.d.ts.map +1 -0
  212. package/dist/react/use-spaces.js +55 -0
  213. package/dist/react/use-spaces.js.map +1 -0
  214. package/dist/react/use-weave-auth.d.ts +10 -0
  215. package/dist/react/use-weave-auth.d.ts.map +1 -0
  216. package/dist/react/use-weave-auth.js +15 -0
  217. package/dist/react/use-weave-auth.js.map +1 -0
  218. package/dist/react/weave-auth.d.ts +17 -0
  219. package/dist/react/weave-auth.d.ts.map +1 -0
  220. package/dist/react/weave-auth.js +38 -0
  221. package/dist/react/weave-auth.js.map +1 -0
  222. package/dist/records/describe.d.ts +38 -0
  223. package/dist/records/describe.d.ts.map +1 -0
  224. package/dist/records/describe.js +101 -0
  225. package/dist/records/describe.js.map +1 -0
  226. package/dist/records/links.d.ts +14 -0
  227. package/dist/records/links.d.ts.map +1 -0
  228. package/dist/records/links.js +25 -0
  229. package/dist/records/links.js.map +1 -0
  230. package/dist/records/rules.d.ts +59 -0
  231. package/dist/records/rules.d.ts.map +1 -0
  232. package/dist/records/rules.js +118 -0
  233. package/dist/records/rules.js.map +1 -0
  234. package/dist/records/version.d.ts +54 -0
  235. package/dist/records/version.d.ts.map +1 -0
  236. package/dist/records/version.js +70 -0
  237. package/dist/records/version.js.map +1 -0
  238. package/dist/schema/collection-def.d.ts +96 -0
  239. package/dist/schema/collection-def.d.ts.map +1 -0
  240. package/dist/schema/collection-def.js +272 -0
  241. package/dist/schema/collection-def.js.map +1 -0
  242. package/dist/schema/expression.d.ts +69 -0
  243. package/dist/schema/expression.d.ts.map +1 -0
  244. package/dist/schema/expression.js +92 -0
  245. package/dist/schema/expression.js.map +1 -0
  246. package/dist/schema/index.d.ts +4 -0
  247. package/dist/schema/index.d.ts.map +1 -0
  248. package/dist/schema/index.js +4 -0
  249. package/dist/schema/index.js.map +1 -0
  250. package/dist/schema/schema-engine.d.ts +42 -0
  251. package/dist/schema/schema-engine.d.ts.map +1 -0
  252. package/dist/schema/schema-engine.js +36 -0
  253. package/dist/schema/schema-engine.js.map +1 -0
  254. package/dist/schema/signer.d.ts +27 -0
  255. package/dist/schema/signer.d.ts.map +1 -0
  256. package/dist/schema/signer.js +36 -0
  257. package/dist/schema/signer.js.map +1 -0
  258. package/dist/schemas/apps.d.ts +88 -0
  259. package/dist/schemas/apps.d.ts.map +1 -0
  260. package/dist/schemas/apps.js +168 -0
  261. package/dist/schemas/apps.js.map +1 -0
  262. package/dist/schemas/index.d.ts +410 -0
  263. package/dist/schemas/index.d.ts.map +1 -0
  264. package/dist/schemas/index.js +208 -0
  265. package/dist/schemas/index.js.map +1 -0
  266. package/dist/schemas/screens.d.ts +67 -0
  267. package/dist/schemas/screens.d.ts.map +1 -0
  268. package/dist/schemas/screens.js +242 -0
  269. package/dist/schemas/screens.js.map +1 -0
  270. package/dist/session/agent-link.d.ts +79 -0
  271. package/dist/session/agent-link.d.ts.map +1 -0
  272. package/dist/session/agent-link.js +251 -0
  273. package/dist/session/agent-link.js.map +1 -0
  274. package/dist/session/auth.d.ts +233 -0
  275. package/dist/session/auth.d.ts.map +1 -0
  276. package/dist/session/auth.js +783 -0
  277. package/dist/session/auth.js.map +1 -0
  278. package/dist/session/connect.d.ts +211 -0
  279. package/dist/session/connect.d.ts.map +1 -0
  280. package/dist/session/connect.js +355 -0
  281. package/dist/session/connect.js.map +1 -0
  282. package/dist/session/connection.d.ts +70 -0
  283. package/dist/session/connection.d.ts.map +1 -0
  284. package/dist/session/connection.js +120 -0
  285. package/dist/session/connection.js.map +1 -0
  286. package/dist/session/credentials.d.ts +44 -0
  287. package/dist/session/credentials.d.ts.map +1 -0
  288. package/dist/session/credentials.js +60 -0
  289. package/dist/session/credentials.js.map +1 -0
  290. package/dist/session/index.d.ts +25 -0
  291. package/dist/session/index.d.ts.map +1 -0
  292. package/dist/session/index.js +18 -0
  293. package/dist/session/index.js.map +1 -0
  294. package/dist/session/pairing.d.ts +59 -0
  295. package/dist/session/pairing.d.ts.map +1 -0
  296. package/dist/session/pairing.js +144 -0
  297. package/dist/session/pairing.js.map +1 -0
  298. package/dist/session/places.d.ts +62 -0
  299. package/dist/session/places.d.ts.map +1 -0
  300. package/dist/session/places.js +101 -0
  301. package/dist/session/places.js.map +1 -0
  302. package/dist/session/stay-signed-in.d.ts +37 -0
  303. package/dist/session/stay-signed-in.d.ts.map +1 -0
  304. package/dist/session/stay-signed-in.js +124 -0
  305. package/dist/session/stay-signed-in.js.map +1 -0
  306. package/dist/space/account-registry.d.ts +64 -0
  307. package/dist/space/account-registry.d.ts.map +1 -0
  308. package/dist/space/account-registry.js +66 -0
  309. package/dist/space/account-registry.js.map +1 -0
  310. package/dist/space/index.d.ts +3 -0
  311. package/dist/space/index.d.ts.map +1 -0
  312. package/dist/space/index.js +3 -0
  313. package/dist/space/index.js.map +1 -0
  314. package/dist/space/pass.d.ts +63 -0
  315. package/dist/space/pass.d.ts.map +1 -0
  316. package/dist/space/pass.js +54 -0
  317. package/dist/space/pass.js.map +1 -0
  318. package/dist/space/presets.d.ts +31 -0
  319. package/dist/space/presets.d.ts.map +1 -0
  320. package/dist/space/presets.js +24 -0
  321. package/dist/space/presets.js.map +1 -0
  322. package/dist/space/roles.d.ts +186 -0
  323. package/dist/space/roles.d.ts.map +1 -0
  324. package/dist/space/roles.js +500 -0
  325. package/dist/space/roles.js.map +1 -0
  326. package/dist/space/space-access.d.ts +80 -0
  327. package/dist/space/space-access.d.ts.map +1 -0
  328. package/dist/space/space-access.js +135 -0
  329. package/dist/space/space-access.js.map +1 -0
  330. package/dist/space/space-manager.d.ts +87 -0
  331. package/dist/space/space-manager.d.ts.map +1 -0
  332. package/dist/space/space-manager.js +187 -0
  333. package/dist/space/space-manager.js.map +1 -0
  334. package/dist/storage/directory-access.d.ts +78 -0
  335. package/dist/storage/directory-access.d.ts.map +1 -0
  336. package/dist/storage/directory-access.js +164 -0
  337. package/dist/storage/directory-access.js.map +1 -0
  338. package/dist/storage/encrypted-adapter.d.ts +49 -0
  339. package/dist/storage/encrypted-adapter.d.ts.map +1 -0
  340. package/dist/storage/encrypted-adapter.js +106 -0
  341. package/dist/storage/encrypted-adapter.js.map +1 -0
  342. package/dist/storage/folder-adapter.d.ts +105 -0
  343. package/dist/storage/folder-adapter.d.ts.map +1 -0
  344. package/dist/storage/folder-adapter.js +280 -0
  345. package/dist/storage/folder-adapter.js.map +1 -0
  346. package/dist/storage/folder-reconcile.d.ts +53 -0
  347. package/dist/storage/folder-reconcile.d.ts.map +1 -0
  348. package/dist/storage/folder-reconcile.js +65 -0
  349. package/dist/storage/folder-reconcile.js.map +1 -0
  350. package/dist/storage/index.d.ts +10 -0
  351. package/dist/storage/index.d.ts.map +1 -0
  352. package/dist/storage/index.js +9 -0
  353. package/dist/storage/index.js.map +1 -0
  354. package/dist/storage/indexeddb-adapter.d.ts +12 -0
  355. package/dist/storage/indexeddb-adapter.d.ts.map +1 -0
  356. package/dist/storage/indexeddb-adapter.js +190 -0
  357. package/dist/storage/indexeddb-adapter.js.map +1 -0
  358. package/dist/storage/mst.d.ts +121 -0
  359. package/dist/storage/mst.d.ts.map +1 -0
  360. package/dist/storage/mst.js +402 -0
  361. package/dist/storage/mst.js.map +1 -0
  362. package/dist/storage/storage-provider.d.ts +85 -0
  363. package/dist/storage/storage-provider.d.ts.map +1 -0
  364. package/dist/storage/storage-provider.js +220 -0
  365. package/dist/storage/storage-provider.js.map +1 -0
  366. package/dist/sync/anti-entropy.d.ts +49 -0
  367. package/dist/sync/anti-entropy.d.ts.map +1 -0
  368. package/dist/sync/anti-entropy.js +62 -0
  369. package/dist/sync/anti-entropy.js.map +1 -0
  370. package/dist/sync/index.d.ts +4 -0
  371. package/dist/sync/index.d.ts.map +1 -0
  372. package/dist/sync/index.js +4 -0
  373. package/dist/sync/index.js.map +1 -0
  374. package/dist/sync/sync-engine.d.ts +71 -0
  375. package/dist/sync/sync-engine.d.ts.map +1 -0
  376. package/dist/sync/sync-engine.js +309 -0
  377. package/dist/sync/sync-engine.js.map +1 -0
  378. package/dist/sync/sync-messages.d.ts +75 -0
  379. package/dist/sync/sync-messages.d.ts.map +1 -0
  380. package/dist/sync/sync-messages.js +12 -0
  381. package/dist/sync/sync-messages.js.map +1 -0
  382. package/dist/types.d.ts +243 -0
  383. package/dist/types.d.ts.map +1 -0
  384. package/dist/types.js +7 -0
  385. package/dist/types.js.map +1 -0
  386. package/dist/utils/encoding.d.ts +63 -0
  387. package/dist/utils/encoding.d.ts.map +1 -0
  388. package/dist/utils/encoding.js +130 -0
  389. package/dist/utils/encoding.js.map +1 -0
  390. package/dist/utils/errors.d.ts +43 -0
  391. package/dist/utils/errors.d.ts.map +1 -0
  392. package/dist/utils/errors.js +28 -0
  393. package/dist/utils/errors.js.map +1 -0
  394. package/dist/utils/events.d.ts +19 -0
  395. package/dist/utils/events.d.ts.map +1 -0
  396. package/dist/utils/events.js +27 -0
  397. package/dist/utils/events.js.map +1 -0
  398. package/dist/utils/hash.d.ts +23 -0
  399. package/dist/utils/hash.d.ts.map +1 -0
  400. package/dist/utils/hash.js +49 -0
  401. package/dist/utils/hash.js.map +1 -0
  402. package/dist/utils/index.d.ts +9 -0
  403. package/dist/utils/index.d.ts.map +1 -0
  404. package/dist/utils/index.js +9 -0
  405. package/dist/utils/index.js.map +1 -0
  406. package/dist/validation/capability-gate.d.ts +50 -0
  407. package/dist/validation/capability-gate.d.ts.map +1 -0
  408. package/dist/validation/capability-gate.js +71 -0
  409. package/dist/validation/capability-gate.js.map +1 -0
  410. package/dist/validation/crypto-gate.d.ts +16 -0
  411. package/dist/validation/crypto-gate.d.ts.map +1 -0
  412. package/dist/validation/crypto-gate.js +37 -0
  413. package/dist/validation/crypto-gate.js.map +1 -0
  414. package/dist/validation/index.d.ts +6 -0
  415. package/dist/validation/index.d.ts.map +1 -0
  416. package/dist/validation/index.js +6 -0
  417. package/dist/validation/index.js.map +1 -0
  418. package/dist/validation/stateful-gate.d.ts +15 -0
  419. package/dist/validation/stateful-gate.d.ts.map +1 -0
  420. package/dist/validation/stateful-gate.js +50 -0
  421. package/dist/validation/stateful-gate.js.map +1 -0
  422. package/dist/validation/structural-gate.d.ts +18 -0
  423. package/dist/validation/structural-gate.d.ts.map +1 -0
  424. package/dist/validation/structural-gate.js +54 -0
  425. package/dist/validation/structural-gate.js.map +1 -0
  426. package/dist/validation/validation-engine.d.ts +28 -0
  427. package/dist/validation/validation-engine.d.ts.map +1 -0
  428. package/dist/validation/validation-engine.js +38 -0
  429. package/dist/validation/validation-engine.js.map +1 -0
  430. package/package.json +107 -0
@@ -0,0 +1,155 @@
1
+ import { base64UrlEncode, base64UrlDecode } from '../utils/encoding.js';
2
+ import { protocolError } from '../utils/errors.js';
3
+ const PRF_SALT = new TextEncoder().encode('weave-protocol-key-v1');
4
+ /**
5
+ * Whether this device has a built-in authenticator — Touch ID, Windows Hello.
6
+ *
7
+ * Worth knowing before asking for one: `attachment: 'platform'` is a filter
8
+ * rather than a preference, so requesting it on a machine that has none fails
9
+ * outright instead of falling back.
10
+ *
11
+ * @returns Whether a platform authenticator can be used here
12
+ */
13
+ export async function hasPlatformAuthenticator() {
14
+ try {
15
+ return ((await globalThis.PublicKeyCredential?.isUserVerifyingPlatformAuthenticatorAvailable?.()) ??
16
+ false);
17
+ }
18
+ catch {
19
+ return false;
20
+ }
21
+ }
22
+ /**
23
+ * Registers a new passkey with PRF extension.
24
+ * @param {PasskeyOptions} options Registration options.
25
+ * @returns {Promise<PasskeyRegistration>} Registration result.
26
+ */
27
+ export async function registerPasskey(options) {
28
+ if (!globalThis.navigator?.credentials) {
29
+ throw protocolError('WEBAUTHN_UNAVAILABLE', 'WebAuthn is not supported in this environment.');
30
+ }
31
+ const userId = options.userId || globalThis.crypto.getRandomValues(new Uint8Array(32));
32
+ const createOptions = {
33
+ rp: { id: options.rpId, name: options.rpName },
34
+ user: {
35
+ id: userId,
36
+ name: options.userName,
37
+ displayName: options.userName,
38
+ },
39
+ challenge: globalThis.crypto.getRandomValues(new Uint8Array(32)),
40
+ pubKeyCredParams: [
41
+ { type: 'public-key', alg: -7 }, // ES256
42
+ { type: 'public-key', alg: -257 } // RS256
43
+ ],
44
+ authenticatorSelection: {
45
+ // Discoverable ("resident") so the passkey can be found again on a later
46
+ // visit without the app having to remember anything about the user.
47
+ residentKey: 'required',
48
+ requireResidentKey: true,
49
+ userVerification: 'required',
50
+ ...(options.attachment ? { authenticatorAttachment: options.attachment } : {})
51
+ },
52
+ ...(options.hints ? { hints: options.hints } : {}),
53
+ extensions: {
54
+ prf: {
55
+ eval: {
56
+ first: PRF_SALT
57
+ }
58
+ }
59
+ } // PRF might not be in standard TS types yet
60
+ };
61
+ const credential = (await globalThis.navigator.credentials.create({
62
+ publicKey: createOptions
63
+ }));
64
+ if (!credential) {
65
+ throw new Error('Failed to create passkey.');
66
+ }
67
+ const response = credential.response;
68
+ const extensions = credential.getClientExtensionResults();
69
+ const prf = extensions.prf;
70
+ const prfDeclared = prf?.results?.first ? true : prf?.enabled;
71
+ // Newer authenticators return the PRF output from the creation ceremony itself,
72
+ // which saves the user a second prompt.
73
+ const prfOutputBuffer = prf?.results?.first;
74
+ const rawId = new Uint8Array(credential.rawId);
75
+ return Object.freeze({
76
+ credentialId: base64UrlEncode(rawId),
77
+ userHandle: base64UrlEncode(userId),
78
+ publicKey: new Uint8Array(response.getPublicKey?.() || new ArrayBuffer(0)),
79
+ prfDeclared,
80
+ prfOutput: prfOutputBuffer ? new Uint8Array(prfOutputBuffer) : null
81
+ });
82
+ }
83
+ /**
84
+ * Asks the passkey provider to show a passkey under a new name.
85
+ *
86
+ * A site cannot edit a password manager, so after an account is renamed its
87
+ * passkey would keep the old label and look like a different account. The
88
+ * WebAuthn Signal API lets a site *ask*; the provider decides. Where the
89
+ * browser does not have it, this does nothing.
90
+ *
91
+ * @returns Whether the browser accepted the request — not whether the provider acted on it
92
+ */
93
+ export async function renamePasskey(params) {
94
+ const signal = globalThis.PublicKeyCredential?.signalCurrentUserDetails;
95
+ if (typeof signal !== 'function')
96
+ return false;
97
+ try {
98
+ await signal.call(globalThis.PublicKeyCredential, {
99
+ rpId: params.rpId,
100
+ userId: params.userHandle,
101
+ name: params.name,
102
+ displayName: params.name,
103
+ });
104
+ return true;
105
+ }
106
+ catch {
107
+ return false;
108
+ }
109
+ }
110
+ /**
111
+ * Authenticates using an existing passkey with PRF extension.
112
+ * @param {string} [credentialId] The credential to use. Omit to let the user pick
113
+ * any discoverable passkey for this origin.
114
+ * @param {AuthOptions} [options] Authentication options.
115
+ * @returns {Promise<PasskeyAuth>} Authentication result.
116
+ */
117
+ export async function authenticatePasskey(credentialId, options) {
118
+ if (!globalThis.navigator?.credentials) {
119
+ throw protocolError('WEBAUTHN_UNAVAILABLE', 'WebAuthn is not supported in this environment.');
120
+ }
121
+ const getOptions = {
122
+ challenge: globalThis.crypto.getRandomValues(new Uint8Array(32)),
123
+ rpId: options?.rpId,
124
+ userVerification: 'required',
125
+ ...(options?.hints ? { hints: options.hints } : {}),
126
+ // Narrow the ceremony to the known credential; without this the browser
127
+ // would prompt for any passkey on the origin.
128
+ ...(credentialId
129
+ ? { allowCredentials: [{ type: 'public-key', id: base64UrlDecode(credentialId) }] }
130
+ : {}),
131
+ extensions: {
132
+ prf: {
133
+ eval: {
134
+ first: PRF_SALT
135
+ }
136
+ }
137
+ }
138
+ };
139
+ const credential = (await globalThis.navigator.credentials.get({
140
+ publicKey: getOptions
141
+ }));
142
+ if (!credential) {
143
+ throw new Error('Failed to authenticate passkey.');
144
+ }
145
+ const response = credential.response;
146
+ const extensions = credential.getClientExtensionResults();
147
+ const prfOutputBuffer = extensions.prf?.results?.first;
148
+ const prfOutput = prfOutputBuffer ? new Uint8Array(prfOutputBuffer) : null;
149
+ return Object.freeze({
150
+ credentialId: base64UrlEncode(new Uint8Array(credential.rawId)),
151
+ prfOutput,
152
+ authenticatorData: new Uint8Array(response.authenticatorData)
153
+ });
154
+ }
155
+ //# sourceMappingURL=webauthn.js.map
@@ -0,0 +1 @@
1
+ {"version":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CAAC;QAC/D,SAAS;QACT,iBAAiB,EAAE,IAAI,UAAU,CAAC,QAAQ,CAAC,iBAAiB,CAAC;KAC9D,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * @weaveprotocol/core
3
+ * Self-sovereign, peer-to-peer protocol for the browser.
4
+ *
5
+ * Identity via WebAuthn passkeys, data as signed Expressions,
6
+ * storage in a Merkle Search Tree, sync via anti-entropy gossip,
7
+ * and end-to-end encryption for private Spaces.
8
+ *
9
+ * @module @weaveprotocol/core
10
+ */
11
+ export type { CryptoProvider, CryptoKeyPairResult, StandardSchemaV1, StandardJSONSchemaV1, StandardSchemaResult, StandardSchemaIssue, Expression, UnsignedExpression, Link, Space, SpaceRole, SpaceVisibility, CollectionDef, PeerInfo, SyncState, StorageAdapter, BatchOp, NetworkMessage, Result, } from './types.js';
12
+ export { ok, err } from './types.js';
13
+ export { createP256Provider, } from './identity/crypto-p256.js';
14
+ export { registerPasskey, authenticatePasskey, renamePasskey, hasPlatformAuthenticator, } from './identity/webauthn.js';
15
+ export type { PasskeyOptions, PasskeyRegistration, PasskeyAuth, AuthOptions } from './identity/webauthn.js';
16
+ export { inspectPasskeyPrf } from './identity/passkey-diagnostics.js';
17
+ export type { PasskeyDiagnostics, DiagnosticsOptions, CeremonyReport } from './identity/passkey-diagnostics.js';
18
+ export { deriveKeyPair, deriveKeyFromPassword, } from './identity/keys.js';
19
+ export type { DerivedKeyPair } from './identity/keys.js';
20
+ export { generateRecoveryCode, generateSeed, seedToRecoveryCode, normalizeRecoveryCode, isValidRecoveryCode, recoveryCodeToSeed, RECOVERY_SEED_BYTES, } from './identity/recovery-code.js';
21
+ export { publicKeyToDid, didToPublicKey, P256_MULTICODEC, } from './identity/did.js';
22
+ export { createIdentityManager, } from './identity/identity-manager.js';
23
+ export { createFolderAccountStore, createBrowserAccountStore, listFolderAccounts, adoptLegacyFolderAccount, accountDataPath, newAccountId, } from './identity/account-store.js';
24
+ export type { AccountStore, AccountSummary } from './identity/account-store.js';
25
+ export { readFolderVault, writeFolderVault, createVault, ACCOUNT_FILE, } from './identity/folder-account.js';
26
+ export type { FolderState } from './identity/folder-account.js';
27
+ export { wrapSeedWithDeviceKey, unwrapSeedWithDeviceKey, wrapSeedWithPassphrase, unwrapSeedWithPassphrase, deriveVaultKey, deriveVaultKeyBytes, deviceWrapsFor, hasPassphraseWrap, withWrap, withoutWrap, PASSPHRASE_ITERATIONS, } from './identity/account-vault.js';
28
+ export type { AccountVault, SeedWrap, DeviceWrap, PassphraseWrap, } from './identity/account-vault.js';
29
+ export type { IdentityManager, Identity, IdentityConfig, CeremonyPreferences } from './identity/identity-manager.js';
30
+ export { createDeviceKey, getDeviceKey, deleteDeviceKey } from './identity/device-key.js';
31
+ export type { DeviceKey } from './identity/device-key.js';
32
+ export { createLocalRootSigner } from './identity/root-signer.js';
33
+ export type { RootSigner } from './identity/root-signer.js';
34
+ export { pairingRoomId, derivePairingKey, encodePairingTicket, decodePairingTicket, sealPairingPayload, openPairingPayload, } from './identity/pairing.js';
35
+ export type { PairingTicket } from './identity/pairing.js';
36
+ export { issueUCAN, parseUCAN, verifyUCAN, isCapabilitySubset, validateDelegationChain, delegateCapabilities, resolveDelegationRoot, } from './identity/ucan.js';
37
+ export { AGENT_FACT, isAgentNote } from './identity/agent-note.js';
38
+ export type { UCANHeader, UCANPayload, UCANToken, Capability, Fact, IssueUCANOptions, UCANValidation, ChainResolution, ProofResolver, DelegateOptions, } from './identity/ucan.js';
39
+ export { createSchemaEngine, } from './schema/schema-engine.js';
40
+ export type { SchemaEngine, ValidationResult } from './schema/schema-engine.js';
41
+ export { createSigner, } from './schema/signer.js';
42
+ export type { Signer } from './schema/signer.js';
43
+ export { createExpression, canonicalize, serializeExpression, deserializeExpression, getExpressionId, signedPart, } from './schema/expression.js';
44
+ export { createIndexedDBAdapter, } from './storage/indexeddb-adapter.js';
45
+ export { createEmptyNode, insertIntoMST, deleteFromMST, lookupInMST, listMSTEntries, collectReachableCids, } from './storage/mst.js';
46
+ export type { MSTNode } from './storage/mst.js';
47
+ export { createStorageProvider, } from './storage/storage-provider.js';
48
+ export type { StorageProvider } from './storage/storage-provider.js';
49
+ export { createFolderAdapter, readFolderFile, writeFolderFile, } from './storage/folder-adapter.js';
50
+ export type { FolderAdapter, FolderReload, DirectoryHandleLike, FileHandleLike, WritableFileLike, } from './storage/folder-adapter.js';
51
+ export { createEncryptedAdapter, DEFAULT_ENCRYPTED_PREFIXES } from './storage/encrypted-adapter.js';
52
+ export type { EncryptedAdapterOptions } from './storage/encrypted-adapter.js';
53
+ export { reconcileFolder } from './storage/folder-reconcile.js';
54
+ export type { FolderReconciliation } from './storage/folder-reconcile.js';
55
+ export { isFolderStorageAvailable, pickDataFolder, queryFolderPermission, ensureFolderPermission, rememberDataFolder, recallDataFolder, forgetDataFolder, } from './storage/directory-access.js';
56
+ export type { FolderAccessMode } from './storage/directory-access.js';
57
+ export { createSpaceManager, parseSpaceInvite } from './space/space-manager.js';
58
+ export { deriveAccountRegistry, MEMBERSHIP_COLLECTION } from './space/account-registry.js';
59
+ export { CATALOG_COLLECTION, checkStoredCollection, checkPublishableSchema, validateJsonSchema, asStandardSchema, toJsonSchema, collection, } from './schema/collection-def.js';
60
+ export type { StoredCollection, JsonSchema, SchemaIssue } from './schema/collection-def.js';
61
+ export type { Membership } from './space/account-registry.js';
62
+ export type { SpaceManager, SpaceRecord, SpaceInvite, InviteOptions, CreateSpaceParams } from './space/space-manager.js';
63
+ export { generateInviteSecret, deriveInviteKey, deriveReadKey, spaceGenesis, spaceIdOf, checkSpace, checkStartingRoles, memberKey, inviteKey, revokeKey, roleKey, signInvite, verifyInvite, } from './space/space-access.js';
64
+ export { replayAccess, permissionMatches, roleHolds, holds, standing, checkRole, MANAGE, INVITE, DEFINE, ROLE_COLLECTION, MEMBER_COLLECTION, INVITE_COLLECTION, REVOKE_COLLECTION, ACCESS_COLLECTIONS, } from './space/roles.js';
65
+ export type { Role, AccessEvent, AccessGenesis, AccessHistory, AccessState, EventStatus, RecordVerdict } from './space/roles.js';
66
+ export { rolePresets, solo, team, community } from './space/presets.js';
67
+ export type { RolePreset } from './space/presets.js';
68
+ export type { SpaceGenesis, SpaceKeyPair } from './space/space-access.js';
69
+ export { createSignalingClient, } from './network/signaling.js';
70
+ export { createMultiSignalingClient, } from './network/multi-signaling.js';
71
+ export { isControlMessage, shouldInitiate, createSeenSignals, signalId, MAX_HOPS, PEERS_MESSAGE, SIGNAL_MESSAGE, } from './network/introductions.js';
72
+ export type { RelayedSignal, SeenSignals } from './network/introductions.js';
73
+ export { createRTCTransport, } from './network/rtc-transport.js';
74
+ export { createWebSocketTransport } from './network/ws-transport.js';
75
+ export type { WebSocketTransportConfig } from './network/ws-transport.js';
76
+ export { createClientAuth, createServerAuth, createMeshAuth, peerNonce } from './network/peer-auth.js';
77
+ export type { ClientAuth, ServerAuth } from './network/peer-auth.js';
78
+ export type { PeerTransport, PeerTransportEvents, SignalledTransport, CandidateSink } from './network/transport.js';
79
+ export { createMesh } from './network/mesh.js';
80
+ export type { Mesh, MeshConfig } from './network/mesh.js';
81
+ export { createNetworkManager, } from './network/network-manager.js';
82
+ export type { NetworkManager, NetworkManagerConfig, NetworkEvents } from './network/network-manager.js';
83
+ export type { SignalingClient, SignalingMessage, SignalKind } from './network/signaling.js';
84
+ export { parseSyncMessage, SYNC_PROTOCOL_VERSION, } from './sync/sync-messages.js';
85
+ export type { SyncMessage } from './sync/sync-messages.js';
86
+ export { verifyNode, unknownChildren, differingEntries, } from './sync/anti-entropy.js';
87
+ export { createSyncEngine, } from './sync/sync-engine.js';
88
+ export type { SyncEngine, SyncEngineConfig, IncomingValidation } from './sync/sync-engine.js';
89
+ export { createCryptoGate, } from './validation/crypto-gate.js';
90
+ export { createStructuralGate, } from './validation/structural-gate.js';
91
+ export { createStatefulGate, } from './validation/stateful-gate.js';
92
+ export { createCapabilityGate, } from './validation/capability-gate.js';
93
+ export type { CapabilityGate, CapabilityGateConfig } from './validation/capability-gate.js';
94
+ export { createValidationEngine, } from './validation/validation-engine.js';
95
+ export type { ValidationEngine, ValidationEngineConfig } from './validation/validation-engine.js';
96
+ export { generateSpaceKey, encryptExpression, decryptExpression, } from './privacy/space-encryption.js';
97
+ export type { SpaceKey, EncryptedExpression, EncryptedExpressionBody } from './privacy/space-encryption.js';
98
+ export { wrapSpaceKey, unwrapSpaceKey, distributeSpaceKey, } from './privacy/key-distribution.js';
99
+ export { createPrivacyGuard, } from './privacy/privacy-guard.js';
100
+ export { base64UrlEncode, base64UrlDecode, utf8Encode, utf8Decode, concatBytes, varintEncode, varintDecode, bytesToHex, hexToBytes, } from './utils/encoding.js';
101
+ export { sha256, cidFromBytes } from './utils/hash.js';
102
+ export { protocolError, isProtocolError } from './utils/errors.js';
103
+ export type { ProtocolError, ProtocolErrorCode } from './utils/errors.js';
104
+ export { createEmitter } from './utils/events.js';
105
+ export type { Emitter } from './utils/events.js';
106
+ export { createNode, SESSION_CAPABILITY, writeCapability, relayRoom, indexedDBStores, folderStores, copyAccountData, NODE_ACTIONS, runAction, checkActionInput, } from './node/index.js';
107
+ export type { StoreFactory, StoreOptions, CopyAccountParams, CopyResult, NodeAction, ActionSchema, P2PNode, NodeConfig, NodeNetworkConfig, NodeSpaces, NodeRecords, NodeRecord, NodeEvent, SpaceSummary, SpaceStatus, CarrierSummary, SpaceProfile, NewSpace, InvitePreview, ListOptions, ConnectionState, DelegateParams, Delegated, NodeCollection, NodeCollections, DefineCollection, NodeAccount, AccountProfileView, } from './node/index.js';
108
+ export { runQuery } from './query/engine.js';
109
+ export type { QuerySource } from './query/engine.js';
110
+ export { matches, checkQuery, fieldValue, MAX_INCLUDE_DEPTH } from './query/filter.js';
111
+ export type { Query, Filter, Operators, Include, SortDirection, QueryRecord, QueryResult, CollectionRef, Typed, BodyOf, IncludedOf, ResultOf } from './query/types.js';
112
+ export { plainQuery } from './query/types.js';
113
+ export { checkRules, onePerKey } from './records/rules.js';
114
+ export { describeCollection } from './records/describe.js';
115
+ export type { CollectionRules, Who } from './records/rules.js';
116
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,kBAAkB,EAClB,IAAI,EACJ,KAAK,EACL,SAAS,EACT,eAAe,EACf,aAAa,EACb,QAAQ,EACR,SAAS,EACT,cAAc,EACd,OAAO,EACP,cAAc,EACd,MAAM,GACP,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAGrC,OAAO,EACL,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC5G,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAChH,OAAO,EACL,aAAa,EACb,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,cAAc,EACd,cAAc,EACd,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,qBAAqB,GACtB,MAAM,gCAAgC,CAAC;AACxC,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AC3D,YAAY,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @weaveprotocol/core
3
+ * Self-sovereign, peer-to-peer protocol for the browser.
4
+ *
5
+ * Identity via WebAuthn passkeys, data as signed Expressions,
6
+ * storage in a Merkle Search Tree, sync via anti-entropy gossip,
7
+ * and end-to-end encryption for private Spaces.
8
+ *
9
+ * @module @weaveprotocol/core
10
+ */
11
+ export { ok, err } from './types.js';
12
+ // Phase 1: Identity & Key Management
13
+ export { createP256Provider, } from './identity/crypto-p256.js';
14
+ export { registerPasskey, authenticatePasskey, renamePasskey, hasPlatformAuthenticator, } from './identity/webauthn.js';
15
+ export { inspectPasskeyPrf } from './identity/passkey-diagnostics.js';
16
+ export { deriveKeyPair, deriveKeyFromPassword, } from './identity/keys.js';
17
+ export { generateRecoveryCode, generateSeed, seedToRecoveryCode, normalizeRecoveryCode, isValidRecoveryCode, recoveryCodeToSeed, RECOVERY_SEED_BYTES, } from './identity/recovery-code.js';
18
+ export { publicKeyToDid, didToPublicKey, P256_MULTICODEC, } from './identity/did.js';
19
+ export { createIdentityManager, } from './identity/identity-manager.js';
20
+ export { createFolderAccountStore, createBrowserAccountStore, listFolderAccounts, adoptLegacyFolderAccount, accountDataPath, newAccountId, } from './identity/account-store.js';
21
+ export { readFolderVault, writeFolderVault, createVault, ACCOUNT_FILE, } from './identity/folder-account.js';
22
+ export { wrapSeedWithDeviceKey, unwrapSeedWithDeviceKey, wrapSeedWithPassphrase, unwrapSeedWithPassphrase, deriveVaultKey, deriveVaultKeyBytes, deviceWrapsFor, hasPassphraseWrap, withWrap, withoutWrap, PASSPHRASE_ITERATIONS, } from './identity/account-vault.js';
23
+ export { createDeviceKey, getDeviceKey, deleteDeviceKey } from './identity/device-key.js';
24
+ export { createLocalRootSigner } from './identity/root-signer.js';
25
+ export { pairingRoomId, derivePairingKey, encodePairingTicket, decodePairingTicket, sealPairingPayload, openPairingPayload, } from './identity/pairing.js';
26
+ export { issueUCAN, parseUCAN, verifyUCAN, isCapabilitySubset, validateDelegationChain, delegateCapabilities, resolveDelegationRoot, } from './identity/ucan.js';
27
+ export { AGENT_FACT, isAgentNote } from './identity/agent-note.js';
28
+ // Phase 2: Schema & Data Structures
29
+ export { createSchemaEngine, } from './schema/schema-engine.js';
30
+ export { createSigner, } from './schema/signer.js';
31
+ export { createExpression, canonicalize, serializeExpression, deserializeExpression, getExpressionId, signedPart, } from './schema/expression.js';
32
+ // Phase 3: Local Storage & State
33
+ export { createIndexedDBAdapter, } from './storage/indexeddb-adapter.js';
34
+ export { createEmptyNode, insertIntoMST, deleteFromMST, lookupInMST, listMSTEntries, collectReachableCids, } from './storage/mst.js';
35
+ export { createStorageProvider, } from './storage/storage-provider.js';
36
+ // Storage in a folder the user owns — the one store that is not origin-scoped
37
+ export { createFolderAdapter, readFolderFile, writeFolderFile, } from './storage/folder-adapter.js';
38
+ export { createEncryptedAdapter, DEFAULT_ENCRYPTED_PREFIXES } from './storage/encrypted-adapter.js';
39
+ export { reconcileFolder } from './storage/folder-reconcile.js';
40
+ export { isFolderStorageAvailable, pickDataFolder, queryFolderPermission, ensureFolderPermission, rememberDataFolder, recallDataFolder, forgetDataFolder, } from './storage/directory-access.js';
41
+ // Spaces
42
+ export { createSpaceManager, parseSpaceInvite } from './space/space-manager.js';
43
+ export { deriveAccountRegistry, MEMBERSHIP_COLLECTION } from './space/account-registry.js';
44
+ export { CATALOG_COLLECTION, checkStoredCollection, checkPublishableSchema, validateJsonSchema, asStandardSchema, toJsonSchema, collection, } from './schema/collection-def.js';
45
+ export { generateInviteSecret, deriveInviteKey, deriveReadKey, spaceGenesis, spaceIdOf, checkSpace, checkStartingRoles, memberKey, inviteKey, revokeKey, roleKey, signInvite, verifyInvite, } from './space/space-access.js';
46
+ export { replayAccess, permissionMatches, roleHolds, holds, standing, checkRole, MANAGE, INVITE, DEFINE, ROLE_COLLECTION, MEMBER_COLLECTION, INVITE_COLLECTION, REVOKE_COLLECTION, ACCESS_COLLECTIONS, } from './space/roles.js';
47
+ export { rolePresets, solo, team, community } from './space/presets.js';
48
+ // Phase 4: P2P Networking
49
+ export { createSignalingClient, } from './network/signaling.js';
50
+ export { createMultiSignalingClient, } from './network/multi-signaling.js';
51
+ export { isControlMessage, shouldInitiate, createSeenSignals, signalId, MAX_HOPS, PEERS_MESSAGE, SIGNAL_MESSAGE, } from './network/introductions.js';
52
+ export { createRTCTransport, } from './network/rtc-transport.js';
53
+ export { createWebSocketTransport } from './network/ws-transport.js';
54
+ export { createClientAuth, createServerAuth, createMeshAuth, peerNonce } from './network/peer-auth.js';
55
+ export { createMesh } from './network/mesh.js';
56
+ export { createNetworkManager, } from './network/network-manager.js';
57
+ // Phase 5: Gossip/Sync Protocol
58
+ export { parseSyncMessage, SYNC_PROTOCOL_VERSION, } from './sync/sync-messages.js';
59
+ export { verifyNode, unknownChildren, differingEntries, } from './sync/anti-entropy.js';
60
+ export { createSyncEngine, } from './sync/sync-engine.js';
61
+ // Phase 6: Validation Engine
62
+ export { createCryptoGate, } from './validation/crypto-gate.js';
63
+ export { createStructuralGate, } from './validation/structural-gate.js';
64
+ export { createStatefulGate, } from './validation/stateful-gate.js';
65
+ export { createCapabilityGate, } from './validation/capability-gate.js';
66
+ export { createValidationEngine, } from './validation/validation-engine.js';
67
+ // Phase 7: Encryption & Privacy
68
+ export { generateSpaceKey, encryptExpression, decryptExpression, } from './privacy/space-encryption.js';
69
+ export { wrapSpaceKey, unwrapSpaceKey, distributeSpaceKey, } from './privacy/key-distribution.js';
70
+ export { createPrivacyGuard, } from './privacy/privacy-guard.js';
71
+ // Utilities
72
+ export { base64UrlEncode, base64UrlDecode, utf8Encode, utf8Decode, concatBytes, varintEncode, varintDecode, bytesToHex, hexToBytes, } from './utils/encoding.js';
73
+ export { sha256, cidFromBytes } from './utils/hash.js';
74
+ export { protocolError, isProtocolError } from './utils/errors.js';
75
+ export { createEmitter } from './utils/events.js';
76
+ // Node: identity + spaces + sync, behind one API
77
+ export { createNode, SESSION_CAPABILITY, writeCapability, relayRoom, indexedDBStores, folderStores, copyAccountData, NODE_ACTIONS, runAction, checkActionInput, } from './node/index.js';
78
+ // Queries: plain-data filters, sorting, paging and includes over a space
79
+ export { runQuery } from './query/engine.js';
80
+ export { matches, checkQuery, fieldValue, MAX_INCLUDE_DEPTH } from './query/filter.js';
81
+ export { plainQuery } from './query/types.js';
82
+ // Rules: who may create, edit and delete a collection's records, what must be unique
83
+ export { checkRules, onePerKey } from './records/rules.js';
84
+ export { describeCollection } from './records/describe.js';
85
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAwBH,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAErC,qCAAqC;AACrC,OAAO,EACL,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,OAAO,EACL,aAAa,EACb,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,cAAc,EACd,cAAc,EACd,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,qBAAqB,GACtB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,kBAAkB,EAClB,wBAAwB,EACxB,eAAe,EACf,YAAY,GACb,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,eAAe,E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AY,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,iDAAiD;AACjD,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,SAAS,EACT,eAAe,EACf,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,SAAS,EACT,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAgCzB,yEAAyE;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEvF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,qFAAqF;AACrF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @fileoverview Network module exports for P2P networking phase 4.
3
+ */
4
+ export { createSignalingClient } from './signaling.js';
5
+ export type { SignalingClient, SignalingMessage, SignalingEvents } from './signaling.js';
6
+ export type { PeerTransport, PeerTransportEvents, SignalledTransport, CandidateSink } from './transport.js';
7
+ export { createRTCTransport } from './rtc-transport.js';
8
+ export type { RTCTransport, RTCTransportConfig, RTCTransportEvents } from './rtc-transport.js';
9
+ export { createWebSocketTransport } from './ws-transport.js';
10
+ export type { WebSocketTransportConfig } from './ws-transport.js';
11
+ export { createMesh } from './mesh.js';
12
+ export type { Mesh, MeshConfig } from './mesh.js';
13
+ export { createNetworkManager } from './network-manager.js';
14
+ export type { NetworkManager, NetworkManagerConfig, NetworkEvents } from './network-manager.js';
15
+ export { createLocalHub } from './local-transport.js';
16
+ export type { LocalHub } from './local-transport.js';
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/network/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEzF,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE5G,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE/F,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,YAAY,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAElD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @fileoverview Network module exports for P2P networking phase 4.
3
+ */
4
+ export { createSignalingClient } from './signaling.js';
5
+ export { createRTCTransport } from './rtc-transport.js';
6
+ export { createWebSocketTransport } from './ws-transport.js';
7
+ export { createMesh } from './mesh.js';
8
+ export { createNetworkManager } from './network-manager.js';
9
+ export { createLocalHub } from './local-transport.js';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/network/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAKvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAG7D,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAG5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @module introductions
3
+ * Letting peers introduce each other, so a relay is only needed to meet the
4
+ * first one.
5
+ *
6
+ * Two browsers cannot find each other unaided — neither can accept an incoming
7
+ * connection — so somebody has to make the introduction. That does not have to
8
+ * be a relay every time. Once you are connected to one peer, its data channel
9
+ * is a perfectly good channel for arranging the next connection, and the peers
10
+ * it already knows are exactly the ones you are looking for.
11
+ *
12
+ * So a relay shrinks from permanent infrastructure to a bootstrap hint: the way
13
+ * into a room you have never been in. After that the mesh introduces itself, and
14
+ * the relay can go away without anyone noticing.
15
+ *
16
+ * Two messages do it. `__peers` says who I can see; `__signal` carries somebody
17
+ * else's connection offer to somebody I can reach.
18
+ */
19
+ /** Message types reserved for the mesh itself, never handed to the application */
20
+ export declare const PEERS_MESSAGE = "__peers";
21
+ export declare const SIGNAL_MESSAGE = "__signal";
22
+ /** The peer handshake (`peer-auth.ts`): a nonce each way, then a proof each way */
23
+ export declare const AUTH_HELLO_MESSAGE = "__auth-hello";
24
+ export declare const AUTH_PROOF_MESSAGE = "__auth-proof";
25
+ /** A peer is leaving a room, though the connection may go on for others */
26
+ export declare const LEAVE_MESSAGE = "__leave";
27
+ /** Whether a message belongs to the mesh rather than the application above it */
28
+ export declare function isControlMessage(type: string): boolean;
29
+ /** The most peers one introduction may name — more is someone trying to make us dial the world */
30
+ export declare const MAX_INTRODUCED = 64;
31
+ /** Whether a string could be a peer's name: a did:key of sane length */
32
+ export declare function isPeerDid(value: unknown): value is string;
33
+ /** Somebody else's signaling, travelling over a data channel */
34
+ export interface RelayedSignal {
35
+ /** Distinguishes this from copies arriving by another route */
36
+ readonly id: string;
37
+ /** Who wants to connect */
38
+ readonly origin: string;
39
+ /** Who they want to connect to */
40
+ readonly target: string;
41
+ readonly kind: 'offer' | 'answer' | 'candidate';
42
+ readonly data: unknown;
43
+ /** Forwards left before this is dropped */
44
+ readonly hops: number;
45
+ }
46
+ /**
47
+ * How far a relayed signal travels.
48
+ *
49
+ * Three is generous for the shape these meshes take — everyone in a room tends
50
+ * to end up within a hop or two of everyone else — and it bounds the work a
51
+ * malicious peer can cause by injecting traffic.
52
+ */
53
+ export declare const MAX_HOPS = 3;
54
+ /**
55
+ * Decides which side opens the connection when two peers learn of each other
56
+ * at the same moment.
57
+ *
58
+ * Both being told about the other simultaneously is the normal case for an
59
+ * introduction, and both offering produces two half-open connections that then
60
+ * have to be unpicked. Comparing identifiers costs nothing and both sides
61
+ * always agree on the answer.
62
+ *
63
+ * @param us This peer
64
+ * @param them The peer just learned about
65
+ * @returns Whether this side should send the offer
66
+ */
67
+ export declare function shouldInitiate(us: string, them: string): boolean;
68
+ /** Remembers recently seen signals, so a flooded message is handled once. */
69
+ export interface SeenSignals {
70
+ /** Records an id, returning whether it is new */
71
+ accept(id: string): boolean;
72
+ }
73
+ /**
74
+ * Creates a bounded record of signal ids.
75
+ *
76
+ * Bounded because it is fed by the network: an unbounded set would be a way for
77
+ * a peer to make this tab run out of memory.
78
+ *
79
+ * @param limit How many ids to remember
80
+ * @returns The record
81
+ */
82
+ export declare function createSeenSignals(limit?: number): SeenSignals;
83
+ /** A fresh identifier for a relayed signal. */
84
+ export declare function signalId(): string;
85
+ //# sourceMappingURL=introductions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"introductions.d.ts","sourceRoot":"","sources":["../../src/network/introductions.ts"],"names":[],"mappings":"AAAA;;;;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iBlE;AAED,+CAA+C;AAC/C,wBAAgB,QAAQ,IAAI,MAAM,CAGjC"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * @module introductions
3
+ * Letting peers introduce each other, so a relay is only needed to meet the
4
+ * first one.
5
+ *
6
+ * Two browsers cannot find each other unaided — neither can accept an incoming
7
+ * connection — so somebody has to make the introduction. That does not have to
8
+ * be a relay every time. Once you are connected to one peer, its data channel
9
+ * is a perfectly good channel for arranging the next connection, and the peers
10
+ * it already knows are exactly the ones you are looking for.
11
+ *
12
+ * So a relay shrinks from permanent infrastructure to a bootstrap hint: the way
13
+ * into a room you have never been in. After that the mesh introduces itself, and
14
+ * the relay can go away without anyone noticing.
15
+ *
16
+ * Two messages do it. `__peers` says who I can see; `__signal` carries somebody
17
+ * else's connection offer to somebody I can reach.
18
+ */
19
+ /** Message types reserved for the mesh itself, never handed to the application */
20
+ export const PEERS_MESSAGE = '__peers';
21
+ export const SIGNAL_MESSAGE = '__signal';
22
+ /** The peer handshake (`peer-auth.ts`): a nonce each way, then a proof each way */
23
+ export const AUTH_HELLO_MESSAGE = '__auth-hello';
24
+ export const AUTH_PROOF_MESSAGE = '__auth-proof';
25
+ /** A peer is leaving a room, though the connection may go on for others */
26
+ export const LEAVE_MESSAGE = '__leave';
27
+ const CONTROL = new Set([PEERS_MESSAGE, SIGNAL_MESSAGE, AUTH_HELLO_MESSAGE, AUTH_PROOF_MESSAGE, LEAVE_MESSAGE]);
28
+ /** Whether a message belongs to the mesh rather than the application above it */
29
+ export function isControlMessage(type) {
30
+ return CONTROL.has(type);
31
+ }
32
+ /** The most peers one introduction may name — more is someone trying to make us dial the world */
33
+ export const MAX_INTRODUCED = 64;
34
+ /** Whether a string could be a peer's name: a did:key of sane length */
35
+ export function isPeerDid(value) {
36
+ return typeof value === 'string' && value.length <= 256 && /^did:key:z[1-9A-HJ-NP-Za-km-z]+$/.test(value);
37
+ }
38
+ /**
39
+ * How far a relayed signal travels.
40
+ *
41
+ * Three is generous for the shape these meshes take — everyone in a room tends
42
+ * to end up within a hop or two of everyone else — and it bounds the work a
43
+ * malicious peer can cause by injecting traffic.
44
+ */
45
+ export const MAX_HOPS = 3;
46
+ /**
47
+ * Decides which side opens the connection when two peers learn of each other
48
+ * at the same moment.
49
+ *
50
+ * Both being told about the other simultaneously is the normal case for an
51
+ * introduction, and both offering produces two half-open connections that then
52
+ * have to be unpicked. Comparing identifiers costs nothing and both sides
53
+ * always agree on the answer.
54
+ *
55
+ * @param us This peer
56
+ * @param them The peer just learned about
57
+ * @returns Whether this side should send the offer
58
+ */
59
+ export function shouldInitiate(us, them) {
60
+ return us < them;
61
+ }
62
+ /**
63
+ * Creates a bounded record of signal ids.
64
+ *
65
+ * Bounded because it is fed by the network: an unbounded set would be a way for
66
+ * a peer to make this tab run out of memory.
67
+ *
68
+ * @param limit How many ids to remember
69
+ * @returns The record
70
+ */
71
+ export function createSeenSignals(limit = 512) {
72
+ const seen = new Set();
73
+ const order = [];
74
+ return {
75
+ accept(id) {
76
+ if (seen.has(id))
77
+ return false;
78
+ seen.add(id);
79
+ order.push(id);
80
+ if (order.length > limit) {
81
+ const oldest = order.shift();
82
+ if (oldest !== undefined)
83
+ seen.delete(oldest);
84
+ }
85
+ return true;
86
+ },
87
+ };
88
+ }
89
+ /** A fresh identifier for a relayed signal. */
90
+ export function signalId() {
91
+ const bytes = globalThis.crypto.getRandomValues(new Uint8Array(8));
92
+ return Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');
93
+ }
94
+ //# sourceMappingURL=introductions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"introductions.js","sourceRoot":"","sources":["../../src/network/introductions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,kFAAkF;AAClF,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AACvC,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AACzC,mFAAmF;AACnF,MAAM,CAAC,MAAM,kBAAkB,G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