@originals/sdk 1.4.3 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/FeeOracleMock.d.ts +6 -0
- package/dist/adapters/FeeOracleMock.js +8 -0
- package/dist/adapters/index.d.ts +4 -0
- package/dist/adapters/index.js +4 -0
- package/dist/adapters/providers/OrdHttpProvider.d.ts +56 -0
- package/dist/adapters/providers/OrdHttpProvider.js +110 -0
- package/dist/adapters/providers/OrdMockProvider.d.ts +70 -0
- package/dist/adapters/providers/OrdMockProvider.js +75 -0
- package/dist/adapters/types.d.ts +71 -0
- package/dist/adapters/types.js +1 -0
- package/dist/bitcoin/BitcoinManager.d.ts +15 -0
- package/dist/bitcoin/BitcoinManager.js +262 -0
- package/dist/bitcoin/BroadcastClient.d.ts +30 -0
- package/dist/bitcoin/BroadcastClient.js +35 -0
- package/dist/bitcoin/OrdinalsClient.d.ts +21 -0
- package/dist/bitcoin/OrdinalsClient.js +105 -0
- package/dist/bitcoin/PSBTBuilder.d.ts +24 -0
- package/dist/bitcoin/PSBTBuilder.js +80 -0
- package/dist/bitcoin/fee-calculation.d.ts +14 -0
- package/dist/bitcoin/fee-calculation.js +31 -0
- package/dist/bitcoin/providers/OrdNodeProvider.d.ts +38 -0
- package/dist/bitcoin/providers/OrdNodeProvider.js +67 -0
- package/dist/bitcoin/providers/OrdinalsProvider.d.ts +33 -0
- package/dist/bitcoin/providers/OrdinalsProvider.js +50 -0
- package/dist/bitcoin/providers/types.d.ts +63 -0
- package/dist/bitcoin/providers/types.js +1 -0
- package/dist/bitcoin/transactions/commit.d.ts +89 -0
- package/dist/bitcoin/transactions/commit.js +311 -0
- package/dist/bitcoin/transactions/index.d.ts +7 -0
- package/dist/bitcoin/transactions/index.js +8 -0
- package/dist/bitcoin/transfer.d.ts +9 -0
- package/dist/bitcoin/transfer.js +26 -0
- package/dist/bitcoin/utxo-selection.d.ts +78 -0
- package/dist/bitcoin/utxo-selection.js +237 -0
- package/dist/bitcoin/utxo.d.ts +26 -0
- package/dist/bitcoin/utxo.js +78 -0
- package/dist/contexts/credentials-v1.json +195 -0
- package/dist/contexts/credentials-v2-examples.json +5 -0
- package/dist/contexts/credentials-v2.json +301 -0
- package/dist/contexts/credentials.json +195 -0
- package/dist/contexts/data-integrity-v2.json +81 -0
- package/dist/contexts/dids.json +57 -0
- package/dist/contexts/ed255192020.json +93 -0
- package/dist/contexts/ordinals-plus.json +23 -0
- package/dist/contexts/originals.json +22 -0
- package/dist/core/OriginalsSDK.d.ts +158 -0
- package/dist/core/OriginalsSDK.js +274 -0
- package/dist/crypto/Multikey.d.ts +30 -0
- package/dist/crypto/Multikey.js +149 -0
- package/dist/crypto/Signer.d.ts +21 -0
- package/dist/crypto/Signer.js +196 -0
- package/dist/crypto/noble-init.d.ts +18 -0
- package/dist/crypto/noble-init.js +106 -0
- package/dist/did/BtcoDidResolver.d.ts +57 -0
- package/dist/did/BtcoDidResolver.js +166 -0
- package/dist/did/DIDManager.d.ts +101 -0
- package/dist/did/DIDManager.js +493 -0
- package/dist/did/Ed25519Verifier.d.ts +30 -0
- package/dist/did/Ed25519Verifier.js +59 -0
- package/dist/did/KeyManager.d.ts +17 -0
- package/dist/did/KeyManager.js +207 -0
- package/dist/did/WebVHManager.d.ts +100 -0
- package/dist/did/WebVHManager.js +312 -0
- package/dist/did/createBtcoDidDocument.d.ts +10 -0
- package/dist/did/createBtcoDidDocument.js +42 -0
- package/dist/did/providers/OrdinalsClientProviderAdapter.d.ts +23 -0
- package/dist/did/providers/OrdinalsClientProviderAdapter.js +51 -0
- package/dist/events/EventEmitter.d.ts +115 -0
- package/dist/events/EventEmitter.js +198 -0
- package/dist/events/index.d.ts +7 -0
- package/dist/events/index.js +6 -0
- package/dist/events/types.d.ts +286 -0
- package/dist/events/types.js +9 -0
- package/dist/examples/basic-usage.d.ts +3 -0
- package/dist/examples/basic-usage.js +62 -0
- package/dist/examples/create-module-original.d.ts +32 -0
- package/dist/examples/create-module-original.js +376 -0
- package/dist/examples/full-lifecycle-flow.d.ts +56 -0
- package/dist/examples/full-lifecycle-flow.js +419 -0
- package/dist/examples/run.d.ts +12 -0
- package/dist/examples/run.js +51 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +52 -0
- package/dist/kinds/KindRegistry.d.ts +76 -0
- package/dist/kinds/KindRegistry.js +216 -0
- package/dist/kinds/index.d.ts +33 -0
- package/dist/kinds/index.js +36 -0
- package/dist/kinds/types.d.ts +363 -0
- package/dist/kinds/types.js +25 -0
- package/dist/kinds/validators/AgentValidator.d.ts +14 -0
- package/dist/kinds/validators/AgentValidator.js +155 -0
- package/dist/kinds/validators/AppValidator.d.ts +14 -0
- package/dist/kinds/validators/AppValidator.js +135 -0
- package/dist/kinds/validators/DatasetValidator.d.ts +14 -0
- package/dist/kinds/validators/DatasetValidator.js +148 -0
- package/dist/kinds/validators/DocumentValidator.d.ts +14 -0
- package/dist/kinds/validators/DocumentValidator.js +180 -0
- package/dist/kinds/validators/MediaValidator.d.ts +14 -0
- package/dist/kinds/validators/MediaValidator.js +172 -0
- package/dist/kinds/validators/ModuleValidator.d.ts +14 -0
- package/dist/kinds/validators/ModuleValidator.js +140 -0
- package/dist/kinds/validators/base.d.ts +96 -0
- package/dist/kinds/validators/base.js +218 -0
- package/dist/kinds/validators/index.d.ts +10 -0
- package/dist/kinds/validators/index.js +10 -0
- package/dist/lifecycle/BatchOperations.d.ts +147 -0
- package/dist/lifecycle/BatchOperations.js +251 -0
- package/dist/lifecycle/LifecycleManager.d.ts +362 -0
- package/dist/lifecycle/LifecycleManager.js +1692 -0
- package/dist/lifecycle/OriginalsAsset.d.ts +164 -0
- package/dist/lifecycle/OriginalsAsset.js +380 -0
- package/dist/lifecycle/ProvenanceQuery.d.ts +126 -0
- package/dist/lifecycle/ProvenanceQuery.js +220 -0
- package/dist/lifecycle/ResourceVersioning.d.ts +73 -0
- package/dist/lifecycle/ResourceVersioning.js +127 -0
- package/dist/migration/MigrationManager.d.ts +86 -0
- package/dist/migration/MigrationManager.js +412 -0
- package/dist/migration/audit/AuditLogger.d.ts +51 -0
- package/dist/migration/audit/AuditLogger.js +156 -0
- package/dist/migration/checkpoint/CheckpointManager.d.ts +31 -0
- package/dist/migration/checkpoint/CheckpointManager.js +96 -0
- package/dist/migration/checkpoint/CheckpointStorage.d.ts +26 -0
- package/dist/migration/checkpoint/CheckpointStorage.js +89 -0
- package/dist/migration/index.d.ts +22 -0
- package/dist/migration/index.js +27 -0
- package/dist/migration/operations/BaseMigration.d.ts +48 -0
- package/dist/migration/operations/BaseMigration.js +83 -0
- package/dist/migration/operations/PeerToBtcoMigration.d.ts +25 -0
- package/dist/migration/operations/PeerToBtcoMigration.js +67 -0
- package/dist/migration/operations/PeerToWebvhMigration.d.ts +19 -0
- package/dist/migration/operations/PeerToWebvhMigration.js +46 -0
- package/dist/migration/operations/WebvhToBtcoMigration.d.ts +25 -0
- package/dist/migration/operations/WebvhToBtcoMigration.js +67 -0
- package/dist/migration/rollback/RollbackManager.d.ts +29 -0
- package/dist/migration/rollback/RollbackManager.js +146 -0
- package/dist/migration/state/StateMachine.d.ts +25 -0
- package/dist/migration/state/StateMachine.js +76 -0
- package/dist/migration/state/StateTracker.d.ts +36 -0
- package/dist/migration/state/StateTracker.js +123 -0
- package/dist/migration/types.d.ts +306 -0
- package/dist/migration/types.js +33 -0
- package/dist/migration/validation/BitcoinValidator.d.ts +13 -0
- package/dist/migration/validation/BitcoinValidator.js +83 -0
- package/dist/migration/validation/CredentialValidator.d.ts +13 -0
- package/dist/migration/validation/CredentialValidator.js +46 -0
- package/dist/migration/validation/DIDCompatibilityValidator.d.ts +16 -0
- package/dist/migration/validation/DIDCompatibilityValidator.js +127 -0
- package/dist/migration/validation/LifecycleValidator.d.ts +10 -0
- package/dist/migration/validation/LifecycleValidator.js +52 -0
- package/dist/migration/validation/StorageValidator.d.ts +10 -0
- package/dist/migration/validation/StorageValidator.js +65 -0
- package/dist/migration/validation/ValidationPipeline.d.ts +29 -0
- package/dist/migration/validation/ValidationPipeline.js +180 -0
- package/dist/resources/ResourceManager.d.ts +231 -0
- package/dist/resources/ResourceManager.js +573 -0
- package/dist/resources/index.d.ts +11 -0
- package/dist/resources/index.js +10 -0
- package/dist/resources/types.d.ts +93 -0
- package/dist/resources/types.js +80 -0
- package/dist/storage/LocalStorageAdapter.d.ts +11 -0
- package/dist/storage/LocalStorageAdapter.js +53 -0
- package/dist/storage/MemoryStorageAdapter.d.ts +6 -0
- package/dist/storage/MemoryStorageAdapter.js +21 -0
- package/dist/storage/StorageAdapter.d.ts +16 -0
- package/dist/storage/StorageAdapter.js +1 -0
- package/dist/storage/index.d.ts +2 -0
- package/dist/storage/index.js +2 -0
- package/dist/types/bitcoin.d.ts +84 -0
- package/dist/types/bitcoin.js +1 -0
- package/dist/types/common.d.ts +82 -0
- package/dist/types/common.js +1 -0
- package/dist/types/credentials.d.ts +75 -0
- package/dist/types/credentials.js +1 -0
- package/dist/types/did.d.ts +26 -0
- package/dist/types/did.js +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +5 -0
- package/dist/types/network.d.ts +78 -0
- package/dist/types/network.js +145 -0
- package/dist/utils/EventLogger.d.ts +71 -0
- package/dist/utils/EventLogger.js +232 -0
- package/dist/utils/Logger.d.ts +106 -0
- package/dist/utils/Logger.js +257 -0
- package/dist/utils/MetricsCollector.d.ts +110 -0
- package/dist/utils/MetricsCollector.js +264 -0
- package/dist/utils/bitcoin-address.d.ts +38 -0
- package/dist/utils/bitcoin-address.js +113 -0
- package/dist/utils/cbor.d.ts +2 -0
- package/dist/utils/cbor.js +9 -0
- package/dist/utils/encoding.d.ts +37 -0
- package/dist/utils/encoding.js +120 -0
- package/dist/utils/hash.d.ts +1 -0
- package/dist/utils/hash.js +5 -0
- package/dist/utils/retry.d.ts +10 -0
- package/dist/utils/retry.js +35 -0
- package/dist/utils/satoshi-validation.d.ts +60 -0
- package/dist/utils/satoshi-validation.js +156 -0
- package/dist/utils/serialization.d.ts +14 -0
- package/dist/utils/serialization.js +76 -0
- package/dist/utils/telemetry.d.ts +17 -0
- package/dist/utils/telemetry.js +24 -0
- package/dist/utils/validation.d.ts +5 -0
- package/dist/utils/validation.js +98 -0
- package/dist/vc/CredentialManager.d.ts +329 -0
- package/dist/vc/CredentialManager.js +615 -0
- package/dist/vc/Issuer.d.ts +27 -0
- package/dist/vc/Issuer.js +70 -0
- package/dist/vc/Verifier.d.ts +16 -0
- package/dist/vc/Verifier.js +50 -0
- package/dist/vc/cryptosuites/bbs.d.ts +44 -0
- package/dist/vc/cryptosuites/bbs.js +213 -0
- package/dist/vc/cryptosuites/bbsSimple.d.ts +9 -0
- package/dist/vc/cryptosuites/bbsSimple.js +12 -0
- package/dist/vc/cryptosuites/eddsa.d.ts +30 -0
- package/dist/vc/cryptosuites/eddsa.js +81 -0
- package/dist/vc/documentLoader.d.ts +16 -0
- package/dist/vc/documentLoader.js +59 -0
- package/dist/vc/proofs/data-integrity.d.ts +21 -0
- package/dist/vc/proofs/data-integrity.js +15 -0
- package/dist/vc/utils/jsonld.d.ts +2 -0
- package/dist/vc/utils/jsonld.js +15 -0
- package/package.json +2 -1
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example: Full Lifecycle Flow
|
|
3
|
+
*
|
|
4
|
+
* This comprehensive example demonstrates the complete lifecycle of an Original:
|
|
5
|
+
*
|
|
6
|
+
* 1. Create a draft (did:peer) - Private, offline creation
|
|
7
|
+
* 2. Validate and estimate costs
|
|
8
|
+
* 3. Publish to web (did:webvh) - Public discovery
|
|
9
|
+
* 4. Inscribe on Bitcoin (did:btco) - Permanent ownership
|
|
10
|
+
* 5. Transfer ownership
|
|
11
|
+
* 6. Track provenance throughout
|
|
12
|
+
*
|
|
13
|
+
* This example uses the clean lifecycle API with progress callbacks.
|
|
14
|
+
*/
|
|
15
|
+
import { OriginalsSDK, OrdMockProvider, ResourceManager, OriginalKind } from '../index';
|
|
16
|
+
import { sha256 } from '@noble/hashes/sha2.js';
|
|
17
|
+
/**
|
|
18
|
+
* Helper to compute content hash
|
|
19
|
+
*/
|
|
20
|
+
function computeHash(content) {
|
|
21
|
+
const buffer = typeof content === 'string' ? Buffer.from(content) : content;
|
|
22
|
+
return Buffer.from(sha256(buffer)).toString('hex');
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Progress logger for lifecycle operations
|
|
26
|
+
*/
|
|
27
|
+
function createProgressLogger(_operation) {
|
|
28
|
+
return (progress) => {
|
|
29
|
+
const bar = '█'.repeat(Math.floor(progress.percentage / 5)) + '░'.repeat(20 - Math.floor(progress.percentage / 5));
|
|
30
|
+
console.log(` [${bar}] ${progress.percentage}% - ${progress.phase}: ${progress.message}`);
|
|
31
|
+
if (progress.details?.transactionId) {
|
|
32
|
+
console.log(` Transaction: ${progress.details.transactionId}`);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Initialize SDK with all necessary providers
|
|
38
|
+
*/
|
|
39
|
+
function initializeSDK() {
|
|
40
|
+
return OriginalsSDK.create({
|
|
41
|
+
network: 'regtest',
|
|
42
|
+
defaultKeyType: 'Ed25519',
|
|
43
|
+
webvhNetwork: 'magby',
|
|
44
|
+
ordinalsProvider: new OrdMockProvider(),
|
|
45
|
+
enableLogging: false,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Step 1: Create resources using ResourceManager
|
|
50
|
+
*/
|
|
51
|
+
function createResources(resourceManager) {
|
|
52
|
+
console.log('\n📁 STEP 1: Creating Resources with ResourceManager\n');
|
|
53
|
+
// Create main content
|
|
54
|
+
const mainContent = `
|
|
55
|
+
# My Digital Artwork
|
|
56
|
+
|
|
57
|
+
This is a unique digital creation that will be permanently recorded
|
|
58
|
+
on the Bitcoin blockchain.
|
|
59
|
+
|
|
60
|
+
## Description
|
|
61
|
+
|
|
62
|
+
A beautiful generative art piece created with mathematical precision.
|
|
63
|
+
|
|
64
|
+
## Attribution
|
|
65
|
+
|
|
66
|
+
Created by: Artist Name
|
|
67
|
+
Date: ${new Date().toISOString()}
|
|
68
|
+
`.trim();
|
|
69
|
+
// Create the resource
|
|
70
|
+
const mainResource = resourceManager.createResource(mainContent, {
|
|
71
|
+
id: 'content.md',
|
|
72
|
+
type: 'document',
|
|
73
|
+
contentType: 'text/markdown',
|
|
74
|
+
description: 'Main artwork description'
|
|
75
|
+
});
|
|
76
|
+
console.log('Created resource:');
|
|
77
|
+
console.log(` ID: ${mainResource.id}`);
|
|
78
|
+
console.log(` Type: ${mainResource.type}`);
|
|
79
|
+
console.log(` Content Type: ${mainResource.contentType}`);
|
|
80
|
+
console.log(` Hash: ${mainResource.hash.substring(0, 16)}...`);
|
|
81
|
+
console.log(` Size: ${mainResource.size} bytes`);
|
|
82
|
+
console.log(` Version: ${mainResource.version}`);
|
|
83
|
+
// Update the resource (creates version 2)
|
|
84
|
+
const updatedContent = mainContent + '\n\n## Update\n\nAdded additional metadata.';
|
|
85
|
+
const v2Resource = resourceManager.updateResource(mainResource, updatedContent, {
|
|
86
|
+
changes: 'Added update section with additional metadata'
|
|
87
|
+
});
|
|
88
|
+
console.log('\nUpdated resource (new version):');
|
|
89
|
+
console.log(` Version: ${v2Resource.version}`);
|
|
90
|
+
console.log(` Previous Hash: ${v2Resource.previousVersionHash?.substring(0, 16)}...`);
|
|
91
|
+
console.log(` New Hash: ${v2Resource.hash.substring(0, 16)}...`);
|
|
92
|
+
// Verify the version chain
|
|
93
|
+
const chainValidation = resourceManager.verifyVersionChain(mainResource.id);
|
|
94
|
+
console.log(`\nVersion chain validation: ${chainValidation.valid ? '✓ Valid' : '✗ Invalid'}`);
|
|
95
|
+
if (chainValidation.warnings.length > 0) {
|
|
96
|
+
console.log(' Warnings:', chainValidation.warnings.join(', '));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Step 2: Create a draft asset (did:peer layer)
|
|
101
|
+
*/
|
|
102
|
+
async function createDraft(sdk) {
|
|
103
|
+
console.log('\n📝 STEP 2: Creating Draft Asset (did:peer)\n');
|
|
104
|
+
const content = `
|
|
105
|
+
{
|
|
106
|
+
"title": "Genesis Artwork #001",
|
|
107
|
+
"artist": "Digital Creator",
|
|
108
|
+
"medium": "Generative Algorithm",
|
|
109
|
+
"created": "${new Date().toISOString()}",
|
|
110
|
+
"description": "A unique piece of digital art inscribed forever on Bitcoin"
|
|
111
|
+
}
|
|
112
|
+
`.trim();
|
|
113
|
+
const resources = [{
|
|
114
|
+
id: 'metadata.json',
|
|
115
|
+
type: 'data',
|
|
116
|
+
content,
|
|
117
|
+
contentType: 'application/json',
|
|
118
|
+
hash: computeHash(content),
|
|
119
|
+
size: content.length,
|
|
120
|
+
}];
|
|
121
|
+
// Create draft with progress tracking
|
|
122
|
+
const draft = await sdk.lifecycle.createDraft(resources, {
|
|
123
|
+
onProgress: createProgressLogger('Create Draft'),
|
|
124
|
+
});
|
|
125
|
+
console.log('\nDraft created:');
|
|
126
|
+
console.log(` Asset ID: ${draft.id}`);
|
|
127
|
+
console.log(` Current Layer: ${draft.currentLayer}`);
|
|
128
|
+
console.log(` Resources: ${draft.resources.length}`);
|
|
129
|
+
// Check provenance
|
|
130
|
+
const provenance = draft.getProvenance();
|
|
131
|
+
console.log(` Created At: ${provenance.createdAt}`);
|
|
132
|
+
console.log(` Creator: ${provenance.creator.substring(0, 30)}...`);
|
|
133
|
+
return draft;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Step 3: Validate migration and estimate costs
|
|
137
|
+
*/
|
|
138
|
+
async function validateAndEstimate(sdk, asset) {
|
|
139
|
+
console.log('\n🔍 STEP 3: Validating Migration & Estimating Costs\n');
|
|
140
|
+
// Validate migration to did:webvh
|
|
141
|
+
console.log('Validating migration to did:webvh:');
|
|
142
|
+
const webvhValidation = await sdk.lifecycle.validateMigration(asset, 'did:webvh');
|
|
143
|
+
printValidation(webvhValidation);
|
|
144
|
+
// Validate migration to did:btco
|
|
145
|
+
console.log('\nValidating migration to did:btco:');
|
|
146
|
+
const btcoValidation = await sdk.lifecycle.validateMigration(asset, 'did:btco');
|
|
147
|
+
printValidation(btcoValidation);
|
|
148
|
+
// Estimate costs for Bitcoin inscription
|
|
149
|
+
console.log('\nCost estimates for Bitcoin inscription:');
|
|
150
|
+
const feeRates = [1, 5, 10, 25, 50];
|
|
151
|
+
for (const feeRate of feeRates) {
|
|
152
|
+
const estimate = await sdk.lifecycle.estimateCost(asset, 'did:btco', feeRate);
|
|
153
|
+
printCostEstimate(estimate, feeRate);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function printValidation(validation) {
|
|
157
|
+
console.log(` Valid: ${validation.valid ? '✓' : '✗'}`);
|
|
158
|
+
console.log(` Current Layer: ${validation.currentLayer}`);
|
|
159
|
+
console.log(` Target Layer: ${validation.targetLayer}`);
|
|
160
|
+
console.log(' Checks:');
|
|
161
|
+
Object.entries(validation.checks).forEach(([check, passed]) => {
|
|
162
|
+
if (passed !== undefined) {
|
|
163
|
+
console.log(` - ${check}: ${passed ? '✓' : '✗'}`);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
if (validation.errors.length > 0) {
|
|
167
|
+
console.log(' Errors:', validation.errors.join(', '));
|
|
168
|
+
}
|
|
169
|
+
if (validation.warnings.length > 0) {
|
|
170
|
+
console.log(' Warnings:', validation.warnings.join(', '));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function printCostEstimate(estimate, feeRate) {
|
|
174
|
+
console.log(` ${feeRate} sat/vB:`);
|
|
175
|
+
console.log(` Total: ${estimate.totalSats} sats (~$${(estimate.totalSats * 0.0006).toFixed(4)} @ $60k/BTC)`);
|
|
176
|
+
console.log(` Breakdown: network=${estimate.breakdown.networkFee}, data=${estimate.breakdown.dataCost}, dust=${estimate.breakdown.dustValue}`);
|
|
177
|
+
console.log(` Confidence: ${estimate.confidence}`);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Step 4: Publish to web (did:webvh layer)
|
|
181
|
+
*/
|
|
182
|
+
async function publishToWeb(sdk, asset) {
|
|
183
|
+
console.log('\n🌐 STEP 4: Publishing to Web (did:webvh)\n');
|
|
184
|
+
// Subscribe to migration events
|
|
185
|
+
const unsubscribe = asset.on('asset:migrated', (event) => {
|
|
186
|
+
const migrationEvent = event;
|
|
187
|
+
console.log(` 🔔 Event: Migrated from ${migrationEvent.asset.fromLayer} to ${migrationEvent.asset.toLayer}`);
|
|
188
|
+
});
|
|
189
|
+
try {
|
|
190
|
+
const published = await sdk.lifecycle.publish(asset, 'did:webvh:magby.originals.build:example:artwork', {
|
|
191
|
+
onProgress: createProgressLogger('Publish'),
|
|
192
|
+
});
|
|
193
|
+
console.log('\nPublished to web:');
|
|
194
|
+
console.log(` Asset ID: ${published.id}`);
|
|
195
|
+
console.log(` Current Layer: ${published.currentLayer}`);
|
|
196
|
+
console.log(` Bindings: ${JSON.stringify(published.bindings || {})}`);
|
|
197
|
+
// Check provenance after migration
|
|
198
|
+
const provenance = published.getProvenance();
|
|
199
|
+
console.log(` Migrations: ${provenance.migrations.length}`);
|
|
200
|
+
if (provenance.migrations.length > 0) {
|
|
201
|
+
const lastMigration = provenance.migrations[provenance.migrations.length - 1];
|
|
202
|
+
console.log(` Last migration: ${lastMigration.from} → ${lastMigration.to} at ${lastMigration.timestamp}`);
|
|
203
|
+
}
|
|
204
|
+
// Check credentials
|
|
205
|
+
console.log(` Credentials: ${published.credentials.length}`);
|
|
206
|
+
published.credentials.forEach((cred, i) => {
|
|
207
|
+
console.log(` ${i + 1}. Type: ${cred.type.join(', ')}`);
|
|
208
|
+
});
|
|
209
|
+
return published;
|
|
210
|
+
}
|
|
211
|
+
finally {
|
|
212
|
+
unsubscribe();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Step 5: Inscribe on Bitcoin (did:btco layer)
|
|
217
|
+
*/
|
|
218
|
+
async function inscribeOnBitcoin(sdk, asset) {
|
|
219
|
+
console.log('\n₿ STEP 5: Inscribing on Bitcoin (did:btco)\n');
|
|
220
|
+
// Subscribe to migration events
|
|
221
|
+
asset.on('asset:migrated', (_event) => {
|
|
222
|
+
console.log(` 🔔 Event: Inscribed on Bitcoin`);
|
|
223
|
+
});
|
|
224
|
+
const inscribed = await sdk.lifecycle.inscribe(asset, {
|
|
225
|
+
feeRate: 10,
|
|
226
|
+
onProgress: createProgressLogger('Inscribe'),
|
|
227
|
+
});
|
|
228
|
+
console.log('\nInscribed on Bitcoin:');
|
|
229
|
+
console.log(` Asset ID: ${inscribed.id}`);
|
|
230
|
+
console.log(` Current Layer: ${inscribed.currentLayer}`);
|
|
231
|
+
console.log(` Bindings: ${JSON.stringify(inscribed.bindings || {})}`);
|
|
232
|
+
// Check provenance after inscription
|
|
233
|
+
const provenance = inscribed.getProvenance();
|
|
234
|
+
console.log(` Total migrations: ${provenance.migrations.length}`);
|
|
235
|
+
const btcoMigration = provenance.migrations.find(m => m.to === 'did:btco');
|
|
236
|
+
if (btcoMigration) {
|
|
237
|
+
console.log('\n Bitcoin inscription details:');
|
|
238
|
+
console.log(` Transaction ID: ${btcoMigration.transactionId || 'N/A'}`);
|
|
239
|
+
console.log(` Inscription ID: ${btcoMigration.inscriptionId || 'N/A'}`);
|
|
240
|
+
console.log(` Satoshi: ${btcoMigration.satoshi || 'N/A'}`);
|
|
241
|
+
console.log(` Fee Rate: ${btcoMigration.feeRate || 'N/A'} sat/vB`);
|
|
242
|
+
console.log(` Commit TX: ${btcoMigration.commitTxId || 'N/A'}`);
|
|
243
|
+
console.log(` Reveal TX: ${btcoMigration.revealTxId || 'N/A'}`);
|
|
244
|
+
}
|
|
245
|
+
return inscribed;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Step 6: Transfer ownership
|
|
249
|
+
*/
|
|
250
|
+
async function transferOwnership(sdk, asset) {
|
|
251
|
+
console.log('\n🔄 STEP 6: Transferring Ownership\n');
|
|
252
|
+
// New owner address (mock address for regtest)
|
|
253
|
+
const newOwner = 'bcrt1qnewowner123456789abcdef';
|
|
254
|
+
// Subscribe to transfer events
|
|
255
|
+
asset.on('asset:transferred', (event) => {
|
|
256
|
+
const transferEvent = event;
|
|
257
|
+
console.log(` 🔔 Event: Ownership transferred to ${transferEvent.to}`);
|
|
258
|
+
});
|
|
259
|
+
const tx = await sdk.lifecycle.transfer(asset, newOwner, {
|
|
260
|
+
onProgress: createProgressLogger('Transfer'),
|
|
261
|
+
});
|
|
262
|
+
console.log('\nOwnership transferred:');
|
|
263
|
+
console.log(` Transaction ID: ${tx.txid}`);
|
|
264
|
+
console.log(` New Owner: ${newOwner}`);
|
|
265
|
+
console.log(` Fee: ${tx.fee} sats`);
|
|
266
|
+
// Check final provenance
|
|
267
|
+
const provenance = asset.getProvenance();
|
|
268
|
+
console.log(`\n Transfer history: ${provenance.transfers.length} transfer(s)`);
|
|
269
|
+
provenance.transfers.forEach((transfer, i) => {
|
|
270
|
+
console.log(` ${i + 1}. ${transfer.from.substring(0, 20)}... → ${transfer.to.substring(0, 20)}...`);
|
|
271
|
+
console.log(` TX: ${transfer.transactionId}`);
|
|
272
|
+
console.log(` At: ${transfer.timestamp}`);
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Step 7: View complete provenance
|
|
277
|
+
*/
|
|
278
|
+
function viewProvenance(asset) {
|
|
279
|
+
console.log('\n📜 STEP 7: Complete Provenance Chain\n');
|
|
280
|
+
const provenance = asset.getProvenance();
|
|
281
|
+
const summary = asset.getProvenanceSummary();
|
|
282
|
+
console.log('Provenance Summary:');
|
|
283
|
+
console.log(` Created: ${summary.created}`);
|
|
284
|
+
console.log(` Creator: ${summary.creator.substring(0, 40)}...`);
|
|
285
|
+
console.log(` Current Layer: ${summary.currentLayer}`);
|
|
286
|
+
console.log(` Migration Count: ${summary.migrationCount}`);
|
|
287
|
+
console.log(` Transfer Count: ${summary.transferCount}`);
|
|
288
|
+
console.log(` Last Activity: ${summary.lastActivity}`);
|
|
289
|
+
console.log('\nMigration History:');
|
|
290
|
+
provenance.migrations.forEach((migration, i) => {
|
|
291
|
+
console.log(` ${i + 1}. ${migration.from} → ${migration.to}`);
|
|
292
|
+
console.log(` Timestamp: ${migration.timestamp}`);
|
|
293
|
+
if (migration.transactionId) {
|
|
294
|
+
console.log(` TX: ${migration.transactionId}`);
|
|
295
|
+
}
|
|
296
|
+
if (migration.inscriptionId) {
|
|
297
|
+
console.log(` Inscription: ${migration.inscriptionId}`);
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
console.log('\nTransfer History:');
|
|
301
|
+
if (provenance.transfers.length === 0) {
|
|
302
|
+
console.log(' No transfers recorded');
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
provenance.transfers.forEach((transfer, i) => {
|
|
306
|
+
console.log(` ${i + 1}. ${transfer.timestamp}`);
|
|
307
|
+
console.log(` From: ${transfer.from}`);
|
|
308
|
+
console.log(` To: ${transfer.to}`);
|
|
309
|
+
console.log(` TX: ${transfer.transactionId}`);
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
console.log('\nResource Updates:');
|
|
313
|
+
if (provenance.resourceUpdates.length === 0) {
|
|
314
|
+
console.log(' No resource updates recorded');
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
provenance.resourceUpdates.forEach((update, i) => {
|
|
318
|
+
console.log(` ${i + 1}. Resource: ${update.resourceId}`);
|
|
319
|
+
console.log(` Version: ${update.fromVersion} → ${update.toVersion}`);
|
|
320
|
+
console.log(` At: ${update.timestamp}`);
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Bonus: Create and publish a typed Original
|
|
326
|
+
*/
|
|
327
|
+
async function typedOriginalFlow(sdk) {
|
|
328
|
+
console.log('\n🎨 BONUS: Typed Media Original Flow\n');
|
|
329
|
+
const imageDescription = `
|
|
330
|
+
{
|
|
331
|
+
"title": "Digital Sunrise",
|
|
332
|
+
"artist": "AI Collaborator",
|
|
333
|
+
"medium": "Generative AI + Human Curation",
|
|
334
|
+
"dimensions": "2048x2048",
|
|
335
|
+
"colorSpace": "sRGB"
|
|
336
|
+
}
|
|
337
|
+
`.trim();
|
|
338
|
+
const mediaAsset = await sdk.lifecycle.createTypedOriginal(OriginalKind.Media, {
|
|
339
|
+
kind: OriginalKind.Media,
|
|
340
|
+
name: 'Digital Sunrise',
|
|
341
|
+
version: '1.0.0',
|
|
342
|
+
description: 'A stunning generative sunrise created with AI',
|
|
343
|
+
resources: [{
|
|
344
|
+
id: 'metadata.json',
|
|
345
|
+
type: 'data',
|
|
346
|
+
content: imageDescription,
|
|
347
|
+
contentType: 'application/json',
|
|
348
|
+
hash: computeHash(imageDescription),
|
|
349
|
+
size: imageDescription.length,
|
|
350
|
+
}],
|
|
351
|
+
tags: ['generative', 'ai', 'sunrise', 'digital-art'],
|
|
352
|
+
author: {
|
|
353
|
+
name: 'AI Collaborator',
|
|
354
|
+
},
|
|
355
|
+
license: 'CC-BY-4.0',
|
|
356
|
+
metadata: {
|
|
357
|
+
mediaType: 'image',
|
|
358
|
+
mimeType: 'image/png',
|
|
359
|
+
dimensions: {
|
|
360
|
+
width: 2048,
|
|
361
|
+
height: 2048,
|
|
362
|
+
aspectRatio: '1:1',
|
|
363
|
+
},
|
|
364
|
+
altText: 'A vibrant digital sunrise over a futuristic cityscape',
|
|
365
|
+
colorSpace: 'sRGB',
|
|
366
|
+
},
|
|
367
|
+
});
|
|
368
|
+
console.log('Created Media Original:');
|
|
369
|
+
console.log(` ID: ${mediaAsset.id}`);
|
|
370
|
+
console.log(` Kind: ${OriginalKind.Media}`);
|
|
371
|
+
// Get the manifest
|
|
372
|
+
const manifest = sdk.lifecycle.getManifest(mediaAsset);
|
|
373
|
+
if (manifest && manifest.metadata) {
|
|
374
|
+
const meta = manifest.metadata;
|
|
375
|
+
console.log(` Name: ${manifest.name}`);
|
|
376
|
+
console.log(` Media Type: ${meta.mediaType}`);
|
|
377
|
+
console.log(` Dimensions: ${meta.dimensions?.width}x${meta.dimensions?.height}`);
|
|
378
|
+
}
|
|
379
|
+
// Estimate inscription cost for this typed original
|
|
380
|
+
const cost = await sdk.lifecycle.estimateTypedOriginalCost(manifest, 'did:btco', 10);
|
|
381
|
+
console.log(`\n Estimated inscription cost: ${cost.totalSats} sats`);
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Main execution - full lifecycle demonstration
|
|
385
|
+
*/
|
|
386
|
+
async function main() {
|
|
387
|
+
console.log('╔════════════════════════════════════════════════════════════════╗');
|
|
388
|
+
console.log('║ ORIGINALS SDK - FULL LIFECYCLE FLOW ║');
|
|
389
|
+
console.log('║ ║');
|
|
390
|
+
console.log('║ did:peer → did:webvh → did:btco → Transfer ║');
|
|
391
|
+
console.log('╚════════════════════════════════════════════════════════════════╝');
|
|
392
|
+
try {
|
|
393
|
+
// Initialize
|
|
394
|
+
const sdk = initializeSDK();
|
|
395
|
+
const resourceManager = new ResourceManager();
|
|
396
|
+
// Execute lifecycle steps
|
|
397
|
+
createResources(resourceManager);
|
|
398
|
+
const draft = await createDraft(sdk);
|
|
399
|
+
await validateAndEstimate(sdk, draft);
|
|
400
|
+
const published = await publishToWeb(sdk, draft);
|
|
401
|
+
const inscribed = await inscribeOnBitcoin(sdk, published);
|
|
402
|
+
await transferOwnership(sdk, inscribed);
|
|
403
|
+
viewProvenance(inscribed);
|
|
404
|
+
await typedOriginalFlow(sdk);
|
|
405
|
+
console.log('\n╔════════════════════════════════════════════════════════════════╗');
|
|
406
|
+
console.log('║ LIFECYCLE COMPLETE ✓ ║');
|
|
407
|
+
console.log('╚════════════════════════════════════════════════════════════════╝\n');
|
|
408
|
+
}
|
|
409
|
+
catch (error) {
|
|
410
|
+
console.error('\n❌ Error during lifecycle flow:', error);
|
|
411
|
+
process.exit(1);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
// Export for use as module
|
|
415
|
+
export { main, initializeSDK, createResources, createDraft, validateAndEstimate, publishToWeb, inscribeOnBitcoin, transferOwnership, viewProvenance, typedOriginalFlow, };
|
|
416
|
+
// Run if executed directly
|
|
417
|
+
if (require.main === module) {
|
|
418
|
+
void main();
|
|
419
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example Runner
|
|
3
|
+
*
|
|
4
|
+
* Run all SDK examples to demonstrate functionality.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* bun run src/examples/run.ts
|
|
8
|
+
* bun run src/examples/run.ts basic
|
|
9
|
+
* bun run src/examples/run.ts module
|
|
10
|
+
* bun run src/examples/run.ts lifecycle
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example Runner
|
|
3
|
+
*
|
|
4
|
+
* Run all SDK examples to demonstrate functionality.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* bun run src/examples/run.ts
|
|
8
|
+
* bun run src/examples/run.ts basic
|
|
9
|
+
* bun run src/examples/run.ts module
|
|
10
|
+
* bun run src/examples/run.ts lifecycle
|
|
11
|
+
*/
|
|
12
|
+
import { basicExample, digitalArtExample } from './basic-usage';
|
|
13
|
+
import { main as createModuleExample } from './create-module-original';
|
|
14
|
+
import { main as fullLifecycleExample } from './full-lifecycle-flow';
|
|
15
|
+
async function runAll() {
|
|
16
|
+
console.log('Running all Originals SDK examples...\n');
|
|
17
|
+
console.log('='.repeat(60));
|
|
18
|
+
console.log('BASIC USAGE EXAMPLES');
|
|
19
|
+
console.log('='.repeat(60));
|
|
20
|
+
await basicExample();
|
|
21
|
+
await digitalArtExample();
|
|
22
|
+
console.log('\n' + '='.repeat(60));
|
|
23
|
+
console.log('CREATE MODULE ORIGINAL EXAMPLES');
|
|
24
|
+
console.log('='.repeat(60));
|
|
25
|
+
await createModuleExample();
|
|
26
|
+
console.log('\n' + '='.repeat(60));
|
|
27
|
+
console.log('FULL LIFECYCLE FLOW EXAMPLE');
|
|
28
|
+
console.log('='.repeat(60));
|
|
29
|
+
await fullLifecycleExample();
|
|
30
|
+
console.log('\n' + '='.repeat(60));
|
|
31
|
+
console.log('ALL EXAMPLES COMPLETED SUCCESSFULLY');
|
|
32
|
+
console.log('='.repeat(60));
|
|
33
|
+
}
|
|
34
|
+
async function main() {
|
|
35
|
+
const arg = process.argv[2];
|
|
36
|
+
switch (arg) {
|
|
37
|
+
case 'basic':
|
|
38
|
+
await basicExample();
|
|
39
|
+
await digitalArtExample();
|
|
40
|
+
break;
|
|
41
|
+
case 'module':
|
|
42
|
+
await createModuleExample();
|
|
43
|
+
break;
|
|
44
|
+
case 'lifecycle':
|
|
45
|
+
await fullLifecycleExample();
|
|
46
|
+
break;
|
|
47
|
+
default:
|
|
48
|
+
await runAll();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
main().catch(console.error);
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import './crypto/noble-init.js';
|
|
2
|
+
import { OriginalsSDK } from './core/OriginalsSDK.js';
|
|
3
|
+
export { OriginalsSDK } from './core/OriginalsSDK.js';
|
|
4
|
+
export type { OriginalsSDKOptions, OriginalResult, CreateOriginalOptions, UpdateOriginalOptions, CreateDIDOriginalOptions, UpdateDIDOriginalOptions } from './core/OriginalsSDK.js';
|
|
5
|
+
export { OriginalsAsset } from './lifecycle/OriginalsAsset.js';
|
|
6
|
+
export type { ProvenanceChain } from './lifecycle/OriginalsAsset.js';
|
|
7
|
+
export * from './types/index.js';
|
|
8
|
+
export { DIDManager, type CreateWebVHOptions, type CreateWebVHResult } from './did/DIDManager.js';
|
|
9
|
+
export { KeyManager } from './did/KeyManager.js';
|
|
10
|
+
export { Ed25519Verifier } from './did/Ed25519Verifier.js';
|
|
11
|
+
export * as encoding from './utils/encoding.js';
|
|
12
|
+
export { CredentialManager, type ResourceCreatedSubject, type ResourceUpdatedSubject, type MigrationSubject, type OwnershipSubject, type CredentialChainOptions, type SelectiveDisclosureOptions, type DerivedProofResult } from './vc/CredentialManager.js';
|
|
13
|
+
export { LifecycleManager, type CostEstimate, type MigrationValidation, type LifecycleProgress, type ProgressCallback, type LifecycleOperationOptions } from './lifecycle/LifecycleManager.js';
|
|
14
|
+
export { BitcoinManager } from './bitcoin/BitcoinManager.js';
|
|
15
|
+
export { OrdinalsClient } from './bitcoin/OrdinalsClient.js';
|
|
16
|
+
export { buildTransferTransaction } from './bitcoin/transfer.js';
|
|
17
|
+
export { selectUtxos, UtxoSelectionError, estimateFeeSats } from './bitcoin/utxo.js';
|
|
18
|
+
export { selectUtxos as selectUtxosSimple, selectResourceUtxos, selectUtxosForPayment, tagResourceUtxos, estimateTransactionSize } from './bitcoin/utxo-selection.js';
|
|
19
|
+
export { calculateFee } from './bitcoin/fee-calculation.js';
|
|
20
|
+
export { BBSCryptosuiteUtils } from './vc/cryptosuites/bbs.js';
|
|
21
|
+
export { BbsSimple } from './vc/cryptosuites/bbsSimple.js';
|
|
22
|
+
export * from './storage/index.js';
|
|
23
|
+
export { ResourceManager } from './resources/index.js';
|
|
24
|
+
export type { Resource, ResourceOptions, ResourceUpdateOptions, ResourceVersionHistory, ResourceManagerConfig, ResourceValidationResult, ResourceType, } from './resources/index.js';
|
|
25
|
+
export { MIME_TYPE_MAP, DEFAULT_RESOURCE_CONFIG } from './resources/index.js';
|
|
26
|
+
export { Signer, ES256KSigner, Ed25519Signer, ES256Signer, Bls12381G2Signer } from './crypto/Signer.js';
|
|
27
|
+
export { multikey } from './crypto/Multikey.js';
|
|
28
|
+
export type { MultikeyType } from './crypto/Multikey.js';
|
|
29
|
+
export * from './events/index.js';
|
|
30
|
+
export { MigrationManager } from './migration/index.js';
|
|
31
|
+
export * from './migration/types.js';
|
|
32
|
+
export { BatchOperationExecutor, BatchValidator, BatchError, type BatchResult, type BatchOperationOptions, type BatchInscriptionOptions, type BatchInscriptionResult, type ValidationResult as BatchValidationResult } from './lifecycle/BatchOperations.js';
|
|
33
|
+
export { OriginalKind, KindRegistry, type DependencyRef, type BaseManifest, type AppMetadata, type AgentMetadata, type ModuleMetadata, type DatasetMetadata, type MediaMetadata, type DocumentMetadata, type KindMetadataMap, type KindMetadata, type OriginalManifest, type AppManifest, type AgentManifest, type ModuleManifest, type DatasetManifest, type MediaManifest, type DocumentManifest, type AnyManifest, type ValidationResult as KindValidationResult, type ValidationError as KindValidationError, type ValidationWarning, type CreateTypedOriginalOptions, type KindValidator, BaseKindValidator, ValidationUtils, AppValidator, AgentValidator, ModuleValidator, DatasetValidator, MediaValidator, DocumentValidator, } from './kinds/index.js';
|
|
34
|
+
export * from './utils/validation.js';
|
|
35
|
+
export * from './utils/satoshi-validation.js';
|
|
36
|
+
export * from './utils/serialization.js';
|
|
37
|
+
export * from './utils/retry.js';
|
|
38
|
+
export * from './utils/telemetry.js';
|
|
39
|
+
export { sha256Bytes } from './utils/hash.js';
|
|
40
|
+
export { OrdMockProvider } from './adapters/providers/OrdMockProvider.js';
|
|
41
|
+
export { FeeOracleMock } from './adapters/FeeOracleMock.js';
|
|
42
|
+
export type { OrdinalsProvider, FeeOracleAdapter, StorageAdapter } from './adapters/types.js';
|
|
43
|
+
export default OriginalsSDK;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* istanbul ignore file */
|
|
2
|
+
// Initialize noble crypto libraries first (must run before any crypto operations)
|
|
3
|
+
import './crypto/noble-init.js';
|
|
4
|
+
import { OriginalsSDK } from './core/OriginalsSDK.js';
|
|
5
|
+
// Main exports
|
|
6
|
+
export { OriginalsSDK } from './core/OriginalsSDK.js';
|
|
7
|
+
export { OriginalsAsset } from './lifecycle/OriginalsAsset.js';
|
|
8
|
+
// Type exports
|
|
9
|
+
export * from './types/index.js';
|
|
10
|
+
// Manager exports
|
|
11
|
+
export { DIDManager } from './did/DIDManager.js';
|
|
12
|
+
export { KeyManager } from './did/KeyManager.js';
|
|
13
|
+
export { Ed25519Verifier } from './did/Ed25519Verifier.js';
|
|
14
|
+
export * as encoding from './utils/encoding.js';
|
|
15
|
+
export { CredentialManager } from './vc/CredentialManager.js';
|
|
16
|
+
export { LifecycleManager } from './lifecycle/LifecycleManager.js';
|
|
17
|
+
export { BitcoinManager } from './bitcoin/BitcoinManager.js';
|
|
18
|
+
export { OrdinalsClient } from './bitcoin/OrdinalsClient.js';
|
|
19
|
+
export { buildTransferTransaction } from './bitcoin/transfer.js';
|
|
20
|
+
export { selectUtxos, UtxoSelectionError, estimateFeeSats } from './bitcoin/utxo.js';
|
|
21
|
+
export { selectUtxos as selectUtxosSimple, selectResourceUtxos, selectUtxosForPayment, tagResourceUtxos, estimateTransactionSize } from './bitcoin/utxo-selection.js';
|
|
22
|
+
export { calculateFee } from './bitcoin/fee-calculation.js';
|
|
23
|
+
export { BBSCryptosuiteUtils } from './vc/cryptosuites/bbs.js';
|
|
24
|
+
export { BbsSimple } from './vc/cryptosuites/bbsSimple.js';
|
|
25
|
+
export * from './storage/index.js';
|
|
26
|
+
// Resource management exports
|
|
27
|
+
export { ResourceManager } from './resources/index.js';
|
|
28
|
+
export { MIME_TYPE_MAP, DEFAULT_RESOURCE_CONFIG } from './resources/index.js';
|
|
29
|
+
// Crypto exports
|
|
30
|
+
export { Signer, ES256KSigner, Ed25519Signer, ES256Signer, Bls12381G2Signer } from './crypto/Signer.js';
|
|
31
|
+
export { multikey } from './crypto/Multikey.js';
|
|
32
|
+
// Event system exports
|
|
33
|
+
export * from './events/index.js';
|
|
34
|
+
// Migration system exports
|
|
35
|
+
export { MigrationManager } from './migration/index.js';
|
|
36
|
+
export * from './migration/types.js';
|
|
37
|
+
// Batch operations exports
|
|
38
|
+
export { BatchOperationExecutor, BatchValidator, BatchError } from './lifecycle/BatchOperations.js';
|
|
39
|
+
// Kind system exports
|
|
40
|
+
export { OriginalKind, KindRegistry, BaseKindValidator, ValidationUtils, AppValidator, AgentValidator, ModuleValidator, DatasetValidator, MediaValidator, DocumentValidator, } from './kinds/index.js';
|
|
41
|
+
// Utility exports
|
|
42
|
+
export * from './utils/validation.js';
|
|
43
|
+
export * from './utils/satoshi-validation.js';
|
|
44
|
+
export * from './utils/serialization.js';
|
|
45
|
+
export * from './utils/retry.js';
|
|
46
|
+
export * from './utils/telemetry.js';
|
|
47
|
+
export { sha256Bytes } from './utils/hash.js';
|
|
48
|
+
// Adapter exports (for testing and custom integrations)
|
|
49
|
+
export { OrdMockProvider } from './adapters/providers/OrdMockProvider.js';
|
|
50
|
+
export { FeeOracleMock } from './adapters/FeeOracleMock.js';
|
|
51
|
+
// Default export
|
|
52
|
+
export default OriginalsSDK;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kind Registry
|
|
3
|
+
*
|
|
4
|
+
* Central registry for Original kinds, providing validation and type management.
|
|
5
|
+
*/
|
|
6
|
+
import { OriginalKind, type OriginalManifest, type ValidationResult, type CreateTypedOriginalOptions } from './types';
|
|
7
|
+
import { type KindValidator } from './validators';
|
|
8
|
+
/**
|
|
9
|
+
* Registry for Original kinds
|
|
10
|
+
*
|
|
11
|
+
* Provides centralized validation and type information for all kinds.
|
|
12
|
+
*/
|
|
13
|
+
export declare class KindRegistry {
|
|
14
|
+
private static instance;
|
|
15
|
+
private validators;
|
|
16
|
+
private constructor();
|
|
17
|
+
/**
|
|
18
|
+
* Get the singleton instance
|
|
19
|
+
*/
|
|
20
|
+
static getInstance(): KindRegistry;
|
|
21
|
+
/**
|
|
22
|
+
* Register default validators for all built-in kinds
|
|
23
|
+
*/
|
|
24
|
+
private registerDefaultValidators;
|
|
25
|
+
/**
|
|
26
|
+
* Register a custom validator for a kind
|
|
27
|
+
* Can be used to override built-in validators or add new kinds
|
|
28
|
+
*/
|
|
29
|
+
registerValidator<K extends OriginalKind>(kind: K, validator: KindValidator<K>): void;
|
|
30
|
+
/**
|
|
31
|
+
* Get the validator for a kind
|
|
32
|
+
*/
|
|
33
|
+
getValidator<K extends OriginalKind>(kind: K): KindValidator<K> | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Check if a kind is registered
|
|
36
|
+
*/
|
|
37
|
+
hasKind(kind: OriginalKind): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Get all registered kinds
|
|
40
|
+
*/
|
|
41
|
+
getRegisteredKinds(): OriginalKind[];
|
|
42
|
+
/**
|
|
43
|
+
* Validate a manifest
|
|
44
|
+
*
|
|
45
|
+
* @param manifest - The manifest to validate
|
|
46
|
+
* @param options - Validation options
|
|
47
|
+
* @returns Validation result
|
|
48
|
+
*/
|
|
49
|
+
validate<K extends OriginalKind>(manifest: OriginalManifest<K>, options?: CreateTypedOriginalOptions): ValidationResult;
|
|
50
|
+
/**
|
|
51
|
+
* Validate a manifest and throw if invalid
|
|
52
|
+
*/
|
|
53
|
+
validateOrThrow<K extends OriginalKind>(manifest: OriginalManifest<K>, options?: CreateTypedOriginalOptions): void;
|
|
54
|
+
/**
|
|
55
|
+
* Check if a value is a valid OriginalKind
|
|
56
|
+
*/
|
|
57
|
+
static isValidKind(value: unknown): value is OriginalKind;
|
|
58
|
+
/**
|
|
59
|
+
* Parse a kind string to OriginalKind
|
|
60
|
+
* Accepts both full URIs (originals:kind:app) and short names (app)
|
|
61
|
+
*/
|
|
62
|
+
static parseKind(value: string): OriginalKind | null;
|
|
63
|
+
/**
|
|
64
|
+
* Get the short name of a kind (e.g., "app" from "originals:kind:app")
|
|
65
|
+
*/
|
|
66
|
+
static getShortName(kind: OriginalKind): string;
|
|
67
|
+
/**
|
|
68
|
+
* Get human-readable display name for a kind
|
|
69
|
+
*/
|
|
70
|
+
static getDisplayName(kind: OriginalKind): string;
|
|
71
|
+
/**
|
|
72
|
+
* Create an empty manifest template for a kind
|
|
73
|
+
* Useful for scaffolding new Originals
|
|
74
|
+
*/
|
|
75
|
+
static createTemplate<K extends OriginalKind>(kind: K, name: string, version?: string): Partial<OriginalManifest<K>>;
|
|
76
|
+
}
|