@smartledger/bsv 6.1.2 → 6.2.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +38 -38
  3. package/SECURITY.md +39 -12
  4. package/bsv-anchor.min.js +18 -11
  5. package/bsv-covenant.min.js +2 -48
  6. package/bsv-didweb.min.js +18 -11
  7. package/bsv-ecies.min.js +2 -20
  8. package/bsv-gdaf.min.js +103 -45
  9. package/bsv-ltp.min.js +103 -45
  10. package/bsv-message.min.js +3 -10
  11. package/bsv-mnemonic.min.js +20 -11
  12. package/bsv-script-helper.min.js +2 -10
  13. package/bsv-security.min.js +2 -10
  14. package/bsv-shamir.min.js +20 -11
  15. package/bsv-smartcontract.min.js +26 -48
  16. package/bsv-statuslist.min.js +74 -17
  17. package/bsv-vcjwt.min.js +18 -11
  18. package/bsv.bundle.js +103 -45
  19. package/bsv.min.js +103 -45
  20. package/build/esbuild/empty.js +2 -0
  21. package/build/esbuild/globals.js +6 -0
  22. package/build/esbuild.js +129 -0
  23. package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
  24. package/docs/THREAT_MODEL.md +127 -0
  25. package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
  26. package/docs/getting-started/INSTALLATION.md +23 -23
  27. package/docs/getting-started/QUICK_START.md +7 -7
  28. package/docs/migration/FROM_BSV_1_5_6.md +5 -5
  29. package/package.json +3 -22
  30. package/test/build/bundle_smoke.js +55 -0
  31. package/test/build/esbuild_main.js +65 -0
  32. package/test/security/threat_model_coverage.js +31 -0
  33. package/build/webpack.anchor.config.js +0 -15
  34. package/build/webpack.base.js +0 -125
  35. package/build/webpack.bundle.config.js +0 -15
  36. package/build/webpack.config.js +0 -17
  37. package/build/webpack.covenant.config.js +0 -17
  38. package/build/webpack.didweb.config.js +0 -15
  39. package/build/webpack.ecies.config.js +0 -15
  40. package/build/webpack.gdaf.config.js +0 -15
  41. package/build/webpack.ltp.config.js +0 -15
  42. package/build/webpack.message.config.js +0 -15
  43. package/build/webpack.mnemonic.config.js +0 -15
  44. package/build/webpack.script-helper.config.js +0 -17
  45. package/build/webpack.security.config.js +0 -15
  46. package/build/webpack.shamir.config.js +0 -15
  47. package/build/webpack.smartcontract.config.js +0 -18
  48. package/build/webpack.statuslist.config.js +0 -15
  49. package/build/webpack.vcjwt.config.js +0 -15
