holosphere 2.0.0-alpha1 → 2.0.0-alpha10

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 (418) hide show
  1. package/CHANGELOG.md +473 -0
  2. package/FEATURES.md +431 -0
  3. package/LICENSE +29 -166
  4. package/LICENSE-AGPL.md +180 -0
  5. package/README.md +97 -16
  6. package/dist/2019-D2OG2idw.js +6680 -0
  7. package/dist/2019-D2OG2idw.js.map +1 -0
  8. package/dist/2019-EION3wKo.cjs +8 -0
  9. package/dist/2019-EION3wKo.cjs.map +1 -0
  10. package/dist/_commonjsHelpers-C37NGDzP.cjs +2 -0
  11. package/dist/_commonjsHelpers-C37NGDzP.cjs.map +1 -0
  12. package/dist/_commonjsHelpers-CUmg6egw.js +7 -0
  13. package/dist/_commonjsHelpers-CUmg6egw.js.map +1 -0
  14. package/dist/browser-BSniCNqO.js +3058 -0
  15. package/dist/browser-BSniCNqO.js.map +1 -0
  16. package/dist/browser-Cq59Ij19.cjs +2 -0
  17. package/dist/browser-Cq59Ij19.cjs.map +1 -0
  18. package/dist/cdn/holosphere.min.js +55 -0
  19. package/dist/cdn/holosphere.min.js.map +1 -0
  20. package/dist/cjs/holosphere.cjs +2 -0
  21. package/dist/cjs/holosphere.cjs.map +1 -0
  22. package/dist/esm/holosphere.js +53 -0
  23. package/dist/esm/holosphere.js.map +1 -0
  24. package/dist/index-DDGt_V9o.cjs +12 -0
  25. package/dist/index-DDGt_V9o.cjs.map +1 -0
  26. package/dist/index-DJXftyvB.js +39841 -0
  27. package/dist/index-DJXftyvB.js.map +1 -0
  28. package/dist/index-DMbdcMtK.cjs +18 -0
  29. package/dist/index-DMbdcMtK.cjs.map +1 -0
  30. package/dist/index-DeZ1xz_s.js +15104 -0
  31. package/dist/index-DeZ1xz_s.js.map +1 -0
  32. package/dist/indexeddb-storage-BFt6hMeF.js +176 -0
  33. package/dist/indexeddb-storage-BFt6hMeF.js.map +1 -0
  34. package/dist/indexeddb-storage-BK5tv4Sh.cjs +2 -0
  35. package/dist/indexeddb-storage-BK5tv4Sh.cjs.map +1 -0
  36. package/dist/memory-storage-C9HuoL2E.js +91 -0
  37. package/dist/memory-storage-C9HuoL2E.js.map +1 -0
  38. package/dist/memory-storage-Dao7jfYG.cjs +2 -0
  39. package/dist/memory-storage-Dao7jfYG.cjs.map +1 -0
  40. package/dist/secp256k1-BbKzbLtD.cjs +12 -0
  41. package/dist/secp256k1-BbKzbLtD.cjs.map +1 -0
  42. package/dist/secp256k1-CreY7Pcl.js +1890 -0
  43. package/dist/secp256k1-CreY7Pcl.js.map +1 -0
  44. package/docs/CONTRACTS.md +797 -0
  45. package/docs/FOSDEM_PROPOSAL.md +388 -0
  46. package/docs/LOCALFIRST.md +266 -0
  47. package/docs/api/ai_aggregation.js.html +333 -0
  48. package/docs/api/ai_breakdown.js.html +524 -0
  49. package/docs/api/ai_classifier.js.html +231 -0
  50. package/docs/api/ai_council.js.html +246 -0
  51. package/docs/api/ai_embeddings.js.html +304 -0
  52. package/docs/api/ai_federation-ai.js.html +338 -0
  53. package/docs/api/ai_h3-ai.js.html +970 -0
  54. package/docs/api/ai_index.js.html +124 -0
  55. package/docs/api/ai_json-ops.js.html +241 -0
  56. package/docs/api/ai_llm-service.js.html +239 -0
  57. package/docs/api/ai_nl-query.js.html +236 -0
  58. package/docs/api/ai_relationships.js.html +367 -0
  59. package/docs/api/ai_schema-extractor.js.html +235 -0
  60. package/docs/api/ai_spatial.js.html +307 -0
  61. package/docs/api/ai_tts.js.html +214 -0
  62. package/docs/api/content_social-protocols.js.html +180 -0
  63. package/docs/api/core_holosphere.js.html +757 -0
  64. package/docs/api/crypto_nostr-utils.js.html +306 -0
  65. package/docs/api/crypto_secp256k1.js.html +267 -0
  66. package/docs/api/data/search.json +1 -0
  67. package/docs/api/federation_discovery.js.html +337 -0
  68. package/docs/api/federation_handshake.js.html +478 -0
  69. package/docs/api/federation_hologram.js.html +1053 -0
  70. package/docs/api/federation_registry.js.html +389 -0
  71. package/docs/api/fonts/Inconsolata-Regular.ttf +0 -0
  72. package/docs/api/fonts/OpenSans-Regular.ttf +0 -0
  73. package/docs/api/fonts/WorkSans-Bold.ttf +0 -0
  74. package/docs/api/global.html +3 -0
  75. package/docs/api/hierarchical_upcast.js.html +128 -0
  76. package/docs/api/index.html +265 -0
  77. package/docs/api/index.js.html +1868 -0
  78. package/docs/api/lib_ai-methods.js.html +660 -0
  79. package/docs/api/lib_contract-methods.js.html +445 -0
  80. package/docs/api/lib_errors.js.html +56 -0
  81. package/docs/api/lib_federation-methods.js.html +348 -0
  82. package/docs/api/lib_index.js.html +33 -0
  83. package/docs/api/module-ai.html +5 -0
  84. package/docs/api/module-ai_aggregation-SmartAggregation.html +6 -0
  85. package/docs/api/module-ai_aggregation.SmartAggregation.html +3 -0
  86. package/docs/api/module-ai_aggregation.html +3 -0
  87. package/docs/api/module-ai_breakdown-TaskBreakdown.html +5 -0
  88. package/docs/api/module-ai_breakdown.TaskBreakdown.html +3 -0
  89. package/docs/api/module-ai_breakdown.html +3 -0
  90. package/docs/api/module-ai_classifier-Classifier.html +6 -0
  91. package/docs/api/module-ai_classifier.Classifier.html +3 -0
  92. package/docs/api/module-ai_classifier.html +3 -0
  93. package/docs/api/module-ai_council-Council.html +6 -0
  94. package/docs/api/module-ai_council.Council.html +3 -0
  95. package/docs/api/module-ai_council.html +3 -0
  96. package/docs/api/module-ai_embeddings-Embeddings.html +5 -0
  97. package/docs/api/module-ai_embeddings.Embeddings.html +3 -0
  98. package/docs/api/module-ai_embeddings.html +3 -0
  99. package/docs/api/module-ai_federation-ai-FederationAdvisor.html +6 -0
  100. package/docs/api/module-ai_federation-ai.FederationAdvisor.html +3 -0
  101. package/docs/api/module-ai_federation-ai.html +3 -0
  102. package/docs/api/module-ai_h3-ai-H3AI.html +6 -0
  103. package/docs/api/module-ai_h3-ai.H3AI.html +3 -0
  104. package/docs/api/module-ai_h3-ai.html +3 -0
  105. package/docs/api/module-ai_json-ops-JSONOps.html +5 -0
  106. package/docs/api/module-ai_json-ops.JSONOps.html +3 -0
  107. package/docs/api/module-ai_json-ops.html +3 -0
  108. package/docs/api/module-ai_llm-service-LLMService.html +5 -0
  109. package/docs/api/module-ai_llm-service.LLMService.html +3 -0
  110. package/docs/api/module-ai_llm-service.html +3 -0
  111. package/docs/api/module-ai_nl-query-NLQuery.html +5 -0
  112. package/docs/api/module-ai_nl-query.NLQuery.html +3 -0
  113. package/docs/api/module-ai_nl-query.html +3 -0
  114. package/docs/api/module-ai_relationships-RelationshipDiscovery.html +6 -0
  115. package/docs/api/module-ai_relationships.RelationshipDiscovery.html +3 -0
  116. package/docs/api/module-ai_relationships.html +3 -0
  117. package/docs/api/module-ai_schema-extractor-SchemaExtractor.html +5 -0
  118. package/docs/api/module-ai_schema-extractor.SchemaExtractor.html +3 -0
  119. package/docs/api/module-ai_schema-extractor.html +3 -0
  120. package/docs/api/module-ai_spatial-SpatialAnalysis.html +6 -0
  121. package/docs/api/module-ai_spatial.SpatialAnalysis.html +3 -0
  122. package/docs/api/module-ai_spatial.html +3 -0
  123. package/docs/api/module-ai_tts-TTS.html +5 -0
  124. package/docs/api/module-ai_tts.TTS.html +3 -0
  125. package/docs/api/module-ai_tts.html +3 -0
  126. package/docs/api/module-content_social-protocols.html +3 -0
  127. package/docs/api/module-core_holosphere-HoloSphere.html +6 -0
  128. package/docs/api/module-core_holosphere.HoloSphere.html +3 -0
  129. package/docs/api/module-core_holosphere.html +3 -0
  130. package/docs/api/module-crypto_nostr-utils.html +3 -0
  131. package/docs/api/module-crypto_secp256k1.html +3 -0
  132. package/docs/api/module-federation_hologram.html +3 -0
  133. package/docs/api/module-hierarchical_upcast.html +3 -0
  134. package/docs/api/module-holosphere-HoloSphereBase.html +3 -0
  135. package/docs/api/module-holosphere.html +3 -0
  136. package/docs/api/module-lib_ai-methods.html +3 -0
  137. package/docs/api/module-lib_contract-methods.html +3 -0
  138. package/docs/api/module-lib_errors-AuthorizationError.html +3 -0
  139. package/docs/api/module-lib_errors-ValidationError.html +3 -0
  140. package/docs/api/module-lib_errors.AuthorizationError.html +3 -0
  141. package/docs/api/module-lib_errors.ValidationError.html +3 -0
  142. package/docs/api/module-lib_errors.html +3 -0
  143. package/docs/api/module-lib_federation-methods.html +3 -0
  144. package/docs/api/module-lib_index.html +3 -0
  145. package/docs/api/module-schema_validator-ValidationError.html +3 -0
  146. package/docs/api/module-schema_validator.ValidationError.html +3 -0
  147. package/docs/api/module-schema_validator.html +3 -0
  148. package/docs/api/module-spatial_h3-operations.html +4 -0
  149. package/docs/api/module-storage_backend-factory.BackendFactory.html +3 -0
  150. package/docs/api/module-storage_backend-factory.html +3 -0
  151. package/docs/api/module-storage_backend-interface-StorageBackend.html +3 -0
  152. package/docs/api/module-storage_backend-interface.StorageBackend.html +3 -0
  153. package/docs/api/module-storage_backend-interface.html +3 -0
  154. package/docs/api/module-storage_backends_activitypub-backend-ActivityPubBackend.html +7 -0
  155. package/docs/api/module-storage_backends_activitypub-backend.ActivityPubBackend.html +3 -0
  156. package/docs/api/module-storage_backends_activitypub-backend.html +3 -0
  157. package/docs/api/module-storage_backends_activitypub_server-ActivityPubServer.html +8 -0
  158. package/docs/api/module-storage_backends_activitypub_server.ActivityPubServer.html +3 -0
  159. package/docs/api/module-storage_backends_activitypub_server.html +3 -0
  160. package/docs/api/module-storage_backends_gundb-backend-GunDBBackend.html +7 -0
  161. package/docs/api/module-storage_backends_gundb-backend.GunDBBackend.html +3 -0
  162. package/docs/api/module-storage_backends_gundb-backend.html +3 -0
  163. package/docs/api/module-storage_backends_nostr-backend-NostrBackend.html +8 -0
  164. package/docs/api/module-storage_backends_nostr-backend.NostrBackend.html +3 -0
  165. package/docs/api/module-storage_backends_nostr-backend.html +3 -0
  166. package/docs/api/module-storage_filesystem-storage-FileSystemStorage.html +5 -0
  167. package/docs/api/module-storage_filesystem-storage-browser-FileSystemStorage.html +3 -0
  168. package/docs/api/module-storage_filesystem-storage-browser.FileSystemStorage.html +3 -0
  169. package/docs/api/module-storage_filesystem-storage-browser.html +3 -0
  170. package/docs/api/module-storage_filesystem-storage.FileSystemStorage.html +3 -0
  171. package/docs/api/module-storage_filesystem-storage.html +3 -0
  172. package/docs/api/module-storage_global-tables.html +3 -0
  173. package/docs/api/module-storage_gun-async.html +3 -0
  174. package/docs/api/module-storage_gun-auth-GunAuth.html +5 -0
  175. package/docs/api/module-storage_gun-auth.GunAuth.html +3 -0
  176. package/docs/api/module-storage_gun-auth.html +3 -0
  177. package/docs/api/module-storage_gun-federation.html +3 -0
  178. package/docs/api/module-storage_gun-references-GunReferenceHandler.html +5 -0
  179. package/docs/api/module-storage_gun-references.GunReferenceHandler.html +3 -0
  180. package/docs/api/module-storage_gun-references.html +3 -0
  181. package/docs/api/module-storage_gun-schema-GunSchemaValidator.html +5 -0
  182. package/docs/api/module-storage_gun-schema.GunSchemaValidator.html +3 -0
  183. package/docs/api/module-storage_gun-schema.html +3 -0
  184. package/docs/api/module-storage_gun-wrapper.html +11 -0
  185. package/docs/api/module-storage_indexeddb-storage-IndexedDBStorage.html +5 -0
  186. package/docs/api/module-storage_indexeddb-storage.IndexedDBStorage.html +3 -0
  187. package/docs/api/module-storage_indexeddb-storage.html +3 -0
  188. package/docs/api/module-storage_key-storage-simple.html +3 -0
  189. package/docs/api/module-storage_key-storage.html +4 -0
  190. package/docs/api/module-storage_memory-storage-MemoryStorage.html +5 -0
  191. package/docs/api/module-storage_memory-storage.MemoryStorage.html +3 -0
  192. package/docs/api/module-storage_memory-storage.html +3 -0
  193. package/docs/api/module-storage_migration-MigrationTool.html +6 -0
  194. package/docs/api/module-storage_migration.MigrationTool.html +3 -0
  195. package/docs/api/module-storage_migration.html +3 -0
  196. package/docs/api/module-storage_nostr-async.html +18 -0
  197. package/docs/api/module-storage_nostr-client-LRUCache.html +3 -0
  198. package/docs/api/module-storage_nostr-client-NostrClient.html +7 -0
  199. package/docs/api/module-storage_nostr-client.NostrClient.html +15 -0
  200. package/docs/api/module-storage_nostr-client.html +6 -0
  201. package/docs/api/module-storage_nostr-wrapper.html +3 -0
  202. package/docs/api/module-storage_outbox-queue-OutboxQueue.html +4 -0
  203. package/docs/api/module-storage_outbox-queue.OutboxQueue.html +3 -0
  204. package/docs/api/module-storage_outbox-queue.html +3 -0
  205. package/docs/api/module-storage_persistent-storage-PersistentStorage.html +3 -0
  206. package/docs/api/module-storage_persistent-storage.html +4 -0
  207. package/docs/api/module-storage_sync-service-SyncService.html +5 -0
  208. package/docs/api/module-storage_sync-service.SyncService.html +3 -0
  209. package/docs/api/module-storage_sync-service.html +3 -0
  210. package/docs/api/module-storage_unified-storage.html +3 -0
  211. package/docs/api/module-subscriptions_manager.SubscriptionRegistry.html +3 -0
  212. package/docs/api/module-subscriptions_manager.html +3 -0
  213. package/docs/api/schema_validator.js.html +113 -0
  214. package/docs/api/scripts/core.js +726 -0
  215. package/docs/api/scripts/core.min.js +23 -0
  216. package/docs/api/scripts/resize.js +90 -0
  217. package/docs/api/scripts/search.js +265 -0
  218. package/docs/api/scripts/search.min.js +6 -0
  219. package/docs/api/scripts/third-party/Apache-License-2.0.txt +202 -0
  220. package/docs/api/scripts/third-party/fuse.js +9 -0
  221. package/docs/api/scripts/third-party/hljs-line-num-original.js +369 -0
  222. package/docs/api/scripts/third-party/hljs-line-num.js +1 -0
  223. package/docs/api/scripts/third-party/hljs-original.js +5171 -0
  224. package/docs/api/scripts/third-party/hljs.js +1 -0
  225. package/docs/api/scripts/third-party/popper.js +5 -0
  226. package/docs/api/scripts/third-party/tippy.js +1 -0
  227. package/docs/api/scripts/third-party/tocbot.js +672 -0
  228. package/docs/api/scripts/third-party/tocbot.min.js +1 -0
  229. package/docs/api/spatial_h3-operations.js.html +129 -0
  230. package/docs/api/storage_backend-factory.js.html +133 -0
  231. package/docs/api/storage_backend-interface.js.html +164 -0
  232. package/docs/api/storage_backends_activitypub-backend.js.html +298 -0
  233. package/docs/api/storage_backends_activitypub_server.js.html +678 -0
  234. package/docs/api/storage_backends_gundb-backend.js.html +878 -0
  235. package/docs/api/storage_backends_nostr-backend.js.html +254 -0
  236. package/docs/api/storage_filesystem-storage-browser.js.html +83 -0
  237. package/docs/api/storage_filesystem-storage.js.html +207 -0
  238. package/docs/api/storage_global-tables.js.html +116 -0
  239. package/docs/api/storage_gun-async.js.html +344 -0
  240. package/docs/api/storage_gun-auth.js.html +376 -0
  241. package/docs/api/storage_gun-federation.js.html +788 -0
  242. package/docs/api/storage_gun-references.js.html +212 -0
  243. package/docs/api/storage_gun-schema.js.html +309 -0
  244. package/docs/api/storage_gun-wrapper.js.html +645 -0
  245. package/docs/api/storage_indexeddb-storage.js.html +224 -0
  246. package/docs/api/storage_key-storage-simple.js.html +102 -0
  247. package/docs/api/storage_key-storage.js.html +171 -0
  248. package/docs/api/storage_memory-storage.js.html +128 -0
  249. package/docs/api/storage_migration.js.html +354 -0
  250. package/docs/api/storage_nostr-async.js.html +1076 -0
  251. package/docs/api/storage_nostr-client.js.html +1598 -0
  252. package/docs/api/storage_nostr-wrapper.js.html +218 -0
  253. package/docs/api/storage_outbox-queue.js.html +248 -0
  254. package/docs/api/storage_persistent-storage.js.html +160 -0
  255. package/docs/api/storage_sync-service.js.html +201 -0
  256. package/docs/api/storage_unified-storage.js.html +157 -0
  257. package/docs/api/styles/clean-jsdoc-theme-base.css +1159 -0
  258. package/docs/api/styles/clean-jsdoc-theme-dark.css +412 -0
  259. package/docs/api/styles/clean-jsdoc-theme-light.css +482 -0
  260. package/docs/api/styles/clean-jsdoc-theme-scrollbar.css +30 -0
  261. package/docs/api/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
  262. package/docs/api/styles/clean-jsdoc-theme.min.css +1 -0
  263. package/docs/api/subscriptions_manager.js.html +162 -0
  264. package/docs/contracts/api-interface.md +793 -0
  265. package/docs/data-model.md +476 -0
  266. package/docs/gun-async-usage.md +338 -0
  267. package/docs/plan.md +349 -0
  268. package/docs/quickstart.md +674 -0
  269. package/docs/research.md +362 -0
  270. package/docs/spec.md +244 -0
  271. package/docs/storage-backends.md +326 -0
  272. package/docs/tasks.md +947 -0
  273. package/examples/demo.html +47 -0
  274. package/examples/holosphere-widget.js +1242 -0
  275. package/examples/widget-demo.html +274 -0
  276. package/examples/widget.html +703 -0
  277. package/jsdoc.json +26 -0
  278. package/package.json +25 -7
  279. package/src/ai/aggregation.js +13 -2
  280. package/src/ai/breakdown.js +12 -2
  281. package/src/ai/classifier.js +14 -3
  282. package/src/ai/council.js +22 -7
  283. package/src/ai/embeddings.js +37 -15
  284. package/src/ai/federation-ai.js +13 -2
  285. package/src/ai/h3-ai.js +14 -2
  286. package/src/ai/index.js +16 -7
  287. package/src/ai/json-ops.js +18 -5
  288. package/src/ai/llm-service.js +62 -31
  289. package/src/ai/nl-query.js +12 -2
  290. package/src/ai/relationships.js +13 -2
  291. package/src/ai/schema-extractor.js +24 -10
  292. package/src/ai/spatial.js +13 -2
  293. package/src/ai/tts.js +25 -8
  294. package/src/cdn-entry.js +22 -0
  295. package/src/content/social-protocols.js +34 -25
  296. package/src/contracts/abis/Appreciative.json +1280 -0
  297. package/src/contracts/abis/AppreciativeFactory.json +101 -0
  298. package/src/contracts/abis/Bundle.json +1438 -0
  299. package/src/contracts/abis/BundleFactory.json +106 -0
  300. package/src/contracts/abis/Holon.json +881 -0
  301. package/src/contracts/abis/Holons.json +330 -0
  302. package/src/contracts/abis/Managed.json +1262 -0
  303. package/src/contracts/abis/ManagedFactory.json +149 -0
  304. package/src/contracts/abis/Membrane.json +261 -0
  305. package/src/contracts/abis/Splitter.json +1624 -0
  306. package/src/contracts/abis/SplitterFactory.json +220 -0
  307. package/src/contracts/abis/TestToken.json +321 -0
  308. package/src/contracts/abis/Zoned.json +1461 -0
  309. package/src/contracts/abis/ZonedFactory.json +154 -0
  310. package/src/contracts/chain-manager.js +403 -0
  311. package/src/contracts/deployer.js +500 -0
  312. package/src/contracts/event-listener.js +539 -0
  313. package/src/contracts/holon-contracts.js +359 -0
  314. package/src/contracts/index.js +82 -0
  315. package/src/contracts/networks.js +229 -0
  316. package/src/contracts/operations.js +687 -0
  317. package/src/contracts/queries.js +638 -0
  318. package/src/core/holosphere.js +487 -6
  319. package/src/crypto/nostr-utils.js +303 -0
  320. package/src/crypto/secp256k1.js +7 -2
  321. package/src/federation/handshake.js +475 -0
  322. package/src/federation/hologram.js +117 -3
  323. package/src/hierarchical/upcast.js +40 -25
  324. package/src/index.js +1501 -1909
  325. package/src/lib/ai-methods.js +657 -0
  326. package/src/lib/contract-methods.js +442 -0
  327. package/src/lib/errors.js +53 -0
  328. package/src/lib/federation-methods.js +345 -0
  329. package/src/lib/index.js +30 -0
  330. package/src/schema/validator.js +22 -3
  331. package/src/spatial/h3-operations.js +19 -3
  332. package/src/storage/backend-factory.js +7 -2
  333. package/src/storage/backend-interface.js +21 -2
  334. package/src/storage/backends/activitypub/server.js +25 -3
  335. package/src/storage/backends/activitypub-backend.js +25 -2
  336. package/src/storage/backends/gundb-backend.js +692 -50
  337. package/src/storage/backends/nostr-backend.js +116 -1
  338. package/src/storage/filesystem-storage-browser.js +42 -2
  339. package/src/storage/filesystem-storage.js +72 -5
  340. package/src/storage/global-tables.js +35 -3
  341. package/src/storage/gun-async.js +75 -15
  342. package/src/storage/gun-auth.js +373 -0
  343. package/src/storage/gun-federation.js +785 -0
  344. package/src/storage/gun-references.js +209 -0
  345. package/src/storage/gun-schema.js +306 -0
  346. package/src/storage/gun-wrapper.js +475 -54
  347. package/src/storage/indexeddb-storage.js +112 -13
  348. package/src/storage/key-storage-simple.js +32 -9
  349. package/src/storage/key-storage.js +45 -13
  350. package/src/storage/memory-storage.js +68 -2
  351. package/src/storage/migration.js +20 -7
  352. package/src/storage/nostr-async.js +412 -122
  353. package/src/storage/nostr-client.js +749 -76
  354. package/src/storage/nostr-wrapper.js +6 -2
  355. package/src/storage/outbox-queue.js +55 -18
  356. package/src/storage/persistent-storage.js +62 -14
  357. package/src/storage/sync-service.js +51 -17
  358. package/src/storage/unified-storage.js +154 -0
  359. package/src/subscriptions/manager.js +34 -17
  360. package/types/index.d.ts +133 -0
  361. package/vite.config.cdn.js +60 -0
  362. package/tests/unit/ai/aggregation.test.js +0 -295
  363. package/tests/unit/ai/breakdown.test.js +0 -446
  364. package/tests/unit/ai/classifier.test.js +0 -294
  365. package/tests/unit/ai/council.test.js +0 -262
  366. package/tests/unit/ai/embeddings.test.js +0 -384
  367. package/tests/unit/ai/federation-ai.test.js +0 -344
  368. package/tests/unit/ai/h3-ai.test.js +0 -458
  369. package/tests/unit/ai/index.test.js +0 -304
  370. package/tests/unit/ai/json-ops.test.js +0 -307
  371. package/tests/unit/ai/llm-service.test.js +0 -390
  372. package/tests/unit/ai/nl-query.test.js +0 -383
  373. package/tests/unit/ai/relationships.test.js +0 -311
  374. package/tests/unit/ai/schema-extractor.test.js +0 -384
  375. package/tests/unit/ai/spatial.test.js +0 -279
  376. package/tests/unit/ai/tts.test.js +0 -279
  377. package/tests/unit/content.test.js +0 -332
  378. package/tests/unit/contract/core.test.js +0 -88
  379. package/tests/unit/contract/crypto.test.js +0 -198
  380. package/tests/unit/contract/data.test.js +0 -223
  381. package/tests/unit/contract/federation.test.js +0 -181
  382. package/tests/unit/contract/hierarchical.test.js +0 -113
  383. package/tests/unit/contract/schema.test.js +0 -114
  384. package/tests/unit/contract/social.test.js +0 -217
  385. package/tests/unit/contract/spatial.test.js +0 -110
  386. package/tests/unit/contract/subscriptions.test.js +0 -128
  387. package/tests/unit/contract/utils.test.js +0 -159
  388. package/tests/unit/core.test.js +0 -152
  389. package/tests/unit/crypto.test.js +0 -328
  390. package/tests/unit/federation.test.js +0 -234
  391. package/tests/unit/gun-async.test.js +0 -252
  392. package/tests/unit/hierarchical.test.js +0 -399
  393. package/tests/unit/integration/scenario-01-geographic-storage.test.js +0 -74
  394. package/tests/unit/integration/scenario-02-federation.test.js +0 -76
  395. package/tests/unit/integration/scenario-03-subscriptions.test.js +0 -102
  396. package/tests/unit/integration/scenario-04-validation.test.js +0 -129
  397. package/tests/unit/integration/scenario-05-hierarchy.test.js +0 -125
  398. package/tests/unit/integration/scenario-06-social.test.js +0 -135
  399. package/tests/unit/integration/scenario-07-persistence.test.js +0 -130
  400. package/tests/unit/integration/scenario-08-authorization.test.js +0 -161
  401. package/tests/unit/integration/scenario-09-cross-dimensional.test.js +0 -139
  402. package/tests/unit/integration/scenario-10-cross-holosphere-capabilities.test.js +0 -357
  403. package/tests/unit/integration/scenario-11-cross-holosphere-federation.test.js +0 -410
  404. package/tests/unit/integration/scenario-12-capability-federated-read.test.js +0 -719
  405. package/tests/unit/performance/benchmark.test.js +0 -85
  406. package/tests/unit/schema.test.js +0 -213
  407. package/tests/unit/spatial.test.js +0 -158
  408. package/tests/unit/storage.test.js +0 -195
  409. package/tests/unit/subscriptions.test.js +0 -328
  410. package/tests/unit/test-data-permanence-debug.js +0 -197
  411. package/tests/unit/test-data-permanence.js +0 -340
  412. package/tests/unit/test-key-persistence-fixed.js +0 -148
  413. package/tests/unit/test-key-persistence.js +0 -172
  414. package/tests/unit/test-relay-permanence.js +0 -376
  415. package/tests/unit/test-second-node.js +0 -95
  416. package/tests/unit/test-simple-write.js +0 -89
  417. /package/{cleanup-test-data.js → scripts/cleanup-test-data.js} +0 -0
  418. /package/{test-ai-real-api.js → scripts/test-ai-real-api.js} +0 -0
