smartledger-bsv 3.3.5 → 3.4.4

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 (126) hide show
  1. package/CHANGELOG.md +400 -0
  2. package/README.md +235 -80
  3. package/SECURITY.md +88 -0
  4. package/anchor-entry.js +1 -0
  5. package/bin/cli.js +354 -0
  6. package/bsv-anchor.min.js +12 -0
  7. package/bsv-covenant.min.js +8 -8
  8. package/bsv-didweb.min.js +12 -0
  9. package/bsv-gdaf.min.js +9 -9
  10. package/bsv-ltp.min.js +9 -9
  11. package/bsv-mnemonic.min.js +2 -2
  12. package/bsv-shamir.min.js +3 -3
  13. package/bsv-smartcontract.min.js +9 -9
  14. package/bsv-statuslist.min.js +18 -0
  15. package/bsv-vcjwt.min.js +12 -0
  16. package/bsv.bundle.js +9 -9
  17. package/bsv.d.ts +486 -9
  18. package/bsv.min.js +8 -8
  19. package/build/webpack.anchor.config.js +17 -0
  20. package/build/webpack.didweb.config.js +17 -0
  21. package/build/webpack.statuslist.config.js +17 -0
  22. package/build/webpack.vcjwt.config.js +17 -0
  23. package/didweb-entry.js +1 -0
  24. package/docs/COVENANT_DEVELOPMENT_RESOLVED.md +2 -2
  25. package/docs/MODULE_REFERENCE_COMPLETE.md +61 -58
  26. package/docs/advanced/LEGAL_TOKEN_PROTOCOL.md +3 -3
  27. package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
  28. package/docs/getting-started/INSTALLATION.md +30 -30
  29. package/docs/getting-started/QUICK_START.md +18 -18
  30. package/docs/migration/FROM_BSV_1_5_6.md +16 -10
  31. package/docs/technical/roadmap.md +3 -3
  32. package/gdaf-entry.js +1 -2
  33. package/index.js +68 -9
  34. package/lib/anchor/index.js +102 -0
  35. package/lib/browser-utxo-manager-es5.js +11 -4
  36. package/lib/browser-utxo-manager.js +15 -8
  37. package/lib/didweb/index.js +177 -0
  38. package/lib/ltp/claim.js +1 -0
  39. package/lib/ltp/obligation.js +1 -0
  40. package/lib/ltp/registry.js +2 -0
  41. package/lib/ltp/right.js +1 -0
  42. package/lib/smart_contract/covenant.js +10 -1
  43. package/lib/smartutxo.js +20 -12
  44. package/lib/statuslist/index.js +164 -0
  45. package/lib/transaction/transaction.js +8 -1
  46. package/lib/util/_.js +7 -1
  47. package/lib/vcjwt/index.js +189 -0
  48. package/ltp-entry.js +1 -2
  49. package/package.json +21 -15
  50. package/statuslist-entry.js +1 -0
  51. package/utilities/blockchain-state.js +32 -23
  52. package/vcjwt-entry.js +1 -0
  53. package/demos/README.md +0 -188
  54. package/demos/architecture_demo.js +0 -247
  55. package/demos/browser-test.html +0 -1208
  56. package/demos/bsv_wallet_demo.js +0 -242
  57. package/demos/complete_ltp_demo.js +0 -511
  58. package/demos/debug_tools_demo.js +0 -87
  59. package/demos/demo_features.js +0 -123
  60. package/demos/easy_interface_demo.js +0 -109
  61. package/demos/ecies_demo.js +0 -182
  62. package/demos/gdaf_core_test.js +0 -131
  63. package/demos/gdaf_demo.js +0 -237
  64. package/demos/ltp_demo.js +0 -361
  65. package/demos/ltp_primitives_demo.js +0 -403
  66. package/demos/message_demo.js +0 -209
  67. package/demos/preimage_separation_demo.js +0 -383
  68. package/demos/script_helper_demo.js +0 -289
  69. package/demos/security_demo.js +0 -287
  70. package/demos/shamir_demo.js +0 -121
  71. package/demos/simple_demo.js +0 -204
  72. package/demos/simple_p2pkh_demo.js +0 -169
  73. package/demos/simple_utxo_preimage_demo.js +0 -196
  74. package/demos/smart_contract_demo.html +0 -1347
  75. package/demos/smart_contract_demo.js +0 -910
  76. package/demos/utxo_generator_demo.js +0 -244
  77. package/demos/validation_pipeline_demo.js +0 -155
  78. package/demos/web3keys.html +0 -740
  79. package/examples/README.md +0 -200
  80. package/examples/basic/transaction-creation.js +0 -534
  81. package/examples/basic/transaction_signature_api_gap.js +0 -178
  82. package/examples/complete_workflow_demo.js +0 -783
  83. package/examples/covenants/advanced_covenant_demo.js +0 -219
  84. package/examples/covenants/covenant_interface_demo.js +0 -270
  85. package/examples/covenants/covenant_manual_signature_resolved.js +0 -212
  86. package/examples/covenants/covenant_signature_template.js +0 -117
  87. package/examples/covenants2/covenant_bidirectional_example.js +0 -262
  88. package/examples/covenants2/covenant_utils_demo.js +0 -120
  89. package/examples/covenants2/preimage_covenant_utils.js +0 -287
  90. package/examples/covenants2/production_integration.js +0 -256
  91. package/examples/data/covenant_utxos.json +0 -28
  92. package/examples/data/utxos.json +0 -26
  93. package/examples/definitive_working_demo.js +0 -261
  94. package/examples/final_working_contracts.js +0 -338
  95. package/examples/preimage/README.md +0 -178
  96. package/examples/preimage/extract_preimage_bidirectional.js +0 -421
  97. package/examples/preimage/generate_sample_preimage.js +0 -208
  98. package/examples/preimage/generate_sighash_examples.js +0 -152
  99. package/examples/preimage/parse_preimage.js +0 -117
  100. package/examples/preimage/test_preimage_extractor.js +0 -53
  101. package/examples/preimage/test_varint_extraction.js +0 -95
  102. package/examples/scripts/custom_script_helper_example.js +0 -273
  103. package/examples/scripts/custom_script_signature_test.js +0 -344
  104. package/examples/scripts/script_interpreter.js +0 -193
  105. package/examples/smart_contract/complete_workflow_demo.js +0 -343
  106. package/examples/smart_contract/covenant_builder_demo.js +0 -176
  107. package/examples/smart_contract/script_testing_integration.js +0 -198
  108. package/examples/smart_contract_templates.js +0 -718
  109. package/examples/working_smart_contracts.js +0 -348
  110. package/lib/smart_contract/test_integration.js +0 -269
  111. package/tests/browser-compatibility/README.md +0 -35
  112. package/tests/browser-compatibility/test-cdn-vs-local.html +0 -186
  113. package/tests/browser-compatibility/test-pbkdf2.html +0 -51
  114. package/tests/bundle-completeness-test.html +0 -131
  115. package/tests/bundle-demo.html +0 -476
  116. package/tests/smartcontract-test.html +0 -239
  117. package/tests/standalone-modules-test.html +0 -260
  118. package/tests/test.html +0 -612
  119. package/tests/test_builtin_verify.js +0 -117
  120. package/tests/test_debug_integration.js +0 -71
  121. package/tests/test_ecdsa_little.js +0 -70
  122. package/tests/test_shamir.js +0 -221
  123. package/tests/test_smartverify_der.js +0 -110
  124. package/tests/test_standalone_shamir.html +0 -83
  125. package/tests/unpkg-demo.html +0 -194
  126. package/utilities/blockchain-state.json +0 -118565