@@ -0,0 +1,2 @@
1
+ 'use strict'
2
+ module.exports = {}
@@ -0,0 +1,6 @@
1
+ // esbuild inject shim: provide the Node `Buffer` and `process` globals in browser
2
+ // bundles (webpack did this via ProvidePlugin). esbuild replaces unbound references
3
+ // to `Buffer` / `process` with these imports.
4
+ import process from 'process/browser'
5
+ export { Buffer } from 'buffer'
6
+ export { process }
@@ -0,0 +1,129 @@
1
+ 'use strict'
2
+ // esbuild build for the browser bundles (webpack -> esbuild migration). Replaces the 16
3
+ // webpack configs + webpack.base.js with one config-driven builder. Two polyfill modes
4
+ // mirror webpack.base.js: `full` = bundlePolyfills (browserify shims for Node built-ins,
5
+ // so Shamir/secrets.js gets a CSPRNG in the browser); `stub` = externStubs (built-ins
6
+ // stubbed to empty; bsv is loaded separately). Feature bundles externalise the bsv root
7
+ // to the global `bsv`. Every bundle is UMD (browser global + require()/AMD).
8
+ //
9
+ // esbuild gotcha: its `alias` prefix-matches (mis-resolving subpaths like process/browser),
10
+ // so resolution is done with precise onResolve plugins instead.
11
+ const path = require('path')
12
+ const esbuild = require('esbuild')
13
+ const R = (p) => require.resolve(p)
14
+ const ROOT = path.resolve(__dirname, '..')
15
+ const BSV_INDEX = path.join(ROOT, 'index.js')
16
+ const EMPTY = path.join(__dirname, 'esbuild/empty.js')
17
+
18
+ const BUILTIN = /^(crypto|stream|assert|util|zlib|vm|buffer|path|http|https|os|url|fs|net|tls|readline|child_process)$/
19
+
20
+ // full (bundlePolyfills): real browserify shims; unused server-only built-ins -> empty.
21
+ const FULL_SHIM = {
22
+ crypto: R('crypto-browserify'),
23
+ stream: R('stream-browserify'),
24
+ assert: R('assert/'),
25
+ util: R('util/'),
26
+ zlib: R('browserify-zlib'),
27
+ vm: R('vm-browserify'),
28
+ buffer: R('buffer/'),
29
+ path: R('path-browserify')
30
+ }
31
+ // stub (externStubs): everything empty except buffer/process (still needed as globals).
32
+ const STUB_SHIM = { buffer: R('buffer/') }
33
+
34
+ function polyfillPlugin (mode) {
35
+ return {
36
+ name: 'node-polyfills-' + mode,
37
+ setup (build) {
38
+ const shim = mode === 'stub' ? STUB_SHIM : FULL_SHIM
39
+ build.onResolve({ filter: BUILTIN }, (a) => ({ path: shim[a.path] || EMPTY }))
40
+ build.onResolve({ filter: /^process(\/browser)?$/ }, () => ({ path: R('process/browser') }))
41
+ // keep `elliptic` out of the bundle (webpack aliased browserify-sign / create-ecdh -> false)
42
+ build.onResolve({ filter: /^(browserify-sign|create-ecdh)(\/|$)/ }, () => ({ path: EMPTY }))
43
+ }
44
+ }
45
+ }
46
+
47
+ // Externalise the bsv root (require('../..') / require('../index.js') / etc.) to the global
48
+ // `bsv` — the webpack `externals: { … : 'bsv' }` behaviour for feature bundles.
49
+ function externalBsvPlugin () {
50
+ return {
51
+ name: 'external-bsv',
52
+ setup (build) {
53
+ build.onResolve({ filter: /^\.\.?[\\/]/ }, (a) => {
54
+ const resolved = path.resolve(a.resolveDir, a.path)
55
+ if (resolved === BSV_INDEX || resolved === ROOT) return { path: a.path, namespace: 'bsv-global' }
56
+ })
57
+ build.onLoad({ filter: /.*/, namespace: 'bsv-global' }, () => ({
58
+ contents: 'module.exports=(typeof globalThis!=="undefined"?globalThis:(typeof self!=="undefined"?self:window)).bsv',
59
+ loader: 'js'
60
+ }))
61
+ }
62
+ }
63
+ }
64
+
65
+ function umdFooter (globalName) {
66
+ return 'if(typeof module!=="undefined"&&module.exports){module.exports=' + globalName +
67
+ '}else if(typeof define==="function"&&define.amd){define([],function(){return ' + globalName + '})}'
68
+ }
69
+
70
+ // The 16 published browser bundles (mirrors package.json build-* scripts).
71
+ const BUNDLES = [
72
+ { file: 'bsv.min.js', entry: 'index.js', global: 'bsv', mode: 'full', externalBsv: false },
73
+ { file: 'bsv.bundle.js', entry: 'bundle-entry.js', global: 'bsv', mode: 'full', externalBsv: false },
74
+ { file: 'bsv-ecies.min.js', entry: 'ecies/index.js', global: 'bsvEcies', mode: 'full', externalBsv: true },
75
+ { file: 'bsv-message.min.js', entry: 'message/index.js', global: 'bsvMessage', mode: 'full', externalBsv: true },
76
+ { file: 'bsv-mnemonic.min.js', entry: 'mnemonic/index.js', global: 'bsvMnemonic', mode: 'full', externalBsv: true },
77
+ { file: 'bsv-shamir.min.js', entry: 'shamir-entry.js', global: 'bsvShamir', mode: 'full', externalBsv: true },
78
+ { file: 'bsv-smartcontract.min.js', entry: 'smartcontract-entry.js', global: 'bsvSmartContract', mode: 'stub', externalBsv: true },
79
+ { file: 'bsv-covenant.min.js', entry: 'covenant-entry.js', global: 'bsvCovenant', mode: 'stub', externalBsv: true },
80
+ { file: 'bsv-script-helper.min.js', entry: 'script-helper-entry.js', global: 'bsvScriptHelper', mode: 'stub', externalBsv: true },
81
+ { file: 'bsv-security.min.js', entry: 'security-entry.js', global: 'bsvSecurity', mode: 'full', externalBsv: false },
82
+ { file: 'bsv-ltp.min.js', entry: 'ltp-entry.js', global: 'bsvLTP', mode: 'full', externalBsv: false },
83
+ { file: 'bsv-gdaf.min.js', entry: 'gdaf-entry.js', global: 'bsvGDAF', mode: 'full', externalBsv: false },
84
+ { file: 'bsv-didweb.min.js', entry: 'didweb-entry.js', global: 'bsvDIDWeb', mode: 'full', externalBsv: false },
85
+ { file: 'bsv-vcjwt.min.js', entry: 'vcjwt-entry.js', global: 'bsvVcJwt', mode: 'full', externalBsv: false },
86
+ { file: 'bsv-statuslist.min.js', entry: 'statuslist-entry.js', global: 'bsvStatusList', mode: 'full', externalBsv: false },
87
+ { file: 'bsv-anchor.min.js', entry: 'anchor-entry.js', global: 'bsvAnchor', mode: 'full', externalBsv: false }
88
+ ]
89
+
90
+ // Build one bundle. Pass { write: false } to get the output in memory (for tests).
91
+ function buildOne (cfg, opts) {
92
+ opts = opts || {}
93
+ const plugins = [polyfillPlugin(cfg.mode)]
94
+ if (cfg.externalBsv) plugins.push(externalBsvPlugin())
95
+ return esbuild.build({
96
+ entryPoints: [path.join(ROOT, cfg.entry)],
97
+ bundle: true,
98
+ format: 'iife',
99
+ globalName: cfg.global,
100
+ platform: 'browser',
101
+ target: ['es2020'], // bsv + @noble/curves use BigInt
102
+ minify: true,
103
+ legalComments: 'none',
104
+ plugins,
105
+ inject: [path.join(__dirname, 'esbuild/globals.js')],
106
+ define: { global: 'globalThis' },
107
+ footer: { js: umdFooter(cfg.global) },
108
+ write: opts.write !== false,
109
+ outfile: opts.write === false ? undefined : path.join(ROOT, cfg.file),
110
+ logLevel: opts.logLevel || 'warning'
111
+ })
112
+ }
113
+
114
+ // The full library bundle (bsv.min.js) — kept for the build-integrity test.
115
+ function buildFullBundle (opts) {
116
+ return buildOne(BUNDLES[0], opts)
117
+ }
118
+
119
+ function buildAll () {
120
+ return Promise.all(BUNDLES.map(function (c) { return buildOne(c) }))
121
+ }
122
+
123
+ module.exports = { buildFullBundle, buildAll, buildOne, BUNDLES }
124
+
125
+ if (require.main === module) {
126
+ buildAll().then(function () {
127
+ console.log('esbuild: built ' + BUNDLES.length + ' bundles')
128
+ }).catch(function (e) { console.error(e.message || e); process.exit(1) })
129
+ }
@@ -55,19 +55,19 @@ Three advanced modules totaling **~2.7MB** of functionality:
55
55
  - **Purpose**: Threshold cryptography for secure secret distribution
