@bopen-io/wallet-toolbox 2.15.0-bopen.1 → 2.15.0-bopen.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/CHANGELOG.md +2 -47
- package/README.md +7 -73
- package/docs/client.md +2729 -3020
- package/docs/monitor.md +153 -164
- package/docs/services.md +710 -856
- package/docs/setup.md +1 -46
- package/docs/storage.md +1636 -1654
- package/docs/wallet.md +1842 -2090
- package/out/src/Setup.d.ts +0 -10
- package/out/src/Setup.d.ts.map +1 -1
- package/out/src/Setup.js +0 -24
- package/out/src/Setup.js.map +1 -1
- package/out/src/monitor/MonitorDaemon.d.ts +0 -2
- package/out/src/monitor/MonitorDaemon.d.ts.map +1 -1
- package/out/src/monitor/MonitorDaemon.js +1 -9
- package/out/src/monitor/MonitorDaemon.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageKnex.d.ts +0 -5
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageKnex.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageKnex.js +3 -11
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageKnex.js.map +1 -1
- package/out/src/storage/StorageKnex.d.ts +0 -3
- package/out/src/storage/StorageKnex.d.ts.map +1 -1
- package/out/src/storage/StorageKnex.js +207 -115
- package/out/src/storage/StorageKnex.js.map +1 -1
- package/out/src/storage/adminServer/adminServer.d.ts.map +1 -1
- package/out/src/storage/adminServer/adminServer.js +41 -3
- package/out/src/storage/adminServer/adminServer.js.map +1 -1
- package/out/src/storage/index.all.d.ts +0 -1
- package/out/src/storage/index.all.d.ts.map +1 -1
- package/out/src/storage/index.all.js +0 -1
- package/out/src/storage/index.all.js.map +1 -1
- package/out/src/storage/methods/listActionsKnex.d.ts.map +1 -1
- package/out/src/storage/methods/listActionsKnex.js +1 -0
- package/out/src/storage/methods/listActionsKnex.js.map +1 -1
- package/out/src/storage/methods/listOutputsKnex.d.ts.map +1 -1
- package/out/src/storage/methods/listOutputsKnex.js +1 -0
- package/out/src/storage/methods/listOutputsKnex.js.map +1 -1
- package/out/src/storage/methods/purgeData.d.ts.map +1 -1
- package/out/src/storage/methods/purgeData.js +3 -0
- package/out/src/storage/methods/purgeData.js.map +1 -1
- package/out/src/storage/methods/reviewStatus.d.ts.map +1 -1
- package/out/src/storage/methods/reviewStatus.js +3 -0
- package/out/src/storage/methods/reviewStatus.js.map +1 -1
- package/out/src/storage/portable/index.js +12 -38
- package/out/src/storage/portable/index.js.map +1 -1
- package/out/src/storage/remoting/StorageServer.d.ts +4 -17
- package/out/src/storage/remoting/StorageServer.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageServer.js +13 -22
- package/out/src/storage/remoting/StorageServer.js.map +1 -1
- package/out/src/storage/schema/KnexMigrations.d.ts +2 -7
- package/out/src/storage/schema/KnexMigrations.d.ts.map +1 -1
- package/out/src/storage/schema/KnexMigrations.js +60 -162
- package/out/src/storage/schema/KnexMigrations.js.map +1 -1
- package/package.json +4 -5
- package/out/src/storage/adminServer/reqReviewQuery.d.ts +0 -41
- package/out/src/storage/adminServer/reqReviewQuery.d.ts.map +0 -1
- package/out/src/storage/adminServer/reqReviewQuery.js +0 -67
- package/out/src/storage/adminServer/reqReviewQuery.js.map +0 -1
- package/out/src/storage/knexPostgres.d.ts +0 -16
- package/out/src/storage/knexPostgres.d.ts.map +0 -1
- package/out/src/storage/knexPostgres.js +0 -34
- package/out/src/storage/knexPostgres.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,53 +4,8 @@ This document captures the history of significant changes to the wallet-toolbox
|
|
|
4
4
|
The git commit history contains the details but is unable to draw
|
|
5
5
|
attention to changes that materially alter behavior or extend functionality.
|
|
6
6
|
|
|
7
|
-
## wallet-toolbox 2.
|
|
8
|
-
|
|
9
|
-
- `StorageKnex` runs on Postgres through the knex `pg` client. Settings report
|
|
10
|
-
`dbtype: 'Postgres'`, and `StorageClient` accepts that value from a remote
|
|
11
|
-
`StorageServer`; older clients reject it. Install `pg` in the application.
|
|
12
|
-
- On a Postgres knex, `StorageKnex` sets an int8 parser on each connection it
|
|
13
|
-
acquires, so bigint columns and counts come back as numbers, as with mysql2
|
|
14
|
-
and better-sqlite3. The process-wide `pg.types` defaults are not changed.
|
|
15
|
-
`usePostgresInt8Numbers(knex)` applies the same parser to a knex directly, and
|
|
16
|
-
`Setup.createPostgresKnex(connectionJson, database)` creates one with it.
|
|
17
|
-
- Postgres runs at READ COMMITTED. The findOrInsert helpers retry a failed
|
|
18
|
-
insert as a find in the same transaction; on Postgres the insert now runs in
|
|
19
|
-
a savepoint so the transaction stays usable. `allocateChangeInput` re-checks
|
|
20
|
-
action batch reservations after taking the output row lock.
|
|
21
|
-
- On Postgres, migrations that add indexes to existing tables run outside a
|
|
22
|
-
transaction and use `CREATE INDEX CONCURRENTLY IF NOT EXISTS`; an invalid
|
|
23
|
-
index left by an interrupted build is dropped and rebuilt. `StorageKnex.migrate`
|
|
24
|
-
runs Postgres migrations one at a time so every other migration keeps its
|
|
25
|
-
journal row in its own transaction. SQLite and MySQL migrations are unchanged.
|
|
26
|
-
- `adminStats` and the admin server's proof request review run on MySQL and
|
|
27
|
-
Postgres. `adminStats` still reports `WERR_NOT_IMPLEMENTED` on SQLite.
|
|
28
|
-
- `MonitorDaemon` accepts `postgresConnection` (JSON node-postgres config), and
|
|
29
|
-
the operator `monitor-daemon` command accepts `--database-client postgres`.
|
|
30
|
-
- `ChaintracksStorageKnex` rejects a Postgres knex before running migrations.
|
|
31
|
-
- Paged `StorageKnex` find queries and the `get*ForUser` sync queries order rows
|
|
32
|
-
by key. Without an order, Postgres could return consecutive LIMIT/OFFSET pages
|
|
33
|
-
in different orders, so `getSyncChunk` repeated some rows and skipped others.
|
|
34
|
-
- `StorageServer.app` is public, so a host can mount the storage server in its
|
|
35
|
-
own Express application (`hostApp.use('/storage', server.app)`) instead of
|
|
36
|
-
calling `start()`. `port` is optional and only required by `start()`.
|
|
37
|
-
- `preRpcMiddleware` adds Express handlers on `POST /` after authentication,
|
|
38
|
-
the authenticated rate limit and payment, immediately before JSON-RPC
|
|
39
|
-
dispatch. A handler that responds stops the call before dispatch.
|
|
40
|
-
- `publicRoutes: false` removes the unauthenticated `GET /`, `/robots.txt` and
|
|
41
|
-
`/healthz` routes. Defaults are unchanged.
|
|
42
|
-
|
|
43
|
-
- Knex storage adds a unique index on `sync_states` (`userId`,
|
|
44
|
-
`storageIdentityKey`). Concurrent `findOrInsertSyncStateAuth` calls for a new
|
|
45
|
-
source could each insert a row, after which every sync with that source failed
|
|
46
|
-
with `Storage identity has conflicting sync states`. The losing insert now
|
|
47
|
-
re-reads the row that won. The migration deletes existing duplicates, keeping
|
|
48
|
-
the oldest row; when the duplicates had different storage names, the kept row
|
|
49
|
-
restarts as a new sync state because its checkpoint may belong to a different
|
|
50
|
-
source database.
|
|
51
|
-
- BRC-38 import keeps one sync state per storage identity. An export holding
|
|
52
|
-
several for one identity imports the oldest under the same rule, and merge
|
|
53
|
-
updates the target's row for that identity even when its storage name differs.
|
|
7
|
+
## wallet-toolbox 2.14.5
|
|
8
|
+
|
|
54
9
|
- `WalletPermissionsManager` retires no-send transaction ownership and reference
|
|
55
10
|
aliases when `createAction` or `signAction` reports them as `sending` or
|
|
56
11
|
`unproven`, including sendWith-only calls and successful members of an
|
package/README.md
CHANGED
|
@@ -66,23 +66,16 @@ journal before recovery; do not delete journal rows or wallet data blindly.
|
|
|
66
66
|
### Postgres storage
|
|
67
67
|
|
|
68
68
|
`StorageKnex` runs on Postgres through the knex `pg` client. Install `pg` in the
|
|
69
|
-
application
|
|
70
|
-
this release reject that value.
|
|
69
|
+
application and pass a Postgres knex:
|
|
71
70
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
back as numbers, as with mysql2 and better-sqlite3. The process-wide `pg.types`
|
|
75
|
-
defaults are not changed. `Setup.createPostgresKnex(connectionJson, database)`
|
|
76
|
-
creates a knex with the same parser installed.
|
|
71
|
+
```ts
|
|
72
|
+
import { knex as makeKnex } from 'knex'
|
|
77
73
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
(JSON node-postgres config). `ChaintracksStorageKnex` does not support Postgres.
|
|
74
|
+
const knex = makeKnex({ client: 'pg', connection: { host, port, user, password, database } })
|
|
75
|
+
const storage = new StorageKnex({ ...StorageKnex.defaultOptions(), chain: 'main', knex })
|
|
76
|
+
```
|
|
82
77
|
|
|
83
|
-
|
|
84
|
-
config) to include Postgres in the Knex test suites. Test databases are created
|
|
85
|
-
on that server as needed.
|
|
78
|
+
`ChaintracksStorageKnex` and `adminStats` do not support Postgres.
|
|
86
79
|
|
|
87
80
|
## Overview
|
|
88
81
|
|
|
@@ -285,10 +278,6 @@ serialized RPC response exceeds the service ceiling, remote clients retry the
|
|
|
285
278
|
read-only request with a smaller chunk budget and remember the working limit
|
|
286
279
|
for the rest of the session.
|
|
287
280
|
|
|
288
|
-
Knex storage keeps one sync state per user and source storage identity, enforced
|
|
289
|
-
by a unique index. Concurrent registrations of the same source return the row the
|
|
290
|
-
first caller inserted.
|
|
291
|
-
|
|
292
281
|
Output synchronization requires a local mapping for every non-null source basket
|
|
293
282
|
ID. A missing mapping rejects the page so its transaction and checkpoint can roll
|
|
294
283
|
back; retry after transferring the missing basket. Newer source updates apply
|
|
@@ -1035,61 +1024,6 @@ Run `StorageKnex.migrate(...)` before constructing the manager during an
|
|
|
1035
1024
|
upgrade. `makeAvailable()` validates and loads an already-migrated database; it
|
|
1036
1025
|
does not apply schema changes.
|
|
1037
1026
|
|
|
1038
|
-
### Mounting StorageServer in an Express application
|
|
1039
|
-
|
|
1040
|
-
`server.app` is the configured Express application. Mount it in a host
|
|
1041
|
-
application instead of calling `start()`; `port` and `http` are only used by
|
|
1042
|
-
`start()`.
|
|
1043
|
-
|
|
1044
|
-
```typescript
|
|
1045
|
-
import express from 'express'
|
|
1046
|
-
import { SessionManager } from '@bsv/sdk'
|
|
1047
|
-
import { AuthRequest, createAuthMiddleware } from '@bsv/auth-express-middleware'
|
|
1048
|
-
import { StorageServer } from '@bsv/wallet-toolbox'
|
|
1049
|
-
|
|
1050
|
-
// Use KnexSessionManager when the host runs more than one process.
|
|
1051
|
-
const sessionManager = new SessionManager()
|
|
1052
|
-
|
|
1053
|
-
const storageServer = new StorageServer(storage, {
|
|
1054
|
-
wallet,
|
|
1055
|
-
monetize: false,
|
|
1056
|
-
sessionManager,
|
|
1057
|
-
// Leave GET /, /robots.txt and /healthz to the host.
|
|
1058
|
-
publicRoutes: false,
|
|
1059
|
-
preRpcMiddleware: [
|
|
1060
|
-
async (req, res, next) => {
|
|
1061
|
-
if (await overQuota((req as AuthRequest).auth.identityKey, req.body.method)) {
|
|
1062
|
-
res.status(507).json({ status: 'error', code: 'ERR_QUOTA_EXCEEDED' })
|
|
1063
|
-
return
|
|
1064
|
-
}
|
|
1065
|
-
next()
|
|
1066
|
-
}
|
|
1067
|
-
]
|
|
1068
|
-
})
|
|
1069
|
-
|
|
1070
|
-
const app = express()
|
|
1071
|
-
app.use('/storage', storageServer.app)
|
|
1072
|
-
app.use(express.json())
|
|
1073
|
-
app.use(createAuthMiddleware({ wallet, sessionManager }))
|
|
1074
|
-
// ...host routes
|
|
1075
|
-
app.listen(8080)
|
|
1076
|
-
```
|
|
1077
|
-
|
|
1078
|
-
Clients connect with `new StorageClient(wallet, 'https://host.example/storage')`.
|
|
1079
|
-
`AuthFetch` sends the BRC-104 handshake to the origin's `/.well-known/auth`,
|
|
1080
|
-
not to the mount path, so the host must answer it with its own auth middleware
|
|
1081
|
-
using the same `wallet` and the same `sessionManager` as the storage server.
|
|
1082
|
-
Mount the storage server before the host's auth middleware and body parsers;
|
|
1083
|
-
the storage app authenticates and parses its own requests. It keeps its own
|
|
1084
|
-
security headers, CORS, concurrency and rate limits, and inherits the host's
|
|
1085
|
-
`trust proxy` setting unless `trustProxy` is set.
|
|
1086
|
-
|
|
1087
|
-
`preRpcMiddleware` handlers run on JSON-RPC `POST /` requests after
|
|
1088
|
-
authentication, the authenticated rate limit and, when `monetize` is set, the
|
|
1089
|
-
payment middleware. They see `req.auth` and the parsed body. A handler that
|
|
1090
|
-
responds instead of calling `next()` stops the call before dispatch. They do not
|
|
1091
|
-
run on the action batch upload routes.
|
|
1092
|
-
|
|
1093
1027
|
## Development
|
|
1094
1028
|
|
|
1095
1029
|
### Overlay identity verification
|