trac-msb 0.2.1 → 0.2.2
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/LICENSE +2 -2
- package/SECURITY.md +54 -0
- package/package.json +1 -1
- package/src/index.js +1 -1
- package/test/acceptance/v1/rpc.test.mjs +1 -0
- package/test/state/apply.addAdmin.basic.test.js +0 -111
package/LICENSE
CHANGED
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
|
|
189
|
+
Copyright 2025 Trac Systems UG
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
|
@@ -198,4 +198,4 @@
|
|
|
198
198
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
199
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
200
|
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|
|
201
|
+
limitations under the License.
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
The following table shows which versions of this project are currently receiving security updates.
|
|
6
|
+
|
|
7
|
+
| Version | Supported |
|
|
8
|
+
| -------- | ------------------ |
|
|
9
|
+
| 0.2.x | :white_check_mark: |
|
|
10
|
+
| < 0.2 | :x: |
|
|
11
|
+
|
|
12
|
+
Older versions (< 0.2.x) are no longer supported.
|
|
13
|
+
Please upgrade to the latest release to ensure you receive security fixes.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Reporting a Vulnerability
|
|
18
|
+
|
|
19
|
+
If you discover a security vulnerability affecting the TRAC Network,
|
|
20
|
+
please **do not disclose it publicly** (e.g., on social media, Discord, or GitHub Issues).
|
|
21
|
+
|
|
22
|
+
Instead, report it responsibly and confidentially through one of the following contacts:
|
|
23
|
+
|
|
24
|
+
- 📧 **info@trac.network** — protocol, API, infrastructure, or tooling vulnerabilities
|
|
25
|
+
|
|
26
|
+
Alternatively, you can use the **“Report a vulnerability”** option on GitHub if available.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
### Responsible Disclosure Guidelines
|
|
31
|
+
|
|
32
|
+
- **Do not exploit or test vulnerabilities on mainnet.**
|
|
33
|
+
Use **testnet** environments or isolated local nodes for proof-of-concepts (PoCs).
|
|
34
|
+
- Include clear and reproducible details in your report:
|
|
35
|
+
- affected **component or module**,
|
|
36
|
+
- minimal **proof of concept (PoC)** showing the issue,
|
|
37
|
+
- expected vs. actual behavior,
|
|
38
|
+
- estimated **impact** (e.g., fund loss, network instability, or data integrity issue),
|
|
39
|
+
- any relevant **logs or transaction hashes** if applicable.
|
|
40
|
+
- Please avoid:
|
|
41
|
+
- phishing or social engineering,
|
|
42
|
+
- denial-of-service (DoS) or spam tests,
|
|
43
|
+
- public disclosure before coordinated remediation.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
### Response Process
|
|
48
|
+
|
|
49
|
+
- You will receive an **acknowledgment within 72 hours** of submission.
|
|
50
|
+
- The TRAC Network security team will investigate and validate the issue.
|
|
51
|
+
- If confirmed, we’ll provide updates on the **remediation plan and timeline**.
|
|
52
|
+
- After a fix is deployed, we may publicly recognize your contribution (with your consent).
|
|
53
|
+
|
|
54
|
+
Thank you for helping us keep the TRAC Network ecosystem secure and resilient 💙
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1199,7 +1199,7 @@ export class MainSettlementBus extends ReadyResource {
|
|
|
1199
1199
|
this.network.validatorConnectionManager.rotate() // force change connection rotation for the next retry
|
|
1200
1200
|
}
|
|
1201
1201
|
|
|
1202
|
-
return { message: "Transaction broadcasted successfully.", signedLength, unsignedLength };
|
|
1202
|
+
return { message: "Transaction broadcasted successfully.", signedLength, unsignedLength, tx: hash };
|
|
1203
1203
|
} else {
|
|
1204
1204
|
// Handle case where payload is missing if called internally without one.
|
|
1205
1205
|
throw new Error("Transaction payload is required for broadcast_transaction command.");
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { test, hook } from '../utils/wrapper.js'
|
|
2
|
-
import Corestore from 'corestore'
|
|
3
|
-
import path from 'path'
|
|
4
|
-
import os from 'os'
|
|
5
|
-
import { promises as fsp } from 'fs'
|
|
6
|
-
import b4a from 'b4a'
|
|
7
|
-
|
|
8
|
-
import PeerWallet from 'trac-wallet'
|
|
9
|
-
import State from '../../src/core/state/State.js'
|
|
10
|
-
import CompleteStateMessageOperations from '../../src/messages/completeStateMessages/CompleteStateMessageOperations.js'
|
|
11
|
-
import { ADMIN_INITIAL_BALANCE } from '../../src/utils/constants.js'
|
|
12
|
-
|
|
13
|
-
// Prosty, szybki test apply(add_admin) inspirowany stylem Autobase/test/basic.js
|
|
14
|
-
// Minimalny setup: Corestore + State + Wallet, bez sieci i dodatkowych warstw
|
|
15
|
-
|
|
16
|
-
let tmpDir
|
|
17
|
-
let store
|
|
18
|
-
let wallet
|
|
19
|
-
let state
|
|
20
|
-
|
|
21
|
-
const STATE_OPTIONS = {
|
|
22
|
-
enable_tx_apply_logs: false,
|
|
23
|
-
enable_error_apply_logs: false
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async function createTempStore() {
|
|
27
|
-
const base = path.join(os.tmpdir(), `msb-state-test-${Date.now()}-${Math.random().toString(16).slice(2)}`)
|
|
28
|
-
await fsp.mkdir(base, { recursive: true })
|
|
29
|
-
return { base, db: path.join(base, 'db') }
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async function createWalletFromFixture({ mnemonic }) {
|
|
33
|
-
const w = new PeerWallet({ mnemonic })
|
|
34
|
-
await w.ready
|
|
35
|
-
return w
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
hook('setup state for add_admin', async () => {
|
|
39
|
-
const paths = await createTempStore()
|
|
40
|
-
tmpDir = paths.base
|
|
41
|
-
|
|
42
|
-
const { testKeyPair1 } = await import('../fixtures/apply.fixtures.js')
|
|
43
|
-
wallet = await createWalletFromFixture(testKeyPair1)
|
|
44
|
-
|
|
45
|
-
// wyciągnij writing key bootstrapu (== klucz lokalnego writera)
|
|
46
|
-
const bootstrapKey = await deriveBootstrapWriterKey(paths.db, wallet)
|
|
47
|
-
|
|
48
|
-
// właściwy store + stan testowy
|
|
49
|
-
store = new Corestore(paths.db)
|
|
50
|
-
await store.ready()
|
|
51
|
-
|
|
52
|
-
state = new State(store, bootstrapKey, wallet, STATE_OPTIONS)
|
|
53
|
-
await state.ready()
|
|
54
|
-
|
|
55
|
-
// pierwszy pusty append zapewnia, że widok/indexery są zainicjalizowane
|
|
56
|
-
await state.append(null)
|
|
57
|
-
await fastForwardIfAvailable(state)
|
|
58
|
-
await state.base.view.update()
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
test('State.apply(add_admin) – podstawowy scenariusz', async t => {
|
|
62
|
-
// preconditions
|
|
63
|
-
const beforeAdmin = await state.getAdminEntry()
|
|
64
|
-
t.is(beforeAdmin, null, 'admin entry nie istnieje przed operacją')
|
|
65
|
-
|
|
66
|
-
// assemble + append
|
|
67
|
-
const validity = await state.getIndexerSequenceState()
|
|
68
|
-
const msg = await CompleteStateMessageOperations.assembleAddAdminMessage(
|
|
69
|
-
wallet,
|
|
70
|
-
state.writingKey,
|
|
71
|
-
validity
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
await state.append(msg)
|
|
75
|
-
// wymuś natychmiastowe przetworzenie apply i aktualizację widoku
|
|
76
|
-
await fastForwardIfAvailable(state)
|
|
77
|
-
await state.base.view.update()
|
|
78
|
-
|
|
79
|
-
// assertions
|
|
80
|
-
const adminEntry = await state.getAdminEntry()
|
|
81
|
-
t.ok(adminEntry, 'admin entry powinien zostać dodany')
|
|
82
|
-
t.ok(b4a.equals(adminEntry.wk, state.writingKey), 'wk admina == writingKey')
|
|
83
|
-
|
|
84
|
-
const node = await state.getNodeEntry(adminEntry.address)
|
|
85
|
-
t.ok(node?.isWriter, 'admin powinien być writerem')
|
|
86
|
-
t.ok(node?.isIndexer, 'admin powinien być indexerem')
|
|
87
|
-
t.ok(b4a.equals(node.balance, ADMIN_INITIAL_BALANCE), 'admin powinien mieć saldo początkowe')
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
hook('teardown state for add_admin', async () => {
|
|
91
|
-
try { if (state) await state.close() } catch {}
|
|
92
|
-
try { if (store) await store.close() } catch {}
|
|
93
|
-
try { if (tmpDir) await fsp.rm(tmpDir, { recursive: true, force: true }) } catch {}
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
async function deriveBootstrapWriterKey(dbPath, walletInstance) {
|
|
97
|
-
const bootstrapStore = new Corestore(dbPath)
|
|
98
|
-
await bootstrapStore.ready()
|
|
99
|
-
const bootstrapState = new State(bootstrapStore, null, walletInstance, STATE_OPTIONS)
|
|
100
|
-
await bootstrapState.ready()
|
|
101
|
-
const wk = bootstrapState.writingKey
|
|
102
|
-
await bootstrapState.close()
|
|
103
|
-
await bootstrapStore.close()
|
|
104
|
-
return wk
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
async function fastForwardIfAvailable(testState) {
|
|
108
|
-
if (typeof testState.base.forceFastForward === 'function') {
|
|
109
|
-
await testState.base.forceFastForward()
|
|
110
|
-
}
|
|
111
|
-
}
|