56
56
  - **Use Cases**: Backup keys, multi-party security, key recovery
57
57
  - **Features**: Split secrets into N shares, require M to reconstruct
58
- - **CDN**: `unpkg.com/@smartledger/bsv@6.1.2/bsv-shamir.min.js`
58
+ - **CDN**: `unpkg.com/@smartledger/bsv@6.2.0/bsv-shamir.min.js`
59
59
 
60
60
  #### **🌐 Global Digital Attestation Framework - GDAF (1184KB)**
61
61
  - **Purpose**: W3C Verifiable Credentials and decentralized identity
62
62
  - **Use Cases**: Identity verification, attestations, zero-knowledge proofs
63
63
  - **Features**: DID creation, credential issuance, selective disclosure
64
- - **CDN**: `unpkg.com/@smartledger/bsv@6.1.2/bsv-gdaf.min.js`
64
+ - **CDN**: `unpkg.com/@smartledger/bsv@6.2.0/bsv-gdaf.min.js`
65
65
 
66
66
  #### **⚖️ Legal Token Protocol - LTP (1184KB)**
67
67
  - **Purpose**: Legal compliance framework for tokenized assets
68
68
  - **Use Cases**: Property rights, obligations, compliant tokenization
69
69
  - **Features**: Legal primitives, compliance checking, attestation anchoring
70
- - **CDN**: `unpkg.com/@smartledger/bsv@6.1.2/bsv-ltp.min.js`
70
+ - **CDN**: `unpkg.com/@smartledger/bsv@6.2.0/bsv-ltp.min.js`
71
71
 
72
72
  ### **2. Incorrect File Sizes in Documentation**
73
73
 
@@ -81,18 +81,18 @@ Three advanced modules totaling **~2.7MB** of functionality:
81
81
 
82
82
  | Module | Size | Use Case | CDN Link |
83
83
  |--------|------|----------|----------|