@@ -1,186 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8">
5
- <title>CDN vs Local PBKDF2 Test</title>
6
- <style>
7
- body { font-family: Arial, sans-serif; margin: 20px; }
8
- .test-section { margin: 20px 0; padding: 15px; border: 1px solid #ccc; border-radius: 5px; }
9
- .error { color: red; }
10
- .success { color: green; }
11
- .info { color: blue; }
12
- pre { background: #f5f5f5; padding: 10px; border-radius: 3px; }
13
- </style>
14
- </head>
15
- <body>
16
- <h1>SmartLedger BSV: CDN vs Local PBKDF2 Test</h1>
17
-
18
- <div class="test-section">
19
- <h2>Test 1: CDN Version (Expected to fail with createHmac error)</h2>
20
- <button onclick="testCDN()">Test CDN Version</button>
21
- <div id="cdn-results"></div>
22
- </div>
23
-
24
- <div class="test-section">
25
- <h2>Test 2: Local Fixed Version (Should work)</h2>
26
- <button onclick="testLocal()">Test Local Version</button>
27
- <div id="local-results"></div>
28
- </div>
29
-
30
- <div class="test-section">
31
- <h2>Summary</h2>
32
- <div id="summary"></div>
33
- </div>
34
-
35
- <script>
36
- function log(elementId, message, type = 'info') {
37
- const element = document.getElementById(elementId);
38
- const className = type === 'error' ? 'error' : type === 'success' ? 'success' : 'info';
39
- element.innerHTML += `<div class="${className}">${message}</div>`;
40
- }
41
-
42
- function clearResults(elementId) {
43
- document.getElementById(elementId).innerHTML = '';
44
- }
45
-
46
- function testCDN() {
47
- clearResults('cdn-results');
48
- log('cdn-results', 'Loading CDN version...');
49
-
50
- // Remove any existing scripts
51
- const existingScripts = document.querySelectorAll('script[src*="bsv"]');
52
- existingScripts.forEach(script => script.remove());
53
-
54
- // Clear global variables
55
- if (window.bsv) delete window.bsv;
56
- if (window.bsvMnemonic) delete window.bsvMnemonic;
57
- if (window.Mnemonic) delete window.Mnemonic;
58
-
59
- // Load CDN scripts
60
- const bsvScript = document.createElement('script');
61
- bsvScript.src = 'https://cdn.jsdelivr.net/npm/smartledger-bsv@3.3.4/bsv.min.js';
62
- bsvScript.onload = () => {
63
- const mnemonicScript = document.createElement('script');
64
- mnemonicScript.src = 'https://cdn.jsdelivr.net/npm/smartledger-bsv@3.3.4/bsv-mnemonic.min.js';
65
- mnemonicScript.onload = () => {
66
- testMnemonicGeneration('cdn-results', 'CDN');
67
- };
68
- mnemonicScript.onerror = () => {
69
- log('cdn-results', '❌ Failed to load CDN mnemonic script', 'error');
70
- };
71
- document.head.appendChild(mnemonicScript);
72
- };
73
- bsvScript.onerror = () => {
74
- log('cdn-results', '❌ Failed to load CDN BSV script', 'error');
75
- };
76
- document.head.appendChild(bsvScript);
77
- }
78
-
79
- function testLocal() {
80
- clearResults('local-results');
81
- log('local-results', 'Loading local fixed version...');
82
-
83
- // Remove any existing scripts
84
- const existingScripts = document.querySelectorAll('script[src*="bsv"]');
85
- existingScripts.forEach(script => script.remove());
86
-
87
- // Clear global variables
88
- if (window.bsv) delete window.bsv;
89
- if (window.bsvMnemonic) delete window.bsvMnemonic;
90
- if (window.Mnemonic) delete window.Mnemonic;
91
-
92
- // Load local scripts
93
- const bsvScript = document.createElement('script');
94
- bsvScript.src = '../bsv.min.js';
95
- bsvScript.onload = () => {
96
- const mnemonicScript = document.createElement('script');
97
- mnemonicScript.src = '../bsv-mnemonic.min.js';
98
- mnemonicScript.onload = () => {
99
- testMnemonicGeneration('local-results', 'Local');
100
- };
101
- mnemonicScript.onerror = () => {
102
- log('local-results', '❌ Failed to load local mnemonic script', 'error');
103
- };
104
- document.head.appendChild(mnemonicScript);
105
- };
106
- bsvScript.onerror = () => {
107
- log('local-results', '❌ Failed to load local BSV script', 'error');
108
- };
109
- document.head.appendChild(bsvScript);
110
- }
111
-
112
- function testMnemonicGeneration(resultElementId, version) {
113
- try {
114
- log(resultElementId, `${version} scripts loaded successfully`, 'info');
115
-
116
- // Check what's available
117
- const MnemonicClass = window.bsvMnemonic || window.Mnemonic || (window.bsv && window.bsv.Mnemonic);
118
- log(resultElementId, `Mnemonic class available: ${!!MnemonicClass}`, 'info');
119
-
120
- if (MnemonicClass) {
121
- // Test mnemonic generation
122
- log(resultElementId, 'Attempting to generate mnemonic...', 'info');
123
- const mnemonic = MnemonicClass.fromRandom(256);
124
- log(resultElementId, `✅ ${version} mnemonic generation successful!`, 'success');
125
- log(resultElementId, `Sample words: ${mnemonic.phrase.split(' ').slice(0, 4).join(' ')}...`, 'info');
126
-
127
- // Test key derivation
128
- log(resultElementId, 'Testing key derivation...', 'info');
129
- const hdPrivateKey = bsv.HDPrivateKey.fromSeed(mnemonic.toSeed());
130
- const derived = hdPrivateKey.deriveChild("m/44'/236'/0'/0/0");
131
- const address = derived.privateKey.toAddress().toString();
132
- log(resultElementId, `✅ ${version} key derivation successful!`, 'success');
133
- log(resultElementId, `Address: ${address}`, 'info');
134
-
135
- updateSummary(version, 'SUCCESS');
136
- } else {
137
- log(resultElementId, `❌ ${version} mnemonic class not available`, 'error');
138
- updateSummary(version, 'NO_MNEMONIC_CLASS');
139
- }
140
-
141
- } catch (error) {
142
- log(resultElementId, `❌ ${version} error: ${error.message}`, 'error');
143
- if (error.message.includes('createHmac')) {
144
- log(resultElementId, '🔍 This is the createHmac error we are fixing!', 'error');
145
- updateSummary(version, 'CREATEHMAC_ERROR');
146
- } else {
147
- updateSummary(version, 'OTHER_ERROR');
148
- }
149
- }
150
- }
151
-
152
- let testResults = {};
153
-
154
- function updateSummary(version, result) {
155
- testResults[version] = result;
156
-
157
- let summary = '<h3>Test Results Summary:</h3>';
158
-
159
- if (testResults['CDN']) {
160
- const cdnStatus = testResults['CDN'] === 'SUCCESS' ? '✅ Working' :
161
- testResults['CDN'] === 'CREATEHMAC_ERROR' ? '❌ createHmac error' :
162
- '❌ Failed';
163
- summary += `<div><strong>CDN Version:</strong> ${cdnStatus}</div>`;
164
- }
165
-
166
- if (testResults['Local']) {
167
- const localStatus = testResults['Local'] === 'SUCCESS' ? '✅ Working' : '❌ Failed';
168
- summary += `<div><strong>Local Fixed Version:</strong> ${localStatus}</div>`;
169
- }
170
-
171
- if (testResults['CDN'] && testResults['Local']) {
172
- if (testResults['CDN'] === 'CREATEHMAC_ERROR' && testResults['Local'] === 'SUCCESS') {
173
- summary += '<div class="success"><strong>✅ Fix confirmed!</strong> The local version resolves the CDN createHmac issue.</div>';
174
- summary += '<div class="info"><strong>Solution:</strong> The CDN bundle needs browser-compatible PBKDF2 implementation that uses BSV crypto instead of Node.js crypto.</div>';
175
- } else if (testResults['CDN'] === 'SUCCESS' && testResults['Local'] === 'SUCCESS') {
176
- summary += '<div class="success"><strong>Both versions working!</strong></div>';
177
- } else {
178
- summary += '<div class="error"><strong>Unexpected results.</strong> Please check the implementation.</div>';
179
- }
180
- }
181
-
182
- document.getElementById('summary').innerHTML = summary;
183
- }
184
- </script>
185
- </body>
186
- </html>
@@ -1,51 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>PBKDF2 Test</title>
5
- </head>
6
- <body>
7
- <h1>Testing PBKDF2 Browser Compatibility</h1>
8
- <div id="results"></div>
9
-
10
- <script src="../bsv.min.js"></script>
11
- <script src="../bsv-mnemonic.min.js"></script>
12
-
13
- <script>
14
- const results = document.getElementById('results');
15
-
16
- function log(message) {
17
- results.innerHTML += '<div>' + message + '</div>';
18
- console.log(message);
19
- }
20
-
21
- // Test mnemonic generation
22
- try {
23
- log('Testing mnemonic generation...');
24
-
25
- // Check if modules are available
26
- const MnemonicClass = window.bsvMnemonic || window.Mnemonic || (window.bsv && window.bsv.Mnemonic);
27
- log('Mnemonic class available: ' + !!MnemonicClass);
28
-
29
- if (MnemonicClass) {
30
- // Generate a mnemonic
31
- const mnemonic = MnemonicClass.fromRandom(256);
32
- log('✅ Mnemonic generated successfully: ' + mnemonic.phrase.split(' ').slice(0, 4).join(' ') + '...');
33
-
34
- // Test derivation
35
- const hdPrivateKey = bsv.HDPrivateKey.fromSeed(mnemonic.toSeed());
36
- const derived = hdPrivateKey.deriveChild("m/44'/236'/0'/0/0");
37
- log('✅ Key derivation successful');
38
- log('✅ Address: ' + derived.privateKey.toAddress().toString());
39
- } else {
40
- log('❌ Mnemonic class not available');
41
- }
42
-
43
- } catch (error) {
44
- log('❌ Error: ' + error.message);
45
- if (error.message.includes('createHmac')) {
46
- log('🔍 This is the createHmac error we are fixing!');
47
- }
48
- }
49
- </script>
50
- </body>
51
- </html>
@@ -1,131 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>BSV Bundle Completeness Test</title>
5
- <style>
6
- body { font-family: Arial; margin: 20px; }
7
- .success { color: green; }
8
- .error { color: red; }
9
- .warning { color: orange; }
10
- .module-test { margin: 10px 0; padding: 10px; border: 1px solid #ccc; }
11
- </style>
12
- </head>
13
- <body>
14
- <h1>🔬 BSV Bundle Completeness Test</h1>
15
- <p>Testing that our bundle includes all modules from the main library...</p>
16
-
17
- <div id="results"></div>
18
-
19
- <script src="bsv.bundle.js"></script>
20
- <script>
21
- const results = document.getElementById('results');
22
-
23
- function log(message, className = '') {
24
- const div = document.createElement('div');
25
- div.className = className;
26
- div.innerHTML = message;
27
- results.appendChild(div);
28
- console.log(message);
29
- }
30
-
31
- function testModule(name, accessor, required = true) {
32
- const div = document.createElement('div');
33
- div.className = 'module-test';
34
-
35
- try {
36
- const module = accessor();
37
- if (module) {
38
- div.innerHTML = `<span class="success">✅ ${name}: Available</span>`;
39
- if (typeof module === 'function') {
40
- div.innerHTML += ` (Constructor)`;
41
- } else if (typeof module === 'object') {
42
- const keys = Object.keys(module);
43
- div.innerHTML += ` (${keys.length} properties: ${keys.slice(0, 3).join(', ')}${keys.length > 3 ? '...' : ''})`;
44
- }
45
- } else {
46
- div.innerHTML = `<span class="${required ? 'error' : 'warning'}">${required ? '❌' : '⚠️'} ${name}: Not available</span>`;
47
- }
48
- } catch (e) {
49
- div.innerHTML = `<span class="${required ? 'error' : 'warning'}">${required ? '❌' : '⚠️'} ${name}: Error - ${e.message}</span>`;
50
- }
51
-
52
- results.appendChild(div);
53
- }
54
-
55
- // Test all modules that should be in the bundle
56
- log('<h2>Core BSV Library</h2>');
57
- testModule('bsv', () => bsv);
58
- testModule('bsv.version', () => bsv.version);
59
- testModule('bsv.PrivateKey', () => bsv.PrivateKey);
60
- testModule('bsv.PublicKey', () => bsv.PublicKey);
61
- testModule('bsv.Address', () => bsv.Address);
62
- testModule('bsv.Transaction', () => bsv.Transaction);
63
- testModule('bsv.Script', () => bsv.Script);
64
-
65
- log('<h2>Crypto Modules</h2>');
66
- testModule('bsv.crypto.Hash', () => bsv.crypto.Hash);
67
- testModule('bsv.crypto.ECDSA', () => bsv.crypto.ECDSA);
68
- testModule('bsv.crypto.Signature', () => bsv.crypto.Signature);
69
- testModule('bsv.crypto.SmartVerify', () => bsv.crypto.SmartVerify);
70
- testModule('bsv.crypto.EllipticFixed', () => bsv.crypto.EllipticFixed);
71
-
72
- log('<h2>SmartLedger Security</h2>');
73
- testModule('bsv.SmartLedger', () => bsv.SmartLedger);
74
- testModule('bsv.SmartVerify', () => bsv.SmartVerify);
75
- testModule('bsv.EllipticFixed', () => bsv.EllipticFixed);
76
-
77
- log('<h2>Additional Modules</h2>');
78
- testModule('bsv.Message', () => bsv.Message);
79
- testModule('bsv.Mnemonic', () => bsv.Mnemonic, false); // May not work in browser
80
- testModule('bsv.ECIES', () => bsv.ECIES);
81
-
82
- log('<h2>SmartContract Framework</h2>');
83
- testModule('bsv.SmartContract', () => bsv.SmartContract);
84
- if (bsv.SmartContract) {
85
- testModule('SmartContract.interpretScript', () => bsv.SmartContract.interpretScript);
86
- testModule('SmartContract.getScriptMetrics', () => bsv.SmartContract.getScriptMetrics);
87
- testModule('SmartContract.examineStack', () => bsv.SmartContract.examineStack);
88
- testModule('SmartContract.optimizeScript', () => bsv.SmartContract.optimizeScript);
89
- }
90
-
91
- log('<h2>NEW: Advanced Development Tools</h2>');
92
- testModule('bsv.CovenantInterface', () => bsv.CovenantInterface);
93
- testModule('bsv.CustomScriptHelper', () => bsv.CustomScriptHelper);
94
- testModule('bsv.Transaction.sighash', () => bsv.Transaction.sighash);
95
-
96
- log('<h2>Bundle Information</h2>');
97
- testModule('bsv.bundle', () => bsv.bundle);
98
- testModule('bsv.SmartLedgerBundle', () => bsv.SmartLedgerBundle);
99
-
100
- // Test bundle convenience methods
101
- log('<h2>Bundle Convenience Methods</h2>');
102
- if (bsv.SmartLedgerBundle) {
103
- testModule('generateKeys()', () => bsv.SmartLedgerBundle.generateKeys);
104
- testModule('createMessage()', () => bsv.SmartLedgerBundle.createMessage);
105
- testModule('encrypt()', () => bsv.SmartLedgerBundle.encrypt);
106
- testModule('examineScript()', () => bsv.SmartLedgerBundle.examineScript);
107
- testModule('createCovenant()', () => bsv.SmartLedgerBundle.createCovenant);
108
- testModule('createCustomSignature()', () => bsv.SmartLedgerBundle.createCustomSignature);
109
- testModule('calculateSighash()', () => bsv.SmartLedgerBundle.calculateSighash);
110
- }
111
-
112
- // Show bundle info
113
- if (bsv.bundle) {
114
- log('<h2>Bundle Contents</h2>');
115
- log(`<div>Version: ${bsv.bundle.version}</div>`);
116
- log(`<div>Type: ${bsv.bundle.type}</div>`);
117
- log(`<div>Includes: ${bsv.bundle.includes.join(', ')}</div>`);
118
- }
119
-
120
- // Final summary
121
- log('<h2>Summary</h2>');
122
- const successCount = document.querySelectorAll('.success').length;
123
- const errorCount = document.querySelectorAll('.error').length;
124
- const warningCount = document.querySelectorAll('.warning').length;
125
-
126
- log(`<div><strong>✅ Successful: ${successCount}</strong></div>`);
127
- if (errorCount > 0) log(`<div><strong>❌ Errors: ${errorCount}</strong></div>`);
128
- if (warningCount > 0) log(`<div><strong>⚠️ Warnings: ${warningCount}</strong></div>`);
129
- </script>
130
- </body>
131
- </html>