@@ -1,159 +0,0 @@
1
- import { describe, it, expect, beforeEach } from 'vitest';
2
- import HoloSphere from '../../../src/index.js';
3
-
4
- describe('Contract: Utility Operations', () => {
5
- let hs;
6
-
7
- beforeEach(() => {
8
- hs = new HoloSphere({ relays: [], appName: 'test-utils' });
9
- });
10
-
11
- describe('isValidH3()', () => {
12
- it('should return true for valid H3 ID', () => {
13
- expect(hs.isValidH3('8928342e20fffff')).toBe(true);
14
- });
15
-
16
- it('should return false for invalid string', () => {
17
- expect(hs.isValidH3('invalid')).toBe(false);
18
- });
19
-
20
- it('should return false for non-string input', () => {
21
- expect(hs.isValidH3(123)).toBe(false);
22
- expect(hs.isValidH3(null)).toBe(false);
23
- expect(hs.isValidH3(undefined)).toBe(false);
24
- expect(hs.isValidH3({})).toBe(false);
25
- });
26
-
27
- it('should validate H3 format (starts with 8, at least 15 chars)', () => {
28
- expect(hs.isValidH3('8a2a1072b59ffff')).toBe(true);
29
- expect(hs.isValidH3('7a2a1072b59ffff')).toBe(false);
30
- expect(hs.isValidH3('8a2a107')).toBe(false);
31
- });
32
- });
33
-
34
- describe('metrics()', () => {
35
- it('should return metrics object', () => {
36
- const metrics = hs.metrics();
37
- expect(typeof metrics).toBe('object');
38
- });
39
-
40
- it('should include writes count', () => {
41
- const metrics = hs.metrics();
42
- expect(metrics).toHaveProperty('writes');
43
- expect(typeof metrics.writes).toBe('number');
44
- });
45
-
46
- it('should include reads count', () => {
47
- const metrics = hs.metrics();
48
- expect(metrics).toHaveProperty('reads');
49
- expect(typeof metrics.reads).toBe('number');
50
- });
51
-
52
- it('should include subscriptions count', () => {
53
- const metrics = hs.metrics();
54
- expect(metrics).toHaveProperty('subscriptions');
55
- expect(typeof metrics.subscriptions).toBe('number');
56
- });
57
-
58
- it('should include federations count', () => {
59
- const metrics = hs.metrics();
60
- expect(metrics).toHaveProperty('federations');
61
- expect(typeof metrics.federations).toBe('number');
62
- });
63
-
64
- it('should include average write time', () => {
65
- const metrics = hs.metrics();
66
- expect(metrics).toHaveProperty('avgWriteTime');
67
- expect(typeof metrics.avgWriteTime).toBe('number');
68
- });
69
-
70
- it('should include average read time', () => {
71
- const metrics = hs.metrics();
72
- expect(metrics).toHaveProperty('avgReadTime');
73
- expect(typeof metrics.avgReadTime).toBe('number');
74
- });
75
-
76
- it('should update metrics after operations', async () => {
77
- const holonId = await hs.toHolon(37.7749, -122.4194, 9);
78
-
79
- const before = hs.metrics();
80
-
81
- await hs.write(holonId, 'test', { id: 'test-1', value: 'data' });
82
- await hs.read(holonId, 'test', 'test-1');
83
-
84
- const after = hs.metrics();
85
-
86
- expect(after.writes).toBeGreaterThanOrEqual(before.writes);
87
- expect(after.reads).toBeGreaterThanOrEqual(before.reads);
88
- });
89
- });
90
-
91
- describe('Error Types', () => {
92
- it('should export ValidationError class', async () => {
93
- try {
94
- await hs.setSchema('test', 'invalid://schema', true);
95
- } catch (err) {
96
- expect(err.constructor.name).toBe('ValidationError');
97
- expect(err).toHaveProperty('errors');
98
- expect(Array.isArray(err.errors)).toBe(true);
99
- }
100
- });
101
-
102
- it('should export AuthorizationError class', async () => {
103
- const holonId = await hs.toHolon(37.7749, -122.4194, 9);
104
-
105
- // Write data with an owner to trigger authorization check
106
- await hs.write(holonId, 'test', {
107
- id: 'others-data',
108
- _creator: '04' + 'fedcba9876543210'.repeat(8) // Different owner
109
- });
110
-
111
- try {
112
- await hs.delete(holonId, 'test', 'others-data');
113
- } catch (err) {
114
- expect(err.constructor.name).toBe('AuthorizationError');
115
- expect(err).toHaveProperty('requiredPermission');
116
- }
117
- });
118
-
119
- it('should export HolosphereError class', () => {
120
- try {
121
- new HoloSphere({ relays: [], appName: 123 });
122
- } catch (err) {
123
- expect(err.constructor.name).toMatch(/Error$/);
124
- }
125
- });
126
-
127
- it('ValidationError should include validation details', async () => {
128
- await hs.setSchema('test', 'test://schema', true);
129
-
130
- try {
131
- await hs.write(
132
- await hs.toHolon(37.7749, -122.4194, 9),
133
- 'test',
134
- { invalid: 'data' },
135
- { strict: true }
136
- );
137
- } catch (err) {
138
- expect(err.message).toBeTruthy();
139
- expect(err.errors).toBeTruthy();
140
- }
141
- });
142
-
143
- it('AuthorizationError should include required permission', async () => {
144
- const holonId = await hs.toHolon(37.7749, -122.4194, 9);
145
-
146
- // Write data with an owner to trigger authorization check
147
- await hs.write(holonId, 'test', {
148
- id: 'protected-data',
149
- _creator: '04' + 'fedcba9876543210'.repeat(8) // Different owner
150
- });
151
-
152
- try {
153
- await hs.delete(holonId, 'test', 'protected-data');
154
- } catch (err) {
155
- expect(err.requiredPermission).toBe('delete');
156
- }
157
- });
158
- });
159
- });
@@ -1,152 +0,0 @@
1
- import { describe, it, expect, beforeEach } from 'vitest';
2
- import HoloSphere from '../../src/index.js';
3
-
4
- describe('Unit: Core Module', () => {
5
- describe('HoloSphere class initialization', () => {
6
- it('should initialize with default config', () => {
7
- const hs = new HoloSphere({ relays: [] });
8
- expect(hs).toBeInstanceOf(HoloSphere);
9
- });
10
-
11
- it('should initialize with custom appName', () => {
12
- const hs = new HoloSphere({ relays: [], appName: 'custom-app' });
13
- expect(hs).toBeInstanceOf(HoloSphere);
14
- });
15
-
16
- it('should initialize with custom peers array', () => {
17
- const hs = new HoloSphere({
18
- appName: 'test',
19
- peers: ['https://relay1.com/gun', 'https://relay2.com/gun']
20
- });
21
- expect(hs).toBeInstanceOf(HoloSphere);
22
- });
23
-
24
- it('should initialize with radisk enabled', () => {
25
- const hs = new HoloSphere({
26
- appName: 'test',
27
- radisk: true
28
- });
29
- expect(hs).toBeInstanceOf(HoloSphere);
30
- });
31
-
32
- it('should initialize with radisk config object', () => {
33
- const hs = new HoloSphere({
34
- appName: 'test',
35
- radisk: { path: './test-data' }
36
- });
37
- expect(hs).toBeInstanceOf(HoloSphere);
38
- });
39
- });
40
-
41
- describe('Config validation', () => {
42
- it('should throw TypeError for invalid appName type', () => {
43
- expect(() => new HoloSphere({ relays: [], appName: 123 })).toThrow(TypeError);
44
- expect(() => new HoloSphere({ relays: [], appName: null })).toThrow(TypeError);
45
- expect(() => new HoloSphere({ relays: [], appName: {} })).toThrow(TypeError);
46
- });
47
-
48
- it('should throw TypeError for invalid relays type', () => {
49
- expect(() => new HoloSphere({ relays: 'not-an-array', appName: 'test' })).toThrow(TypeError);
50
- expect(() => new HoloSphere({ relays: 123, appName: 'test' })).toThrow(TypeError);
51
- });
52
-
53
- it('should throw TypeError for invalid logLevel', () => {
54
- expect(() => new HoloSphere({ logLevel: 'INVALID' })).toThrow(TypeError);
55
- expect(() => new HoloSphere({ logLevel: 123 })).toThrow(TypeError);
56
- });
57
-
58
- it('should validate config defaults are applied', () => {
59
- const hs = new HoloSphere({ relays: [] });
60
- // Should use default appName, radisk: true, logLevel: 'WARN'
61
- expect(hs).toBeInstanceOf(HoloSphere);
62
- });
63
- });
64
-
65
- describe('Nostr client creation', () => {
66
- it('should create Nostr client instance internally', () => {
67
- const hs = new HoloSphere({ relays: [], appName: 'test' });
68
- // Internal client instance should exist
69
- expect(hs).toHaveProperty('client');
70
- });
71
-
72
- it('should configure Nostr client with relays', () => {
73
- const relays = ['wss://relay.example.com'];
74
- const hs = new HoloSphere({ relays, appName: 'test' });
75
- expect(hs).toBeInstanceOf(HoloSphere);
76
- expect(hs.client.relays).toEqual(relays);
77
- });
78
-
79
- it('should accept empty relays array for testing', () => {
80
- const hs = new HoloSphere({ relays: [], appName: 'test' });
81
- expect(hs.client.relays).toEqual([]);
82
- });
83
- });
84
-
85
- describe('Radisk adapter integration', () => {
86
- it('should integrate radisk when enabled', () => {
87
- const hs = new HoloSphere({
88
- appName: 'test',
89
- radisk: true
90
- });
91
- expect(hs).toBeInstanceOf(HoloSphere);
92
- });
93
-
94
- it('should accept radisk path configuration', () => {
95
- const hs = new HoloSphere({
96
- appName: 'test',
97
- radisk: { path: './custom-path' }
98
- });
99
- expect(hs).toBeInstanceOf(HoloSphere);
100
- });
101
-
102
- it('should work without radisk when disabled', () => {
103
- const hs = new HoloSphere({
104
- appName: 'test',
105
- radisk: false
106
- });
107
- expect(hs).toBeInstanceOf(HoloSphere);
108
- });
109
- });
110
-
111
- describe('Log level configuration', () => {
112
- it('should accept ERROR log level', () => {
113
- const hs = new HoloSphere({ logLevel: 'ERROR' });
114
- expect(hs).toBeInstanceOf(HoloSphere);
115
- });
116
-
117
- it('should accept WARN log level', () => {
118
- const hs = new HoloSphere({ logLevel: 'WARN' });
119
- expect(hs).toBeInstanceOf(HoloSphere);
120
- });
121
-
122
- it('should accept INFO log level', () => {
123
- const hs = new HoloSphere({ logLevel: 'INFO' });
124
- expect(hs).toBeInstanceOf(HoloSphere);
125
- });
126
-
127
- it('should accept DEBUG log level', () => {
128
- const hs = new HoloSphere({ logLevel: 'DEBUG' });
129
- expect(hs).toBeInstanceOf(HoloSphere);
130
- });
131
-
132
- it('should use WARN as default log level', () => {
133
- const hs = new HoloSphere({ relays: [] });
134
- // Default should be WARN
135
- expect(hs).toBeInstanceOf(HoloSphere);
136
- });
137
- });
138
-
139
- describe('App configuration storage', () => {
140
- it('should store app configuration internally', () => {
141
- const config = {
142
- appName: 'test-app',
143
- peers: ['https://relay.com/gun'],
144
- logLevel: 'DEBUG'
145
- };
146
-
147
- const hs = new HoloSphere(config);
148
- // Config should be accessible (implementation-specific)
149
- expect(hs).toHaveProperty('config');
150
- });
151
- });
152
- });
@@ -1,328 +0,0 @@
1
- import { describe, it, expect, beforeEach } from 'vitest';
2
- import HoloSphere from '../../src/index.js';
3
- import { getPublicKey } from '../../src/crypto/secp256k1.js';
4
-
5
- describe('Unit: Crypto Module', () => {
6
- let hs;
7
- let privateKey;
8
- let publicKey;
9
-
10
- beforeEach(async () => {
11
- hs = new HoloSphere({ relays: [], appName: 'test-crypto-unit', relays: [] });
12
- // Use valid secp256k1 keys - derive public key from private key
13
- privateKey = '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
14
- publicKey = await getPublicKey(privateKey);
15
- });
16
-
17
- describe('secp256k1 signing and verification', () => {
18
- it('should sign content with private key', async () => {
19
- const content = { message: 'Test message' };
20
- const signature = await hs.sign(content, privateKey);
21
-
22
- expect(typeof signature).toBe('string');
23
- expect(signature).toMatch(/^[0-9a-f]+$/);
24
- expect(signature.length).toBeGreaterThan(0);
25
- });
26
-
27
- it('should verify valid signature', async () => {
28
- const content = { message: 'Test message' };
29
- const signature = await hs.sign(content, privateKey);
30
-
31
- const isValid = await hs.verify(content, signature, publicKey);
32
- expect(isValid).toBe(true);
33
- });
34
-
35
- it('should reject invalid signature', async () => {
36
- const content = { message: 'Test message' };
37
- const invalidSig = 'invalid-signature';
38
-
39
- const isValid = await hs.verify(content, invalidSig, publicKey);
40
- expect(isValid).toBe(false);
41
- });
42
-
43
- it('should reject tampered content', async () => {
44
- const content = { message: 'Original message' };
45
- const signature = await hs.sign(content, privateKey);
46
-
47
- const tamperedContent = { message: 'Tampered message' };
48
- const isValid = await hs.verify(tamperedContent, signature, publicKey);
49
- expect(isValid).toBe(false);
50
- });
51
-
52
- it('should reject wrong public key', async () => {
53
- const content = { message: 'Test message' };
54
- const signature = await hs.sign(content, privateKey);
55
-
56
- const wrongPublicKey = '04' + 'fedcba9876543210'.repeat(8);
57
- const isValid = await hs.verify(content, signature, wrongPublicKey);
58
- expect(isValid).toBe(false);
59
- });
60
-
61
- it('should handle string content', async () => {
62
- const content = 'Plain string content';
63
- const signature = await hs.sign(content, privateKey);
64
-
65
- expect(typeof signature).toBe('string');
66
-
67
- const isValid = await hs.verify(content, signature, publicKey);
68
- expect(isValid).toBe(true);
69
- });
70
-
71
- it('should handle complex object content', async () => {
72
- const content = {
73
- nested: {
74
- deep: {
75
- object: 'value',
76
- array: [1, 2, 3]
77
- }
78
- },
79
- number: 42,
80
- boolean: true
81
- };
82
-
83
- const signature = await hs.sign(content, privateKey);
84
- const isValid = await hs.verify(content, signature, publicKey);
85
- expect(isValid).toBe(true);
86
- });
87
- });
88
-
89
- describe('Capability token generation', () => {
90
- it('should generate capability token', async () => {
91
- const token = await hs.issueCapability(
92
- ['read', 'write'],
93
- { holonId: '8928342e20fffff', lensName: 'test' },
94
- publicKey
95
- );
96
-
97
- expect(typeof token).toBe('string');
98
- expect(token.length).toBeGreaterThan(0);
99
- });
100
-
101
- it('should include permissions in token', async () => {
102
- const token = await hs.issueCapability(
103
- ['read', 'write', 'delete'],
104
- { holonId: '8928342e20fffff', lensName: 'test' },
105
- publicKey
106
- );
107
-
108
- // Token should encode permissions
109
- expect(typeof token).toBe('string');
110
- });
111
-
112
- it('should include scope in token', async () => {
113
- const token = await hs.issueCapability(
114
- ['read'],
115
- { holonId: '8928342e20fffff', lensName: 'specific-lens' },
116
- publicKey
117
- );
118
-
119
- expect(typeof token).toBe('string');
120
- });
121
-
122
- it('should include recipient public key in token', async () => {
123
- const recipientKey = '04' + 'abcdef0123456789'.repeat(8);
124
- const token = await hs.issueCapability(
125
- ['write'],
126
- { holonId: '8928342e20fffff', lensName: 'test' },
127
- recipientKey
128
- );
129
-
130
- expect(typeof token).toBe('string');
131
- });
132
-
133
- it('should accept custom expiration time', async () => {
134
- const token = await hs.issueCapability(
135
- ['read'],
136
- { holonId: '8928342e20fffff', lensName: 'test' },
137
- publicKey,
138
- { expiresIn: 86400000 } // 24 hours
139
- );
140
-
141
- expect(typeof token).toBe('string');
142
- });
143
-
144
- it('should use issuer key when provided', async () => {
145
- const token = await hs.issueCapability(
146
- ['delete'],
147
- { holonId: '8928342e20fffff', lensName: 'test' },
148
- publicKey,
149
- { issuerKey: privateKey }
150
- );
151
-
152
- expect(typeof token).toBe('string');
153
- });
154
- });
155
-
156
- describe('Token expiration validation', () => {
157
- it('should validate non-expired token', async () => {
158
- const token = await hs.issueCapability(
159
- ['read'],
160
- { holonId: '8928342e20fffff', lensName: 'test' },
161
- publicKey,
162
- { expiresIn: 3600000 } // 1 hour
163
- );
164
-
165
- const isValid = await hs.verifyCapability(
166
- token,
167
- 'read',
168
- { holonId: '8928342e20fffff', lensName: 'test' }
169
- );
170
-
171
- expect(isValid).toBe(true);
172
- });
173
-
174
- it('should reject expired token', async () => {
175
- const token = await hs.issueCapability(
176
- ['read'],
177
- { holonId: '8928342e20fffff', lensName: 'test' },
178
- publicKey,
179
- { expiresIn: -1000 } // Already expired
180
- );
181
-
182
- const isValid = await hs.verifyCapability(
183
- token,
184
- 'read',
185
- { holonId: '8928342e20fffff', lensName: 'test' }
186
- );
187
-
188
- expect(isValid).toBe(false);
189
- });
190
-
191
- it('should validate token with sufficient time remaining', async () => {
192
- const token = await hs.issueCapability(
193
- ['write'],
194
- { holonId: '8928342e20fffff', lensName: 'test' },
195
- publicKey,
196
- { expiresIn: 7200000 } // 2 hours
197
- );
198
-
199
- const isValid = await hs.verifyCapability(
200
- token,
201
- 'write',
202
- { holonId: '8928342e20fffff', lensName: 'test' }
203
- );
204
-
205
- expect(isValid).toBe(true);
206
- });
207
- });
208
-
209
- describe('Nonce uniqueness (replay protection)', () => {
210
- it('should include unique nonce in each token', async () => {
211
- const token1 = await hs.issueCapability(
212
- ['read'],
213
- { holonId: '8928342e20fffff', lensName: 'test' },
214
- publicKey
215
- );
216
-
217
- const token2 = await hs.issueCapability(
218
- ['read'],
219
- { holonId: '8928342e20fffff', lensName: 'test' },
220
- publicKey
221
- );
222
-
223
- // Tokens should be different due to unique nonces
224
- expect(token1).not.toBe(token2);
225
- });
226
-
227
- it('should reject replayed token', async () => {
228
- const token = await hs.issueCapability(
229
- ['write'],
230
- { holonId: '8928342e20fffff', lensName: 'test' },
231
- publicKey
232
- );
233
-
234
- // First use should succeed
235
- const firstUse = await hs.verifyCapability(
236
- token,
237
- 'write',
238
- { holonId: '8928342e20fffff', lensName: 'test' }
239
- );
240
- expect(firstUse).toBe(true);
241
-
242
- // Replay should be rejected (if nonce tracking implemented)
243
- // This depends on implementation of replay protection
244
- });
245
- });
246
-
247
- describe('Lazy initialization (module not loaded until first use)', () => {
248
- it('should not load crypto module on HoloSphere initialization', () => {
249
- const hs = new HoloSphere({ relays: [], appName: 'lazy-test', relays: [] });
250
-
251
- // Crypto module should not be loaded yet
252
- expect(hs).toBeInstanceOf(HoloSphere);
253
- });
254
-
255
- it('should lazy load crypto module on first sign() call', async () => {
256
- const hs = new HoloSphere({ relays: [], appName: 'lazy-test', relays: [] });
257
-
258
- // First crypto operation triggers lazy load
259
- const signature = await hs.sign({ test: 'data' }, privateKey);
260
-
261
- expect(typeof signature).toBe('string');
262
- });
263
-
264
- it('should lazy load crypto module on first issueCapability() call', async () => {
265
- const hs = new HoloSphere({ relays: [], appName: 'lazy-test', relays: [] });
266
-
267
- const token = await hs.issueCapability(
268
- ['read'],
269
- { holonId: '8928342e20fffff', lensName: 'test' },
270
- publicKey
271
- );
272
-
273
- expect(typeof token).toBe('string');
274
- });
275
-
276
- it('should reuse loaded crypto module for subsequent operations', async () => {
277
- const hs = new HoloSphere({ relays: [], appName: 'lazy-test', relays: [] });
278
-
279
- // First operation loads module
280
- await hs.sign({ test: 'data' }, privateKey);
281
-
282
- // Subsequent operations use loaded module
283
- const token = await hs.issueCapability(
284
- ['read'],
285
- { holonId: '8928342e20fffff', lensName: 'test' },
286
- publicKey
287
- );
288
-
289
- expect(typeof token).toBe('string');
290
- });
291
- });
292
-
293
- describe('Error handling', () => {
294
- it('should throw error for invalid private key format', async () => {
295
- await expect(
296
- hs.sign({ test: 'data' }, 'invalid-key')
297
- ).rejects.toThrow(Error);
298
- });
299
-
300
- it('should throw error for invalid public key format', async () => {
301
- const signature = await hs.sign({ test: 'data' }, privateKey);
302
-
303
- await expect(
304
- hs.verify({ test: 'data' }, signature, 'invalid-pubkey')
305
- ).rejects.toThrow(Error);
306
- });
307
-
308
- it('should handle empty permissions array', async () => {
309
- await expect(
310
- hs.issueCapability(
311
- [],
312
- { holonId: '8928342e20fffff', lensName: 'test' },
313
- publicKey
314
- )
315
- ).rejects.toThrow(Error);
316
- });
317
-
318
- it('should handle invalid scope', async () => {
319
- await expect(
320
- hs.issueCapability(
321
- ['read'],
322
- { holonId: '', lensName: '' },
323
- publicKey
324
- )
325
- ).rejects.toThrow(Error);
326
- });
327
- });
328
- });