84
- | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@6.1.2/bsv.min.js` |
85
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@6.1.2/bsv.bundle.js` |
86
- | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@6.1.2/bsv-smartcontract.min.js` |
87
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@6.1.2/bsv-covenant.min.js` |
88
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@6.1.2/bsv-script-helper.min.js` |
89
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@6.1.2/bsv-security.min.js` |
90
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@6.1.2/bsv-ecies.min.js` |
91
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@6.1.2/bsv-message.min.js` |
92
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@6.1.2/bsv-mnemonic.min.js` |
93
- | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@6.1.2/bsv-shamir.min.js` |
94
- | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@6.1.2/bsv-gdaf.min.js` |
95
- | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@6.1.2/bsv-ltp.min.js` |
84
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@6.2.0/bsv.min.js` |
85
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@6.2.0/bsv.bundle.js` |
86
+ | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@6.2.0/bsv-smartcontract.min.js` |
87
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@6.2.0/bsv-covenant.min.js` |
88
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@6.2.0/bsv-script-helper.min.js` |
89
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@6.2.0/bsv-security.min.js` |
90
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@6.2.0/bsv-ecies.min.js` |
91
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@6.2.0/bsv-message.min.js` |
92
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@6.2.0/bsv-mnemonic.min.js` |
93
+ | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@6.2.0/bsv-shamir.min.js` |
94
+ | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@6.2.0/bsv-gdaf.min.js` |
95
+ | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@6.2.0/bsv-ltp.min.js` |
96
96
 
97
97
  ## 🎯 **Updated Usage Examples**
98
98
 
@@ -100,22 +100,22 @@ Three advanced modules totaling **~2.7MB** of functionality:
100
100
 
101
101
  #### **1. Basic Development (~963KB)**
102
102
  ```html
103
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv.min.js"></script>
104
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv-script-helper.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv.min.js"></script>
104
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv-script-helper.min.js"></script>
105
105
  ```
106
106
 
107
107
  #### **2. Smart Contract Development (~2.7MB — each bundle re-embeds core BSV)**
108
108
  ```html
109
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv.min.js"></script>
110
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv-covenant.min.js"></script>
111
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv-smartcontract.min.js"></script>
109
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv.min.js"></script>
110
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv-covenant.min.js"></script>
111
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv-smartcontract.min.js"></script>
112
112
  ```
113
113
 
114
114
  #### **3. 🆕 Legal & Compliance Development (~3.2MB — each bundle re-embeds core BSV)**
115
115
  ```html
116
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv.min.js"></script>
117
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv-ltp.min.js"></script>
118
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv-gdaf.min.js"></script>
116
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv.min.js"></script>
117
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv-ltp.min.js"></script>
118
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv-gdaf.min.js"></script>
119
119
  <script>
120
120
  // Legal Token Protocol
121
121
  const legalToken = bsv.createLegalToken({
@@ -132,9 +132,9 @@ Three advanced modules totaling **~2.7MB** of functionality:
132
132
 
133
133
  #### **4. 🆕 Security & Cryptography (~1.4MB)**
134
134
  ```html
135
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv.min.js"></script>
136
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv-security.min.js"></script>
137
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv-shamir.min.js"></script>
135
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv-security.min.js"></script>
137
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv-shamir.min.js"></script>
138
138
  <script>
139
139
  // Shamir Secret Sharing
140
140
  const shares = bsv.splitSecret('my_secret_key', 5, 3); // 5 shares, 3 needed
@@ -146,7 +146,7 @@ Three advanced modules totaling **~2.7MB** of functionality:
146
146
 
147
147
  #### **5. Everything Bundle (937KB)**
