@originals/sdk 1.2.0 → 1.4.3
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/package.json +4 -1
- package/.eslintrc.json +0 -33
- package/.turbo/turbo-build.log +0 -1
- package/dist/adapters/FeeOracleMock.d.ts +0 -6
- package/dist/adapters/FeeOracleMock.js +0 -8
- package/dist/adapters/index.d.ts +0 -4
- package/dist/adapters/index.js +0 -4
- package/dist/adapters/providers/OrdHttpProvider.d.ts +0 -56
- package/dist/adapters/providers/OrdHttpProvider.js +0 -110
- package/dist/adapters/providers/OrdMockProvider.d.ts +0 -70
- package/dist/adapters/providers/OrdMockProvider.js +0 -75
- package/dist/adapters/types.d.ts +0 -71
- package/dist/adapters/types.js +0 -1
- package/dist/bitcoin/BitcoinManager.d.ts +0 -15
- package/dist/bitcoin/BitcoinManager.js +0 -262
- package/dist/bitcoin/BroadcastClient.d.ts +0 -30
- package/dist/bitcoin/BroadcastClient.js +0 -35
- package/dist/bitcoin/OrdinalsClient.d.ts +0 -21
- package/dist/bitcoin/OrdinalsClient.js +0 -105
- package/dist/bitcoin/PSBTBuilder.d.ts +0 -24
- package/dist/bitcoin/PSBTBuilder.js +0 -80
- package/dist/bitcoin/fee-calculation.d.ts +0 -14
- package/dist/bitcoin/fee-calculation.js +0 -31
- package/dist/bitcoin/providers/OrdNodeProvider.d.ts +0 -38
- package/dist/bitcoin/providers/OrdNodeProvider.js +0 -67
- package/dist/bitcoin/providers/OrdinalsProvider.d.ts +0 -33
- package/dist/bitcoin/providers/OrdinalsProvider.js +0 -50
- package/dist/bitcoin/providers/types.d.ts +0 -63
- package/dist/bitcoin/providers/types.js +0 -1
- package/dist/bitcoin/transactions/commit.d.ts +0 -89
- package/dist/bitcoin/transactions/commit.js +0 -311
- package/dist/bitcoin/transactions/index.d.ts +0 -7
- package/dist/bitcoin/transactions/index.js +0 -8
- package/dist/bitcoin/transfer.d.ts +0 -9
- package/dist/bitcoin/transfer.js +0 -26
- package/dist/bitcoin/utxo-selection.d.ts +0 -78
- package/dist/bitcoin/utxo-selection.js +0 -237
- package/dist/bitcoin/utxo.d.ts +0 -26
- package/dist/bitcoin/utxo.js +0 -78
- package/dist/contexts/credentials-v1.json +0 -195
- package/dist/contexts/credentials-v2-examples.json +0 -5
- package/dist/contexts/credentials-v2.json +0 -301
- package/dist/contexts/credentials.json +0 -195
- package/dist/contexts/data-integrity-v2.json +0 -81
- package/dist/contexts/dids.json +0 -57
- package/dist/contexts/ed255192020.json +0 -93
- package/dist/contexts/ordinals-plus.json +0 -23
- package/dist/contexts/originals.json +0 -22
- package/dist/core/OriginalsSDK.d.ts +0 -158
- package/dist/core/OriginalsSDK.js +0 -274
- package/dist/crypto/Multikey.d.ts +0 -30
- package/dist/crypto/Multikey.js +0 -149
- package/dist/crypto/Signer.d.ts +0 -21
- package/dist/crypto/Signer.js +0 -196
- package/dist/crypto/noble-init.d.ts +0 -18
- package/dist/crypto/noble-init.js +0 -106
- package/dist/did/BtcoDidResolver.d.ts +0 -57
- package/dist/did/BtcoDidResolver.js +0 -166
- package/dist/did/DIDManager.d.ts +0 -101
- package/dist/did/DIDManager.js +0 -493
- package/dist/did/Ed25519Verifier.d.ts +0 -30
- package/dist/did/Ed25519Verifier.js +0 -59
- package/dist/did/KeyManager.d.ts +0 -17
- package/dist/did/KeyManager.js +0 -207
- package/dist/did/WebVHManager.d.ts +0 -100
- package/dist/did/WebVHManager.js +0 -304
- package/dist/did/createBtcoDidDocument.d.ts +0 -10
- package/dist/did/createBtcoDidDocument.js +0 -42
- package/dist/did/providers/OrdinalsClientProviderAdapter.d.ts +0 -23
- package/dist/did/providers/OrdinalsClientProviderAdapter.js +0 -51
- package/dist/events/EventEmitter.d.ts +0 -115
- package/dist/events/EventEmitter.js +0 -198
- package/dist/events/index.d.ts +0 -7
- package/dist/events/index.js +0 -6
- package/dist/events/types.d.ts +0 -286
- package/dist/events/types.js +0 -9
- package/dist/examples/basic-usage.d.ts +0 -3
- package/dist/examples/basic-usage.js +0 -62
- package/dist/examples/run.d.ts +0 -1
- package/dist/examples/run.js +0 -4
- package/dist/index.d.ts +0 -39
- package/dist/index.js +0 -47
- package/dist/lifecycle/BatchOperations.d.ts +0 -147
- package/dist/lifecycle/BatchOperations.js +0 -251
- package/dist/lifecycle/LifecycleManager.d.ts +0 -116
- package/dist/lifecycle/LifecycleManager.js +0 -971
- package/dist/lifecycle/OriginalsAsset.d.ts +0 -164
- package/dist/lifecycle/OriginalsAsset.js +0 -380
- package/dist/lifecycle/ProvenanceQuery.d.ts +0 -126
- package/dist/lifecycle/ProvenanceQuery.js +0 -220
- package/dist/lifecycle/ResourceVersioning.d.ts +0 -73
- package/dist/lifecycle/ResourceVersioning.js +0 -127
- package/dist/migration/MigrationManager.d.ts +0 -86
- package/dist/migration/MigrationManager.js +0 -412
- package/dist/migration/audit/AuditLogger.d.ts +0 -51
- package/dist/migration/audit/AuditLogger.js +0 -156
- package/dist/migration/checkpoint/CheckpointManager.d.ts +0 -31
- package/dist/migration/checkpoint/CheckpointManager.js +0 -96
- package/dist/migration/checkpoint/CheckpointStorage.d.ts +0 -26
- package/dist/migration/checkpoint/CheckpointStorage.js +0 -89
- package/dist/migration/index.d.ts +0 -22
- package/dist/migration/index.js +0 -27
- package/dist/migration/operations/BaseMigration.d.ts +0 -48
- package/dist/migration/operations/BaseMigration.js +0 -83
- package/dist/migration/operations/PeerToBtcoMigration.d.ts +0 -25
- package/dist/migration/operations/PeerToBtcoMigration.js +0 -67
- package/dist/migration/operations/PeerToWebvhMigration.d.ts +0 -19
- package/dist/migration/operations/PeerToWebvhMigration.js +0 -46
- package/dist/migration/operations/WebvhToBtcoMigration.d.ts +0 -25
- package/dist/migration/operations/WebvhToBtcoMigration.js +0 -67
- package/dist/migration/rollback/RollbackManager.d.ts +0 -29
- package/dist/migration/rollback/RollbackManager.js +0 -146
- package/dist/migration/state/StateMachine.d.ts +0 -25
- package/dist/migration/state/StateMachine.js +0 -76
- package/dist/migration/state/StateTracker.d.ts +0 -36
- package/dist/migration/state/StateTracker.js +0 -123
- package/dist/migration/types.d.ts +0 -306
- package/dist/migration/types.js +0 -33
- package/dist/migration/validation/BitcoinValidator.d.ts +0 -13
- package/dist/migration/validation/BitcoinValidator.js +0 -83
- package/dist/migration/validation/CredentialValidator.d.ts +0 -13
- package/dist/migration/validation/CredentialValidator.js +0 -46
- package/dist/migration/validation/DIDCompatibilityValidator.d.ts +0 -16
- package/dist/migration/validation/DIDCompatibilityValidator.js +0 -127
- package/dist/migration/validation/LifecycleValidator.d.ts +0 -10
- package/dist/migration/validation/LifecycleValidator.js +0 -52
- package/dist/migration/validation/StorageValidator.d.ts +0 -10
- package/dist/migration/validation/StorageValidator.js +0 -65
- package/dist/migration/validation/ValidationPipeline.d.ts +0 -29
- package/dist/migration/validation/ValidationPipeline.js +0 -180
- package/dist/storage/LocalStorageAdapter.d.ts +0 -11
- package/dist/storage/LocalStorageAdapter.js +0 -53
- package/dist/storage/MemoryStorageAdapter.d.ts +0 -6
- package/dist/storage/MemoryStorageAdapter.js +0 -21
- package/dist/storage/StorageAdapter.d.ts +0 -16
- package/dist/storage/StorageAdapter.js +0 -1
- package/dist/storage/index.d.ts +0 -2
- package/dist/storage/index.js +0 -2
- package/dist/types/bitcoin.d.ts +0 -84
- package/dist/types/bitcoin.js +0 -1
- package/dist/types/common.d.ts +0 -82
- package/dist/types/common.js +0 -1
- package/dist/types/credentials.d.ts +0 -75
- package/dist/types/credentials.js +0 -1
- package/dist/types/did.d.ts +0 -26
- package/dist/types/did.js +0 -1
- package/dist/types/index.d.ts +0 -5
- package/dist/types/index.js +0 -5
- package/dist/types/network.d.ts +0 -78
- package/dist/types/network.js +0 -145
- package/dist/utils/EventLogger.d.ts +0 -71
- package/dist/utils/EventLogger.js +0 -232
- package/dist/utils/Logger.d.ts +0 -106
- package/dist/utils/Logger.js +0 -257
- package/dist/utils/MetricsCollector.d.ts +0 -110
- package/dist/utils/MetricsCollector.js +0 -264
- package/dist/utils/bitcoin-address.d.ts +0 -38
- package/dist/utils/bitcoin-address.js +0 -113
- package/dist/utils/cbor.d.ts +0 -2
- package/dist/utils/cbor.js +0 -9
- package/dist/utils/encoding.d.ts +0 -37
- package/dist/utils/encoding.js +0 -120
- package/dist/utils/hash.d.ts +0 -1
- package/dist/utils/hash.js +0 -5
- package/dist/utils/retry.d.ts +0 -10
- package/dist/utils/retry.js +0 -35
- package/dist/utils/satoshi-validation.d.ts +0 -60
- package/dist/utils/satoshi-validation.js +0 -156
- package/dist/utils/serialization.d.ts +0 -14
- package/dist/utils/serialization.js +0 -76
- package/dist/utils/telemetry.d.ts +0 -17
- package/dist/utils/telemetry.js +0 -24
- package/dist/utils/validation.d.ts +0 -5
- package/dist/utils/validation.js +0 -98
- package/dist/vc/CredentialManager.d.ts +0 -22
- package/dist/vc/CredentialManager.js +0 -227
- package/dist/vc/Issuer.d.ts +0 -27
- package/dist/vc/Issuer.js +0 -70
- package/dist/vc/Verifier.d.ts +0 -16
- package/dist/vc/Verifier.js +0 -50
- package/dist/vc/cryptosuites/bbs.d.ts +0 -44
- package/dist/vc/cryptosuites/bbs.js +0 -213
- package/dist/vc/cryptosuites/bbsSimple.d.ts +0 -9
- package/dist/vc/cryptosuites/bbsSimple.js +0 -12
- package/dist/vc/cryptosuites/eddsa.d.ts +0 -30
- package/dist/vc/cryptosuites/eddsa.js +0 -81
- package/dist/vc/documentLoader.d.ts +0 -16
- package/dist/vc/documentLoader.js +0 -59
- package/dist/vc/proofs/data-integrity.d.ts +0 -21
- package/dist/vc/proofs/data-integrity.js +0 -15
- package/dist/vc/utils/jsonld.d.ts +0 -2
- package/dist/vc/utils/jsonld.js +0 -15
- package/src/adapters/FeeOracleMock.ts +0 -9
- package/src/adapters/index.ts +0 -5
- package/src/adapters/providers/OrdHttpProvider.ts +0 -126
- package/src/adapters/providers/OrdMockProvider.ts +0 -101
- package/src/adapters/types.ts +0 -66
- package/src/bitcoin/BitcoinManager.ts +0 -330
- package/src/bitcoin/BroadcastClient.ts +0 -54
- package/src/bitcoin/OrdinalsClient.ts +0 -119
- package/src/bitcoin/PSBTBuilder.ts +0 -106
- package/src/bitcoin/fee-calculation.ts +0 -38
- package/src/bitcoin/providers/OrdNodeProvider.ts +0 -92
- package/src/bitcoin/providers/OrdinalsProvider.ts +0 -56
- package/src/bitcoin/providers/types.ts +0 -59
- package/src/bitcoin/transactions/commit.ts +0 -465
- package/src/bitcoin/transactions/index.ts +0 -13
- package/src/bitcoin/transfer.ts +0 -43
- package/src/bitcoin/utxo-selection.ts +0 -322
- package/src/bitcoin/utxo.ts +0 -113
- package/src/contexts/credentials-v1.json +0 -237
- package/src/contexts/credentials-v2-examples.json +0 -5
- package/src/contexts/credentials-v2.json +0 -340
- package/src/contexts/credentials.json +0 -237
- package/src/contexts/data-integrity-v2.json +0 -81
- package/src/contexts/dids.json +0 -58
- package/src/contexts/ed255192020.json +0 -93
- package/src/contexts/ordinals-plus.json +0 -23
- package/src/contexts/originals.json +0 -22
- package/src/core/OriginalsSDK.ts +0 -416
- package/src/crypto/Multikey.ts +0 -194
- package/src/crypto/Signer.ts +0 -254
- package/src/crypto/noble-init.ts +0 -121
- package/src/did/BtcoDidResolver.ts +0 -227
- package/src/did/DIDManager.ts +0 -694
- package/src/did/Ed25519Verifier.ts +0 -68
- package/src/did/KeyManager.ts +0 -236
- package/src/did/WebVHManager.ts +0 -489
- package/src/did/createBtcoDidDocument.ts +0 -59
- package/src/did/providers/OrdinalsClientProviderAdapter.ts +0 -68
- package/src/events/EventEmitter.ts +0 -222
- package/src/events/index.ts +0 -19
- package/src/events/types.ts +0 -331
- package/src/examples/basic-usage.ts +0 -78
- package/src/examples/run.ts +0 -5
- package/src/index.ts +0 -84
- package/src/lifecycle/BatchOperations.ts +0 -373
- package/src/lifecycle/LifecycleManager.ts +0 -1218
- package/src/lifecycle/OriginalsAsset.ts +0 -524
- package/src/lifecycle/ProvenanceQuery.ts +0 -280
- package/src/lifecycle/ResourceVersioning.ts +0 -163
- package/src/migration/MigrationManager.ts +0 -527
- package/src/migration/audit/AuditLogger.ts +0 -176
- package/src/migration/checkpoint/CheckpointManager.ts +0 -112
- package/src/migration/checkpoint/CheckpointStorage.ts +0 -101
- package/src/migration/index.ts +0 -33
- package/src/migration/operations/BaseMigration.ts +0 -126
- package/src/migration/operations/PeerToBtcoMigration.ts +0 -105
- package/src/migration/operations/PeerToWebvhMigration.ts +0 -62
- package/src/migration/operations/WebvhToBtcoMigration.ts +0 -105
- package/src/migration/rollback/RollbackManager.ts +0 -170
- package/src/migration/state/StateMachine.ts +0 -92
- package/src/migration/state/StateTracker.ts +0 -156
- package/src/migration/types.ts +0 -344
- package/src/migration/validation/BitcoinValidator.ts +0 -107
- package/src/migration/validation/CredentialValidator.ts +0 -62
- package/src/migration/validation/DIDCompatibilityValidator.ts +0 -151
- package/src/migration/validation/LifecycleValidator.ts +0 -64
- package/src/migration/validation/StorageValidator.ts +0 -79
- package/src/migration/validation/ValidationPipeline.ts +0 -213
- package/src/storage/LocalStorageAdapter.ts +0 -61
- package/src/storage/MemoryStorageAdapter.ts +0 -29
- package/src/storage/StorageAdapter.ts +0 -25
- package/src/storage/index.ts +0 -3
- package/src/types/bitcoin.ts +0 -98
- package/src/types/common.ts +0 -92
- package/src/types/credentials.ts +0 -88
- package/src/types/did.ts +0 -31
- package/src/types/external-shims.d.ts +0 -53
- package/src/types/index.ts +0 -7
- package/src/types/network.ts +0 -175
- package/src/utils/EventLogger.ts +0 -298
- package/src/utils/Logger.ts +0 -322
- package/src/utils/MetricsCollector.ts +0 -358
- package/src/utils/bitcoin-address.ts +0 -130
- package/src/utils/cbor.ts +0 -12
- package/src/utils/encoding.ts +0 -127
- package/src/utils/hash.ts +0 -6
- package/src/utils/retry.ts +0 -46
- package/src/utils/satoshi-validation.ts +0 -196
- package/src/utils/serialization.ts +0 -96
- package/src/utils/telemetry.ts +0 -40
- package/src/utils/validation.ts +0 -119
- package/src/vc/CredentialManager.ts +0 -273
- package/src/vc/Issuer.ts +0 -100
- package/src/vc/Verifier.ts +0 -47
- package/src/vc/cryptosuites/bbs.ts +0 -253
- package/src/vc/cryptosuites/bbsSimple.ts +0 -21
- package/src/vc/cryptosuites/eddsa.ts +0 -99
- package/src/vc/documentLoader.ts +0 -67
- package/src/vc/proofs/data-integrity.ts +0 -33
- package/src/vc/utils/jsonld.ts +0 -18
- package/test/logs/did_webvh_QmNTn9Kkp8dQ75WrF9xqJ2kuDp9QhKc3aPiERRMj8XoTBN_example_com.jsonl +0 -1
- package/test/logs/did_webvh_QmNu4MNr8Lr5txx5gYNhuhZDchXsZEu3hJXKYuphpWTPDp_example_com_users_etc_passwd.jsonl +0 -1
- package/test/logs/did_webvh_QmR9MrGZACzjKETA8SBRNCKG11HxU85c4bVR2qN5eDCfsD_example_com.jsonl +0 -1
- package/test/logs/did_webvh_QmUc5suaqRM2P4nrXxZwqYMfqzhdMqjuL7oJaJbEpCQVCd_example_com_users_etc_passwd.jsonl +0 -1
- package/test/logs/did_webvh_QmUkiB2RCV2VZ1RTXsCebWN25Eiy9TLvpzDWAJNjhgvB4X_example_com_etc_passwd.jsonl +0 -1
- package/test/logs/did_webvh_QmUoRTe8UMwpAQXZSAW7pjAgZK1tq2X3C6Kfxq3UXGcaGy_example_com_secret.jsonl +0 -1
- package/test/logs/did_webvh_QmWWot3chx1t6KwTmcE5i2FeDZ5JMkQw3qXycsKDVmJ9Be_example_com_users_alice.jsonl +0 -1
- package/test/logs/did_webvh_QmWvVgALL5kjZdpgR7KZay7J8UiiUr834kkRmWeFAxjAuC_example_com_users_etc_passwd.jsonl +0 -1
- package/test/logs/did_webvh_QmWwaRQHUZAFcKihFC6xR6tRTTrQhHPTku6azf1egWbpy1_example_com_users_alice.jsonl +0 -1
- package/test/logs/did_webvh_QmXJLtkz23r7AozbtXsZMKWnVU6rd38CkVtjdWuATU3Yp6_example_com_users_alice123_profile.jsonl +0 -1
- package/test/logs/did_webvh_QmYsce448po14oDE1wXbyaP6wY9HQgHSKLwdezn1k577SF_example_com_my_org_user_name_test_123.jsonl +0 -1
- package/test/logs/did_webvh_QmZBeNzzqajxdfwcDUPZ4P8C5YSXyRztrAwmPiKuKUxmAK_example_com.jsonl +0 -1
- package/test/logs/did_webvh_QmZhJsqxizwVbRtqCUkmE6XQunSxtxMt3gbTYadVBNAaEq_example_com.jsonl +0 -1
- package/test/logs/did_webvh_QmZk7NHU2D57RzzbMq4tWW9gBa9AqtVTWfiRM6RFdwGVj2_example_com.jsonl +0 -1
- package/test/logs/did_webvh_QmZshSXp9w8ovH62zGGBS1b5pGGPsuYiu1VQ935sga2hWF_example_com_level1_level2.jsonl +0 -1
- package/test/logs/did_webvh_QmbWAmw7HQL7vKJyCsctZihXf1rmT4sGvggKCPKWcUWjw1_example_com.jsonl +0 -1
- package/test/logs/did_webvh_QmbdLUMbYs3juR39TLB6hhrFWLcNg45ybUzeBJCS1MhCh1_example_com_C_Windows_System32.jsonl +0 -1
- package/test/logs/did_webvh_QmcaQ1Ma4gkSbae85aCm8Mv4rvdT2Sb2RR3JzYwrm5XBq8_example_com_etc_passwd.jsonl +0 -1
- package/test/logs/did_webvh_QmcbA7WQhsBqZSoDpKJHjV8Q5o53h8vmgJhQfo6rqTY5ho_example_com.jsonl +0 -1
- package/test/logs/did_webvh_Qmdy8uWr2gkUJrXsThynAug3DASTWwb3onEj89LKmMGZYB_example_com.jsonl +0 -1
- package/tests/__mocks__/bbs-signatures.js +0 -17
- package/tests/__mocks__/mf-base58.js +0 -24
- package/tests/e2e/README.md +0 -97
- package/tests/e2e/example.spec.ts +0 -78
- package/tests/fixtures/did-documents.ts +0 -247
- package/tests/index.test.ts +0 -21
- package/tests/integration/BatchOperations.test.ts +0 -531
- package/tests/integration/CompleteLifecycle.e2e.test.ts +0 -735
- package/tests/integration/CredentialManager.test.ts +0 -42
- package/tests/integration/DIDManager.test.ts +0 -41
- package/tests/integration/DidPeerToWebVhFlow.test.ts +0 -351
- package/tests/integration/Events.test.ts +0 -435
- package/tests/integration/Lifecycle.transfer.btco.integration.test.ts +0 -25
- package/tests/integration/LifecycleManager.test.ts +0 -21
- package/tests/integration/MultikeyFlow.test.ts +0 -52
- package/tests/integration/TelemetryIntegration.test.ts +0 -395
- package/tests/integration/WebVhPublish.test.ts +0 -48
- package/tests/integration/migration/peer-to-webvh.test.ts +0 -172
- package/tests/manual/test-commit-creation.ts +0 -323
- package/tests/mocks/MockKeyStore.ts +0 -38
- package/tests/mocks/adapters/MemoryStorageAdapter.ts +0 -24
- package/tests/mocks/adapters/MockFeeOracle.ts +0 -11
- package/tests/mocks/adapters/MockOrdinalsProvider.ts +0 -76
- package/tests/mocks/adapters/OrdMockProvider.test.ts +0 -176
- package/tests/mocks/adapters/index.ts +0 -6
- package/tests/performance/BatchOperations.perf.test.ts +0 -403
- package/tests/performance/logging.perf.test.ts +0 -336
- package/tests/sdk.test.ts +0 -43
- package/tests/security/bitcoin-penetration-tests.test.ts +0 -622
- package/tests/setup.bun.ts +0 -69
- package/tests/setup.jest.ts +0 -23
- package/tests/stress/batch-operations-stress.test.ts +0 -571
- package/tests/unit/adapters/FeeOracleMock.test.ts +0 -40
- package/tests/unit/bitcoin/BitcoinManager.test.ts +0 -293
- package/tests/unit/bitcoin/BroadcastClient.test.ts +0 -52
- package/tests/unit/bitcoin/OrdNodeProvider.test.ts +0 -53
- package/tests/unit/bitcoin/OrdinalsClient.test.ts +0 -381
- package/tests/unit/bitcoin/OrdinalsClientProvider.test.ts +0 -102
- package/tests/unit/bitcoin/PSBTBuilder.test.ts +0 -84
- package/tests/unit/bitcoin/fee-calculation.test.ts +0 -261
- package/tests/unit/bitcoin/transactions/commit.test.ts +0 -649
- package/tests/unit/bitcoin/transfer.test.ts +0 -31
- package/tests/unit/bitcoin/utxo-selection-new.test.ts +0 -502
- package/tests/unit/bitcoin/utxo.more.test.ts +0 -39
- package/tests/unit/bitcoin/utxo.selection.test.ts +0 -38
- package/tests/unit/core/OriginalsSDK.test.ts +0 -152
- package/tests/unit/crypto/Multikey.test.ts +0 -206
- package/tests/unit/crypto/Signer.test.ts +0 -408
- package/tests/unit/did/BtcoDidResolver.test.ts +0 -611
- package/tests/unit/did/DIDManager.more.test.ts +0 -43
- package/tests/unit/did/DIDManager.test.ts +0 -185
- package/tests/unit/did/Ed25519Verifier.test.ts +0 -160
- package/tests/unit/did/KeyManager.test.ts +0 -452
- package/tests/unit/did/OrdinalsClientProviderAdapter.test.ts +0 -45
- package/tests/unit/did/WebVHManager.test.ts +0 -435
- package/tests/unit/did/createBtcoDidDocument.test.ts +0 -67
- package/tests/unit/did/providers/OrdinalsClientProviderAdapter.test.ts +0 -159
- package/tests/unit/events/EventEmitter.test.ts +0 -407
- package/tests/unit/lifecycle/BatchOperations.test.ts +0 -527
- package/tests/unit/lifecycle/LifecycleManager.keymanagement.test.ts +0 -312
- package/tests/unit/lifecycle/LifecycleManager.prov.test.ts +0 -18
- package/tests/unit/lifecycle/LifecycleManager.test.ts +0 -213
- package/tests/unit/lifecycle/LifecycleManager.transfer.unit.test.ts +0 -30
- package/tests/unit/lifecycle/OriginalsAsset.test.ts +0 -176
- package/tests/unit/lifecycle/ProvenanceQuery.test.ts +0 -577
- package/tests/unit/lifecycle/ResourceVersioning.test.ts +0 -651
- package/tests/unit/storage/MemoryStorageAdapter.test.ts +0 -93
- package/tests/unit/types/network.test.ts +0 -255
- package/tests/unit/utils/EventIntegration.test.ts +0 -384
- package/tests/unit/utils/Logger.test.ts +0 -473
- package/tests/unit/utils/MetricsCollector.test.ts +0 -358
- package/tests/unit/utils/bitcoin-address.test.ts +0 -250
- package/tests/unit/utils/cbor.test.ts +0 -35
- package/tests/unit/utils/encoding.test.ts +0 -318
- package/tests/unit/utils/hash.test.ts +0 -12
- package/tests/unit/utils/retry.test.ts +0 -100
- package/tests/unit/utils/satoshi-validation.test.ts +0 -354
- package/tests/unit/utils/serialization.test.ts +0 -124
- package/tests/unit/utils/telemetry.test.ts +0 -52
- package/tests/unit/utils/validation.test.ts +0 -141
- package/tests/unit/vc/CredentialManager.test.ts +0 -487
- package/tests/unit/vc/Issuer.test.ts +0 -107
- package/tests/unit/vc/Verifier.test.ts +0 -525
- package/tests/unit/vc/bbs.test.ts +0 -282
- package/tests/unit/vc/cryptosuites/eddsa.test.ts +0 -398
- package/tests/unit/vc/documentLoader.test.ts +0 -121
- package/tests/unit/vc/proofs/data-integrity.test.ts +0 -24
- package/tsconfig.json +0 -31
- package/tsconfig.test.json +0 -15
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { LayerType } from './common';
|
|
2
|
-
export interface VerifiableCredential {
|
|
3
|
-
'@context': string[];
|
|
4
|
-
type: string[];
|
|
5
|
-
id?: string;
|
|
6
|
-
issuer: string | Issuer;
|
|
7
|
-
issuanceDate: string;
|
|
8
|
-
expirationDate?: string;
|
|
9
|
-
credentialSubject: CredentialSubject;
|
|
10
|
-
credentialStatus?: CredentialStatus;
|
|
11
|
-
proof?: Proof | Proof[];
|
|
12
|
-
}
|
|
13
|
-
export interface Issuer {
|
|
14
|
-
id: string;
|
|
15
|
-
name?: string;
|
|
16
|
-
}
|
|
17
|
-
export interface CredentialSubject {
|
|
18
|
-
id?: string;
|
|
19
|
-
[key: string]: any;
|
|
20
|
-
}
|
|
21
|
-
export interface CredentialStatus {
|
|
22
|
-
id: string;
|
|
23
|
-
type: string;
|
|
24
|
-
}
|
|
25
|
-
export interface Proof {
|
|
26
|
-
type: string;
|
|
27
|
-
created: string;
|
|
28
|
-
verificationMethod: string;
|
|
29
|
-
proofPurpose: string;
|
|
30
|
-
proofValue: string;
|
|
31
|
-
}
|
|
32
|
-
export interface VerifiablePresentation {
|
|
33
|
-
'@context': string[];
|
|
34
|
-
type: string[];
|
|
35
|
-
id?: string;
|
|
36
|
-
holder: string;
|
|
37
|
-
verifiableCredential: VerifiableCredential[];
|
|
38
|
-
proof?: Proof | Proof[];
|
|
39
|
-
}
|
|
40
|
-
export interface ResourceCreatedCredential extends VerifiableCredential {
|
|
41
|
-
credentialSubject: {
|
|
42
|
-
id: string;
|
|
43
|
-
resourceId: string;
|
|
44
|
-
resourceType: string;
|
|
45
|
-
createdAt: string;
|
|
46
|
-
creator: string;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
export interface ResourceUpdatedCredential extends VerifiableCredential {
|
|
50
|
-
credentialSubject: {
|
|
51
|
-
id: string;
|
|
52
|
-
resourceId: string;
|
|
53
|
-
updatedAt: string;
|
|
54
|
-
updateReason?: string;
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
export interface ResourceMigratedCredential extends VerifiableCredential {
|
|
58
|
-
credentialSubject: {
|
|
59
|
-
id: string;
|
|
60
|
-
resourceId: string;
|
|
61
|
-
fromLayer: LayerType;
|
|
62
|
-
toLayer: LayerType;
|
|
63
|
-
migratedAt: string;
|
|
64
|
-
migrationReason?: string;
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
export interface KeyRecoveryCredential extends VerifiableCredential {
|
|
68
|
-
credentialSubject: {
|
|
69
|
-
id: string;
|
|
70
|
-
recoveredAt: string;
|
|
71
|
-
recoveryReason: string;
|
|
72
|
-
previousVerificationMethods: string[];
|
|
73
|
-
newVerificationMethod: string;
|
|
74
|
-
};
|
|
75
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/types/did.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export interface DIDDocument {
|
|
2
|
-
'@context': string[];
|
|
3
|
-
id: string;
|
|
4
|
-
verificationMethod?: VerificationMethod[];
|
|
5
|
-
authentication?: (string | VerificationMethod)[];
|
|
6
|
-
assertionMethod?: (string | VerificationMethod)[];
|
|
7
|
-
keyAgreement?: (string | VerificationMethod)[];
|
|
8
|
-
capabilityInvocation?: (string | VerificationMethod)[];
|
|
9
|
-
capabilityDelegation?: (string | VerificationMethod)[];
|
|
10
|
-
service?: ServiceEndpoint[];
|
|
11
|
-
controller?: string[];
|
|
12
|
-
alsoKnownAs?: string[];
|
|
13
|
-
}
|
|
14
|
-
export interface VerificationMethod {
|
|
15
|
-
id: string;
|
|
16
|
-
type: string;
|
|
17
|
-
controller: string;
|
|
18
|
-
publicKeyMultibase: string;
|
|
19
|
-
revoked?: string;
|
|
20
|
-
compromised?: string;
|
|
21
|
-
}
|
|
22
|
-
export interface ServiceEndpoint {
|
|
23
|
-
id: string;
|
|
24
|
-
type: string;
|
|
25
|
-
serviceEndpoint: string | object;
|
|
26
|
-
}
|
package/dist/types/did.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/types/index.d.ts
DELETED
package/dist/types/index.js
DELETED
package/dist/types/network.d.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WebVH Network Configuration
|
|
3
|
-
*
|
|
4
|
-
* Defines the three deployment networks for the Originals Protocol:
|
|
5
|
-
* - magby: Development network (patch versions) → Bitcoin regtest
|
|
6
|
-
* - cleffa: Staging network (minor versions) → Bitcoin signet
|
|
7
|
-
* - pichu: Production network (major versions) → Bitcoin mainnet
|
|
8
|
-
*/
|
|
9
|
-
export type WebVHNetworkName = 'magby' | 'cleffa' | 'pichu';
|
|
10
|
-
export type BitcoinNetworkName = 'mainnet' | 'regtest' | 'signet';
|
|
11
|
-
export type VersionStability = 'patch' | 'minor' | 'major';
|
|
12
|
-
export interface WebVHNetworkConfig {
|
|
13
|
-
name: WebVHNetworkName;
|
|
14
|
-
domain: string;
|
|
15
|
-
stability: VersionStability;
|
|
16
|
-
description: string;
|
|
17
|
-
contextUrl: string;
|
|
18
|
-
bitcoinNetwork: BitcoinNetworkName;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Network configurations for the Originals Protocol WebVH deployments
|
|
22
|
-
*/
|
|
23
|
-
export declare const WEBVH_NETWORKS: Record<WebVHNetworkName, WebVHNetworkConfig>;
|
|
24
|
-
/**
|
|
25
|
-
* Default network for backward compatibility
|
|
26
|
-
*/
|
|
27
|
-
export declare const DEFAULT_WEBVH_NETWORK: WebVHNetworkName;
|
|
28
|
-
/**
|
|
29
|
-
* Get network configuration by name
|
|
30
|
-
* @param network - Network name
|
|
31
|
-
* @returns Network configuration
|
|
32
|
-
*/
|
|
33
|
-
export declare function getNetworkConfig(network: WebVHNetworkName): WebVHNetworkConfig;
|
|
34
|
-
/**
|
|
35
|
-
* Get network domain
|
|
36
|
-
* @param network - Network name
|
|
37
|
-
* @returns Network domain
|
|
38
|
-
*/
|
|
39
|
-
export declare function getNetworkDomain(network: WebVHNetworkName): string;
|
|
40
|
-
/**
|
|
41
|
-
* Get network context URL
|
|
42
|
-
* @param network - Network name
|
|
43
|
-
* @returns Context URL for the network
|
|
44
|
-
*/
|
|
45
|
-
export declare function getNetworkContextUrl(network: WebVHNetworkName): string;
|
|
46
|
-
/**
|
|
47
|
-
* Validate that a version string matches the network's stability requirements
|
|
48
|
-
* @param version - Semver version string (e.g., "1.2.3")
|
|
49
|
-
* @param network - Network name
|
|
50
|
-
* @returns True if the version is allowed on this network
|
|
51
|
-
*/
|
|
52
|
-
export declare function validateVersionForNetwork(version: string, network: WebVHNetworkName): boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Get the appropriate network for a given version
|
|
55
|
-
* Returns the most restrictive network that accepts this version
|
|
56
|
-
* @param version - Semver version string
|
|
57
|
-
* @returns Recommended network name
|
|
58
|
-
*/
|
|
59
|
-
export declare function getRecommendedNetworkForVersion(version: string): WebVHNetworkName;
|
|
60
|
-
/**
|
|
61
|
-
* Get the corresponding Bitcoin network for a WebVH network
|
|
62
|
-
* This ensures consistent environment mapping across the stack:
|
|
63
|
-
* - magby (dev) → regtest (dev)
|
|
64
|
-
* - cleffa (staging) → signet (staging)
|
|
65
|
-
* - pichu (production) → mainnet (production)
|
|
66
|
-
*
|
|
67
|
-
* @param webvhNetwork - WebVH network name
|
|
68
|
-
* @returns Corresponding Bitcoin network name
|
|
69
|
-
*/
|
|
70
|
-
export declare function getBitcoinNetworkForWebVH(webvhNetwork: WebVHNetworkName): BitcoinNetworkName;
|
|
71
|
-
/**
|
|
72
|
-
* Get the WebVH network that corresponds to a Bitcoin network
|
|
73
|
-
* This is the reverse mapping of getBitcoinNetworkForWebVH
|
|
74
|
-
*
|
|
75
|
-
* @param bitcoinNetwork - Bitcoin network name
|
|
76
|
-
* @returns Corresponding WebVH network name, or undefined if no mapping exists
|
|
77
|
-
*/
|
|
78
|
-
export declare function getWebVHNetworkForBitcoin(bitcoinNetwork: BitcoinNetworkName): WebVHNetworkName | undefined;
|
package/dist/types/network.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WebVH Network Configuration
|
|
3
|
-
*
|
|
4
|
-
* Defines the three deployment networks for the Originals Protocol:
|
|
5
|
-
* - magby: Development network (patch versions) → Bitcoin regtest
|
|
6
|
-
* - cleffa: Staging network (minor versions) → Bitcoin signet
|
|
7
|
-
* - pichu: Production network (major versions) → Bitcoin mainnet
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Network configurations for the Originals Protocol WebVH deployments
|
|
11
|
-
*/
|
|
12
|
-
export const WEBVH_NETWORKS = {
|
|
13
|
-
magby: {
|
|
14
|
-
name: 'magby',
|
|
15
|
-
domain: 'magby.originals.build',
|
|
16
|
-
stability: 'patch',
|
|
17
|
-
description: 'Development network - accepts all patch versions (most unstable)',
|
|
18
|
-
contextUrl: 'https://magby.originals.build/context',
|
|
19
|
-
bitcoinNetwork: 'regtest', // Development → regtest
|
|
20
|
-
},
|
|
21
|
-
cleffa: {
|
|
22
|
-
name: 'cleffa',
|
|
23
|
-
domain: 'cleffa.originals.build',
|
|
24
|
-
stability: 'minor',
|
|
25
|
-
description: 'Staging network - accepts minor releases',
|
|
26
|
-
contextUrl: 'https://cleffa.originals.build/context',
|
|
27
|
-
bitcoinNetwork: 'signet', // Staging → signet
|
|
28
|
-
},
|
|
29
|
-
pichu: {
|
|
30
|
-
name: 'pichu',
|
|
31
|
-
domain: 'pichu.originals.build',
|
|
32
|
-
stability: 'major',
|
|
33
|
-
description: 'Production network - accepts major releases only (most stable)',
|
|
34
|
-
contextUrl: 'https://pichu.originals.build/context',
|
|
35
|
-
bitcoinNetwork: 'mainnet', // Production → mainnet
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Default network for backward compatibility
|
|
40
|
-
*/
|
|
41
|
-
export const DEFAULT_WEBVH_NETWORK = 'pichu';
|
|
42
|
-
/**
|
|
43
|
-
* Get network configuration by name
|
|
44
|
-
* @param network - Network name
|
|
45
|
-
* @returns Network configuration
|
|
46
|
-
*/
|
|
47
|
-
export function getNetworkConfig(network) {
|
|
48
|
-
const config = WEBVH_NETWORKS[network];
|
|
49
|
-
if (!config) {
|
|
50
|
-
throw new Error(`Invalid WebVH network: ${network}. Valid networks: magby, cleffa, pichu`);
|
|
51
|
-
}
|
|
52
|
-
return config;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Get network domain
|
|
56
|
-
* @param network - Network name
|
|
57
|
-
* @returns Network domain
|
|
58
|
-
*/
|
|
59
|
-
export function getNetworkDomain(network) {
|
|
60
|
-
return getNetworkConfig(network).domain;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Get network context URL
|
|
64
|
-
* @param network - Network name
|
|
65
|
-
* @returns Context URL for the network
|
|
66
|
-
*/
|
|
67
|
-
export function getNetworkContextUrl(network) {
|
|
68
|
-
return getNetworkConfig(network).contextUrl;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Validate that a version string matches the network's stability requirements
|
|
72
|
-
* @param version - Semver version string (e.g., "1.2.3")
|
|
73
|
-
* @param network - Network name
|
|
74
|
-
* @returns True if the version is allowed on this network
|
|
75
|
-
*/
|
|
76
|
-
export function validateVersionForNetwork(version, network) {
|
|
77
|
-
const config = getNetworkConfig(network);
|
|
78
|
-
// Parse semver (basic parsing, assumes format X.Y.Z)
|
|
79
|
-
const match = version.match(/^(\d+)\.(\d+)\.(\d+)(?:-.*)?$/);
|
|
80
|
-
if (!match) {
|
|
81
|
-
throw new Error(`Invalid version format: ${version}. Expected semver format (e.g., 1.2.3)`);
|
|
82
|
-
}
|
|
83
|
-
const [, major, minor, patch] = match;
|
|
84
|
-
switch (config.stability) {
|
|
85
|
-
case 'major':
|
|
86
|
-
// Pichu: Only allow major releases (X.0.0)
|
|
87
|
-
return minor === '0' && patch === '0';
|
|
88
|
-
case 'minor':
|
|
89
|
-
// Cleffa: Allow minor releases (X.Y.0)
|
|
90
|
-
return patch === '0';
|
|
91
|
-
case 'patch':
|
|
92
|
-
// Magby: Allow all versions including patches
|
|
93
|
-
return true;
|
|
94
|
-
default:
|
|
95
|
-
throw new Error(`Unknown stability level: ${config.stability}`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Get the appropriate network for a given version
|
|
100
|
-
* Returns the most restrictive network that accepts this version
|
|
101
|
-
* @param version - Semver version string
|
|
102
|
-
* @returns Recommended network name
|
|
103
|
-
*/
|
|
104
|
-
export function getRecommendedNetworkForVersion(version) {
|
|
105
|
-
// Try networks from most restrictive to least restrictive
|
|
106
|
-
if (validateVersionForNetwork(version, 'pichu')) {
|
|
107
|
-
return 'pichu';
|
|
108
|
-
}
|
|
109
|
-
if (validateVersionForNetwork(version, 'cleffa')) {
|
|
110
|
-
return 'cleffa';
|
|
111
|
-
}
|
|
112
|
-
return 'magby';
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Get the corresponding Bitcoin network for a WebVH network
|
|
116
|
-
* This ensures consistent environment mapping across the stack:
|
|
117
|
-
* - magby (dev) → regtest (dev)
|
|
118
|
-
* - cleffa (staging) → signet (staging)
|
|
119
|
-
* - pichu (production) → mainnet (production)
|
|
120
|
-
*
|
|
121
|
-
* @param webvhNetwork - WebVH network name
|
|
122
|
-
* @returns Corresponding Bitcoin network name
|
|
123
|
-
*/
|
|
124
|
-
export function getBitcoinNetworkForWebVH(webvhNetwork) {
|
|
125
|
-
return getNetworkConfig(webvhNetwork).bitcoinNetwork;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Get the WebVH network that corresponds to a Bitcoin network
|
|
129
|
-
* This is the reverse mapping of getBitcoinNetworkForWebVH
|
|
130
|
-
*
|
|
131
|
-
* @param bitcoinNetwork - Bitcoin network name
|
|
132
|
-
* @returns Corresponding WebVH network name, or undefined if no mapping exists
|
|
133
|
-
*/
|
|
134
|
-
export function getWebVHNetworkForBitcoin(bitcoinNetwork) {
|
|
135
|
-
switch (bitcoinNetwork) {
|
|
136
|
-
case 'mainnet':
|
|
137
|
-
return 'pichu';
|
|
138
|
-
case 'signet':
|
|
139
|
-
return 'cleffa';
|
|
140
|
-
case 'regtest':
|
|
141
|
-
return 'magby';
|
|
142
|
-
default:
|
|
143
|
-
return undefined;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Event Logger - Integration between Event System and Logger
|
|
3
|
-
*
|
|
4
|
-
* Features:
|
|
5
|
-
* - Auto-subscribe to EventEmitter events
|
|
6
|
-
* - Configurable logging levels per event type
|
|
7
|
-
* - Automatic metrics extraction from events
|
|
8
|
-
* - Performance tracking
|
|
9
|
-
*/
|
|
10
|
-
import type { EventEmitter } from '../events/EventEmitter';
|
|
11
|
-
import type { Logger, LogLevel } from './Logger';
|
|
12
|
-
import type { MetricsCollector } from './MetricsCollector';
|
|
13
|
-
/**
|
|
14
|
-
* Event logging configuration
|
|
15
|
-
*/
|
|
16
|
-
export interface EventLoggingConfig {
|
|
17
|
-
'asset:created'?: LogLevel | false;
|
|
18
|
-
'asset:migrated'?: LogLevel | false;
|
|
19
|
-
'asset:transferred'?: LogLevel | false;
|
|
20
|
-
'resource:published'?: LogLevel | false;
|
|
21
|
-
'credential:issued'?: LogLevel | false;
|
|
22
|
-
'resource:version:created'?: LogLevel | false;
|
|
23
|
-
'verification:completed'?: LogLevel | false;
|
|
24
|
-
'batch:started'?: LogLevel | false;
|
|
25
|
-
'batch:completed'?: LogLevel | false;
|
|
26
|
-
'batch:failed'?: LogLevel | false;
|
|
27
|
-
'migration:started'?: LogLevel | false;
|
|
28
|
-
'migration:validated'?: LogLevel | false;
|
|
29
|
-
'migration:checkpointed'?: LogLevel | false;
|
|
30
|
-
'migration:in_progress'?: LogLevel | false;
|
|
31
|
-
'migration:anchoring'?: LogLevel | false;
|
|
32
|
-
'migration:completed'?: LogLevel | false;
|
|
33
|
-
'migration:failed'?: LogLevel | false;
|
|
34
|
-
'migration:rolledback'?: LogLevel | false;
|
|
35
|
-
'migration:quarantine'?: LogLevel | false;
|
|
36
|
-
'batch:progress'?: LogLevel | false;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* EventLogger class for integrating events with logging and metrics
|
|
40
|
-
*/
|
|
41
|
-
export declare class EventLogger {
|
|
42
|
-
private logger;
|
|
43
|
-
private metricsCollector;
|
|
44
|
-
private config;
|
|
45
|
-
private unsubscribeFns;
|
|
46
|
-
constructor(logger: Logger, metricsCollector: MetricsCollector);
|
|
47
|
-
/**
|
|
48
|
-
* Subscribe to all events from an EventEmitter
|
|
49
|
-
*/
|
|
50
|
-
subscribeToEvents(eventEmitter: EventEmitter): void;
|
|
51
|
-
/**
|
|
52
|
-
* Configure which events to log at which levels
|
|
53
|
-
*/
|
|
54
|
-
configureEventLogging(config: EventLoggingConfig): void;
|
|
55
|
-
/**
|
|
56
|
-
* Unsubscribe from all events
|
|
57
|
-
*/
|
|
58
|
-
unsubscribe(): void;
|
|
59
|
-
/**
|
|
60
|
-
* Handle an event - log and extract metrics
|
|
61
|
-
*/
|
|
62
|
-
private handleEvent;
|
|
63
|
-
/**
|
|
64
|
-
* Log an event at the specified level
|
|
65
|
-
*/
|
|
66
|
-
private logEvent;
|
|
67
|
-
/**
|
|
68
|
-
* Extract metrics from an event
|
|
69
|
-
*/
|
|
70
|
-
private extractMetrics;
|
|
71
|
-
}
|
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Event Logger - Integration between Event System and Logger
|
|
3
|
-
*
|
|
4
|
-
* Features:
|
|
5
|
-
* - Auto-subscribe to EventEmitter events
|
|
6
|
-
* - Configurable logging levels per event type
|
|
7
|
-
* - Automatic metrics extraction from events
|
|
8
|
-
* - Performance tracking
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Default event logging configuration
|
|
12
|
-
*/
|
|
13
|
-
const DEFAULT_EVENT_CONFIG = {
|
|
14
|
-
'asset:created': 'info',
|
|
15
|
-
'asset:migrated': 'info',
|
|
16
|
-
'asset:transferred': 'info',
|
|
17
|
-
'resource:published': 'info',
|
|
18
|
-
'credential:issued': 'info',
|
|
19
|
-
'resource:version:created': 'info',
|
|
20
|
-
'verification:completed': 'info',
|
|
21
|
-
'batch:started': 'info',
|
|
22
|
-
'batch:completed': 'info',
|
|
23
|
-
'batch:failed': 'warn',
|
|
24
|
-
'migration:started': 'info',
|
|
25
|
-
'migration:validated': 'info',
|
|
26
|
-
'migration:checkpointed': 'info',
|
|
27
|
-
'migration:in_progress': 'info',
|
|
28
|
-
'migration:anchoring': 'info',
|
|
29
|
-
'migration:completed': 'info',
|
|
30
|
-
'migration:failed': 'warn',
|
|
31
|
-
'migration:rolledback': 'warn',
|
|
32
|
-
'migration:quarantine': 'error',
|
|
33
|
-
'batch:progress': 'debug'
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* EventLogger class for integrating events with logging and metrics
|
|
37
|
-
*/
|
|
38
|
-
export class EventLogger {
|
|
39
|
-
constructor(logger, metricsCollector) {
|
|
40
|
-
this.logger = logger;
|
|
41
|
-
this.metricsCollector = metricsCollector;
|
|
42
|
-
this.unsubscribeFns = [];
|
|
43
|
-
this.config = { ...DEFAULT_EVENT_CONFIG };
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Subscribe to all events from an EventEmitter
|
|
47
|
-
*/
|
|
48
|
-
subscribeToEvents(eventEmitter) {
|
|
49
|
-
// Subscribe to each event type
|
|
50
|
-
const eventTypes = [
|
|
51
|
-
'asset:created',
|
|
52
|
-
'asset:migrated',
|
|
53
|
-
'asset:transferred',
|
|
54
|
-
'resource:published',
|
|
55
|
-
'credential:issued',
|
|
56
|
-
'resource:version:created',
|
|
57
|
-
'verification:completed',
|
|
58
|
-
'batch:started',
|
|
59
|
-
'batch:completed',
|
|
60
|
-
'batch:failed'
|
|
61
|
-
];
|
|
62
|
-
for (const eventType of eventTypes) {
|
|
63
|
-
const unsubscribe = eventEmitter.on(eventType, (event) => {
|
|
64
|
-
this.handleEvent(event);
|
|
65
|
-
});
|
|
66
|
-
this.unsubscribeFns.push(unsubscribe);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Configure which events to log at which levels
|
|
71
|
-
*/
|
|
72
|
-
configureEventLogging(config) {
|
|
73
|
-
this.config = { ...this.config, ...config };
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Unsubscribe from all events
|
|
77
|
-
*/
|
|
78
|
-
unsubscribe() {
|
|
79
|
-
for (const unsubscribe of this.unsubscribeFns) {
|
|
80
|
-
unsubscribe();
|
|
81
|
-
}
|
|
82
|
-
this.unsubscribeFns = [];
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Handle an event - log and extract metrics
|
|
86
|
-
*/
|
|
87
|
-
handleEvent(event) {
|
|
88
|
-
const eventType = event.type;
|
|
89
|
-
const logLevel = this.config[eventType];
|
|
90
|
-
// Always extract metrics from the event (even if logging is disabled)
|
|
91
|
-
this.extractMetrics(event);
|
|
92
|
-
// Skip logging if disabled for this event type
|
|
93
|
-
if (logLevel === false) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
// Log the event
|
|
97
|
-
if (logLevel) {
|
|
98
|
-
this.logEvent(event, logLevel);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Log an event at the specified level
|
|
103
|
-
*/
|
|
104
|
-
logEvent(event, level) {
|
|
105
|
-
let message;
|
|
106
|
-
let data;
|
|
107
|
-
switch (event.type) {
|
|
108
|
-
case 'asset:created':
|
|
109
|
-
message = 'Asset created';
|
|
110
|
-
data = {
|
|
111
|
-
assetId: event.asset.id,
|
|
112
|
-
layer: event.asset.layer,
|
|
113
|
-
resourceCount: event.asset.resourceCount
|
|
114
|
-
};
|
|
115
|
-
break;
|
|
116
|
-
case 'asset:migrated':
|
|
117
|
-
message = 'Asset migrated';
|
|
118
|
-
data = {
|
|
119
|
-
assetId: event.asset.id,
|
|
120
|
-
fromLayer: event.asset.fromLayer,
|
|
121
|
-
toLayer: event.asset.toLayer,
|
|
122
|
-
details: event.details
|
|
123
|
-
};
|
|
124
|
-
break;
|
|
125
|
-
case 'asset:transferred':
|
|
126
|
-
message = 'Asset transferred';
|
|
127
|
-
data = {
|
|
128
|
-
assetId: event.asset.id,
|
|
129
|
-
layer: event.asset.layer,
|
|
130
|
-
from: event.from,
|
|
131
|
-
to: event.to,
|
|
132
|
-
transactionId: event.transactionId
|
|
133
|
-
};
|
|
134
|
-
break;
|
|
135
|
-
case 'resource:published':
|
|
136
|
-
message = 'Resource published';
|
|
137
|
-
data = {
|
|
138
|
-
assetId: event.asset.id,
|
|
139
|
-
resourceId: event.resource.id,
|
|
140
|
-
url: event.resource.url,
|
|
141
|
-
publisherDid: event.publisherDid
|
|
142
|
-
};
|
|
143
|
-
break;
|
|
144
|
-
case 'credential:issued':
|
|
145
|
-
message = 'Credential issued';
|
|
146
|
-
data = {
|
|
147
|
-
assetId: event.asset.id,
|
|
148
|
-
credentialType: event.credential.type,
|
|
149
|
-
issuer: event.credential.issuer
|
|
150
|
-
};
|
|
151
|
-
break;
|
|
152
|
-
case 'resource:version:created':
|
|
153
|
-
message = 'Resource version created';
|
|
154
|
-
data = {
|
|
155
|
-
assetId: event.asset.id,
|
|
156
|
-
resourceId: event.resource.id,
|
|
157
|
-
fromVersion: event.resource.fromVersion,
|
|
158
|
-
toVersion: event.resource.toVersion,
|
|
159
|
-
changes: event.changes
|
|
160
|
-
};
|
|
161
|
-
break;
|
|
162
|
-
case 'verification:completed':
|
|
163
|
-
message = 'Verification completed';
|
|
164
|
-
data = {
|
|
165
|
-
assetId: event.asset.id,
|
|
166
|
-
result: event.result,
|
|
167
|
-
checks: event.checks
|
|
168
|
-
};
|
|
169
|
-
break;
|
|
170
|
-
case 'batch:started':
|
|
171
|
-
message = 'Batch operation started';
|
|
172
|
-
data = {
|
|
173
|
-
batchId: event.batchId,
|
|
174
|
-
operation: event.operation,
|
|
175
|
-
itemCount: event.itemCount
|
|
176
|
-
};
|
|
177
|
-
break;
|
|
178
|
-
case 'batch:completed':
|
|
179
|
-
message = 'Batch operation completed';
|
|
180
|
-
data = {
|
|
181
|
-
batchId: event.batchId,
|
|
182
|
-
operation: event.operation,
|
|
183
|
-
results: event.results
|
|
184
|
-
};
|
|
185
|
-
break;
|
|
186
|
-
case 'batch:failed':
|
|
187
|
-
message = 'Batch operation failed';
|
|
188
|
-
data = {
|
|
189
|
-
batchId: event.batchId,
|
|
190
|
-
operation: event.operation,
|
|
191
|
-
error: event.error,
|
|
192
|
-
partialResults: event.partialResults
|
|
193
|
-
};
|
|
194
|
-
break;
|
|
195
|
-
default:
|
|
196
|
-
return; // Unknown event type
|
|
197
|
-
}
|
|
198
|
-
// Call the appropriate log method based on level
|
|
199
|
-
switch (level) {
|
|
200
|
-
case 'debug':
|
|
201
|
-
this.logger.debug(message, data);
|
|
202
|
-
break;
|
|
203
|
-
case 'info':
|
|
204
|
-
this.logger.info(message, data);
|
|
205
|
-
break;
|
|
206
|
-
case 'warn':
|
|
207
|
-
this.logger.warn(message, data);
|
|
208
|
-
break;
|
|
209
|
-
case 'error':
|
|
210
|
-
this.logger.error(message, undefined, data);
|
|
211
|
-
break;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Extract metrics from an event
|
|
216
|
-
*/
|
|
217
|
-
extractMetrics(event) {
|
|
218
|
-
switch (event.type) {
|
|
219
|
-
case 'asset:created':
|
|
220
|
-
this.metricsCollector.recordAssetCreated();
|
|
221
|
-
break;
|
|
222
|
-
case 'asset:migrated':
|
|
223
|
-
this.metricsCollector.recordMigration(event.asset.fromLayer, event.asset.toLayer);
|
|
224
|
-
break;
|
|
225
|
-
case 'asset:transferred':
|
|
226
|
-
this.metricsCollector.recordTransfer();
|
|
227
|
-
break;
|
|
228
|
-
// Other events don't need explicit metric recording
|
|
229
|
-
// as they're tracked elsewhere
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|