@smartledger/bsv 5.3.1 → 5.4.1
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/CHANGELOG.md +49 -0
- package/README.md +67 -62
- package/bsv-anchor.min.js +4 -4
- package/bsv-covenant.min.js +2 -2
- package/bsv-didweb.min.js +4 -4
- package/bsv-gdaf.min.js +13 -13
- package/bsv-ltp.min.js +13 -13
- package/bsv-mnemonic.min.js +4 -4
- package/bsv-shamir.min.js +4 -4
- package/bsv-smartcontract.min.js +2 -2
- package/bsv-statuslist.min.js +5 -5
- package/bsv-vcjwt.min.js +4 -4
- package/bsv.bundle.js +13 -13
- package/bsv.min.js +13 -13
- package/build/webpack.base.js +10 -0
- package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/getting-started/INSTALLATION.md +23 -23
- package/docs/getting-started/QUICK_START.md +7 -7
- package/docs/migration/FROM_BSV_1_5_6.md +5 -5
- package/lib/ltp/index.js +34 -46
- package/lib/ltp/right.js +132 -33
- package/package.json +1 -1
package/build/webpack.base.js
CHANGED
|
@@ -86,6 +86,16 @@ function bundlePolyfills (config) {
|
|
|
86
86
|
config.module.rules = (config.module.rules || []).concat([
|
|
87
87
|
{ test: /secrets\.js-grempe/, parser: { amd: false } }
|
|
88
88
|
])
|
|
89
|
+
// crypto-browserify drags in the whole `elliptic` library via browserify-sign
|
|
90
|
+
// + create-ecdh (for crypto.createSign/createVerify/createECDH) — APIs bsv
|
|
91
|
+
// never calls (its EC crypto is @noble). Stub them so `elliptic` is not bundled
|
|
92
|
+
// (~140KB/bundle). randomBytes/createHash/createHmac (the Shamir CSPRNG and
|
|
93
|
+
// hashing) are unaffected.
|
|
94
|
+
config.resolve = config.resolve || {}
|
|
95
|
+
config.resolve.alias = Object.assign(
|
|
96
|
+
{ 'browserify-sign': false, 'create-ecdh': false },
|
|
97
|
+
config.resolve.alias
|
|
98
|
+
)
|
|
89
99
|
return merge(config, FULL_FALLBACK, [
|
|
90
100
|
new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'], process: 'process/browser' })
|
|
91
101
|
])
|
|
@@ -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@5.
|
|
58
|
+
- **CDN**: `unpkg.com/@smartledger/bsv@5.4.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@5.
|
|
64
|
+
- **CDN**: `unpkg.com/@smartledger/bsv@5.4.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@5.
|
|
70
|
+
- **CDN**: `unpkg.com/@smartledger/bsv@5.4.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@5.
|
|
85
|
-
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@5.
|
|
86
|
-
| **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@5.
|
|
87
|
-
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@5.
|
|
88
|
-
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@5.
|
|
89
|
-
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@5.
|
|
90
|
-
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@5.
|
|
91
|
-
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@5.
|
|
92
|
-
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@5.
|
|
93
|
-
| **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@5.
|
|
94
|
-
| **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@5.
|
|
95
|
-
| **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@5.
|
|
84
|
+
| **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@5.4.0/bsv.min.js` |
|
|
85
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@5.4.0/bsv.bundle.js` |
|
|
86
|
+
| **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@5.4.0/bsv-smartcontract.min.js` |
|
|
87
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@5.4.0/bsv-covenant.min.js` |
|
|
88
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@5.4.0/bsv-script-helper.min.js` |
|
|
89
|
+
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@5.4.0/bsv-security.min.js` |
|
|
90
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@5.4.0/bsv-ecies.min.js` |
|
|
91
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@5.4.0/bsv-message.min.js` |
|
|
92
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@5.4.0/bsv-mnemonic.min.js` |
|
|
93
|
+
| **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@5.4.0/bsv-shamir.min.js` |
|
|
94
|
+
| **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@5.4.0/bsv-gdaf.min.js` |
|
|
95
|
+
| **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@5.4.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@5.
|
|
104
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
103
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv.min.js"></script>
|
|
104
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.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@5.
|
|
110
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
111
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
109
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv.min.js"></script>
|
|
110
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv-covenant.min.js"></script>
|
|
111
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.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@5.
|
|
117
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
118
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
116
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv.min.js"></script>
|
|
117
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv-ltp.min.js"></script>
|
|
118
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.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@5.
|
|
136
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
137
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
135
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv.min.js"></script>
|
|
136
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv-security.min.js"></script>
|
|
137
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.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@5.
|
|
149
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv.bundle.js"></script>
|
|
150
150
|
<script>
|
|
151
151
|
// Everything available immediately
|
|
152
152
|
const shares = bsv.splitSecret('secret', 5, 3);
|
|
@@ -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@5.
|
|
725
|
+
<script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@5.4.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@5.
|
|
51
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.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@5.
|
|
61
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.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@5.
|
|
75
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
76
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
74
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv.min.js"></script>
|
|
75
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv-covenant.min.js"></script>
|
|
76
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.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@5.
|
|
86
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
87
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
85
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv.min.js"></script>
|
|
86
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv-ltp.min.js"></script>
|
|
87
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.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@5.
|
|
102
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
103
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
101
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv.min.js"></script>
|
|
102
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv-security.min.js"></script>
|
|
103
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.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@5.
|
|
118
|
-
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@5.
|
|
119
|
-
| **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@5.
|
|
120
|
-
| **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@5.
|
|
121
|
-
| **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@5.
|
|
122
|
-
| **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@5.
|
|
123
|
-
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@5.
|
|
124
|
-
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@5.
|
|
125
|
-
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@5.
|
|
126
|
-
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@5.
|
|
127
|
-
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@5.
|
|
128
|
-
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@5.
|
|
117
|
+
| **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@5.4.0/bsv.min.js` |
|
|
118
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@5.4.0/bsv.bundle.js` |
|
|
119
|
+
| **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@5.4.0/bsv-smartcontract.min.js` |
|
|
120
|
+
| **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@5.4.0/bsv-ltp.min.js` |
|
|
121
|
+
| **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@5.4.0/bsv-gdaf.min.js` |
|
|
122
|
+
| **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@5.4.0/bsv-shamir.min.js` |
|
|
123
|
+
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@5.4.0/bsv-security.min.js` |
|
|
124
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@5.4.0/bsv-mnemonic.min.js` |
|
|
125
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@5.4.0/bsv-ecies.min.js` |
|
|
126
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@5.4.0/bsv-covenant.min.js` |
|
|
127
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@5.4.0/bsv-script-helper.min.js` |
|
|
128
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@5.4.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@5.
|
|
17
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv.min.js"></script>
|
|
18
18
|
|
|
19
19
|
<!-- Everything included (937KB) -->
|
|
20
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
20
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.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@5.
|
|
130
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv.min.js"></script>
|
|
131
131
|
|
|
132
132
|
<!-- Smart contracts (937KB) -->
|
|
133
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
133
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv-smartcontract.min.js"></script>
|
|
134
134
|
|
|
135
135
|
<!-- Legal tokens (1.16MB) -->
|
|
136
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
136
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv-ltp.min.js"></script>
|
|
137
137
|
|
|
138
138
|
<!-- Digital identity (1.16MB) -->
|
|
139
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
139
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv-gdaf.min.js"></script>
|
|
140
140
|
|
|
141
141
|
<!-- Everything (937KB) -->
|
|
142
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
142
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.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@5.
|
|
162
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv.min.js"></script>
|
|
163
163
|
|
|
164
164
|
<!-- Add smart contracts when ready -->
|
|
165
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
165
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv-smartcontract.min.js"></script>
|
|
166
166
|
|
|
167
167
|
<!-- Add advanced features as needed -->
|
|
168
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
169
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
168
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv-ltp.min.js"></script>
|
|
169
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv-gdaf.min.js"></script>
|
|
170
170
|
|
|
171
171
|
<!-- Everything in one file -->
|
|
172
|
-
<script src="https://unpkg.com/@smartledger/bsv@5.
|
|
172
|
+
<script src="https://unpkg.com/@smartledger/bsv@5.4.0/bsv.bundle.js"></script>
|
|
173
173
|
```
|
|
174
174
|
|
|
175
175
|
## 🔍 **Testing Your Migration**
|
package/lib/ltp/index.js
CHANGED
|
@@ -63,16 +63,11 @@ LTP.prototype.createRightToken = function(rightData, privateKey, options) {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
// Add cryptographic proof
|
|
66
|
+
// Add cryptographic proof. Sign via the right-token signer (which sets
|
|
67
|
+
// proof.jws + tokenHash); the older LTPProof.createSignature entrypoint no
|
|
68
|
+
// longer exists (proof.js exposes prepareSignatureProof).
|
|
67
69
|
if (options.addProof !== false) {
|
|
68
|
-
|
|
69
|
-
purpose: 'assertionMethod'
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
if (proofResult.success) {
|
|
73
|
-
token.proof = proofResult.proof
|
|
74
|
-
token.tokenHash = proofResult.tokenHash
|
|
75
|
-
}
|
|
70
|
+
token = LTPRight._signToken(token, privateKey)
|
|
76
71
|
}
|
|
77
72
|
|
|
78
73
|
// Anchor to blockchain if requested
|
|
@@ -128,7 +123,7 @@ LTP.prototype.validateClaim = function(claimData, schemaType) {
|
|
|
128
123
|
* @returns {Object} Selective disclosure proof
|
|
129
124
|
*/
|
|
130
125
|
LTP.prototype.createSelectiveDisclosure = function(token, revealedFields, nonce) {
|
|
131
|
-
return LTPProof.
|
|
126
|
+
return LTPProof.prepareSelectiveDisclosure(token, revealedFields, nonce)
|
|
132
127
|
}
|
|
133
128
|
|
|
134
129
|
/**
|
|
@@ -144,8 +139,12 @@ LTP.prototype.verifyToken = function(token, publicKey) {
|
|
|
144
139
|
error: 'No proof found in token'
|
|
145
140
|
}
|
|
146
141
|
}
|
|
147
|
-
|
|
148
|
-
|
|
142
|
+
|
|
143
|
+
// Instance-created tokens (right/transfer/obligation) are signed by
|
|
144
|
+
// RightToken._signToken (detached ES256K JWS + tokenHash), so verification
|
|
145
|
+
// goes through the matching RightToken.verifyToken rather than the
|
|
146
|
+
// proofValue-based LTPProof path.
|
|
147
|
+
return LTPRight.verifyToken(token, publicKey)
|
|
149
148
|
}
|
|
150
149
|
|
|
151
150
|
/**
|
|
@@ -164,7 +163,7 @@ LTP.prototype.transferRight = function(token, newOwner, ownerKey, options) {
|
|
|
164
163
|
options = options || {}
|
|
165
164
|
|
|
166
165
|
try {
|
|
167
|
-
// Verify current ownership
|
|
166
|
+
// Verify current ownership against the owner's key before transferring.
|
|
168
167
|
var verification = this.verifyToken(token, ownerKey.toPublicKey().toString())
|
|
169
168
|
if (!verification.valid) {
|
|
170
169
|
return {
|
|
@@ -172,23 +171,21 @@ LTP.prototype.transferRight = function(token, newOwner, ownerKey, options) {
|
|
|
172
171
|
error: 'Invalid token or ownership proof'
|
|
173
172
|
}
|
|
174
173
|
}
|
|
175
|
-
|
|
176
|
-
//
|
|
177
|
-
|
|
178
|
-
|
|
174
|
+
|
|
175
|
+
// Build and sign the transferred token. prepareRightTokenTransfer signs
|
|
176
|
+
// the new token with the current owner's key, so no separate proof step
|
|
177
|
+
// is needed.
|
|
178
|
+
var transferResult = LTPRight.prepareRightTokenTransfer(token, newOwner, ownerKey, options)
|
|
179
|
+
if (!transferResult.success) {
|
|
180
|
+
return {
|
|
181
|
+
success: false,
|
|
182
|
+
error: transferResult.error
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
179
186
|
var transferredToken = transferResult.newToken
|
|
180
187
|
var transferProof = transferResult.transferProof
|
|
181
|
-
|
|
182
|
-
// Add new proof with new owner
|
|
183
|
-
var proofResult = LTPProof.createSignature(transferredToken, ownerKey, {
|
|
184
|
-
purpose: 'authentication'
|
|
185
|
-
})
|
|
186
|
-
|
|
187
|
-
if (proofResult.success) {
|
|
188
|
-
transferredToken.proof = proofResult.proof
|
|
189
|
-
transferredToken.tokenHash = proofResult.tokenHash
|
|
190
|
-
}
|
|
191
|
-
|
|
188
|
+
|
|
192
189
|
// Anchor transfer if requested
|
|
193
190
|
if (options.anchor) {
|
|
194
191
|
var anchorResult = LTPAnchor.anchorToken(transferredToken, options.anchor)
|
|
@@ -243,29 +240,20 @@ LTP.prototype.createObligation = function(rightToken, obligationData, privateKey
|
|
|
243
240
|
$.checkArgument(privateKey instanceof PrivateKey, 'Invalid private key')
|
|
244
241
|
|
|
245
242
|
try {
|
|
246
|
-
//
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
243
|
+
// Build and sign the correlative obligation token. prepareObligationToken
|
|
244
|
+
// signs inline via _signToken, so no separate proof step is needed.
|
|
245
|
+
var obligationResult = LTPRight.prepareObligationToken(rightToken, obligationData.obligor, obligationData, privateKey)
|
|
246
|
+
|
|
247
|
+
if (!obligationResult.success) {
|
|
250
248
|
return {
|
|
251
249
|
success: false,
|
|
252
|
-
error:
|
|
250
|
+
error: obligationResult.error
|
|
253
251
|
}
|
|
254
252
|
}
|
|
255
|
-
|
|
256
|
-
// Add proof
|
|
257
|
-
var proofResult = LTPProof.createSignature(obligation, privateKey, {
|
|
258
|
-
purpose: 'assertionMethod'
|
|
259
|
-
})
|
|
260
|
-
|
|
261
|
-
if (proofResult.success) {
|
|
262
|
-
obligation.proof = proofResult.proof
|
|
263
|
-
obligation.tokenHash = proofResult.tokenHash
|
|
264
|
-
}
|
|
265
|
-
|
|
253
|
+
|
|
266
254
|
return {
|
|
267
255
|
success: true,
|
|
268
|
-
obligation:
|
|
256
|
+
obligation: obligationResult.obligationToken,
|
|
269
257
|
rightTokenId: rightToken.id
|
|
270
258
|
}
|
|
271
259
|
|
|
@@ -360,7 +348,7 @@ LTP.prototype.getRegistryStats = function() {
|
|
|
360
348
|
* @returns {Object} Legal validity proof
|
|
361
349
|
*/
|
|
362
350
|
LTP.prototype.createLegalValidityProof = function(token, jurisdiction, nonce) {
|
|
363
|
-
return LTPProof.
|
|
351
|
+
return LTPProof.prepareLegalValidityProof(token, jurisdiction, nonce)
|
|
364
352
|
}
|
|
365
353
|
|
|
366
354
|
/**
|
package/lib/ltp/right.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var bsv = require('../../')
|
|
4
4
|
var Hash = bsv.crypto.Hash
|
|
5
5
|
var ECDSA = bsv.crypto.ECDSA
|
|
6
|
+
var Signature = bsv.crypto.Signature
|
|
6
7
|
var PrivateKey = bsv.PrivateKey
|
|
7
8
|
var $ = bsv.util.preconditions
|
|
8
9
|
var _ = require('../util/_')
|
|
@@ -40,7 +41,60 @@ var RightTypes = {
|
|
|
40
41
|
* Legal Right Token
|
|
41
42
|
*/
|
|
42
43
|
var RightToken = {
|
|
43
|
-
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Build an (unsigned) legal right token structure. Callers that need a signed
|
|
47
|
+
* token use prepareRightToken (signs inline) or add their own proof afterward
|
|
48
|
+
* (e.g. LTP#createRightToken via LTPProof).
|
|
49
|
+
* @param {String} type - Right type (from RightTypes)
|
|
50
|
+
* @param {String} issuerDID - Issuer DID
|
|
51
|
+
* @param {String} subjectDID - Subject DID
|
|
52
|
+
* @param {Object} claim - Legal claim object
|
|
53
|
+
* @param {PrivateKey} [issuerPrivateKey] - unused here; accepted for signature parity
|
|
54
|
+
* @param {Object} options - Additional options
|
|
55
|
+
* @returns {Object} Unsigned legal right token
|
|
56
|
+
*/
|
|
57
|
+
create: function(type, issuerDID, subjectDID, claim, issuerPrivateKey, options) {
|
|
58
|
+
options = options || {}
|
|
59
|
+
|
|
60
|
+
$.checkArgument(typeof type === 'string', 'Right type must be string')
|
|
61
|
+
$.checkArgument(typeof issuerDID === 'string', 'Issuer DID must be string')
|
|
62
|
+
$.checkArgument(typeof subjectDID === 'string', 'Subject DID must be string')
|
|
63
|
+
$.checkArgument(claim && typeof claim === 'object', 'Claim must be object')
|
|
64
|
+
|
|
65
|
+
var validTypes = Object.values(RightTypes)
|
|
66
|
+
$.checkArgument(validTypes.includes(type), 'Invalid right type: ' + type)
|
|
67
|
+
|
|
68
|
+
var rightToken = {
|
|
69
|
+
'@context': [
|
|
70
|
+
'https://www.w3.org/2018/credentials/v1',
|
|
71
|
+
'https://smartledger.technology/contexts/ltp/v1'
|
|
72
|
+
],
|
|
73
|
+
id: 'urn:uuid:' + this._generateUUID(),
|
|
74
|
+
type: ['VerifiableCredential', 'LegalRightToken', type],
|
|
75
|
+
issuer: issuerDID,
|
|
76
|
+
issuanceDate: new Date().toISOString(),
|
|
77
|
+
credentialSubject: {
|
|
78
|
+
id: subjectDID,
|
|
79
|
+
rightType: type,
|
|
80
|
+
claim: claim,
|
|
81
|
+
jurisdiction: options.jurisdiction || 'US',
|
|
82
|
+
purpose: options.purpose || 'legal_right',
|
|
83
|
+
validFrom: options.validFrom || new Date().toISOString(),
|
|
84
|
+
validUntil: options.validUntil || null,
|
|
85
|
+
transferable: options.transferable !== false,
|
|
86
|
+
revocable: options.revocable !== false
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Add metadata
|
|
91
|
+
if (options.metadata) {
|
|
92
|
+
rightToken.credentialSubject.metadata = options.metadata
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return rightToken
|
|
96
|
+
},
|
|
97
|
+
|
|
44
98
|
/**
|
|
45
99
|
* Prepare legal right token for external processing
|
|
46
100
|
* @param {String} type - Right type (from RightTypes)
|
|
@@ -65,33 +119,8 @@ var RightToken = {
|
|
|
65
119
|
$.checkArgument(validTypes.includes(type), 'Invalid right type: ' + type)
|
|
66
120
|
|
|
67
121
|
try {
|
|
68
|
-
var rightToken =
|
|
69
|
-
|
|
70
|
-
'https://www.w3.org/2018/credentials/v1',
|
|
71
|
-
'https://smartledger.technology/contexts/ltp/v1'
|
|
72
|
-
],
|
|
73
|
-
id: 'urn:uuid:' + this._generateUUID(),
|
|
74
|
-
type: ['VerifiableCredential', 'LegalRightToken', type],
|
|
75
|
-
issuer: issuerDID,
|
|
76
|
-
issuanceDate: new Date().toISOString(),
|
|
77
|
-
credentialSubject: {
|
|
78
|
-
id: subjectDID,
|
|
79
|
-
rightType: type,
|
|
80
|
-
claim: claim,
|
|
81
|
-
jurisdiction: options.jurisdiction || 'US',
|
|
82
|
-
purpose: options.purpose || 'legal_right',
|
|
83
|
-
validFrom: options.validFrom || new Date().toISOString(),
|
|
84
|
-
validUntil: options.validUntil || null,
|
|
85
|
-
transferable: options.transferable !== false,
|
|
86
|
-
revocable: options.revocable !== false
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Add metadata
|
|
91
|
-
if (options.metadata) {
|
|
92
|
-
rightToken.credentialSubject.metadata = options.metadata
|
|
93
|
-
}
|
|
94
|
-
|
|
122
|
+
var rightToken = this.create(type, issuerDID, subjectDID, claim, issuerPrivateKey, options)
|
|
123
|
+
|
|
95
124
|
// Sign the token
|
|
96
125
|
var signedToken = this._signToken(rightToken, issuerPrivateKey)
|
|
97
126
|
|
|
@@ -540,6 +569,72 @@ var RightToken = {
|
|
|
540
569
|
getRightTypes: function() {
|
|
541
570
|
return RightTypes
|
|
542
571
|
},
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Verify a token signed by _signToken against a public key.
|
|
575
|
+
*
|
|
576
|
+
* Tokens produced here carry a detached ES256K JWS in proof.jws plus the
|
|
577
|
+
* canonical tokenHash. Verification recomputes the canonical hash (catching
|
|
578
|
+
* tampering of any field), confirms it matches the stored tokenHash, then
|
|
579
|
+
* checks the ECDSA signature embedded in the JWS against the supplied public
|
|
580
|
+
* key. This is the verification counterpart to _signToken and works for
|
|
581
|
+
* right, transfer and obligation tokens alike — all are signed the same way.
|
|
582
|
+
*
|
|
583
|
+
* @param {Object} token - Token with a proof.jws produced by _signToken
|
|
584
|
+
* @param {String|PublicKey} publicKey - Expected signer's public key
|
|
585
|
+
* @returns {Object} { valid, errors, tokenHash, verifiedAt }
|
|
586
|
+
*/
|
|
587
|
+
verifyToken: function(token, publicKey) {
|
|
588
|
+
var errors = []
|
|
589
|
+
try {
|
|
590
|
+
$.checkArgument(token && typeof token === 'object', 'Invalid token')
|
|
591
|
+
|
|
592
|
+
if (!token.proof || !token.proof.jws) {
|
|
593
|
+
errors.push('Missing signature proof')
|
|
594
|
+
return { valid: false, errors: errors }
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
var pubKey = publicKey instanceof bsv.PublicKey
|
|
598
|
+
? publicKey
|
|
599
|
+
: bsv.PublicKey.fromString(publicKey)
|
|
600
|
+
|
|
601
|
+
// Recompute the canonical hash and confirm integrity.
|
|
602
|
+
var canonicalToken = this._canonicalizeToken(token)
|
|
603
|
+
var tokenHash = Hash.sha256(Buffer.from(canonicalToken))
|
|
604
|
+
|
|
605
|
+
if (token.tokenHash && token.tokenHash !== tokenHash.toString('hex')) {
|
|
606
|
+
errors.push('Token hash mismatch')
|
|
607
|
+
return { valid: false, errors: errors }
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
// Extract the DER signature from the detached JWS (header..signature).
|
|
611
|
+
var parts = token.proof.jws.split('.')
|
|
612
|
+
if (parts.length !== 3 || !parts[2]) {
|
|
613
|
+
errors.push('Malformed JWS')
|
|
614
|
+
return { valid: false, errors: errors }
|
|
615
|
+
}
|
|
616
|
+
var signature = Signature.fromDER(Buffer.from(parts[2], 'base64url'))
|
|
617
|
+
|
|
618
|
+
var ecdsa = new ECDSA()
|
|
619
|
+
ecdsa.hashbuf = tokenHash
|
|
620
|
+
ecdsa.sig = signature
|
|
621
|
+
ecdsa.pubkey = pubKey
|
|
622
|
+
|
|
623
|
+
if (!ecdsa.verify().verified) {
|
|
624
|
+
errors.push('Signature verification failed')
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
return {
|
|
628
|
+
valid: errors.length === 0,
|
|
629
|
+
errors: errors,
|
|
630
|
+
tokenHash: tokenHash.toString('hex'),
|
|
631
|
+
verifiedAt: new Date().toISOString()
|
|
632
|
+
}
|
|
633
|
+
} catch (error) {
|
|
634
|
+
errors.push(error.message)
|
|
635
|
+
return { valid: false, errors: errors }
|
|
636
|
+
}
|
|
637
|
+
},
|
|
543
638
|
|
|
544
639
|
/**
|
|
545
640
|
* Sign a token with private key
|
|
@@ -577,19 +672,23 @@ var RightToken = {
|
|
|
577
672
|
},
|
|
578
673
|
|
|
579
674
|
/**
|
|
580
|
-
*
|
|
675
|
+
* Build a detached compact JWS (RFC 7797) for a token hash + ECDSA signature.
|
|
676
|
+
* The payload segment is intentionally empty (header..signature) because the
|
|
677
|
+
* signed content is the canonical token hash, carried separately as tokenHash.
|
|
581
678
|
* @private
|
|
679
|
+
* @param {Buffer} hash - 32-byte canonical token hash
|
|
680
|
+
* @param {Signature} signature - ECDSA signature over the hash
|
|
681
|
+
* @returns {String} compact detached JWS
|
|
582
682
|
*/
|
|
583
|
-
|
|
683
|
+
_createJWS: function(hash, signature) {
|
|
584
684
|
var header = {
|
|
585
685
|
alg: 'ES256K',
|
|
586
686
|
typ: 'JWT'
|
|
587
687
|
}
|
|
588
|
-
|
|
688
|
+
|
|
589
689
|
var headerB64 = Buffer.from(JSON.stringify(header)).toString('base64url')
|
|
590
|
-
var payloadB64 = hash.toString('base64url')
|
|
591
690
|
var signatureB64 = signature.toDER().toString('base64url')
|
|
592
|
-
|
|
691
|
+
|
|
593
692
|
return headerB64 + '..' + signatureB64
|
|
594
693
|
},
|
|
595
694
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartledger/bsv",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.1",
|
|
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",
|