148
148
  ```html
149
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv.bundle.js"></script>
149
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv.bundle.js"></script>
150
150
  <script>
151
151
  // Everything available immediately
152
152
  const shares = bsv.splitSecret('secret', 5, 3);
@@ -0,0 +1,127 @@
1
+ # Threat model — `@smartledger/bsv`
2
+
3
+ This document states, property by property, **what the library guarantees, under what
4
+ assumptions, and which adversarial test proves each guarantee.** It is deliberately
5
+ honest about what is *not* guaranteed. Every ``test/…`` path referenced here is checked
6
+ to exist by `test/security/threat_model_coverage.js`, so this document cannot drift from
7
+ the suite (the same "docs are tested claims" principle behind the type-drift gate).
8
+
9
+ The guiding principle, learned the hard way (see `SECURITY.md` → 6.0.0): **verification
10
+ fails closed by construction** — a verify function returns a strict boolean or throws,
11
+ never a truthy object that can be mistaken for success — and **every security property
12
+ ships an adversarial test that asserts the *bad* input is rejected.**
13
+
14
+ ## 1. Assets and trust boundaries
15
+
16
+ | Asset | Boundary | What must not happen |
17
+ | --- | --- | --- |
18
+ | Private keys / entropy | key-gen, HD derivation, CSPRNG | weak/predictable keys; entropy from `Math.random` |
19
+ | ECDSA signatures | `verify` / `verifyBool` | a forged signature verifying as valid (fail-open) |
20
+ | On-chain covenants | the Script interpreter | spending a covenant UTXO in a way the covenant forbids |
21
+ | Ordinal listings | the OrdLock covenant | taking the ordinal without paying the seller/royalty/fee |
22
+ | Credentials / DIDs | JWS verify + issuer binding | forged/tampered/attacker-issuer credentials accepted |
23
+ | Revocation status | StatusList2021 verify | a revoked credential reading as valid (bypass) |
24
+ | SPV inclusion | Merkle branch + header PoW | a transaction "proven" included when it is not |
25
+
26
+ The trust boundary is the **verify / enforce** call. Inputs on the far side are treated
27
+ as adversarial. Callers on the near side are trusted (a malicious local process, patched
28
+ Node, or hostile browser extension is out of scope — see `SECURITY.md`).
29
+
30
+ ## 2. Security properties and the tests that enforce them
31
+
32
+ ### 2.1 Signature verification fails closed
33
+
34
+ - Static `crypto.ECDSA.verify` and `SmartVerify.smartVerify` return a **strict boolean**
35
+ and **reject a forged signature** (wrong key); `ECDSA.prototype.verifyBool()` is the
36
+ safe boolean path. The instance `verify()` returns the instance (documented trap) — its
37
+ contract is pinned so a regression to fail-open trips a red test.
38
+ → `test/security/fail_closed_contracts.js`
39
+ - The hardened curve produces **low-S canonical** signatures, keeps `recoveryParam`
40
+ consistent, **rejects zero / out-of-range `r`,`s`**, and **returns `false` (never
41
+ throws) on malformed signatures**.
42
+ → `test/crypto/elliptic-fixed.js`
43
+
44
+ ### 2.2 Covenants enforce their spend rule
45
+
46
+ - The OP_PUSH_TX core, Token state-machine, and value covenants are **interpreter-verified**:
47
+ a spend that violates the covenant is rejected by the consensus interpreter.
48
+ → `test/smart_contract/covenants.js`, `test/smart_contract/token_generalized.js`,
49
+ `test/smart_contract/ordinal_transfer.js`
50
+ - **Ordinal marketplace (OrdLock):** the ordinal cannot be taken without recreating the
51
+ required payment(s) byte-for-byte — underpaying the seller, redirecting a royalty/fee, or
52
+ cancelling with the wrong key are all rejected; tampering any output after signing breaks
53
+ the covenant.
54
+ → `test/ordinals/ordlock.js`
55
+
56
+ ### 2.3 Credential / token verification fails closed (C1–C4)
57
+
58
+ - A **tampered JWS** signature is rejected; a token **re-signed by an attacker but attributed
59
+ to the victim issuer** is rejected (issuer-key binding, C4); `verifyOwnership` **rejects a
60
+ signature by the wrong key** (C2); `verifyAnchor` **refuses to fabricate success** without a
61
+ real chain proof (C3); `prepareRightTokenTransfer` **rejects a non-owner** transfer.
62
+ → `test/ltp/verify_failclosed.js`
63
+
64
+ ### 2.4 Revocation cannot be bypassed
65
+
66
+ - A status list whose **bitstring was tampered without re-signing** is rejected; reading
67
+ **refuses without a pinned `expectedIssuerDid`**; a list **signed by a different (attacker)
68
+ issuer** under the victim DID is rejected.
69
+ → `test/statuslist/failclosed.js`
70
+
71
+ ### 2.5 SPV inclusion cannot be forged
72
+
73
+ - `verifyMerkleProof` recomputes the root for every leaf (cross-checked against
74
+ `Block.getMerkleTree`), **rejects a tampered branch node** and the **right proof against the
75
+ wrong txid**; `verifyTxInclusion` binds the branch to a header's merkle root.
76
+ → `test/spv/merkleproof.js`
77
+ - `verifyHeaderChain` **rejects a broken link** and a **header that fails proof-of-work**, and
78
+ honours a trusted-hash checkpoint.
79
+ → `test/spv/headerchain.js`
80
+
81
+ ### 2.6 Secret sharing does not leak
82
+
83
+ - Shamir shares do **not** embed a hash of the secret by default (checksum is opt-in), so a
84
+ sub-threshold holder cannot brute-force a low-entropy secret offline.
85
+ → `test/crypto/shamir.js`
86
+
87
+ ### 2.7 The type surface does not lie
88
+
89
+ - `bsv.d.ts` declares only APIs that exist at runtime, and the modules added in 6.x stay fully
90
+ typed (parsed via the TypeScript AST).
91
+ → `test/types/dts_drift.js`
92
+
93
+ ## 3. Trust assumptions and known limitations (honest)
94
+
95
+ - **The inherited crypto/tx/script core has not been independently audited by us.** This
96
+ library forks `moneybutton/bsv` ← `bitpay/bitcore-lib`. We hardened the layer where the
97
+ 6.0.0 bugs lived (verification/enforcement) and test the trust boundaries adversarially,
98
+ but the underlying EC math (`@noble/curves@2`, audited upstream), BN, and script primitives
99
+ are **trusted, not re-audited here**. An external audit is the top open item.
100
+ - **`ECDSA.prototype.verify()` remains a footgun** (returns the instance). Mitigated by
101
+ `verifyBool()`, types, and a pinning test; **removal is planned for the next major.**
102
+ - **`verifyHeaderChain` does not validate difficulty retargeting** — it checks linkage and
103
+ per-header PoW, not that the difficulty is correct for the height. Anchor confirmations
104
+ should therefore be pinned to a **trusted checkpoint hash**; this is by design and
105
+ documented in `lib/spv/headerchain.js`.
106
+ - **`verifyAnchor`** is trustless only on the `{spvProof, header/headerChain, rawTx}` path;
107
+ the `chainProvider` path trusts the injected provider.
108
+ - **No published provenance yet.** Bundles are a reproducible build of source (see §4) but
109
+ npm provenance attestation is pending a trusted-publisher registration (2FA-gated). This is
110
+ a *supply-chain verifiability* gap, not a code vulnerability.
111
+ - **Genesis limits.** Covenant scripts require post-Genesis limits (`SmartContract.enableGenesis()`);
112
+ the guarantees assume a post-Genesis BSV node.
113
+
114
+ ## 4. Supply chain / reproducible builds
115
+
116
+ - The published `*.min.js` / `*.bundle.js` are a **byte-for-byte reproducible build** of
117
+ `lib/` — CI rebuilds them and fails if they differ (the "Build & bundle integrity" gate),
118
+ and the build is deterministic across Node 20 and 22.
119
+ - The published tarball ships **no `node_modules`**; the runtime dependency set is small and
120
+ pinned, and `elliptic` was removed from the runtime/bundle path (6.x uses `@noble/curves`).
121
+ - Merges are gated on the full test suite (Node 20 + 22), a pristine scoped lint of the
122
+ audited modules, a whole-repo lint ratchet, and the type-drift gate.
123
+
124
+ ## 5. Reporting
125
+
126
+ See [`SECURITY.md`](../SECURITY.md) for private disclosure. Do not open public issues for
127
+ vulnerabilities.
@@ -722,7 +722,7 @@ interface UTXO {
722
722
  <html>
723
723
  <head>
724
724
  <title>UTXO Manager Demo</title>
725
- <script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@6.1.2/bsv.min.js"></script>
725
+ <script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@6.2.0/bsv.min.js"></script>
726
726
  </head>
727
727
  <body>
728
728
  <script>
@@ -48,7 +48,7 @@ const tx: Transaction = new Transaction();
48
48
  #### **Core Library Only (937KB)**
49
49
  For basic Bitcoin SV operations:
50
50
  ```html
