@bsv/wallet-toolbox 2.4.3 → 2.4.4
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 +38 -1
- package/docs/README.md +3 -1
- package/docs/action-batch-planning.md +117 -0
- package/docs/authentication-observability.md +94 -0
- package/docs/client.md +1566 -627
- package/docs/monitor.md +26 -5
- package/docs/storage.md +514 -334
- package/docs/wallet.md +1109 -932
- package/out/src/CWIStyleWalletManager.d.ts +52 -5
- package/out/src/CWIStyleWalletManager.d.ts.map +1 -1
- package/out/src/CWIStyleWalletManager.js +500 -128
- package/out/src/CWIStyleWalletManager.js.map +1 -1
- package/out/src/Wallet.d.ts +8 -0
- package/out/src/Wallet.d.ts.map +1 -1
- package/out/src/Wallet.js +23 -9
- package/out/src/Wallet.js.map +1 -1
- package/out/src/WalletAuthenticationManager.d.ts +20 -6
- package/out/src/WalletAuthenticationManager.d.ts.map +1 -1
- package/out/src/WalletAuthenticationManager.js +214 -34
- package/out/src/WalletAuthenticationManager.js.map +1 -1
- package/out/src/index.all.d.ts +1 -0
- package/out/src/index.all.d.ts.map +1 -1
- package/out/src/index.all.js +1 -0
- package/out/src/index.all.js.map +1 -1
- package/out/src/index.client.d.ts +2 -0
- package/out/src/index.client.d.ts.map +1 -1
- package/out/src/index.client.js +2 -0
- package/out/src/index.client.js.map +1 -1
- package/out/src/index.mobile.d.ts +1 -0
- package/out/src/index.mobile.d.ts.map +1 -1
- package/out/src/index.mobile.js +1 -0
- package/out/src/index.mobile.js.map +1 -1
- package/out/src/monitor/Monitor.d.ts.map +1 -1
- package/out/src/monitor/Monitor.js +4 -3
- package/out/src/monitor/Monitor.js.map +1 -1
- package/out/src/monitor/tasks/TaskCleanupActionBatches.d.ts +13 -0
- package/out/src/monitor/tasks/TaskCleanupActionBatches.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskCleanupActionBatches.js +24 -0
- package/out/src/monitor/tasks/TaskCleanupActionBatches.js.map +1 -0
- package/out/src/monitor/tasks/index.all.d.ts +1 -0
- package/out/src/monitor/tasks/index.all.d.ts.map +1 -1
- package/out/src/monitor/tasks/index.all.js +1 -0
- package/out/src/monitor/tasks/index.all.js.map +1 -1
- package/out/src/sdk/ActionBatch.interfaces.d.ts +105 -0
- package/out/src/sdk/ActionBatch.interfaces.d.ts.map +1 -0
- package/out/src/sdk/ActionBatch.interfaces.js +3 -0
- package/out/src/sdk/ActionBatch.interfaces.js.map +1 -0
- package/out/src/sdk/WalletStorage.interfaces.d.ts +18 -1
- package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
- package/out/src/sdk/index.d.ts +1 -0
- package/out/src/sdk/index.d.ts.map +1 -1
- package/out/src/sdk/index.js +1 -0
- package/out/src/sdk/index.js.map +1 -1
- package/out/src/signer/actionBatch/ActionBatchPlanner.d.ts +28 -0
- package/out/src/signer/actionBatch/ActionBatchPlanner.d.ts.map +1 -0
- package/out/src/signer/actionBatch/ActionBatchPlanner.js +313 -0
- package/out/src/signer/actionBatch/ActionBatchPlanner.js.map +1 -0
- package/out/src/signer/actionBatch/ActionBatchWorkspace.d.ts +33 -0
- package/out/src/signer/actionBatch/ActionBatchWorkspace.d.ts.map +1 -0
- package/out/src/signer/actionBatch/ActionBatchWorkspace.js +693 -0
- package/out/src/signer/actionBatch/ActionBatchWorkspace.js.map +1 -0
- package/out/src/signer/methods/buildSignableTransaction.d.ts.map +1 -1
- package/out/src/signer/methods/buildSignableTransaction.js +2 -1
- package/out/src/signer/methods/buildSignableTransaction.js.map +1 -1
- package/out/src/signer/methods/createAction.d.ts.map +1 -1
- package/out/src/signer/methods/createAction.js +4 -1
- package/out/src/signer/methods/createAction.js.map +1 -1
- package/out/src/storage/StorageIdb.d.ts +14 -0
- package/out/src/storage/StorageIdb.d.ts.map +1 -1
- package/out/src/storage/StorageIdb.js +156 -30
- package/out/src/storage/StorageIdb.js.map +1 -1
- package/out/src/storage/StorageKnex.d.ts +19 -0
- package/out/src/storage/StorageKnex.d.ts.map +1 -1
- package/out/src/storage/StorageKnex.js +107 -1
- package/out/src/storage/StorageKnex.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts +28 -0
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +49 -0
- package/out/src/storage/StorageProvider.js.map +1 -1
- package/out/src/storage/WalletStorageManager.d.ts +8 -0
- package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
- package/out/src/storage/WalletStorageManager.js +24 -0
- package/out/src/storage/WalletStorageManager.js.map +1 -1
- package/out/src/storage/idbHelpers.d.ts +2 -0
- package/out/src/storage/idbHelpers.d.ts.map +1 -1
- package/out/src/storage/idbHelpers.js +19 -0
- package/out/src/storage/idbHelpers.js.map +1 -1
- package/out/src/storage/methods/actionBatch.d.ts +14 -0
- package/out/src/storage/methods/actionBatch.d.ts.map +1 -0
- package/out/src/storage/methods/actionBatch.js +644 -0
- package/out/src/storage/methods/actionBatch.js.map +1 -0
- package/out/src/storage/methods/actionBatchBlobs.d.ts +12 -0
- package/out/src/storage/methods/actionBatchBlobs.d.ts.map +1 -0
- package/out/src/storage/methods/actionBatchBlobs.js +121 -0
- package/out/src/storage/methods/actionBatchBlobs.js.map +1 -0
- package/out/src/storage/methods/actionBatchValidation.d.ts +15 -0
- package/out/src/storage/methods/actionBatchValidation.d.ts.map +1 -0
- package/out/src/storage/methods/actionBatchValidation.js +310 -0
- package/out/src/storage/methods/actionBatchValidation.js.map +1 -0
- package/out/src/storage/methods/actionPlanning.d.ts +12 -0
- package/out/src/storage/methods/actionPlanning.d.ts.map +1 -0
- package/out/src/storage/methods/actionPlanning.js +48 -0
- package/out/src/storage/methods/actionPlanning.js.map +1 -0
- package/out/src/storage/methods/createAction.d.ts.map +1 -1
- package/out/src/storage/methods/createAction.js +9 -25
- package/out/src/storage/methods/createAction.js.map +1 -1
- package/out/src/storage/remoting/StorageClientBase.d.ts +9 -0
- package/out/src/storage/remoting/StorageClientBase.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageClientBase.js +36 -1
- package/out/src/storage/remoting/StorageClientBase.js.map +1 -1
- package/out/src/storage/remoting/StorageServer.d.ts +10 -0
- package/out/src/storage/remoting/StorageServer.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageServer.js +147 -7
- package/out/src/storage/remoting/StorageServer.js.map +1 -1
- package/out/src/storage/schema/KnexMigrations.d.ts.map +1 -1
- package/out/src/storage/schema/KnexMigrations.js +44 -0
- package/out/src/storage/schema/KnexMigrations.js.map +1 -1
- package/out/src/storage/schema/StorageIdbSchema.d.ts +24 -0
- package/out/src/storage/schema/StorageIdbSchema.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableActionBatch.d.ts +24 -0
- package/out/src/storage/schema/tables/TableActionBatch.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableActionBatch.js +3 -0
- package/out/src/storage/schema/tables/TableActionBatch.js.map +1 -0
- package/out/src/storage/schema/tables/index.d.ts +1 -0
- package/out/src/storage/schema/tables/index.d.ts.map +1 -1
- package/out/src/storage/schema/tables/index.js +1 -0
- package/out/src/storage/schema/tables/index.js.map +1 -1
- package/out/src/utility/actionBatchDigest.d.ts +9 -0
- package/out/src/utility/actionBatchDigest.d.ts.map +1 -0
- package/out/src/utility/actionBatchDigest.js +48 -0
- package/out/src/utility/actionBatchDigest.js.map +1 -0
- package/out/src/utility/beefForTxids.d.ts +9 -0
- package/out/src/utility/beefForTxids.d.ts.map +1 -0
- package/out/src/utility/beefForTxids.js +35 -0
- package/out/src/utility/beefForTxids.js.map +1 -0
- package/out/src/wab-client/WABClient.d.ts +36 -90
- package/out/src/wab-client/WABClient.d.ts.map +1 -1
- package/out/src/wab-client/WABClient.js +103 -151
- package/out/src/wab-client/WABClient.js.map +1 -1
- package/out/src/wab-client/WABTransport.d.ts +53 -0
- package/out/src/wab-client/WABTransport.d.ts.map +1 -0
- package/out/src/wab-client/WABTransport.js +300 -0
- package/out/src/wab-client/WABTransport.js.map +1 -0
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.d.ts +10 -10
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.d.ts.map +1 -1
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js +16 -21
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js.map +1 -1
- package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.d.ts +2 -1
- package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.d.ts.map +1 -1
- package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.js +14 -0
- package/out/src/wab-client/auth-method-interactors/TwilioPhoneInteractor.js.map +1 -1
- package/package.json +23 -23
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,43 @@ attention to changes that materially alter behavior or extend functionality.
|
|
|
6
6
|
|
|
7
7
|
## wallet-toolbox (unreleased)
|
|
8
8
|
|
|
9
|
+
- Harden CWI/WAB account continuity so overlay failures, malformed or ambiguous
|
|
10
|
+
UMP results, and snapshot-load failures cannot silently enter new-user
|
|
11
|
+
onboarding. Add an expiring WAB auth session, legacy-compatible WAB account
|
|
12
|
+
status inference, canonical E.164 phone identity, bounded KDF/snapshot
|
|
13
|
+
parsing, and fail-closed UMP renewal/broadcast behavior.
|
|
14
|
+
- Replace WAB's endpoint-by-endpoint raw `fetch` calls with one typed transport
|
|
15
|
+
enforcing HTTPS (localhost excepted), timeouts, request/response limits,
|
|
16
|
+
redirect and ambient-credential protection, correlation IDs, and privacy-safe errors.
|
|
17
|
+
Wallet authentication, UMP, WAB, and snapshot events now support the SDK's
|
|
18
|
+
opt-in generic telemetry sink without reporting keys, snapshots, payloads,
|
|
19
|
+
OTPs, or Shamir shares.
|
|
20
|
+
- Add automatically negotiated, in-memory planning for dependent `noSend` workloads. Capable
|
|
21
|
+
storage providers reserve funding once, perform middle action planning and signing without
|
|
22
|
+
persistence round trips, and atomically commit the complete workspace on `sendWith`. Existing
|
|
23
|
+
BRC-100 arguments and results are unchanged, and providers without `actionBatch: 1` retain the
|
|
24
|
+
legacy path. SQLite, MySQL/Knex, IndexedDB, authenticated remote clients, browser, and mobile
|
|
25
|
+
builds share the same capability contract.
|
|
26
|
+
- Add leased per-output batch reservations, expiry cleanup, adaptive pool extension, idempotent
|
|
27
|
+
manifest commits, inline content-addressed blobs up to 4 MiB, and authenticated binary uploads
|
|
28
|
+
in provider-sized chunks with four-way bounded concurrency for larger batches. Broadcast remains
|
|
29
|
+
outside the atomic persistence transaction.
|
|
30
|
+
- Make batch funding converge on fragmented wallets at production fee rates. Reservation targets
|
|
31
|
+
include the fee and viable-change overhead of an added input, reactive extensions request only
|
|
32
|
+
the remaining shortfall, and EWMA runway extensions subtract unconsumed reserved funding without
|
|
33
|
+
compounding after empty or partial responses. The regression runs 16 independent actions through
|
|
34
|
+
both the in-process and authenticated remote-storage paths and commits the complete batch.
|
|
35
|
+
- Bind remote batch authorization exclusively to the BRC-103 authenticated identity and its active
|
|
36
|
+
storage provider, ignoring caller-supplied user IDs and active-state claims. Restrict JSON-RPC
|
|
37
|
+
dispatch to the public remote-storage protocol so authenticated callers cannot invoke low-level
|
|
38
|
+
provider methods, and rate-limit authenticated RPCs per identity key without limiting workspace
|
|
39
|
+
length. Unauthenticated and cross-user batch-management regressions cover the boundary.
|
|
40
|
+
- Replace the cumulative 64-output reservation ceiling with repeatable extensions bounded to 64
|
|
41
|
+
outputs per storage call. Workspaces and spend chains no longer have an action-count or confirmed
|
|
42
|
+
funding-input ceiling; an 80-action independent batch crosses the old boundary and commits.
|
|
43
|
+
- Add a retained workload benchmark covering 1, 10, 50, and 250 actions across dependent,
|
|
44
|
+
independent, mixed-input, and two-step signing models, four script sizes, and 25/100/250 ms
|
|
45
|
+
storage latency. Run it with `pnpm --filter @bsv/wallet-toolbox bench:action-batch`.
|
|
9
46
|
- Release prep for `2.4.2`: transaction-pipeline, BEEF fetching, and binary transport
|
|
10
47
|
performance improvements described below, published in lockstep for Node, browser, and mobile.
|
|
11
48
|
- Transaction pipeline performance: reuse parsed BEEF through `createAction`/`signAction`, retain
|
|
@@ -34,7 +71,7 @@ attention to changes that materially alter behavior or extend functionality.
|
|
|
34
71
|
`auth-express-middleware@2.1.1` likewise declares its `mime-types` runtime
|
|
35
72
|
import so strict package managers do not fail when loading the built packages.
|
|
36
73
|
|
|
37
|
-
- Release prep for `2.4.2`: proof completion now discovers every local
|
|
74
|
+
- Release prep for `2.4.2`: proof completion now discovers every local
|
|
38
75
|
transaction row sharing the proven txid, repairs notification-set drift from
|
|
39
76
|
concurrent multi-user `internalizeAction` calls, and idempotently completes
|
|
40
77
|
any local copy omitted by a last-writer-wins notification update.
|
package/docs/README.md
CHANGED
|
@@ -9,7 +9,9 @@ The documentation is split into various pages, each covering a set of related fu
|
|
|
9
9
|
- [Storage](./storage.md) — Wallet data persistent storage classes and related APIs.
|
|
10
10
|
- [Services](./services.md) — Support for abstracted external network services.
|
|
11
11
|
- [Monitor](./monitor.md) — Background task manager for wallet action validation and processing.
|
|
12
|
+
- [Action batch planning](./action-batch-planning.md) — Session-local `noSend` planning and atomic storage commit.
|
|
12
13
|
- [WAB Shamir](./wab-shamir.md) — Shamir 2-of-3 key recovery system with entropy collection and WAB server integration.
|
|
14
|
+
- [Authentication observability](./authentication-observability.md) — Privacy-safe telemetry, WAB transport hardening, and account-continuity handling.
|
|
13
15
|
|
|
14
16
|
## Open API
|
|
15
17
|
|
|
@@ -83,4 +85,4 @@ const rw = await wallet.internalizeAction(args)
|
|
|
83
85
|
console.log(rw.accepted)
|
|
84
86
|
```
|
|
85
87
|
|
|
86
|
-
[Return to Top](#bsv-wallet-toolbox-api-documentation)
|
|
88
|
+
[Return to Top](#bsv-wallet-toolbox-api-documentation)
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# In-memory action batch planning
|
|
2
|
+
|
|
3
|
+
Wallet Toolbox can plan a sequence of `noSend` actions in memory and commit it
|
|
4
|
+
atomically when the application uses `sendWith`. This removes per-action storage
|
|
5
|
+
round trips without changing the BRC-100 wallet interface, action arguments, or
|
|
6
|
+
result shapes. Applications continue to create, sign, and send actions exactly as
|
|
7
|
+
before.
|
|
8
|
+
|
|
9
|
+
## Negotiation and compatibility
|
|
10
|
+
|
|
11
|
+
`WalletArgs.actionBatchMode` accepts `auto` (the default) or `legacy`. In `auto`
|
|
12
|
+
mode, the wallet asks its active storage provider for capabilities once. A provider
|
|
13
|
+
advertising `actionBatch: { version: 1, ...limits }` enables local planning. A
|
|
14
|
+
provider without that capability uses the existing persistence flow before any
|
|
15
|
+
workspace begins. A workspace never mixes storage modes or changes active provider.
|
|
16
|
+
|
|
17
|
+
The capability and its methods are Wallet Toolbox storage extensions. They do not
|
|
18
|
+
extend `WalletInterface`, `CreateActionArgs`, `SignActionArgs`, `noSend`,
|
|
19
|
+
`noSendChange`, `sendWith`, or their results.
|
|
20
|
+
|
|
21
|
+
## Lifecycle
|
|
22
|
+
|
|
23
|
+
1. The first `noSend` action begins a workspace, reserves the canonical funding
|
|
24
|
+
inputs needed for that action plus limited headroom, and returns their proof
|
|
25
|
+
data in one storage call.
|
|
26
|
+
2. The wallet plans, signs, validates, and indexes subsequent actions locally. A
|
|
27
|
+
shared BEEF graph and content-addressed locking-script blobs avoid retaining
|
|
28
|
+
repeated ancestry and script copies.
|
|
29
|
+
3. If confirmed funding runs low, the wallet extends its reservation pool using
|
|
30
|
+
an EWMA estimate and geometrically increasing runway. Forwarded staged change
|
|
31
|
+
needs no reservation or extension.
|
|
32
|
+
4. `sendWith`, or a normal action created while the workspace is open, validates
|
|
33
|
+
and atomically persists every staged action. Only the requested transactions
|
|
34
|
+
are sent; earlier actions retain their `nosend` status.
|
|
35
|
+
5. Broadcast occurs after the storage transaction. Delayed mode returns after the
|
|
36
|
+
batch is durably queued; immediate mode uses the existing aggregate broadcaster
|
|
37
|
+
and review results.
|
|
38
|
+
|
|
39
|
+
Intermediate state is deliberately session-scoped. If the wallet process exits,
|
|
40
|
+
the uncommitted transaction workspace is lost and its durable reservations expire
|
|
41
|
+
or are released by cleanup. The final commit is the remote durability boundary.
|
|
42
|
+
|
|
43
|
+
## Reservations and cleanup
|
|
44
|
+
|
|
45
|
+
Reservations belong to individual outputs, not the wallet. Other wallet activity
|
|
46
|
+
can use unreserved outputs normally. A uniqueness constraint prevents one output
|
|
47
|
+
from belonging to two active batches.
|
|
48
|
+
|
|
49
|
+
The initial reservation includes at most three extra candidates and never more
|
|
50
|
+
than eight outputs. Its canonical funding target includes the marginal P2PKH
|
|
51
|
+
input fee and enough value to recover an economically viable first change output,
|
|
52
|
+
so a low basket minimum cannot repeatedly select inputs that satisfy the nominal
|
|
53
|
+
deficit but cost too much to use.
|
|
54
|
+
|
|
55
|
+
Extensions add at most 64 outputs per storage call, but there is no cumulative
|
|
56
|
+
reservation, workspace-size, action-count, or spend-chain limit. Additional
|
|
57
|
+
bounded calls continue for as long as the workspace needs confirmed funding.
|
|
58
|
+
They use the same exact, least-over, then largest-under selection policy as
|
|
59
|
+
normal funding. Retry targets are incremental shortfalls: the planner credits
|
|
60
|
+
the value and count of every unconsumed reserved output before asking for more.
|
|
61
|
+
Confirmed inputs already used by staged transactions remain reserved until
|
|
62
|
+
commit but are not credited as available funding. Proactive EWMA requests
|
|
63
|
+
likewise subtract the unconsumed pool, initialize from the first complete
|
|
64
|
+
sample, and increase geometric runway only when the provider fulfills both the
|
|
65
|
+
requested count and value. Empty or partial extensions therefore cannot
|
|
66
|
+
compound a target against unchanged wallet state.
|
|
67
|
+
Leases last 15 minutes with a 60-minute hard lifetime. Long-running workspaces
|
|
68
|
+
renew near 80% of the lease; commit may atomically reacquire an expired reservation
|
|
69
|
+
when no conflicting spend or reservation occurred. Commit, abort, wallet
|
|
70
|
+
destruction, expiry cleanup, and the one-minute monitor task release unused state.
|
|
71
|
+
|
|
72
|
+
## Atomic commit and payload transport
|
|
73
|
+
|
|
74
|
+
The provider checks graph order, duplicate spends, scripts, TXIDs, signatures,
|
|
75
|
+
fees, commissions, leases, and output metadata before persistence. Transactions,
|
|
76
|
+
outputs, labels, tags, maps, and proof requests are written under one database
|
|
77
|
+
transaction together with reservation consumption and release. Batch ID plus a
|
|
78
|
+
semantic manifest digest makes persistence retries idempotent.
|
|
79
|
+
|
|
80
|
+
Content-addressed raw transactions, dependency BEEF, and locking scripts travel
|
|
81
|
+
inline for batches up to the provider's inline limit (4 MiB by default). Larger
|
|
82
|
+
workloads prepare a manifest, upload only missing blobs through authenticated raw
|
|
83
|
+
binary requests, and commit by digest. Logical blobs are split at the provider's
|
|
84
|
+
advertised limit (8 MiB by default), deduplicated by digest, and uploaded with at
|
|
85
|
+
most four concurrent requests. Incomplete uploads expire with their batch.
|
|
86
|
+
|
|
87
|
+
The remote server derives the batch user ID and active-storage state from the
|
|
88
|
+
BRC-103 authenticated identity for every management call and binary upload.
|
|
89
|
+
Caller-supplied user IDs or active-state claims are never authoritative, and the
|
|
90
|
+
JSON-RPC dispatcher exposes only the public remote-storage protocol rather than
|
|
91
|
+
low-level provider methods. Authenticated RPC and blob requests are rate-limited
|
|
92
|
+
by identity key without limiting the number of actions, transactions, or blobs
|
|
93
|
+
in a workspace; operators can configure the rate and a shared multi-replica
|
|
94
|
+
store through `WalletStorageServerOptions.rateLimit`.
|
|
95
|
+
|
|
96
|
+
## Rollout and measurement roadmap
|
|
97
|
+
|
|
98
|
+
The compatibility boundary permits a server-first rollout: deploy schema and
|
|
99
|
+
provider support, then deploy clients in `auto` mode. Old clients ignore the
|
|
100
|
+
capability; new clients fall back against old providers. Operators can use
|
|
101
|
+
`actionBatchMode: 'legacy'` for controlled comparisons.
|
|
102
|
+
|
|
103
|
+
The retained benchmark is the performance regression gate:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
pnpm --filter @bsv/wallet-toolbox bench:action-batch
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
It records planning, signing and validation, storage RPCs, database transactions,
|
|
110
|
+
request bytes, commit and broadcast time, CPU, and incremental peak heap. Physical
|
|
111
|
+
SQLite runs compare 1, 10, 50, and 250 action chains at 1 KiB and exercise each
|
|
112
|
+
larger script size with a real action, including the 4 MiB upload path. Its complete
|
|
113
|
+
model covers dependent, independent, explicit-input, and two-step signing workloads
|
|
114
|
+
at every action count; 1 KiB, 64 KiB, 1 MiB, and 4 MiB scripts; and 25, 100, and
|
|
115
|
+
250 ms storage RTT. Production rollout should additionally track reservation
|
|
116
|
+
conflicts, extensions, expiries, commit retries, upload deduplication, commit
|
|
117
|
+
duration, and broadcaster review outcomes by provider type.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Authentication observability and account continuity
|
|
2
|
+
|
|
3
|
+
Wallet Toolbox authentication uses the SDK's generic `TelemetryConfig`. The
|
|
4
|
+
same sink can correlate SDK overlay resolution, UMP account lookup, WAB HTTP,
|
|
5
|
+
wallet snapshot, and authentication state-transition events.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import {
|
|
9
|
+
LookupResolver,
|
|
10
|
+
TelemetryConfig
|
|
11
|
+
} from '@bsv/sdk'
|
|
12
|
+
import {
|
|
13
|
+
OverlayUMPTokenInteractor,
|
|
14
|
+
WABClient
|
|
15
|
+
} from '@bsv/wallet-toolbox'
|
|
16
|
+
|
|
17
|
+
const telemetry: TelemetryConfig = {
|
|
18
|
+
minimumSeverity: 'info',
|
|
19
|
+
sink: {
|
|
20
|
+
capture: event => supportReporter.capture(event)
|
|
21
|
+
},
|
|
22
|
+
beforeSend: event => ({
|
|
23
|
+
...event,
|
|
24
|
+
attributes: {
|
|
25
|
+
...event.attributes,
|
|
26
|
+
applicationVersion: '4.7.0',
|
|
27
|
+
operatingSystem: 'ubuntu'
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const resolver = new LookupResolver({ telemetry })
|
|
33
|
+
const ump = new OverlayUMPTokenInteractor(resolver, undefined, telemetry)
|
|
34
|
+
const wab = new WABClient('https://wab.example.com', { telemetry })
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Pass the same `telemetry` configuration in
|
|
38
|
+
`WalletAuthenticationManagerOptions` when constructing the manager. Correlation
|
|
39
|
+
IDs then connect the WAB start/complete requests to account-continuity events
|
|
40
|
+
without exposing authentication payloads.
|
|
41
|
+
|
|
42
|
+
## Privacy boundary
|
|
43
|
+
|
|
44
|
+
Telemetry is opt-in and no-op by default. Wallet Toolbox reports operation
|
|
45
|
+
names, result categories, host counts, HTTP status, durations, format versions,
|
|
46
|
+
and correlation IDs. It never reports:
|
|
47
|
+
|
|
48
|
+
- private, presentation, recovery, or password-derived keys;
|
|
49
|
+
- passwords, phone numbers, OTPs, auth tokens, or request payloads;
|
|
50
|
+
- UMP token fields, Shamir shares, ciphertext, or transaction material;
|
|
51
|
+
- wallet snapshots or decrypted profile data.
|
|
52
|
+
|
|
53
|
+
The SDK sanitizes events before and after consumer enrichment. Sink failures do
|
|
54
|
+
not affect authentication or wallet behavior.
|
|
55
|
+
|
|
56
|
+
## Account-state rules
|
|
57
|
+
|
|
58
|
+
`authenticationFlow` starts as `unknown`. A password cannot create a wallet
|
|
59
|
+
until account lookup has completed.
|
|
60
|
+
|
|
61
|
+
An empty UMP answer means `new-user` only when every selected overlay host
|
|
62
|
+
settled successfully and returned an empty output list. Timeout, host failure,
|
|
63
|
+
malformed response, semantic rejection, or a malformed UMP token raises
|
|
64
|
+
`UMPTokenLookupError`. Multiple distinct valid UMP tokens are also treated as
|
|
65
|
+
ambiguous instead of choosing one by response order. Applications should
|
|
66
|
+
present retry and account-recovery options for these errors, never a
|
|
67
|
+
new-password prompt.
|
|
68
|
+
|
|
69
|
+
WAB completion uses an explicit `accountStatus` or `existingUser` response when
|
|
70
|
+
available. For older WAB servers it derives the status from the established
|
|
71
|
+
protocol: a new account returns the temporary presentation key, while an
|
|
72
|
+
existing account returns its stored key. If WAB identifies an existing account
|
|
73
|
+
but UMP authoritatively appears absent, `WABAccountContinuityError` prevents
|
|
74
|
+
new-wallet creation.
|
|
75
|
+
|
|
76
|
+
Temporary WAB authentication state expires after ten minutes by default and is
|
|
77
|
+
cleared when authentication is cancelled, completed, or destroyed.
|
|
78
|
+
|
|
79
|
+
Snapshot initialization is also fail-closed. Awaiting `manager.ready` rejects
|
|
80
|
+
when a supplied snapshot cannot be loaded instead of silently resetting the
|
|
81
|
+
manager into onboarding.
|
|
82
|
+
|
|
83
|
+
## WAB transport
|
|
84
|
+
|
|
85
|
+
Every WAB endpoint uses one transport with:
|
|
86
|
+
|
|
87
|
+
- HTTPS enforcement, with plain HTTP limited to localhost development;
|
|
88
|
+
- a hard wall-clock timeout;
|
|
89
|
+
- bounded JSON request and response sizes;
|
|
90
|
+
- rejected redirects and omitted ambient credentials;
|
|
91
|
+
- typed, privacy-safe failures and correlated telemetry.
|
|
92
|
+
|
|
93
|
+
Configure `timeoutMs`, `maxRequestBytes`, and `maxResponseBytes` in `WABClient`
|
|
94
|
+
options when the defaults of 10 seconds and 1 MiB are not appropriate.
|