@originals/sdk 1.2.0 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/package.json +1 -1
  2. package/src/did/DIDManager.ts +1 -1
  3. package/src/did/WebVHManager.ts +11 -2
  4. package/src/examples/create-module-original.ts +435 -0
  5. package/src/examples/full-lifecycle-flow.ts +514 -0
  6. package/src/examples/run.ts +59 -4
  7. package/src/index.ts +69 -3
  8. package/src/kinds/KindRegistry.ts +290 -0
  9. package/src/kinds/index.ts +74 -0
  10. package/src/kinds/types.ts +470 -0
  11. package/src/kinds/validators/AgentValidator.ts +257 -0
  12. package/src/kinds/validators/AppValidator.ts +211 -0
  13. package/src/kinds/validators/DatasetValidator.ts +242 -0
  14. package/src/kinds/validators/DocumentValidator.ts +311 -0
  15. package/src/kinds/validators/MediaValidator.ts +269 -0
  16. package/src/kinds/validators/ModuleValidator.ts +225 -0
  17. package/src/kinds/validators/base.ts +276 -0
  18. package/src/kinds/validators/index.ts +12 -0
  19. package/src/lifecycle/LifecycleManager.ts +909 -1
  20. package/src/resources/ResourceManager.ts +655 -0
  21. package/src/resources/index.ts +21 -0
  22. package/src/resources/types.ts +202 -0
  23. package/src/types/common.ts +1 -1
  24. package/src/vc/CredentialManager.ts +647 -2
  25. package/tests/integration/createTypedOriginal.test.ts +379 -0
  26. package/tests/performance/BatchOperations.perf.test.ts +2 -2
  27. package/tests/unit/kinds/KindRegistry.test.ts +329 -0
  28. package/tests/unit/kinds/types.test.ts +409 -0
  29. package/tests/unit/kinds/validators.test.ts +651 -0
  30. package/tests/unit/lifecycle/LifecycleManager.cleanapi.test.ts +441 -0
  31. package/tests/unit/resources/ResourceManager.test.ts +740 -0
  32. package/tests/unit/vc/CredentialManager.helpers.test.ts +527 -0
  33. package/.turbo/turbo-build.log +0 -1
  34. package/dist/adapters/FeeOracleMock.d.ts +0 -6
  35. package/dist/adapters/FeeOracleMock.js +0 -8
  36. package/dist/adapters/index.d.ts +0 -4
  37. package/dist/adapters/index.js +0 -4
  38. package/dist/adapters/providers/OrdHttpProvider.d.ts +0 -56
  39. package/dist/adapters/providers/OrdHttpProvider.js +0 -110
  40. package/dist/adapters/providers/OrdMockProvider.d.ts +0 -70
  41. package/dist/adapters/providers/OrdMockProvider.js +0 -75
  42. package/dist/adapters/types.d.ts +0 -71
  43. package/dist/adapters/types.js +0 -1
  44. package/dist/bitcoin/BitcoinManager.d.ts +0 -15
  45. package/dist/bitcoin/BitcoinManager.js +0 -262
  46. package/dist/bitcoin/BroadcastClient.d.ts +0 -30
  47. package/dist/bitcoin/BroadcastClient.js +0 -35
  48. package/dist/bitcoin/OrdinalsClient.d.ts +0 -21
  49. package/dist/bitcoin/OrdinalsClient.js +0 -105
  50. package/dist/bitcoin/PSBTBuilder.d.ts +0 -24
  51. package/dist/bitcoin/PSBTBuilder.js +0 -80
  52. package/dist/bitcoin/fee-calculation.d.ts +0 -14
  53. package/dist/bitcoin/fee-calculation.js +0 -31
  54. package/dist/bitcoin/providers/OrdNodeProvider.d.ts +0 -38
  55. package/dist/bitcoin/providers/OrdNodeProvider.js +0 -67
  56. package/dist/bitcoin/providers/OrdinalsProvider.d.ts +0 -33
  57. package/dist/bitcoin/providers/OrdinalsProvider.js +0 -50
  58. package/dist/bitcoin/providers/types.d.ts +0 -63
  59. package/dist/bitcoin/providers/types.js +0 -1
  60. package/dist/bitcoin/transactions/commit.d.ts +0 -89
  61. package/dist/bitcoin/transactions/commit.js +0 -311
  62. package/dist/bitcoin/transactions/index.d.ts +0 -7
  63. package/dist/bitcoin/transactions/index.js +0 -8
  64. package/dist/bitcoin/transfer.d.ts +0 -9
  65. package/dist/bitcoin/transfer.js +0 -26
  66. package/dist/bitcoin/utxo-selection.d.ts +0 -78
  67. package/dist/bitcoin/utxo-selection.js +0 -237
  68. package/dist/bitcoin/utxo.d.ts +0 -26
  69. package/dist/bitcoin/utxo.js +0 -78
  70. package/dist/contexts/credentials-v1.json +0 -195
  71. package/dist/contexts/credentials-v2-examples.json +0 -5
  72. package/dist/contexts/credentials-v2.json +0 -301
  73. package/dist/contexts/credentials.json +0 -195
  74. package/dist/contexts/data-integrity-v2.json +0 -81
  75. package/dist/contexts/dids.json +0 -57
  76. package/dist/contexts/ed255192020.json +0 -93
  77. package/dist/contexts/ordinals-plus.json +0 -23
  78. package/dist/contexts/originals.json +0 -22
  79. package/dist/core/OriginalsSDK.d.ts +0 -158
  80. package/dist/core/OriginalsSDK.js +0 -274
  81. package/dist/crypto/Multikey.d.ts +0 -30
  82. package/dist/crypto/Multikey.js +0 -149
  83. package/dist/crypto/Signer.d.ts +0 -21
  84. package/dist/crypto/Signer.js +0 -196
  85. package/dist/crypto/noble-init.d.ts +0 -18
  86. package/dist/crypto/noble-init.js +0 -106
  87. package/dist/did/BtcoDidResolver.d.ts +0 -57
  88. package/dist/did/BtcoDidResolver.js +0 -166
  89. package/dist/did/DIDManager.d.ts +0 -101
  90. package/dist/did/DIDManager.js +0 -493
  91. package/dist/did/Ed25519Verifier.d.ts +0 -30
  92. package/dist/did/Ed25519Verifier.js +0 -59
  93. package/dist/did/KeyManager.d.ts +0 -17
  94. package/dist/did/KeyManager.js +0 -207
  95. package/dist/did/WebVHManager.d.ts +0 -100
  96. package/dist/did/WebVHManager.js +0 -304
  97. package/dist/did/createBtcoDidDocument.d.ts +0 -10
  98. package/dist/did/createBtcoDidDocument.js +0 -42
  99. package/dist/did/providers/OrdinalsClientProviderAdapter.d.ts +0 -23
  100. package/dist/did/providers/OrdinalsClientProviderAdapter.js +0 -51
  101. package/dist/events/EventEmitter.d.ts +0 -115
  102. package/dist/events/EventEmitter.js +0 -198
  103. package/dist/events/index.d.ts +0 -7
  104. package/dist/events/index.js +0 -6
  105. package/dist/events/types.d.ts +0 -286
  106. package/dist/events/types.js +0 -9
  107. package/dist/examples/basic-usage.d.ts +0 -3
  108. package/dist/examples/basic-usage.js +0 -62
  109. package/dist/examples/run.d.ts +0 -1
  110. package/dist/examples/run.js +0 -4
  111. package/dist/index.d.ts +0 -39
  112. package/dist/index.js +0 -47
  113. package/dist/lifecycle/BatchOperations.d.ts +0 -147
  114. package/dist/lifecycle/BatchOperations.js +0 -251
  115. package/dist/lifecycle/LifecycleManager.d.ts +0 -116
  116. package/dist/lifecycle/LifecycleManager.js +0 -971
  117. package/dist/lifecycle/OriginalsAsset.d.ts +0 -164
  118. package/dist/lifecycle/OriginalsAsset.js +0 -380
  119. package/dist/lifecycle/ProvenanceQuery.d.ts +0 -126
  120. package/dist/lifecycle/ProvenanceQuery.js +0 -220
  121. package/dist/lifecycle/ResourceVersioning.d.ts +0 -73
  122. package/dist/lifecycle/ResourceVersioning.js +0 -127
  123. package/dist/migration/MigrationManager.d.ts +0 -86
  124. package/dist/migration/MigrationManager.js +0 -412
  125. package/dist/migration/audit/AuditLogger.d.ts +0 -51
  126. package/dist/migration/audit/AuditLogger.js +0 -156
  127. package/dist/migration/checkpoint/CheckpointManager.d.ts +0 -31
  128. package/dist/migration/checkpoint/CheckpointManager.js +0 -96
  129. package/dist/migration/checkpoint/CheckpointStorage.d.ts +0 -26
  130. package/dist/migration/checkpoint/CheckpointStorage.js +0 -89
  131. package/dist/migration/index.d.ts +0 -22
  132. package/dist/migration/index.js +0 -27
  133. package/dist/migration/operations/BaseMigration.d.ts +0 -48
  134. package/dist/migration/operations/BaseMigration.js +0 -83
  135. package/dist/migration/operations/PeerToBtcoMigration.d.ts +0 -25
  136. package/dist/migration/operations/PeerToBtcoMigration.js +0 -67
  137. package/dist/migration/operations/PeerToWebvhMigration.d.ts +0 -19
  138. package/dist/migration/operations/PeerToWebvhMigration.js +0 -46
  139. package/dist/migration/operations/WebvhToBtcoMigration.d.ts +0 -25
  140. package/dist/migration/operations/WebvhToBtcoMigration.js +0 -67
  141. package/dist/migration/rollback/RollbackManager.d.ts +0 -29
  142. package/dist/migration/rollback/RollbackManager.js +0 -146
  143. package/dist/migration/state/StateMachine.d.ts +0 -25
  144. package/dist/migration/state/StateMachine.js +0 -76
  145. package/dist/migration/state/StateTracker.d.ts +0 -36
  146. package/dist/migration/state/StateTracker.js +0 -123
  147. package/dist/migration/types.d.ts +0 -306
  148. package/dist/migration/types.js +0 -33
  149. package/dist/migration/validation/BitcoinValidator.d.ts +0 -13
  150. package/dist/migration/validation/BitcoinValidator.js +0 -83
  151. package/dist/migration/validation/CredentialValidator.d.ts +0 -13
  152. package/dist/migration/validation/CredentialValidator.js +0 -46
  153. package/dist/migration/validation/DIDCompatibilityValidator.d.ts +0 -16
  154. package/dist/migration/validation/DIDCompatibilityValidator.js +0 -127
  155. package/dist/migration/validation/LifecycleValidator.d.ts +0 -10
  156. package/dist/migration/validation/LifecycleValidator.js +0 -52
  157. package/dist/migration/validation/StorageValidator.d.ts +0 -10
  158. package/dist/migration/validation/StorageValidator.js +0 -65
  159. package/dist/migration/validation/ValidationPipeline.d.ts +0 -29
  160. package/dist/migration/validation/ValidationPipeline.js +0 -180
  161. package/dist/storage/LocalStorageAdapter.d.ts +0 -11
  162. package/dist/storage/LocalStorageAdapter.js +0 -53
  163. package/dist/storage/MemoryStorageAdapter.d.ts +0 -6
  164. package/dist/storage/MemoryStorageAdapter.js +0 -21
  165. package/dist/storage/StorageAdapter.d.ts +0 -16
  166. package/dist/storage/StorageAdapter.js +0 -1
  167. package/dist/storage/index.d.ts +0 -2
  168. package/dist/storage/index.js +0 -2
  169. package/dist/types/bitcoin.d.ts +0 -84
  170. package/dist/types/bitcoin.js +0 -1
  171. package/dist/types/common.d.ts +0 -82
  172. package/dist/types/common.js +0 -1
  173. package/dist/types/credentials.d.ts +0 -75
  174. package/dist/types/credentials.js +0 -1
  175. package/dist/types/did.d.ts +0 -26
  176. package/dist/types/did.js +0 -1
  177. package/dist/types/index.d.ts +0 -5
  178. package/dist/types/index.js +0 -5
  179. package/dist/types/network.d.ts +0 -78
  180. package/dist/types/network.js +0 -145
  181. package/dist/utils/EventLogger.d.ts +0 -71
  182. package/dist/utils/EventLogger.js +0 -232
  183. package/dist/utils/Logger.d.ts +0 -106
  184. package/dist/utils/Logger.js +0 -257
  185. package/dist/utils/MetricsCollector.d.ts +0 -110
  186. package/dist/utils/MetricsCollector.js +0 -264
  187. package/dist/utils/bitcoin-address.d.ts +0 -38
  188. package/dist/utils/bitcoin-address.js +0 -113
  189. package/dist/utils/cbor.d.ts +0 -2
  190. package/dist/utils/cbor.js +0 -9
  191. package/dist/utils/encoding.d.ts +0 -37
  192. package/dist/utils/encoding.js +0 -120
  193. package/dist/utils/hash.d.ts +0 -1
  194. package/dist/utils/hash.js +0 -5
  195. package/dist/utils/retry.d.ts +0 -10
  196. package/dist/utils/retry.js +0 -35
  197. package/dist/utils/satoshi-validation.d.ts +0 -60
  198. package/dist/utils/satoshi-validation.js +0 -156
  199. package/dist/utils/serialization.d.ts +0 -14
  200. package/dist/utils/serialization.js +0 -76
  201. package/dist/utils/telemetry.d.ts +0 -17
  202. package/dist/utils/telemetry.js +0 -24
  203. package/dist/utils/validation.d.ts +0 -5
  204. package/dist/utils/validation.js +0 -98
  205. package/dist/vc/CredentialManager.d.ts +0 -22
  206. package/dist/vc/CredentialManager.js +0 -227
  207. package/dist/vc/Issuer.d.ts +0 -27
  208. package/dist/vc/Issuer.js +0 -70
  209. package/dist/vc/Verifier.d.ts +0 -16
  210. package/dist/vc/Verifier.js +0 -50
  211. package/dist/vc/cryptosuites/bbs.d.ts +0 -44
  212. package/dist/vc/cryptosuites/bbs.js +0 -213
  213. package/dist/vc/cryptosuites/bbsSimple.d.ts +0 -9
  214. package/dist/vc/cryptosuites/bbsSimple.js +0 -12
  215. package/dist/vc/cryptosuites/eddsa.d.ts +0 -30
  216. package/dist/vc/cryptosuites/eddsa.js +0 -81
  217. package/dist/vc/documentLoader.d.ts +0 -16
  218. package/dist/vc/documentLoader.js +0 -59
  219. package/dist/vc/proofs/data-integrity.d.ts +0 -21
  220. package/dist/vc/proofs/data-integrity.js +0 -15
  221. package/dist/vc/utils/jsonld.d.ts +0 -2
  222. package/dist/vc/utils/jsonld.js +0 -15
  223. package/test/logs/did_webvh_QmNTn9Kkp8dQ75WrF9xqJ2kuDp9QhKc3aPiERRMj8XoTBN_example_com.jsonl +0 -1
  224. package/test/logs/did_webvh_QmNu4MNr8Lr5txx5gYNhuhZDchXsZEu3hJXKYuphpWTPDp_example_com_users_etc_passwd.jsonl +0 -1
  225. package/test/logs/did_webvh_QmR9MrGZACzjKETA8SBRNCKG11HxU85c4bVR2qN5eDCfsD_example_com.jsonl +0 -1
  226. package/test/logs/did_webvh_QmUc5suaqRM2P4nrXxZwqYMfqzhdMqjuL7oJaJbEpCQVCd_example_com_users_etc_passwd.jsonl +0 -1
  227. package/test/logs/did_webvh_QmUkiB2RCV2VZ1RTXsCebWN25Eiy9TLvpzDWAJNjhgvB4X_example_com_etc_passwd.jsonl +0 -1
  228. package/test/logs/did_webvh_QmUoRTe8UMwpAQXZSAW7pjAgZK1tq2X3C6Kfxq3UXGcaGy_example_com_secret.jsonl +0 -1
  229. package/test/logs/did_webvh_QmWWot3chx1t6KwTmcE5i2FeDZ5JMkQw3qXycsKDVmJ9Be_example_com_users_alice.jsonl +0 -1
  230. package/test/logs/did_webvh_QmWvVgALL5kjZdpgR7KZay7J8UiiUr834kkRmWeFAxjAuC_example_com_users_etc_passwd.jsonl +0 -1
  231. package/test/logs/did_webvh_QmWwaRQHUZAFcKihFC6xR6tRTTrQhHPTku6azf1egWbpy1_example_com_users_alice.jsonl +0 -1
  232. package/test/logs/did_webvh_QmXJLtkz23r7AozbtXsZMKWnVU6rd38CkVtjdWuATU3Yp6_example_com_users_alice123_profile.jsonl +0 -1
  233. package/test/logs/did_webvh_QmYsce448po14oDE1wXbyaP6wY9HQgHSKLwdezn1k577SF_example_com_my_org_user_name_test_123.jsonl +0 -1
  234. package/test/logs/did_webvh_QmZBeNzzqajxdfwcDUPZ4P8C5YSXyRztrAwmPiKuKUxmAK_example_com.jsonl +0 -1
  235. package/test/logs/did_webvh_QmZhJsqxizwVbRtqCUkmE6XQunSxtxMt3gbTYadVBNAaEq_example_com.jsonl +0 -1
  236. package/test/logs/did_webvh_QmZk7NHU2D57RzzbMq4tWW9gBa9AqtVTWfiRM6RFdwGVj2_example_com.jsonl +0 -1
  237. package/test/logs/did_webvh_QmZshSXp9w8ovH62zGGBS1b5pGGPsuYiu1VQ935sga2hWF_example_com_level1_level2.jsonl +0 -1
  238. package/test/logs/did_webvh_QmbWAmw7HQL7vKJyCsctZihXf1rmT4sGvggKCPKWcUWjw1_example_com.jsonl +0 -1
  239. package/test/logs/did_webvh_QmbdLUMbYs3juR39TLB6hhrFWLcNg45ybUzeBJCS1MhCh1_example_com_C_Windows_System32.jsonl +0 -1
  240. package/test/logs/did_webvh_QmcaQ1Ma4gkSbae85aCm8Mv4rvdT2Sb2RR3JzYwrm5XBq8_example_com_etc_passwd.jsonl +0 -1
  241. package/test/logs/did_webvh_QmcbA7WQhsBqZSoDpKJHjV8Q5o53h8vmgJhQfo6rqTY5ho_example_com.jsonl +0 -1
  242. package/test/logs/did_webvh_Qmdy8uWr2gkUJrXsThynAug3DASTWwb3onEj89LKmMGZYB_example_com.jsonl +0 -1
  243. package/tests/e2e/README.md +0 -97
  244. package/tests/e2e/example.spec.ts +0 -78
@@ -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 {};
@@ -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 {};
@@ -1,5 +0,0 @@
1
- export * from './common';
2
- export * from './did';
3
- export * from './credentials';
4
- export * from './bitcoin';
5
- export * from './network';
@@ -1,5 +0,0 @@
1
- export * from './common';
2
- export * from './did';
3
- export * from './credentials';
4
- export * from './bitcoin';
5
- export * from './network';
@@ -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;
@@ -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
- }