51
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv.min.js"></script>
51
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv.min.js"></script>
52
52
  <script>
53
53
  const privateKey = new bsv.PrivateKey();
54
54
  const address = privateKey.toAddress();
@@ -58,7 +58,7 @@ For basic Bitcoin SV operations:
58
58
  #### **Complete Bundle (937KB)**
59
59
  Everything in one file:
60
60
  ```html
61
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv.bundle.js"></script>
61
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv.bundle.js"></script>
62
62
  <script>
63
63
  // All features available immediately
64
64
  const shares = bsv.splitSecret('secret', 5, 3);
@@ -71,9 +71,9 @@ Everything in one file:
71
71
 
72
72
  #### **Smart Contract Development (~2.7MB total — each bundle is self-contained and re-embeds core BSV)**
73
73
  ```html
74
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv.min.js"></script>
75
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv-covenant.min.js"></script>
76
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv-smartcontract.min.js"></script>
74
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv.min.js"></script>
75
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv-covenant.min.js"></script>
76
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv-smartcontract.min.js"></script>
77
77
  <script>
78
78
  const covenant = bsv.SmartContract.createCovenantBuilder()
79
79
  .extractField('amount').push(50000).greaterThanOrEqual().build();
@@ -82,9 +82,9 @@ Everything in one file:
82
82
 
