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.
- package/CHANGELOG.md +473 -0
- package/FEATURES.md +431 -0
- package/LICENSE +29 -166
- package/LICENSE-AGPL.md +180 -0
- package/README.md +97 -16
- package/dist/2019-D2OG2idw.js +6680 -0
- package/dist/2019-D2OG2idw.js.map +1 -0
- package/dist/2019-EION3wKo.cjs +8 -0
- package/dist/2019-EION3wKo.cjs.map +1 -0
- package/dist/_commonjsHelpers-C37NGDzP.cjs +2 -0
- package/dist/_commonjsHelpers-C37NGDzP.cjs.map +1 -0
- package/dist/_commonjsHelpers-CUmg6egw.js +7 -0
- package/dist/_commonjsHelpers-CUmg6egw.js.map +1 -0
- package/dist/browser-BSniCNqO.js +3058 -0
- package/dist/browser-BSniCNqO.js.map +1 -0
- package/dist/browser-Cq59Ij19.cjs +2 -0
- package/dist/browser-Cq59Ij19.cjs.map +1 -0
- package/dist/cdn/holosphere.min.js +55 -0
- package/dist/cdn/holosphere.min.js.map +1 -0
- package/dist/cjs/holosphere.cjs +2 -0
- package/dist/cjs/holosphere.cjs.map +1 -0
- package/dist/esm/holosphere.js +53 -0
- package/dist/esm/holosphere.js.map +1 -0
- package/dist/index-DDGt_V9o.cjs +12 -0
- package/dist/index-DDGt_V9o.cjs.map +1 -0
- package/dist/index-DJXftyvB.js +39841 -0
- package/dist/index-DJXftyvB.js.map +1 -0
- package/dist/index-DMbdcMtK.cjs +18 -0
- package/dist/index-DMbdcMtK.cjs.map +1 -0
- package/dist/index-DeZ1xz_s.js +15104 -0
- package/dist/index-DeZ1xz_s.js.map +1 -0
- package/dist/indexeddb-storage-BFt6hMeF.js +176 -0
- package/dist/indexeddb-storage-BFt6hMeF.js.map +1 -0
- package/dist/indexeddb-storage-BK5tv4Sh.cjs +2 -0
- package/dist/indexeddb-storage-BK5tv4Sh.cjs.map +1 -0
- package/dist/memory-storage-C9HuoL2E.js +91 -0
- package/dist/memory-storage-C9HuoL2E.js.map +1 -0
- package/dist/memory-storage-Dao7jfYG.cjs +2 -0
- package/dist/memory-storage-Dao7jfYG.cjs.map +1 -0
- package/dist/secp256k1-BbKzbLtD.cjs +12 -0
- package/dist/secp256k1-BbKzbLtD.cjs.map +1 -0
- package/dist/secp256k1-CreY7Pcl.js +1890 -0
- package/dist/secp256k1-CreY7Pcl.js.map +1 -0
- package/docs/CONTRACTS.md +797 -0
- package/docs/FOSDEM_PROPOSAL.md +388 -0
- package/docs/LOCALFIRST.md +266 -0
- package/docs/api/ai_aggregation.js.html +333 -0
- package/docs/api/ai_breakdown.js.html +524 -0
- package/docs/api/ai_classifier.js.html +231 -0
- package/docs/api/ai_council.js.html +246 -0
- package/docs/api/ai_embeddings.js.html +304 -0
- package/docs/api/ai_federation-ai.js.html +338 -0
- package/docs/api/ai_h3-ai.js.html +970 -0
- package/docs/api/ai_index.js.html +124 -0
- package/docs/api/ai_json-ops.js.html +241 -0
- package/docs/api/ai_llm-service.js.html +239 -0
- package/docs/api/ai_nl-query.js.html +236 -0
- package/docs/api/ai_relationships.js.html +367 -0
- package/docs/api/ai_schema-extractor.js.html +235 -0
- package/docs/api/ai_spatial.js.html +307 -0
- package/docs/api/ai_tts.js.html +214 -0
- package/docs/api/content_social-protocols.js.html +180 -0
- package/docs/api/core_holosphere.js.html +757 -0
- package/docs/api/crypto_nostr-utils.js.html +306 -0
- package/docs/api/crypto_secp256k1.js.html +267 -0
- package/docs/api/data/search.json +1 -0
- package/docs/api/federation_discovery.js.html +337 -0
- package/docs/api/federation_handshake.js.html +478 -0
- package/docs/api/federation_hologram.js.html +1053 -0
- package/docs/api/federation_registry.js.html +389 -0
- package/docs/api/fonts/Inconsolata-Regular.ttf +0 -0
- package/docs/api/fonts/OpenSans-Regular.ttf +0 -0
- package/docs/api/fonts/WorkSans-Bold.ttf +0 -0
- package/docs/api/global.html +3 -0
- package/docs/api/hierarchical_upcast.js.html +128 -0
- package/docs/api/index.html +265 -0
- package/docs/api/index.js.html +1868 -0
- package/docs/api/lib_ai-methods.js.html +660 -0
- package/docs/api/lib_contract-methods.js.html +445 -0
- package/docs/api/lib_errors.js.html +56 -0
- package/docs/api/lib_federation-methods.js.html +348 -0
- package/docs/api/lib_index.js.html +33 -0
- package/docs/api/module-ai.html +5 -0
- package/docs/api/module-ai_aggregation-SmartAggregation.html +6 -0
- package/docs/api/module-ai_aggregation.SmartAggregation.html +3 -0
- package/docs/api/module-ai_aggregation.html +3 -0
- package/docs/api/module-ai_breakdown-TaskBreakdown.html +5 -0
- package/docs/api/module-ai_breakdown.TaskBreakdown.html +3 -0
- package/docs/api/module-ai_breakdown.html +3 -0
- package/docs/api/module-ai_classifier-Classifier.html +6 -0
- package/docs/api/module-ai_classifier.Classifier.html +3 -0
- package/docs/api/module-ai_classifier.html +3 -0
- package/docs/api/module-ai_council-Council.html +6 -0
- package/docs/api/module-ai_council.Council.html +3 -0
- package/docs/api/module-ai_council.html +3 -0
- package/docs/api/module-ai_embeddings-Embeddings.html +5 -0
- package/docs/api/module-ai_embeddings.Embeddings.html +3 -0
- package/docs/api/module-ai_embeddings.html +3 -0
- package/docs/api/module-ai_federation-ai-FederationAdvisor.html +6 -0
- package/docs/api/module-ai_federation-ai.FederationAdvisor.html +3 -0
- package/docs/api/module-ai_federation-ai.html +3 -0
- package/docs/api/module-ai_h3-ai-H3AI.html +6 -0
- package/docs/api/module-ai_h3-ai.H3AI.html +3 -0
- package/docs/api/module-ai_h3-ai.html +3 -0
- package/docs/api/module-ai_json-ops-JSONOps.html +5 -0
- package/docs/api/module-ai_json-ops.JSONOps.html +3 -0
- package/docs/api/module-ai_json-ops.html +3 -0
- package/docs/api/module-ai_llm-service-LLMService.html +5 -0
- package/docs/api/module-ai_llm-service.LLMService.html +3 -0
- package/docs/api/module-ai_llm-service.html +3 -0
- package/docs/api/module-ai_nl-query-NLQuery.html +5 -0
- package/docs/api/module-ai_nl-query.NLQuery.html +3 -0
- package/docs/api/module-ai_nl-query.html +3 -0
- package/docs/api/module-ai_relationships-RelationshipDiscovery.html +6 -0
- package/docs/api/module-ai_relationships.RelationshipDiscovery.html +3 -0
- package/docs/api/module-ai_relationships.html +3 -0
- package/docs/api/module-ai_schema-extractor-SchemaExtractor.html +5 -0
- package/docs/api/module-ai_schema-extractor.SchemaExtractor.html +3 -0
- package/docs/api/module-ai_schema-extractor.html +3 -0
- package/docs/api/module-ai_spatial-SpatialAnalysis.html +6 -0
- package/docs/api/module-ai_spatial.SpatialAnalysis.html +3 -0
- package/docs/api/module-ai_spatial.html +3 -0
- package/docs/api/module-ai_tts-TTS.html +5 -0
- package/docs/api/module-ai_tts.TTS.html +3 -0
- package/docs/api/module-ai_tts.html +3 -0
- package/docs/api/module-content_social-protocols.html +3 -0
- package/docs/api/module-core_holosphere-HoloSphere.html +6 -0
- package/docs/api/module-core_holosphere.HoloSphere.html +3 -0
- package/docs/api/module-core_holosphere.html +3 -0
- package/docs/api/module-crypto_nostr-utils.html +3 -0
- package/docs/api/module-crypto_secp256k1.html +3 -0
- package/docs/api/module-federation_hologram.html +3 -0
- package/docs/api/module-hierarchical_upcast.html +3 -0
- package/docs/api/module-holosphere-HoloSphereBase.html +3 -0
- package/docs/api/module-holosphere.html +3 -0
- package/docs/api/module-lib_ai-methods.html +3 -0
- package/docs/api/module-lib_contract-methods.html +3 -0
- package/docs/api/module-lib_errors-AuthorizationError.html +3 -0
- package/docs/api/module-lib_errors-ValidationError.html +3 -0
- package/docs/api/module-lib_errors.AuthorizationError.html +3 -0
- package/docs/api/module-lib_errors.ValidationError.html +3 -0
- package/docs/api/module-lib_errors.html +3 -0
- package/docs/api/module-lib_federation-methods.html +3 -0
- package/docs/api/module-lib_index.html +3 -0
- package/docs/api/module-schema_validator-ValidationError.html +3 -0
- package/docs/api/module-schema_validator.ValidationError.html +3 -0
- package/docs/api/module-schema_validator.html +3 -0
- package/docs/api/module-spatial_h3-operations.html +4 -0
- package/docs/api/module-storage_backend-factory.BackendFactory.html +3 -0
- package/docs/api/module-storage_backend-factory.html +3 -0
- package/docs/api/module-storage_backend-interface-StorageBackend.html +3 -0
- package/docs/api/module-storage_backend-interface.StorageBackend.html +3 -0
- package/docs/api/module-storage_backend-interface.html +3 -0
- package/docs/api/module-storage_backends_activitypub-backend-ActivityPubBackend.html +7 -0
- package/docs/api/module-storage_backends_activitypub-backend.ActivityPubBackend.html +3 -0
- package/docs/api/module-storage_backends_activitypub-backend.html +3 -0
- package/docs/api/module-storage_backends_activitypub_server-ActivityPubServer.html +8 -0
- package/docs/api/module-storage_backends_activitypub_server.ActivityPubServer.html +3 -0
- package/docs/api/module-storage_backends_activitypub_server.html +3 -0
- package/docs/api/module-storage_backends_gundb-backend-GunDBBackend.html +7 -0
- package/docs/api/module-storage_backends_gundb-backend.GunDBBackend.html +3 -0
- package/docs/api/module-storage_backends_gundb-backend.html +3 -0
- package/docs/api/module-storage_backends_nostr-backend-NostrBackend.html +8 -0
- package/docs/api/module-storage_backends_nostr-backend.NostrBackend.html +3 -0
- package/docs/api/module-storage_backends_nostr-backend.html +3 -0
- package/docs/api/module-storage_filesystem-storage-FileSystemStorage.html +5 -0
- package/docs/api/module-storage_filesystem-storage-browser-FileSystemStorage.html +3 -0
- package/docs/api/module-storage_filesystem-storage-browser.FileSystemStorage.html +3 -0
- package/docs/api/module-storage_filesystem-storage-browser.html +3 -0
- package/docs/api/module-storage_filesystem-storage.FileSystemStorage.html +3 -0
- package/docs/api/module-storage_filesystem-storage.html +3 -0
- package/docs/api/module-storage_global-tables.html +3 -0
- package/docs/api/module-storage_gun-async.html +3 -0
- package/docs/api/module-storage_gun-auth-GunAuth.html +5 -0
- package/docs/api/module-storage_gun-auth.GunAuth.html +3 -0
- package/docs/api/module-storage_gun-auth.html +3 -0
- package/docs/api/module-storage_gun-federation.html +3 -0
- package/docs/api/module-storage_gun-references-GunReferenceHandler.html +5 -0
- package/docs/api/module-storage_gun-references.GunReferenceHandler.html +3 -0
- package/docs/api/module-storage_gun-references.html +3 -0
- package/docs/api/module-storage_gun-schema-GunSchemaValidator.html +5 -0
- package/docs/api/module-storage_gun-schema.GunSchemaValidator.html +3 -0
- package/docs/api/module-storage_gun-schema.html +3 -0
- package/docs/api/module-storage_gun-wrapper.html +11 -0
- package/docs/api/module-storage_indexeddb-storage-IndexedDBStorage.html +5 -0
- package/docs/api/module-storage_indexeddb-storage.IndexedDBStorage.html +3 -0
- package/docs/api/module-storage_indexeddb-storage.html +3 -0
- package/docs/api/module-storage_key-storage-simple.html +3 -0
- package/docs/api/module-storage_key-storage.html +4 -0
- package/docs/api/module-storage_memory-storage-MemoryStorage.html +5 -0
- package/docs/api/module-storage_memory-storage.MemoryStorage.html +3 -0
- package/docs/api/module-storage_memory-storage.html +3 -0
- package/docs/api/module-storage_migration-MigrationTool.html +6 -0
- package/docs/api/module-storage_migration.MigrationTool.html +3 -0
- package/docs/api/module-storage_migration.html +3 -0
- package/docs/api/module-storage_nostr-async.html +18 -0
- package/docs/api/module-storage_nostr-client-LRUCache.html +3 -0
- package/docs/api/module-storage_nostr-client-NostrClient.html +7 -0
- package/docs/api/module-storage_nostr-client.NostrClient.html +15 -0
- package/docs/api/module-storage_nostr-client.html +6 -0
- package/docs/api/module-storage_nostr-wrapper.html +3 -0
- package/docs/api/module-storage_outbox-queue-OutboxQueue.html +4 -0
- package/docs/api/module-storage_outbox-queue.OutboxQueue.html +3 -0
- package/docs/api/module-storage_outbox-queue.html +3 -0
- package/docs/api/module-storage_persistent-storage-PersistentStorage.html +3 -0
- package/docs/api/module-storage_persistent-storage.html +4 -0
- package/docs/api/module-storage_sync-service-SyncService.html +5 -0
- package/docs/api/module-storage_sync-service.SyncService.html +3 -0
- package/docs/api/module-storage_sync-service.html +3 -0
- package/docs/api/module-storage_unified-storage.html +3 -0
- package/docs/api/module-subscriptions_manager.SubscriptionRegistry.html +3 -0
- package/docs/api/module-subscriptions_manager.html +3 -0
- package/docs/api/schema_validator.js.html +113 -0
- package/docs/api/scripts/core.js +726 -0
- package/docs/api/scripts/core.min.js +23 -0
- package/docs/api/scripts/resize.js +90 -0
- package/docs/api/scripts/search.js +265 -0
- package/docs/api/scripts/search.min.js +6 -0
- package/docs/api/scripts/third-party/Apache-License-2.0.txt +202 -0
- package/docs/api/scripts/third-party/fuse.js +9 -0
- package/docs/api/scripts/third-party/hljs-line-num-original.js +369 -0
- package/docs/api/scripts/third-party/hljs-line-num.js +1 -0
- package/docs/api/scripts/third-party/hljs-original.js +5171 -0
- package/docs/api/scripts/third-party/hljs.js +1 -0
- package/docs/api/scripts/third-party/popper.js +5 -0
- package/docs/api/scripts/third-party/tippy.js +1 -0
- package/docs/api/scripts/third-party/tocbot.js +672 -0
- package/docs/api/scripts/third-party/tocbot.min.js +1 -0
- package/docs/api/spatial_h3-operations.js.html +129 -0
- package/docs/api/storage_backend-factory.js.html +133 -0
- package/docs/api/storage_backend-interface.js.html +164 -0
- package/docs/api/storage_backends_activitypub-backend.js.html +298 -0
- package/docs/api/storage_backends_activitypub_server.js.html +678 -0
- package/docs/api/storage_backends_gundb-backend.js.html +878 -0
- package/docs/api/storage_backends_nostr-backend.js.html +254 -0
- package/docs/api/storage_filesystem-storage-browser.js.html +83 -0
- package/docs/api/storage_filesystem-storage.js.html +207 -0
- package/docs/api/storage_global-tables.js.html +116 -0
- package/docs/api/storage_gun-async.js.html +344 -0
- package/docs/api/storage_gun-auth.js.html +376 -0
- package/docs/api/storage_gun-federation.js.html +788 -0
- package/docs/api/storage_gun-references.js.html +212 -0
- package/docs/api/storage_gun-schema.js.html +309 -0
- package/docs/api/storage_gun-wrapper.js.html +645 -0
- package/docs/api/storage_indexeddb-storage.js.html +224 -0
- package/docs/api/storage_key-storage-simple.js.html +102 -0
- package/docs/api/storage_key-storage.js.html +171 -0
- package/docs/api/storage_memory-storage.js.html +128 -0
- package/docs/api/storage_migration.js.html +354 -0
- package/docs/api/storage_nostr-async.js.html +1076 -0
- package/docs/api/storage_nostr-client.js.html +1598 -0
- package/docs/api/storage_nostr-wrapper.js.html +218 -0
- package/docs/api/storage_outbox-queue.js.html +248 -0
- package/docs/api/storage_persistent-storage.js.html +160 -0
- package/docs/api/storage_sync-service.js.html +201 -0
- package/docs/api/storage_unified-storage.js.html +157 -0
- package/docs/api/styles/clean-jsdoc-theme-base.css +1159 -0
- package/docs/api/styles/clean-jsdoc-theme-dark.css +412 -0
- package/docs/api/styles/clean-jsdoc-theme-light.css +482 -0
- package/docs/api/styles/clean-jsdoc-theme-scrollbar.css +30 -0
- package/docs/api/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
- package/docs/api/styles/clean-jsdoc-theme.min.css +1 -0
- package/docs/api/subscriptions_manager.js.html +162 -0
- package/docs/contracts/api-interface.md +793 -0
- package/docs/data-model.md +476 -0
- package/docs/gun-async-usage.md +338 -0
- package/docs/plan.md +349 -0
- package/docs/quickstart.md +674 -0
- package/docs/research.md +362 -0
- package/docs/spec.md +244 -0
- package/docs/storage-backends.md +326 -0
- package/docs/tasks.md +947 -0
- package/examples/demo.html +47 -0
- package/examples/holosphere-widget.js +1242 -0
- package/examples/widget-demo.html +274 -0
- package/examples/widget.html +703 -0
- package/jsdoc.json +26 -0
- package/package.json +25 -7
- package/src/ai/aggregation.js +13 -2
- package/src/ai/breakdown.js +12 -2
- package/src/ai/classifier.js +14 -3
- package/src/ai/council.js +22 -7
- package/src/ai/embeddings.js +37 -15
- package/src/ai/federation-ai.js +13 -2
- package/src/ai/h3-ai.js +14 -2
- package/src/ai/index.js +16 -7
- package/src/ai/json-ops.js +18 -5
- package/src/ai/llm-service.js +62 -31
- package/src/ai/nl-query.js +12 -2
- package/src/ai/relationships.js +13 -2
- package/src/ai/schema-extractor.js +24 -10
- package/src/ai/spatial.js +13 -2
- package/src/ai/tts.js +25 -8
- package/src/cdn-entry.js +22 -0
- package/src/content/social-protocols.js +34 -25
- package/src/contracts/abis/Appreciative.json +1280 -0
- package/src/contracts/abis/AppreciativeFactory.json +101 -0
- package/src/contracts/abis/Bundle.json +1438 -0
- package/src/contracts/abis/BundleFactory.json +106 -0
- package/src/contracts/abis/Holon.json +881 -0
- package/src/contracts/abis/Holons.json +330 -0
- package/src/contracts/abis/Managed.json +1262 -0
- package/src/contracts/abis/ManagedFactory.json +149 -0
- package/src/contracts/abis/Membrane.json +261 -0
- package/src/contracts/abis/Splitter.json +1624 -0
- package/src/contracts/abis/SplitterFactory.json +220 -0
- package/src/contracts/abis/TestToken.json +321 -0
- package/src/contracts/abis/Zoned.json +1461 -0
- package/src/contracts/abis/ZonedFactory.json +154 -0
- package/src/contracts/chain-manager.js +403 -0
- package/src/contracts/deployer.js +500 -0
- package/src/contracts/event-listener.js +539 -0
- package/src/contracts/holon-contracts.js +359 -0
- package/src/contracts/index.js +82 -0
- package/src/contracts/networks.js +229 -0
- package/src/contracts/operations.js +687 -0
- package/src/contracts/queries.js +638 -0
- package/src/core/holosphere.js +487 -6
- package/src/crypto/nostr-utils.js +303 -0
- package/src/crypto/secp256k1.js +7 -2
- package/src/federation/handshake.js +475 -0
- package/src/federation/hologram.js +117 -3
- package/src/hierarchical/upcast.js +40 -25
- package/src/index.js +1501 -1909
- package/src/lib/ai-methods.js +657 -0
- package/src/lib/contract-methods.js +442 -0
- package/src/lib/errors.js +53 -0
- package/src/lib/federation-methods.js +345 -0
- package/src/lib/index.js +30 -0
- package/src/schema/validator.js +22 -3
- package/src/spatial/h3-operations.js +19 -3
- package/src/storage/backend-factory.js +7 -2
- package/src/storage/backend-interface.js +21 -2
- package/src/storage/backends/activitypub/server.js +25 -3
- package/src/storage/backends/activitypub-backend.js +25 -2
- package/src/storage/backends/gundb-backend.js +692 -50
- package/src/storage/backends/nostr-backend.js +116 -1
- package/src/storage/filesystem-storage-browser.js +42 -2
- package/src/storage/filesystem-storage.js +72 -5
- package/src/storage/global-tables.js +35 -3
- package/src/storage/gun-async.js +75 -15
- package/src/storage/gun-auth.js +373 -0
- package/src/storage/gun-federation.js +785 -0
- package/src/storage/gun-references.js +209 -0
- package/src/storage/gun-schema.js +306 -0
- package/src/storage/gun-wrapper.js +475 -54
- package/src/storage/indexeddb-storage.js +112 -13
- package/src/storage/key-storage-simple.js +32 -9
- package/src/storage/key-storage.js +45 -13
- package/src/storage/memory-storage.js +68 -2
- package/src/storage/migration.js +20 -7
- package/src/storage/nostr-async.js +412 -122
- package/src/storage/nostr-client.js +749 -76
- package/src/storage/nostr-wrapper.js +6 -2
- package/src/storage/outbox-queue.js +55 -18
- package/src/storage/persistent-storage.js +62 -14
- package/src/storage/sync-service.js +51 -17
- package/src/storage/unified-storage.js +154 -0
- package/src/subscriptions/manager.js +34 -17
- package/types/index.d.ts +133 -0
- package/vite.config.cdn.js +60 -0
- package/tests/unit/ai/aggregation.test.js +0 -295
- package/tests/unit/ai/breakdown.test.js +0 -446
- package/tests/unit/ai/classifier.test.js +0 -294
- package/tests/unit/ai/council.test.js +0 -262
- package/tests/unit/ai/embeddings.test.js +0 -384
- package/tests/unit/ai/federation-ai.test.js +0 -344
- package/tests/unit/ai/h3-ai.test.js +0 -458
- package/tests/unit/ai/index.test.js +0 -304
- package/tests/unit/ai/json-ops.test.js +0 -307
- package/tests/unit/ai/llm-service.test.js +0 -390
- package/tests/unit/ai/nl-query.test.js +0 -383
- package/tests/unit/ai/relationships.test.js +0 -311
- package/tests/unit/ai/schema-extractor.test.js +0 -384
- package/tests/unit/ai/spatial.test.js +0 -279
- package/tests/unit/ai/tts.test.js +0 -279
- package/tests/unit/content.test.js +0 -332
- package/tests/unit/contract/core.test.js +0 -88
- package/tests/unit/contract/crypto.test.js +0 -198
- package/tests/unit/contract/data.test.js +0 -223
- package/tests/unit/contract/federation.test.js +0 -181
- package/tests/unit/contract/hierarchical.test.js +0 -113
- package/tests/unit/contract/schema.test.js +0 -114
- package/tests/unit/contract/social.test.js +0 -217
- package/tests/unit/contract/spatial.test.js +0 -110
- package/tests/unit/contract/subscriptions.test.js +0 -128
- package/tests/unit/contract/utils.test.js +0 -159
- package/tests/unit/core.test.js +0 -152
- package/tests/unit/crypto.test.js +0 -328
- package/tests/unit/federation.test.js +0 -234
- package/tests/unit/gun-async.test.js +0 -252
- package/tests/unit/hierarchical.test.js +0 -399
- package/tests/unit/integration/scenario-01-geographic-storage.test.js +0 -74
- package/tests/unit/integration/scenario-02-federation.test.js +0 -76
- package/tests/unit/integration/scenario-03-subscriptions.test.js +0 -102
- package/tests/unit/integration/scenario-04-validation.test.js +0 -129
- package/tests/unit/integration/scenario-05-hierarchy.test.js +0 -125
- package/tests/unit/integration/scenario-06-social.test.js +0 -135
- package/tests/unit/integration/scenario-07-persistence.test.js +0 -130
- package/tests/unit/integration/scenario-08-authorization.test.js +0 -161
- package/tests/unit/integration/scenario-09-cross-dimensional.test.js +0 -139
- package/tests/unit/integration/scenario-10-cross-holosphere-capabilities.test.js +0 -357
- package/tests/unit/integration/scenario-11-cross-holosphere-federation.test.js +0 -410
- package/tests/unit/integration/scenario-12-capability-federated-read.test.js +0 -719
- package/tests/unit/performance/benchmark.test.js +0 -85
- package/tests/unit/schema.test.js +0 -213
- package/tests/unit/spatial.test.js +0 -158
- package/tests/unit/storage.test.js +0 -195
- package/tests/unit/subscriptions.test.js +0 -328
- package/tests/unit/test-data-permanence-debug.js +0 -197
- package/tests/unit/test-data-permanence.js +0 -340
- package/tests/unit/test-key-persistence-fixed.js +0 -148
- package/tests/unit/test-key-persistence.js +0 -172
- package/tests/unit/test-relay-permanence.js +0 -376
- package/tests/unit/test-second-node.js +0 -95
- package/tests/unit/test-simple-write.js +0 -89
- /package/{cleanup-test-data.js → scripts/cleanup-test-data.js} +0 -0
- /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
|
-
});
|
package/tests/unit/core.test.js
DELETED
|
@@ -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
|
-
});
|