@cloak.dev/sdk 0.2.12 → 0.2.14
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 +57 -0
- package/README.md +43 -4
- package/dist/index.cjs +287 -68
- package/dist/index.d.cts +65 -12
- package/dist/index.d.ts +65 -12
- package/dist/index.js +294 -73
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,63 @@ the README's "Version and compatibility" section and in the git history.
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.14]
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
* A Ledger driven through Phantom, Solflare or Backpack can authenticate to the relay again. With
|
|
15
|
+
the hardware-wallet envelope on, these wallets change the 0 SOL auth transaction before the device
|
|
16
|
+
signs it (Phantom adds compute-budget instructions to a transaction that has none, Solflare adds
|
|
17
|
+
its guard instructions), so the signature covered the wallet's message while the relay rebuilt
|
|
18
|
+
the SDK's and refused it. In production this stopped every such user at viewing-key registration
|
|
19
|
+
with "Signature verification failed". `signRelayAuthPayload` now returns the message the wallet
|
|
20
|
+
signed as `txMessage` when it differs from ours and still binds the payload (the wallet as fee
|
|
21
|
+
payer and only signer, `sha256(payload)` as the blockhash, our 0-lamport self-transfer still in
|
|
22
|
+
it), and every relay request carries it as `auth_tx_message` (`tx_message` on
|
|
23
|
+
`/viewing-key/register`). The wallet may add only what wallets add on their own: instructions of
|
|
24
|
+
ComputeBudget (Phantom, Solflare) and Lighthouse (Solflare), the programs seen in real Phantom and
|
|
25
|
+
Solflare messages. Anything else next to the transfer is how a phishing page would disguise the
|
|
26
|
+
envelope, so it is refused, as is a message that fails the relay's `sanitize()` rules or whose
|
|
27
|
+
signature does not cover it. All of these are refused before anything is sent. A wallet that signs the
|
|
28
|
+
envelope unchanged sends exactly what it sent before. Needs the matching relay release; an older
|
|
29
|
+
relay ignores the field.
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
|
|
33
|
+
* `walletAuthTransactionMessageBinds(sender, payload, bytes)`, the client copy of the relay's
|
|
34
|
+
`wallet_tx_message_binds` (pinned to it by a shared corpus,
|
|
35
|
+
`src/__tests__/fixtures/wallet-tx-message-corpus.json`), `WALLET_ADDED_PROGRAMS`, and the
|
|
36
|
+
`SignedRelayAuthPayload` type. `WALLET_ADDED_PROGRAMS` mirrors the relay and grows when a new
|
|
37
|
+
wallet is seen adding another program; read it from the SDK version you run, do not copy it.
|
|
38
|
+
|
|
39
|
+
### Changed
|
|
40
|
+
|
|
41
|
+
* `signRelayAuthPayload` verifies the signature a transaction-only wallet returns over the message
|
|
42
|
+
it returned, before anything is sent: a wallet that signed other bytes is refused with a sentence
|
|
43
|
+
instead of a 401 after the proof. Message-mode signatures are returned unchecked, as before, so
|
|
44
|
+
callers that verify them and fall back to the envelope (web's affiliate signer) keep working.
|
|
45
|
+
* `TransactOptions.affiliateCode`, `TransactOptions.onWarning` and `normalizeAffiliateCode` are now
|
|
46
|
+
public API. Any approved Cloak partner can pass their code from their own app and earn commission
|
|
47
|
+
on the withdrawals, sends to an address and swaps it makes; before, only Cloak's own web and
|
|
48
|
+
mobile apps were counted. Behaviour and wire format are unchanged: the code is still sent only
|
|
49
|
+
on fee-bearing requests, normalised, signed inside the request, and left out (reported through
|
|
50
|
+
`onWarning`) when invalid. Counting codes from other apps needs the matching relay release.
|
|
51
|
+
|
|
52
|
+
## [0.2.13]
|
|
53
|
+
|
|
54
|
+
### Fixed
|
|
55
|
+
|
|
56
|
+
* The threaded prover starts at most 8 workers (2 in a 32-bit browser) instead of one per reported
|
|
57
|
+
core, up to 64. Measured in Chrome on one real proof: 64 workers peak at +3.2 GB, 8 at +1.2 GB,
|
|
58
|
+
2 at +0.7 GB, and the proof barely gets faster past 8 (1.6 s at 64, 2.1 s at 8). A many-core
|
|
59
|
+
Windows PC in a 32-bit Chrome hung on "Generating the proof" and then crashed the tab "Out of
|
|
60
|
+
Memory" at about 1 GB.
|
|
61
|
+
* A threaded proof that neither finishes nor fails (a worker that never answers) is abandoned after
|
|
62
|
+
60 s and retried single-threaded, instead of waiting forever.
|
|
63
|
+
* The circuit download (~23 MB, first proof of a page) aborts after 20 s without data and retries,
|
|
64
|
+
up to 3 attempts, instead of waiting forever. It reports "Downloading circuit files (n of m MB)..."
|
|
65
|
+
through the flow's status callback, then "Generating zero-knowledge proof..." once it finishes.
|
|
66
|
+
|
|
10
67
|
## [0.2.12]
|
|
11
68
|
|
|
12
69
|
### Fixed
|
package/README.md
CHANGED
|
@@ -5,13 +5,13 @@ per-mint pool, send privately inside the pool, withdraw to any address, or swap
|
|
|
5
5
|
USDC/USDT with the output landing in a public token account. Groth16 proofs are generated
|
|
6
6
|
client-side (snarkjs) and verified on-chain by the Cloak program.
|
|
7
7
|
|
|
8
|
-
Version 0.2.
|
|
8
|
+
Version 0.2.14 targets the mainnet program deployed on 2026-08-24 and the ceremony-frozen
|
|
9
9
|
`cloak-transaction-0.2.0` circuit bundle. See [Version and compatibility](#version-and-compatibility).
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
npm install @cloak.dev/sdk@^0.2.
|
|
14
|
+
npm install @cloak.dev/sdk@^0.2.14
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
The SDK is built on [`@solana/kit`](https://github.com/anza-xyz/kit) and re-exports the pieces an
|
|
@@ -267,7 +267,11 @@ await transact(
|
|
|
267
267
|
A wallet that cannot sign messages (Ledger, Trezor) passes `signer` instead of `signMessage`: the
|
|
268
268
|
sender then authenticates by signing a 0-lamport no-op self-transfer that carries the request
|
|
269
269
|
digest (`auth_mode: "transaction"`). Give a wallet one of the two; when both are present
|
|
270
|
-
`signMessage` is used.
|
|
270
|
+
`signMessage` is used. If the wallet changes that transaction before its device signs it (Phantom
|
|
271
|
+
adds compute-budget instructions, Solflare its guards), the SDK sends the message the wallet
|
|
272
|
+
actually signed as `auth_tx_message`. Only ComputeBudget and Lighthouse instructions may be added
|
|
273
|
+
(`WALLET_ADDED_PROGRAMS`); any other change is refused before anything is sent
|
|
274
|
+
(`walletAuthTransactionMessageBinds`).
|
|
271
275
|
|
|
272
276
|
`signMessage` must return the raw 64-byte ed25519 detached signature over the bytes it is given;
|
|
273
277
|
adapters that re-encode or wrap the result are rejected by name. `walletPublicKey` must be the end
|
|
@@ -506,6 +510,32 @@ keypair, then look up the leaf index as in
|
|
|
506
510
|
[Recovery and discovery](#recovery-and-discovery-viewing-key). `swap.refund` no longer carries a
|
|
507
511
|
private key: the refund is spent with the wallet's own `ownerUtxoKeypair`.
|
|
508
512
|
|
|
513
|
+
### Partner code (rev share)
|
|
514
|
+
|
|
515
|
+
An approved [Cloak partner](https://cloak.ag/affiliates) earns 20% of Cloak's percentage fee on the
|
|
516
|
+
fee-bearing transactions their app makes, by passing their code:
|
|
517
|
+
|
|
518
|
+
```ts
|
|
519
|
+
import { fullWithdraw, normalizeAffiliateCode } from "@cloak.dev/sdk";
|
|
520
|
+
|
|
521
|
+
const affiliateCode = normalizeAffiliateCode(process.env.CLOAK_PARTNER_CODE); // null if malformed
|
|
522
|
+
|
|
523
|
+
await fullWithdraw(notes, recipient, {
|
|
524
|
+
...spendOptions,
|
|
525
|
+
...(affiliateCode ? { affiliateCode } : {}),
|
|
526
|
+
onWarning: (message) => console.warn(message),
|
|
527
|
+
});
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
The code rides only on withdrawals and sends to a public address, and on swaps. Deposits,
|
|
531
|
+
shield-to-shield sends and the merge steps of `partialWithdraw` never carry it. It is trimmed and
|
|
532
|
+
lower-cased, must match `^[a-z0-9_]{3,24}$`, is signed inside the request and never written
|
|
533
|
+
on-chain; an invalid code is left out and reported through `onWarning`, never failing the
|
|
534
|
+
transaction. Cloak decides after confirmation whether it earns: approved code, not the partner's own
|
|
535
|
+
payout wallet, a fee verified on-chain, and the first approved code per wallet for two calendar
|
|
536
|
+
months. Users pay the same fees either way. Full rules:
|
|
537
|
+
[docs.cloak.ag/affiliates/sdk-integration](https://docs.cloak.ag/affiliates/sdk-integration).
|
|
538
|
+
|
|
509
539
|
## Recovery and discovery (viewing key)
|
|
510
540
|
|
|
511
541
|
The viewing base `nk` is derived from the wallet's long-lived UTXO private key
|
|
@@ -799,7 +829,7 @@ relay endpoint and the localhost-RPC check.
|
|
|
799
829
|
|
|
800
830
|
## Version and compatibility
|
|
801
831
|
|
|
802
|
-
- SDK 0.2.
|
|
832
|
+
- SDK 0.2.14 pairs with the mainnet program at `zh1eLd6rSphLejbFfJEneUwzHRfMKxgzrgkfwA6qRkW`
|
|
803
833
|
(deployed 2026-08-24) and the 0.2.0 circuit bundle — the program and circuit bundle are unchanged
|
|
804
834
|
since 0.2.0; only the SDK package version has moved. The 0.2.5 flows were exercised on mainnet on
|
|
805
835
|
2026-08-25: deposit, private send and withdraw on SOL, USDC and USDT; swaps SOL to USDC and USDT;
|
|
@@ -833,6 +863,15 @@ relay endpoint and the localhost-RPC check.
|
|
|
833
863
|
- 0.2.12 retries a proof with fewer workers, then single-threaded, when the browser runs out of
|
|
834
864
|
memory handing data to the prover workers; it changes no wire format, hash or signature (see
|
|
835
865
|
[CHANGELOG.md](CHANGELOG.md)).
|
|
866
|
+
- 0.2.13 caps the prover at 8 workers (2 in a 32-bit browser), bounds the circuit download and
|
|
867
|
+
retries a stalled proof single-threaded; it changes no wire format, hash or signature (see
|
|
868
|
+
[CHANGELOG.md](CHANGELOG.md)).
|
|
869
|
+
- 0.2.14 lets a hardware wallet authenticate through a software wallet that changes the 0 SOL
|
|
870
|
+
auth transaction before the device signs it (Phantom adds compute budget, Solflare its guards):
|
|
871
|
+
the message the wallet signed is sent as `auth_tx_message` (`tx_message` on
|
|
872
|
+
`/viewing-key/register`). The field appears only for such a wallet, so every other request is
|
|
873
|
+
byte-identical to 0.2.13; it needs the matching relay release, and an older relay ignores it and
|
|
874
|
+
refuses those signatures as before (see [CHANGELOG.md](CHANGELOG.md)).
|
|
836
875
|
- Proofs generated with the 0.1.x circuits are rejected by the mainnet program. SDK 0.1.x builds
|
|
837
876
|
(which ship the 0.1.0 bundle) are not usable against it; upgrade to 0.2.x.
|
|
838
877
|
- The note-based `CloakSDK` class is removed in 0.2.0. It targeted the pre-0.2.0 instruction layout
|