83
83
  #### **Legal & Identity Development (~3.2MB total — each bundle is self-contained and re-embeds core BSV)**
84
84
  ```html
85
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv.min.js"></script>
86
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv-ltp.min.js"></script>
87
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv-gdaf.min.js"></script>
85
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv.min.js"></script>
86
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv-ltp.min.js"></script>
87
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv-gdaf.min.js"></script>
88
88
  <script>
89
89
  // Legal Token Protocol
90
90
  const propertyToken = bsv.createPropertyToken({
@@ -98,9 +98,9 @@ Everything in one file:
98
98
 
99
99
  #### **Security & Cryptography (~1.4MB total — each bundle is self-contained and re-embeds core BSV)**
100
100
  ```html
101
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv.min.js"></script>
102
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv-security.min.js"></script>
103
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv-shamir.min.js"></script>
101
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv.min.js"></script>
102
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv-security.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv-shamir.min.js"></script>
104
104
  <script>
105
105
  // Threshold Cryptography
106
106
  const shares = bsv.splitSecret('my_secret_key', 5, 3);
@@ -114,18 +114,18 @@ Everything in one file:
114
114
 
115
115
  | Module | Size | Purpose | CDN Link |
116
116
  |--------|------|---------|----------|
117
- | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@6.1.2/bsv.min.js` |
118
- | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@6.1.2/bsv.bundle.js` |
119
- | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@6.1.2/bsv-smartcontract.min.js` |
120
- | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@6.1.2/bsv-ltp.min.js` |
121
- | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@6.1.2/bsv-gdaf.min.js` |
122
- | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@6.1.2/bsv-shamir.min.js` |
123
- | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@6.1.2/bsv-security.min.js` |
124
- | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@6.1.2/bsv-mnemonic.min.js` |
125
- | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@6.1.2/bsv-ecies.min.js` |
126
- | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@6.1.2/bsv-covenant.min.js` |
127
- | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@6.1.2/bsv-script-helper.min.js` |
128
- | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@6.1.2/bsv-message.min.js` |
117
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@6.2.0/bsv.min.js` |
118
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@6.2.0/bsv.bundle.js` |
119
+ | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@6.2.0/bsv-smartcontract.min.js` |
120
+ | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@6.2.0/bsv-ltp.min.js` |
121
+ | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@6.2.0/bsv-gdaf.min.js` |
122
+ | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@6.2.0/bsv-shamir.min.js` |
123
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@6.2.0/bsv-security.min.js` |
124
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@6.2.0/bsv-mnemonic.min.js` |
125
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@6.2.0/bsv-ecies.min.js` |
126
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@6.2.0/bsv-covenant.min.js` |
127
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@6.2.0/bsv-script-helper.min.js` |
128
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@6.2.0/bsv-message.min.js` |
129
129
 
130
130
  ## ⚙️ **Development Environment Setup**
131
131
 
@@ -14,10 +14,10 @@ npm install @smartledger/bsv
14
14
  ### Browser CDN (Instant)
15
15
  ```html
16
16
  <!-- Core library (937KB) -->
17
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv.min.js"></script>
17
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv.min.js"></script>
18
18
 
19
19
  <!-- Everything included (937KB) -->
20
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv.bundle.js"></script>
20
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv.bundle.js"></script>
21
21
  ```
22
22
 
23
23
  ## 💰 **Your First Transaction (60 seconds)**
@@ -127,19 +127,19 @@ SmartLedger-BSV offers 12 different loading options - use only what you need:
127
127
 
128
128
  ```html
129
129
  <!-- Core BSV only (937KB) -->
130
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv.min.js"></script>
130
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv.min.js"></script>
131
131
 
132
132
  <!-- Smart contracts (937KB) -->
133
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv-smartcontract.min.js"></script>
133
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv-smartcontract.min.js"></script>
134
134
 
135
135
  <!-- Legal tokens (1.16MB) -->
136
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv-ltp.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv-ltp.min.js"></script>
137
137
 
138
138
  <!-- Digital identity (1.16MB) -->
139
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv-gdaf.min.js"></script>
139
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv-gdaf.min.js"></script>
140
140
 
141
141
  <!-- Everything (937KB) -->
142
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv.bundle.js"></script>
142
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv.bundle.js"></script>
143
143
  ```
144
144
 
145
145
  ## ⚡ **Key Advantages**
@@ -159,17 +159,17 @@ const recovered = bsv.reconstructSecret([shares[0], shares[2], shares[4]]);
159
159
  ### **New Modular Options**
