@ninsei-labs/sdk 0.55.3 → 0.56.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 +64 -0
- package/README.md +34 -20
- package/assets/vendors/MANIFEST.json +22 -0
- package/assets/vendors/sdk/sdk-browser.js +2058 -2
- package/engine/atomic/dleq2.js +74 -10
- package/engine/core/config.js +14 -14
- package/engine/core/store.js +25 -4
- package/engine/core/swap.js +52 -50
- package/engine/evm/factory.js +13 -20
- package/engine/sdk/bridge.js +1 -1
- package/index.d.ts +9 -16
- package/package.json +22 -7
- package/src/actions.mjs +49 -9
- package/src/adapters/evm-wallet.mjs +24 -5
- package/src/adapters/index.d.ts +66 -0
- package/src/adapters/index.mjs +0 -6
- package/src/codes.mjs +9 -0
- package/src/factoryPolicy.mjs +24 -0
- package/src/index.mjs +10 -4
- package/src/lock.mjs +1 -1
- package/src/provider/envFile.mjs +11 -1
- package/src/public/order.d.ts +4 -0
- package/src/public/recovery.d.ts +40 -54
- package/src/public/recovery.mjs +2 -8
- package/src/public/xmr.d.ts +14 -3
- package/src/quoteEip712Spec.mjs +9 -1
- package/src/quotes.mjs +21 -26
- package/src/record.mjs +3 -3
- package/src/recovery-key.mjs +132 -226
- package/src/relayFirmClient.mjs +40 -3
- package/src/relayQuote.mjs +1 -1
- package/src/relayRequest.mjs +12 -3
- package/src/swap-flow.mjs +59 -15
- package/src/swaps.mjs +115 -113
- package/src/sweep-restore.mjs +6 -2
- package/src/sweep.mjs +30 -11
- package/src/version.mjs +1 -1
- package/src/xmr-arrival.mjs +22 -6
- package/src/adapters/node-test-evm-wallet.mjs +0 -357
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,59 @@
|
|
|
1
|
+
## 0.56.1 — 2026-11-03
|
|
2
|
+
|
|
3
|
+
- The provider settings search now includes the documented `rfq/` layout and has no duplicate candidates; the local file still outranks the production one.
|
|
4
|
+
|
|
5
|
+
- Every teeth script now runs against a throwaway copy of the tree, so a hard interruption cannot leave a mutated source file in the checkout. The coverage command enforces committed floors for the critical money-path modules and refuses a new never-loaded critical file.
|
|
6
|
+
|
|
7
|
+
- `arbitrum-sepolia` moves to the `contracts-testnet-2026.11.03-fix` deployment: factory
|
|
8
|
+
`0x6ab0ef3aa67b022d4007550e7556108537debb55` (block `325677796`), cashier
|
|
9
|
+
`0x6c6c6da6392a92b8b9c69b3ec234d524cdcfcb57`, registry
|
|
10
|
+
`0xf06ec2b1de69ff5b528ed917edffbee7be6dccc9` and implementation code hash
|
|
11
|
+
`0x334d6802099fccaef87b9569618ab3c46f6a2f075c2934c0cdbc8d4e4042944b`. The factory code pin moves to
|
|
12
|
+
`0x9246f3b981311c4ed988d77bb2177ef45d78182e47d77a2077d0afe3f3377cb8`.
|
|
13
|
+
|
|
14
|
+
## 0.56.0 — 2026-11-02
|
|
15
|
+
|
|
16
|
+
- Hardened test evidence: the V8 coverage merger now combines equal ranges across processes instead of keeping the first zero count, lists never-loaded source files, and has a regression check for both behaviours; the DLEQ oracle can require Rust in CI; the quote-TTL check drives direct and sale with the same edge table and a named post-expiry sentinel; the packed consumer compiles the TypeScript declarations from the installed tarball; and the claim sender seam is exercised end to end.
|
|
17
|
+
- Added local SDK lifecycle scenarios for a sell record: a restarted facade resumes the same record, a changed offer is refused, an unreadable store is a named refusal before a record is reported, and a failed escrow gate removes the premature record. The check also records the read trace of a sell start. These are fast in-process checks; the scheduled end-to-end contour runs separately.
|
|
18
|
+
- Added a machine-checked security-invariant map and a baseline V8 line-coverage command. The map ties sender/chain binding, quote policy and TTL, DLEQ knowledge proofs, recovery, storage, relay, terminal state, arrival and the adapter surface to executable checks; the coverage command runs the normal battery with `NODE_V8_COVERAGE` and writes `coverage/coverage-summary.json`.
|
|
19
|
+
- Rebuilt the committed browser bundle after the adapter and instance-scope changes, and pinned its new SHA-256 in `assets/vendors/MANIFEST.json`. CI now reports a stale bundle with a stat line instead of dumping the minified diff to the job log.
|
|
20
|
+
- Every `createNinsei` instance now owns its storage store; the engine's swap-record helpers accept that store, so two clients with different adapters list, read and forget separate records. Action guards read the chain and the latest block through the provider of the wallet adapter they were given, not through the process-wide engine provider. The legacy `bindStorage` remains only for the demo/test setup.
|
|
21
|
+
- `./adapters` now carries TypeScript declarations for the five production adapters; the TypeScript consumer imports `evmWallet`, the storage adapters and both Monero wallet roles from the packed subpath. The test-only Node EVM wallet moved to `tools/` and is no longer exported from the production adapter barrel.
|
|
22
|
+
- Recovery and CI comments now describe the v2 binding (the factory is part of it) and the current TypeScript consumer; the README export inventory lists every published subpath.
|
|
23
|
+
- Added a test-only DLEQ oracle pair under `test/dleq-oracle`: a Go fork that generates `ninsei-dleq-vector/2` proofs in SDK mode (right-aligned secp256k1 reduction, 253 bits, `pokA`/`pokB`) and an independently written Rust verifier. CI builds both and cross-checks Go → SDK/Rust, SDK → Go/Rust and the committed JS fixtures; a wrong context, point, low-order point or witness and a corrupted knowledge proof are refused by every verifier. The reference R-REF-1 reduction is not used by the SDK oracle.
|
|
24
|
+
- Direct and sale quotes require `validUntil` to be a safe integer strictly after the quote's clock. A zero, fractional, non-numeric or unsafe expiry is refused as `quote-expired`; a direct quote can no longer behave as a non-expiring quote while the relay path requires a future integer.
|
|
25
|
+
- **Security:** the EVM wallet adapter re-reads `eth_accounts` at the `send` boundary and refuses an account other than the one captured by the action (`wrong-account`). Funding passes the order's locker; mark-ready, claim and refund pass the wallet account read at the start of the action. A wallet switch between the guard and the transaction can no longer publish a claim half from a foreign account.
|
|
26
|
+
- The swap record takes its Monero network from the SDK instance's `xmrNetwork` (or an explicit `moneroNetwork` on the request), not from the demo's stagenet constant. The recovery file copies that value, so a testnet instance no longer asks its nodes for stagenet.
|
|
27
|
+
- `openRecoveryKeyFile` returns the file's creation date: the plain file's header day at 00:00 UTC, and the password file's sealed full time. Opening a key no longer replaces its date with the time of opening.
|
|
28
|
+
- `runAtomicOrder` accepts an explicit `xmrNetwork`; without one it keeps the chain's Monero profile and then the demo fallback.
|
|
29
|
+
- The EVM wallet adapter reads `eth_chainId` again at the `send` boundary, refuses a mismatch with `wrong-chain`, and puts `chainId` into the transaction. Funding and the three order actions pass the expected chain, so a wallet that switches networks after the action guard cannot sign on the wrong chain.
|
|
30
|
+
- The release publish job runs in the `npm-publish` environment, so protection rules and required reviewers attach to the job that can publish; the trusted publisher must name the same environment.
|
|
31
|
+
- **Breaking:** the v1 index recovery derivation is gone. `findSwaps` no longer accepts `fromIndex`, `maxIndex`, `signal` or `onProgress`, and its result is `{ swaps, complete }`. `swaps.start` no longer accepts `recoveryIndex`; new swaps always use the order's public salt. A search no longer scans a number range and can no longer become `max-index` incomplete when another person's order shares the factory.
|
|
32
|
+
- Removed the public `takerHalves`, `reserveRecoveryIndex`, `releaseRecoveryIndex`, `commitRecoveryIndex`, `recoveryIndexTaken`, `recoveryBinding`, `RECOVERY_INDEX_MAX`, `RECOVERY_SCAN_DEFAULT` and `RECOVERY_KEY_DOMAIN` exports. The salt-based `takerHalvesV2`, `recoveryBindingV2` and `newRecoverySalt` remain.
|
|
33
|
+
- The scan start height is the OLDEST height among the good Monero witnesses, not the first answer; witnesses more than 100 blocks apart are refused as a disagreement.
|
|
34
|
+
- A withdrawal window whose spent status could not be read no longer reports a complete scan; it names `spent-status-unavailable`.
|
|
35
|
+
- The live refund state follows the escrow: between `readyBy` and `t1` without the mark it stays closed, and at `t1` it opens to anyone holding the depositor's half.
|
|
36
|
+
- Claim, refund and mark-ready read the order before signing: a closed or unfunded order is refused and a second mark is refused; the claim's ready/time rule stays with the contract.
|
|
37
|
+
- A start whose receipt is gone reads the predicted escrow's `status()` before it stays `funding-pending`; a funded escrow is resumed as `xmr-incoming`.
|
|
38
|
+
- Claim, refund and mark-ready read the latest block timestamp and the escrow deadlines; a claim before `readyBy` without the mark, a refund between `readyBy` and `t1`, and a mark after `readyBy` are refused before signing.
|
|
39
|
+
- `firmRelay` compares the signed fee recipient and, without a partner key, the fee rate with `GET /v1/relay`; a mismatch is refused. A timed-out quote request is retried once with the same bytes.
|
|
40
|
+
- `pnpm run build:sdk` rebuilds `assets/vendors/sdk/sdk-browser.js` with esbuild from `tools/sdk-browser-entry.mjs`; CI rebuilds it and refuses a diff, so the committed bundle cannot drift from `src/`.
|
|
41
|
+
- Browser vendor bundles are pinned by SHA-256 in `assets/vendors/MANIFEST.json`; the `vendor-bundles` check reddens when a file changes without a manifest update.
|
|
42
|
+
- `package.json` records `allowScripts` for `esbuild` and `keccak`; a clean npm install no longer warns about unreviewed install scripts.
|
|
43
|
+
- **Breaking:** the DLEQ proof carries `pokA` and `pokB`: a Schnorr proof of knowledge per curve. It proves the claimed point is a pure multiple of the generator, so an `X = x*G + rho*H` quote is refused instead of passing the bit proof and locking the order. `verify` requires both fields; `requireKnowledge: false` exists only for historical vectors.
|
|
44
|
+
- The firm request carries `pokA` and `pokB` through its proof normalisation. Point prefixes accept `0X` and `0x`, and unknown fields inside `sig` are ignored instead of being parsed as scalars.
|
|
45
|
+
- `tools/check-dleq-vectors.mjs` pins four positive vectors and one pure-multiple vector. The pure-multiple proof passes the old statement and is refused by the knowledge proofs; the check mutates a copy to prove that guard reddens.
|
|
46
|
+
- Release workflow: the checkout, setup-node and pnpm actions are pinned by commit, and npm is installed at an exact version.
|
|
47
|
+
|
|
48
|
+
## 0.55.4 — 2026-11-01
|
|
49
|
+
|
|
50
|
+
- `createNinsei` now defaults the factory and escrow-implementation pins from the settlement network; a caller's
|
|
51
|
+
explicit list still wins. A browser caller with default options no longer funds whatever factory the maker's
|
|
52
|
+
registry names. An unknown network keeps no implementation policy instead of inheriting the default chain's pin.
|
|
53
|
+
- `verifyArrival` classifies a browser `TimeoutError` as `timeout` (not `network`) and a body cut by the same
|
|
54
|
+
timeout as `timeout` (not `bad-answer`); every answered witness carries its height, and `xmr-locked`,
|
|
55
|
+
`xmr-underpaid` and the observation disagreement carry the failed nodes.
|
|
56
|
+
|
|
1
57
|
## 0.55.3 — 2026-10-31
|
|
2
58
|
|
|
3
59
|
- Relay ask carries both view scalars: 64 bytes of plaintext and an 80-byte ciphertext, the same shape as bid.
|
|
@@ -6,6 +62,14 @@
|
|
|
6
62
|
`contracts-testnet-2026.10.26` build. A quote through an unknown factory is refused before signing.
|
|
7
63
|
- `verifyArrival` reports why each Monero node failed (`timeout`, `network`, `http` with status, `bad-answer`)
|
|
8
64
|
and keeps a completed walk pending when another node was unreachable.
|
|
65
|
+
- `swaps.startSell` reads the funded escrow before it returns `send-xmr`: code at the predicted address, an open
|
|
66
|
+
`funded` status, the slots matching the verified halves, and the deadlines by chain time. A missing or late
|
|
67
|
+
escrow is refused instead of handing out the XMR address.
|
|
68
|
+
- The registry read happens before view material is sealed to the features' HPKE key, and the quote's factory is
|
|
69
|
+
checked against the network's pinned build. A relay cannot substitute its own keys or factory.
|
|
70
|
+
- `order.fund` builds the commitment from the verified proof, not from a counterparty-provided `half` field.
|
|
71
|
+
- The wallet's chain is read before funding, claim and refund. **Breaking:** `actions.refund` now requires
|
|
72
|
+
`expect.chainId` and refuses with `bad-input {field: "chainId"}` without it.
|
|
9
73
|
|
|
10
74
|
## 0.55.2 — 2026-10-30
|
|
11
75
|
|
package/README.md
CHANGED
|
@@ -7,6 +7,21 @@ agreement: there is nothing to lay out here, and nothing to compute there.
|
|
|
7
7
|
The package **knows nothing about the DOM**: neither `document`, nor `window`, nor `localStorage` (checked by
|
|
8
8
|
machine). The wallet arrives as an EIP-1193 provider, storage as an adapter, and the interface opens the windows.
|
|
9
9
|
|
|
10
|
+
## Coverage
|
|
11
|
+
|
|
12
|
+
The security-invariant map and the V8 line-coverage command are described in [`docs/coverage.md`](docs/coverage.md).
|
|
13
|
+
|
|
14
|
+
## Integration
|
|
15
|
+
|
|
16
|
+
The seam table, buy/sell/claim/recovery flows, retry and idempotency rules, cancellation semantics and the support
|
|
17
|
+
matrix are in [`docs/integration.md`](docs/integration.md). The declarations remain the source of truth for types.
|
|
18
|
+
|
|
19
|
+
## Security
|
|
20
|
+
|
|
21
|
+
Report suspected vulnerabilities through GitHub's private **Report a vulnerability** flow, not a public issue.
|
|
22
|
+
The supported versions, scope, response targets, safe-harbor rules and disclosure process are in
|
|
23
|
+
[`SECURITY.md`](SECURITY.md).
|
|
24
|
+
|
|
10
25
|
## State (0.1.0)
|
|
11
26
|
|
|
12
27
|
| Surface | State |
|
|
@@ -53,8 +68,9 @@ claim. A future driver adds its own settlement methods; the profile alone never
|
|
|
53
68
|
compares the list of what the SDK returns with what is declared in the contract (both ways).
|
|
54
69
|
|
|
55
70
|
EVERY PUBLISHED SUBPATH CARRIES ITS OWN DECLARATIONS: `.` (`index.d.ts`), `./xmr`, `./order`, `./evm`,
|
|
56
|
-
`./core`, `./recovery
|
|
57
|
-
|
|
71
|
+
`./core`, `./networks`, `./recovery`, `./provider`, `./relay` (`src/public/<entry>.d.ts`) and `./adapters`
|
|
72
|
+
(`src/adapters/index.d.ts`). Each of them declares exactly the symbols its barrel re-exports, so a typed consumer sees
|
|
73
|
+
the same surface the runtime has, and nothing else.
|
|
58
74
|
`tools/check.mjs --only=types` keeps the two sides equal (a subpath without a `types` target, a declarations
|
|
59
75
|
file that does not read as declarations, or a symbol declared on one side only is red), and
|
|
60
76
|
`tools/check-types-teeth.mjs` is its breaking run.
|
|
@@ -178,17 +194,11 @@ range is not aligned: it is the provider's refusal, and it arrives as a code. In
|
|
|
178
194
|
|
|
179
195
|
## Found orders and the paying token
|
|
180
196
|
|
|
181
|
-
`findSwaps` returns the orders whose commitment came from the recovery key.
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
`derivation: "salt-v2"` and
|
|
185
|
-
|
|
186
|
-
run of empty numbers. One call scans at most `RECOVERY_SCAN_DEFAULT` (1000) indices; that keeps a shared factory from
|
|
187
|
-
freezing the page. The result names where it stopped: `complete: false`, `searchedUpTo`, `incompleteReason: "max-index"`
|
|
188
|
-
and `nextIndex`. A caller that needs more passes `nextIndex` back as `fromIndex`; the scan yields between chunks so the
|
|
189
|
-
page stays responsive. `maxIndex` is the number of indices for this call, and `gap` is ignored. `onProgress` receives
|
|
190
|
-
`{ scanned, index }` after each chunk and after the final index; `signal` stops between chunks and returns
|
|
191
|
-
`incompleteReason: "aborted"` with the same resumable shape.
|
|
197
|
+
`findSwaps` returns the orders whose commitment came from the recovery key. An order is found from the public `salt`
|
|
198
|
+
in its own `OrderCreated`: the binding is `ninsei-taker-v2|<chain>|<factory>|taker|<salt>`, so the same words on
|
|
199
|
+
another device or at another factory produce a different half and no number is reserved. The result says
|
|
200
|
+
`derivation: "salt-v2"` and has no index. There is no range scan and no `max-index` result: every order in the logs is
|
|
201
|
+
read once, and an unreadable log request is a refusal, not a partial answer.
|
|
192
202
|
|
|
193
203
|
- `amount` — the escrow's **native** amount in wei;
|
|
194
204
|
- `settlementToken: "native"` — what the escrow receives;
|
|
@@ -211,8 +221,7 @@ touching the index allocator.
|
|
|
211
221
|
The found order also carries the Monero start height and the reason it is absent. `no-block-time`,
|
|
212
222
|
`monero-nodes-unreachable` and `monero-network-mismatch` are different answers: a missing settlement timestamp is not
|
|
213
223
|
a dead node, and a node on another network is not an absent reader. A page that starts swaps without the SDK's start
|
|
214
|
-
path
|
|
215
|
-
logs from the registry's deployment block.
|
|
224
|
+
path must use the order's own public salt; there is no number to reserve or check.
|
|
216
225
|
|
|
217
226
|
A revealed half published as `h + n` (the alias the escrow accepts) is reduced modulo the secp256k1 order before the
|
|
218
227
|
sweep key check, so it rebuilds the same key and remains withdrawable.
|
|
@@ -243,8 +252,8 @@ The retired backend no longer decides a swap: its watch row may observe money, b
|
|
|
243
252
|
a decline; the client's two-node check and the escrow's own `Declined` event do.
|
|
244
253
|
|
|
245
254
|
Storage is a refusal, not a silent empty state: a failed read, corrupt JSON, a failed write or remove is
|
|
246
|
-
`storage-unavailable` with a step
|
|
247
|
-
|
|
255
|
+
`storage-unavailable` with a step. Every SDK instance gets its own store over the adapter it was given, so two
|
|
256
|
+
clients with different adapters keep separate records and neither takes over the other's.
|
|
248
257
|
|
|
249
258
|
Every body route the SDK sends carries `sdkVersion` from the package (`quotes.firm`, `quotes.sale` and the funding
|
|
250
259
|
mark). The caller cannot override it with a different line.
|
|
@@ -307,9 +316,10 @@ trigger where those exist; on another VM they simply do not appear, rather than
|
|
|
307
316
|
Network -> virtual machine -> driver: the SDK takes networks from the engine's registry (`CHAINS`) rather than
|
|
308
317
|
keeping its own list; a network without a driver is rejected by name (`not-implemented` with `vm` and the list
|
|
309
318
|
of supported ones), rather than being assumed EVM.
|
|
310
|
-
Storage arrives through the `storage` option and becomes
|
|
311
|
-
|
|
312
|
-
|
|
319
|
+
Storage arrives through the `storage` option and becomes THAT INSTANCE'S swap store: the state of unfinished
|
|
320
|
+
swaps lives where the interface decided. Without the option the instance takes the default — web storage if it
|
|
321
|
+
is present in the environment, otherwise process memory. Actions read the chain through the provider of the
|
|
322
|
+
wallet adapter they were given, not through a process-wide provider.
|
|
313
323
|
3. **The wallet is outside.** The SDK opens no windows and does not look for injected providers itself.
|
|
314
324
|
4. **The step order and the guards are inside `swaps.start`** (stage 2): funds are not locked until the interface
|
|
315
325
|
has confirmed the recovery file is saved; retrying after an error or a reload is safe.
|
|
@@ -337,6 +347,10 @@ demo pin the **exact** version (`"@ninsei-labs/sdk": "0.40.0-develop.1"`) rather
|
|
|
337
347
|
move, so `npm install @ninsei-labs/sdk` keeps serving the last real release. Shipping a release is then its own
|
|
338
348
|
decision: a plain `X.Y.Z`, the only shape that publishes under `latest`.
|
|
339
349
|
|
|
350
|
+
Every publish, a prerelease too, comes from a commit on `main` whose CI run on the push to `main` passed. The release
|
|
351
|
+
workflow checks both before it builds, for a tag and for a manual run that publishes, and refuses any other commit; a
|
|
352
|
+
CI run still going is waited for, at most 20 minutes. A dry run builds any branch.
|
|
353
|
+
|
|
340
354
|
The tag is passed to `npm publish` explicitly (`--tag <tag>`), and `tools/npm-tag.mjs` refuses the two ways this
|
|
341
355
|
can go wrong **by name** - a prerelease that would take `latest`, and a plain version that would slide into a
|
|
342
356
|
channel someone else owns. A manual run of the release workflow may override the tag with an input; when it does,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"note": "Pinned browser bundles. A change to one of these files must be accompanied by a matching SHA-256 here and a rebuild of the page's asset registry.",
|
|
4
|
+
"bundles": {
|
|
5
|
+
"atomic/atomic-browser.js": {
|
|
6
|
+
"sha256": "2c038c56d94d63a6445b2496dfd7ba77508965f8c4fe608c9d6610b6dc30501c",
|
|
7
|
+
"source": "www/js/atomic + @noble/curves + @noble/hashes"
|
|
8
|
+
},
|
|
9
|
+
"monero/monero-js-browser.js": {
|
|
10
|
+
"sha256": "05c682ea514db089b3f872e4e8eee3d526e7131079bdb3871dad57d201db7e89",
|
|
11
|
+
"source": "monero-js"
|
|
12
|
+
},
|
|
13
|
+
"sdk/sdk-browser.js": {
|
|
14
|
+
"sha256": "d74a7abdde8599ee429b7d148d60a7a798c3583b83be222d128b28700089f34f",
|
|
15
|
+
"source": "sdk/src (facade, adapters, recovery)"
|
|
16
|
+
},
|
|
17
|
+
"walletconnect/wc-browser.js": {
|
|
18
|
+
"sha256": "fb64f27c1ec026811fe72bfff06da1f997bbf720569ea73be87818e2c5847eec",
|
|
19
|
+
"source": "@walletconnect"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|