@smartledger/bsv 7.5.1 → 7.5.3
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 +110 -0
- package/README.md +38 -38
- package/bsv-gdaf.min.js +33 -33
- package/bsv-ltp.min.js +33 -33
- package/bsv-smartcontract.min.js +2 -2
- package/bsv-statuslist.min.js +1 -1
- package/bsv.bundle.js +33 -33
- package/bsv.d.ts +56 -11
- package/bsv.min.js +33 -33
- 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/index.js +4 -1
- package/lib/gdaf/smartledger-anchor.js +120 -11
- package/lib/smart_contract/authorizers.js +8 -0
- package/lib/smart_contract/index.js +4 -2
- package/lib/statuslist/index.js +11 -3
- package/package.json +12 -1
- package/test/gdaf/anchor_no_key_leak.js +59 -1
- package/test/types/dts_drift.js +23 -1
- package/test/types/surface_honesty.js +102 -0
- package/version.js +1 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/* global describe, it */
|
|
4
|
+
|
|
5
|
+
// Runtime half of a field review that found declarations disagreeing with the code.
|
|
6
|
+
// The declarations themselves are gated by dts_drift.js and by the tsc check in CI; the
|
|
7
|
+
// cases below are the ones where the RUNTIME also had to change, because a declaration
|
|
8
|
+
// that merely matched the old behaviour would have been documenting a bug.
|
|
9
|
+
|
|
10
|
+
var should = require('chai').should()
|
|
11
|
+
var bsv = require('../..')
|
|
12
|
+
var SC = bsv.SmartContract
|
|
13
|
+
|
|
14
|
+
describe('public surface tells the truth about itself', function () {
|
|
15
|
+
describe('SmartContract.ownershipToken forwards its authorizer', function () {
|
|
16
|
+
it('is not a two-argument alias that drops the third', function () {
|
|
17
|
+
// The top-level alias took (fee, ownerPubKeyHash) and called through with only
|
|
18
|
+
// those two, so a co-signed token built via this path came out single-key — the
|
|
19
|
+
// authorizer was accepted and silently discarded.
|
|
20
|
+
var auth = SC.Authorizers.multisig(2, 3)
|
|
21
|
+
var withAuth = SC.ownershipToken(1, Buffer.alloc(20), auth).toHex()
|
|
22
|
+
var without = SC.ownershipToken(1, Buffer.alloc(20)).toHex()
|
|
23
|
+
withAuth.should.not.equal(without)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('agrees with SmartContract.Token.ownershipToken', function () {
|
|
27
|
+
var auth = SC.Authorizers.multisig(2, 3)
|
|
28
|
+
SC.ownershipToken(1, Buffer.alloc(20), auth).toHex()
|
|
29
|
+
.should.equal(SC.Token.ownershipToken(1, Buffer.alloc(20), auth).toHex())
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
describe('Authorizers.multisig takes a key COUNT', function () {
|
|
34
|
+
it('rejects an array of keys instead of silently building a broken authorizer', function () {
|
|
35
|
+
// `m > nKeys` compared a number to an array, which coerces to NaN, so the guard
|
|
36
|
+
// passed and the array was interpolated into the authorizer's name.
|
|
37
|
+
var keys = [1, 2, 3].map(function () {
|
|
38
|
+
return bsv.PrivateKey.fromRandom().toPublicKey().toBuffer()
|
|
39
|
+
})
|
|
40
|
+
;(function () { SC.Authorizers.multisig(2, keys) }).should.throw(/NUMBER of keys/)
|
|
41
|
+
// The message names the fix.
|
|
42
|
+
;(function () { SC.Authorizers.multisig(2, keys) }).should.throw(/pass 3 instead/)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('still accepts the documented count form', function () {
|
|
46
|
+
SC.Authorizers.multisig(2, 3).n.should.equal(3)
|
|
47
|
+
SC.Authorizers.multisig(2, 3).m.should.equal(2)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('rejects non-integer m', function () {
|
|
51
|
+
(function () { SC.Authorizers.multisig('2', 3) }).should.throw(/m must be an integer/)
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
describe('StatusList refuses to record a suspension as a revocation', function () {
|
|
56
|
+
it('throws on status: suspended rather than setting the revocation bit', function () {
|
|
57
|
+
// Both statuses set the SAME bit and read back as 'revoked', so a suspension was
|
|
58
|
+
// silently recorded — and later reported — as a permanent revocation.
|
|
59
|
+
return bsv.StatusList.updateStatusList({
|
|
60
|
+
listVcJwt: 'x', index: 1, status: 'suspended', privateJwk: {}
|
|
61
|
+
}).then(
|
|
62
|
+
function () { throw new Error('should not have accepted suspended') },
|
|
63
|
+
function (err) { err.message.should.match(/'suspended' is not supported/) }
|
|
64
|
+
)
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
describe('securityFeatures describes what is actually shipped', function () {
|
|
69
|
+
it('no longer claims elliptic patches, since elliptic is not a dependency', function () {
|
|
70
|
+
var pkg = require('../../package.json')
|
|
71
|
+
var deps = Object.keys(pkg.dependencies || {})
|
|
72
|
+
deps.indexOf('elliptic').should.equal(-1)
|
|
73
|
+
bsv.securityFeatures.indexOf('elliptic-patches').should.equal(-1)
|
|
74
|
+
bsv.securityFeatures.should.be.an('array')
|
|
75
|
+
bsv.securityFeatures.length.should.be.above(0)
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
describe('documented sub-path entry points resolve', function () {
|
|
80
|
+
// Every one of these was MODULE_NOT_FOUND: the package `exports` map had no aliases
|
|
81
|
+
// for the *-entry.js files, so a documented deep import could not be loaded at all.
|
|
82
|
+
var SUBPATHS = ['didweb', 'vcjwt', 'gdaf', 'ltp', 'statuslist', 'shamir',
|
|
83
|
+
'anchor', 'covenant', 'security', 'smartcontract', 'script-helper']
|
|
84
|
+
|
|
85
|
+
SUBPATHS.forEach(function (name) {
|
|
86
|
+
it('@smartledger/bsv/' + name, function () {
|
|
87
|
+
var mod = require('@smartledger/bsv/' + name)
|
|
88
|
+
// Some entry points export a class (a function), others a namespace object.
|
|
89
|
+
var t = typeof mod
|
|
90
|
+
t.should.be.oneOf(['object', 'function'])
|
|
91
|
+
should.exist(mod)
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('still resolves the package root and lib deep imports', function () {
|
|
96
|
+
require('@smartledger/bsv').should.be.an('object')
|
|
97
|
+
require('@smartledger/bsv/version').should.be.a('string')
|
|
98
|
+
// Directory deep-imports need the explicit file — a documented 7.0 exports break.
|
|
99
|
+
require('@smartledger/bsv/lib/ordinals/index.js').should.be.an('object')
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
})
|
package/version.js
CHANGED