160
160
  ```html
161
161
  <!-- Core compatibility (same size as bsv@1.5.6) -->
162
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv.min.js"></script>
162
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv.min.js"></script>
163
163
 
164
164
  <!-- Add smart contracts when ready -->
165
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv-smartcontract.min.js"></script>
165
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv-smartcontract.min.js"></script>
166
166
 
167
167
  <!-- Add advanced features as needed -->
168
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv-ltp.min.js"></script>
169
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv-gdaf.min.js"></script>
168
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv-ltp.min.js"></script>
169
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv-gdaf.min.js"></script>
170
170
 
171
171
  <!-- Everything in one file -->
172
- <script src="https://unpkg.com/@smartledger/bsv@6.1.2/bsv.bundle.js"></script>
172
+ <script src="https://unpkg.com/@smartledger/bsv@6.2.0/bsv.bundle.js"></script>
173
173
  ```
174
174
 
175
175
  ## 🔍 **Testing Your Migration**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartledger/bsv",
3
- "version": "6.1.2",
3
+ "version": "6.2.0",
4
4
  "description": "🚀 Complete Bitcoin SV development framework with legally-recognizable DID:web + W3C VC-JWT toolkit, Legal Token Protocol (LTP), Global Digital Attestation Framework (GDAF), StatusList2021 revocation, and 16 flexible loading options. Standards-based credentials with ES256/ES256K support, on-chain BSV anchoring, and comprehensive Bitcoin SV API. Perfect for legal tokens, verifiable credentials, DeFi, smart contracts, and secure Bitcoin applications.",
5
5
  "author": "SmartLedger Technology <hello@smartledger.technology> (https://smartledger.technology)",
6
6
  "homepage": "https://github.com/codenlighten/smartledger-bsv#readme",
@@ -45,27 +45,7 @@
45
45
  "smart-contracts": "node examples/smart_contract_templates.js",
46
46
  "smart-contracts:working": "node examples/final_working_contracts.js",
47
47
  "workflow": "node examples/complete_workflow_demo.js",
48
- "build-bsv": "webpack --config build/webpack.config.js",
49
- "build-ecies": "webpack --config build/webpack.ecies.config.js",
50
- "build-message": "webpack --config build/webpack.message.config.js",
51
- "build-mnemonic": "webpack --config build/webpack.mnemonic.config.js",
52
- "build-shamir": "webpack --config build/webpack.shamir.config.js",
53
- "build-ltp": "webpack --config build/webpack.ltp.config.js",
54
- "build-gdaf": "webpack --config build/webpack.gdaf.config.js",
55
- "build-smartcontract": "webpack --config build/webpack.smartcontract.config.js",
56
- "build-covenant": "webpack --config build/webpack.covenant.config.js",
57
- "build-script-helper": "webpack --config build/webpack.script-helper.config.js",
58
- "build-security": "webpack --config build/webpack.security.config.js",
59
- "build-didweb": "webpack --config build/webpack.didweb.config.js",
60
- "build-vcjwt": "webpack --config build/webpack.vcjwt.config.js",
61
- "build-statuslist": "webpack --config build/webpack.statuslist.config.js",
62
- "build-anchor": "webpack --config build/webpack.anchor.config.js",
63
- "build-bundle": "webpack --config build/webpack.bundle.config.js",
64
- "build": "npm run build-bsv && npm run build-ecies && npm run build-message && npm run build-mnemonic && npm run build-shamir && npm run build-smartcontract",
65
- "build-specialized": "npm run build-covenant && npm run build-script-helper && npm run build-security",
66
- "build-credentials": "npm run build-didweb && npm run build-vcjwt && npm run build-statuslist && npm run build-anchor",
67
- "build-advanced": "npm run build-ltp && npm run build-gdaf",
68
- "build-all": "npm run build && npm run build-bundle && npm run build-specialized && npm run build-advanced && npm run build-credentials",
48
+ "build-all": "node build/esbuild.js",
69
49
  "test:browser": "echo 'Open tests/standalone-modules-test.html in browser for comprehensive testing'",
70
50
  "test:bundle": "echo 'Open tests/bundle-completeness-test.html in browser to verify bundle completeness'",
71
51
  "preimage:extract": "node examples/preimage/extract_preimage_bidirectional.js",
@@ -220,6 +200,7 @@
220
200
  "buffer": "^6.0.3",
221
201
  "chai": "4.2.0",
222
202
  "crypto-browserify": "^3.12.1",
203
+ "esbuild": "^0.28.1",
223
204
  "jose": "^5.10.0",
224
205
  "mocha": "^11.7.6",
225
206
  "nyc": "^18.0.0",