@cloak.dev/sdk 0.2.6 → 0.2.7
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 +32 -0
- package/README.md +6 -3
- package/dist/index.cjs +67 -8
- package/dist/index.d.cts +62 -15
- package/dist/index.d.ts +62 -15
- package/dist/index.js +65 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,38 @@ All notable changes to `@cloak.dev/sdk` are documented here. The format follows
|
|
|
5
5
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html). Releases before 0.2.6 are described in
|
|
6
6
|
the README's "Version and compatibility" section and in the git history.
|
|
7
7
|
|
|
8
|
+
## [0.2.7]
|
|
9
|
+
|
|
10
|
+
Pairs with the same mainnet program (`zh1eLd6rSphLejbFfJEneUwzHRfMKxgzrgkfwA6qRkW`) and the same
|
|
11
|
+
0.2.0 circuit bundle as 0.2.6. Note format, hashing and the relay wire format are unchanged; no
|
|
12
|
+
public signature changes. Works with the relay from the partner-program release (services#208).
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
* Internal partner (affiliate) code, used by Cloak's own web and mobile apps (#61):
|
|
17
|
+
`TransactOptions.affiliateCode` is trimmed and lower-cased once at the flow boundary, before it
|
|
18
|
+
enters the request body and the signed relay digest, because the relay only counts
|
|
19
|
+
`^[a-z0-9_]{3,24}$` and silently ignores anything else. A code that is still invalid is left out
|
|
20
|
+
of the request and reported through the new optional `TransactOptions.onWarning(message)`; it
|
|
21
|
+
never fails the request. A code that was already valid is sent exactly as before, so its digest
|
|
22
|
+
is unchanged. `transact`, `transfer`, `partialWithdraw`, `fullWithdraw`, `swapUtxo`,
|
|
23
|
+
`swapWithChange` and `transactBatch` all prepare the option once; which requests carry it is
|
|
24
|
+
unchanged (a withdrawal with a recipient, and a swap intake; never a deposit, a
|
|
25
|
+
shield-to-shield send or a `partialWithdraw` merge step). In `transactBatch` the batch's code
|
|
26
|
+
applies to every fee-bearing item and an item's own `options.affiliateCode` overrides it.
|
|
27
|
+
* Internal `TransactOptions.relayClientId` (for Cloak's mobile app, e.g. `"cloak-mobile/ios/1.4.0"`)
|
|
28
|
+
sends `X-Cloak-Client` with `POST /transact` and `POST /transact_swap`, replacing a same-named
|
|
29
|
+
`relayHeaders` entry. A value that does not match `cloak-mobile/(ios|android)/MAJOR.MINOR.PATCH`
|
|
30
|
+
is left out and reported through `onWarning`; it never fails the request. Browser callers leave
|
|
31
|
+
it unset.
|
|
32
|
+
* Internal helpers `normalizeAffiliateCode(raw): string | null` and
|
|
33
|
+
`isValidRelayClientId(value)` are exported for the apps.
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
* Scan results label BRS (`BRSxQRUaGswjLs7ewcH7uXj3r7SgmfKSSLLXyCKHZtUo`) notes as `BRS` instead
|
|
38
|
+
of a truncated mint (#58). Label only; amounts and decimals are unchanged.
|
|
39
|
+
|
|
8
40
|
## [0.2.6]
|
|
9
41
|
|
|
10
42
|
Pairs with the same mainnet program (`zh1eLd6rSphLejbFfJEneUwzHRfMKxgzrgkfwA6qRkW`) and the same
|
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.7 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.7
|
|
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
|
|
@@ -790,7 +790,7 @@ relay endpoint and the localhost-RPC check.
|
|
|
790
790
|
|
|
791
791
|
## Version and compatibility
|
|
792
792
|
|
|
793
|
-
- SDK 0.2.
|
|
793
|
+
- SDK 0.2.7 pairs with the mainnet program at `zh1eLd6rSphLejbFfJEneUwzHRfMKxgzrgkfwA6qRkW`
|
|
794
794
|
(deployed 2026-08-24) and the 0.2.0 circuit bundle — the program and circuit bundle are unchanged
|
|
795
795
|
since 0.2.0; only the SDK package version has moved. The 0.2.5 flows were exercised on mainnet on
|
|
796
796
|
2026-08-25: deposit, private send and withdraw on SOL, USDC and USDT; swaps SOL to USDC and USDT;
|
|
@@ -810,6 +810,9 @@ relay endpoint and the localhost-RPC check.
|
|
|
810
810
|
relay answers them with 401. 0.2.6 also makes nk view-only for notes created from 0.2.6 on, which
|
|
811
811
|
changes several public signatures (`ownerUtxoKeypair` is now required by every spend flow); the
|
|
812
812
|
full list is in [CHANGELOG.md](CHANGELOG.md).
|
|
813
|
+
- 0.2.7 changes no wire format, hash or public signature. Scan results label BRS notes as `BRS`,
|
|
814
|
+
and Cloak's own apps get stricter handling of the internal partner code (see
|
|
815
|
+
[CHANGELOG.md](CHANGELOG.md)).
|
|
813
816
|
- Proofs generated with the 0.1.x circuits are rejected by the mainnet program. SDK 0.1.x builds
|
|
814
817
|
(which ship the 0.1.0 bundle) are not usable against it; upgrade to 0.2.x.
|
|
815
818
|
- The note-based `CloakSDK` class is removed in 0.2.0. It targeted the pre-0.2.0 instruction layout
|
package/dist/index.cjs
CHANGED
|
@@ -808,6 +808,7 @@ __export(index_exports, {
|
|
|
808
808
|
isTerminalFailure: () => isTerminalFailure,
|
|
809
809
|
isTransactionSigner: () => import_kit2.isTransactionSigner,
|
|
810
810
|
isValidHex: () => isValidHex,
|
|
811
|
+
isValidRelayClientId: () => isValidRelayClientId,
|
|
811
812
|
isValidRpcUrl: () => isValidRpcUrl,
|
|
812
813
|
isValidSolanaAddress: () => isValidSolanaAddress,
|
|
813
814
|
isWithdrawAmountSufficient: () => isWithdrawAmountSufficient,
|
|
@@ -821,6 +822,7 @@ __export(index_exports, {
|
|
|
821
822
|
matchSwapRefundLeaf: () => matchSwapRefundLeaf,
|
|
822
823
|
mayRetry: () => mayRetry,
|
|
823
824
|
messageSignerFromCallback: () => messageSignerFromCallback,
|
|
825
|
+
normalizeAffiliateCode: () => normalizeAffiliateCode,
|
|
824
826
|
openRecipientDeliveryNote: () => openRecipientDeliveryNote,
|
|
825
827
|
parseAmount: () => parseAmount,
|
|
826
828
|
parseDeliveryCarrierMemo: () => parseDeliveryCarrierMemo,
|
|
@@ -5531,6 +5533,19 @@ async function preflightCheck(relayUrl, rootHex) {
|
|
|
5531
5533
|
};
|
|
5532
5534
|
}
|
|
5533
5535
|
|
|
5536
|
+
// src/relay/affiliate.ts
|
|
5537
|
+
var AFFILIATE_CODE_PATTERN = /^[a-z0-9_]{3,24}$/;
|
|
5538
|
+
var RELAY_CLIENT_HEADER_NAME = "X-Cloak-Client";
|
|
5539
|
+
var RELAY_CLIENT_HEADER_PATTERN = /^cloak-mobile\/(ios|android)\/\d+\.\d+\.\d+$/;
|
|
5540
|
+
function normalizeAffiliateCode(raw) {
|
|
5541
|
+
if (typeof raw !== "string") return null;
|
|
5542
|
+
const code = raw.trim().toLowerCase();
|
|
5543
|
+
return AFFILIATE_CODE_PATTERN.test(code) ? code : null;
|
|
5544
|
+
}
|
|
5545
|
+
function isValidRelayClientId(value) {
|
|
5546
|
+
return typeof value === "string" && RELAY_CLIENT_HEADER_PATTERN.test(value);
|
|
5547
|
+
}
|
|
5548
|
+
|
|
5534
5549
|
// src/flows/transact.ts
|
|
5535
5550
|
var import_kit8 = require("@solana/kit");
|
|
5536
5551
|
var import_compute_budget = require("@solana-program/compute-budget");
|
|
@@ -7189,7 +7204,41 @@ function assertInputMints(inputUtxos, expectedMint) {
|
|
|
7189
7204
|
}
|
|
7190
7205
|
}
|
|
7191
7206
|
function affiliateCodeOrUndefined(code) {
|
|
7192
|
-
return
|
|
7207
|
+
return normalizeAffiliateCode(code) ?? void 0;
|
|
7208
|
+
}
|
|
7209
|
+
function prepareAffiliateAndClient(options) {
|
|
7210
|
+
let next = options;
|
|
7211
|
+
const raw = options.affiliateCode;
|
|
7212
|
+
if (raw !== void 0 && raw !== null) {
|
|
7213
|
+
const normalized = normalizeAffiliateCode(raw);
|
|
7214
|
+
if (normalized === null) {
|
|
7215
|
+
if (typeof raw === "string" && raw.trim() !== "") {
|
|
7216
|
+
options.onWarning?.(
|
|
7217
|
+
`affiliateCode ${JSON.stringify(raw)} is not a valid partner code (3-24 characters of a-z, 0-9 or _, after trimming and lower-casing); it was left out of the request.`
|
|
7218
|
+
);
|
|
7219
|
+
}
|
|
7220
|
+
next = { ...next, affiliateCode: void 0 };
|
|
7221
|
+
} else if (normalized !== raw) {
|
|
7222
|
+
next = { ...next, affiliateCode: normalized };
|
|
7223
|
+
}
|
|
7224
|
+
}
|
|
7225
|
+
const clientId = options.relayClientId;
|
|
7226
|
+
if (clientId !== void 0 && clientId !== null && !isValidRelayClientId(clientId)) {
|
|
7227
|
+
if (typeof clientId !== "string" || clientId.trim() !== "") {
|
|
7228
|
+
options.onWarning?.(
|
|
7229
|
+
`relayClientId ${JSON.stringify(clientId)} does not match cloak-mobile/(ios|android)/MAJOR.MINOR.PATCH; no X-Cloak-Client header was sent.`
|
|
7230
|
+
);
|
|
7231
|
+
}
|
|
7232
|
+
next = { ...next, relayClientId: void 0 };
|
|
7233
|
+
} else if (isValidRelayClientId(clientId)) {
|
|
7234
|
+
const headers = {};
|
|
7235
|
+
for (const [name, value] of Object.entries(options.relayHeaders ?? {})) {
|
|
7236
|
+
if (name.toLowerCase() !== RELAY_CLIENT_HEADER_NAME.toLowerCase()) headers[name] = value;
|
|
7237
|
+
}
|
|
7238
|
+
headers[RELAY_CLIENT_HEADER_NAME] = clientId;
|
|
7239
|
+
next = { ...next, relayHeaders: headers };
|
|
7240
|
+
}
|
|
7241
|
+
return next;
|
|
7193
7242
|
}
|
|
7194
7243
|
function parseNkInput(input) {
|
|
7195
7244
|
if (typeof input !== "string") {
|
|
@@ -8844,7 +8893,8 @@ async function submitTransactToRelay(args) {
|
|
|
8844
8893
|
new Error(`Relay submission exhausted ${maxNetworkRetries + 1} attempts without an outcome`)
|
|
8845
8894
|
);
|
|
8846
8895
|
}
|
|
8847
|
-
async function transact(params,
|
|
8896
|
+
async function transact(params, rawOptions) {
|
|
8897
|
+
const options = prepareAffiliateAndClient(rawOptions);
|
|
8848
8898
|
const {
|
|
8849
8899
|
connection,
|
|
8850
8900
|
programId,
|
|
@@ -9965,7 +10015,8 @@ async function transact(params, options) {
|
|
|
9965
10015
|
addressLookupTableAccounts: resultAddressLookupTableAccounts
|
|
9966
10016
|
};
|
|
9967
10017
|
}
|
|
9968
|
-
async function transfer(inputUtxos, recipientPubkey, amount,
|
|
10018
|
+
async function transfer(inputUtxos, recipientPubkey, amount, rawOptions) {
|
|
10019
|
+
const options = prepareAffiliateAndClient(rawOptions);
|
|
9969
10020
|
const owner = await requireOwnerUtxoKeypair(options, "transfer");
|
|
9970
10021
|
const transferNk = await requireWalletNk(options, "transfer");
|
|
9971
10022
|
const inputSum = sumUtxoAmounts(inputUtxos);
|
|
@@ -10036,7 +10087,8 @@ async function transfer(inputUtxos, recipientPubkey, amount, options) {
|
|
|
10036
10087
|
{ ...spendOptions, chainNoteSalt: changeNoteSalt }
|
|
10037
10088
|
);
|
|
10038
10089
|
}
|
|
10039
|
-
async function partialWithdraw(inputUtxos, recipient, withdrawAmount,
|
|
10090
|
+
async function partialWithdraw(inputUtxos, recipient, withdrawAmount, rawOptions) {
|
|
10091
|
+
const options = prepareAffiliateAndClient(rawOptions);
|
|
10040
10092
|
const owner = await requireOwnerUtxoKeypair(options, "partialWithdraw");
|
|
10041
10093
|
const walletNk = await requireWalletNk(options, "partialWithdraw");
|
|
10042
10094
|
const inputSum = sumUtxoAmounts(inputUtxos);
|
|
@@ -10178,7 +10230,8 @@ async function waitForSwapCompletion(relayUrl, requestId, onProgress, maxAttempt
|
|
|
10178
10230
|
}
|
|
10179
10231
|
return null;
|
|
10180
10232
|
}
|
|
10181
|
-
async function swapUtxo(params,
|
|
10233
|
+
async function swapUtxo(params, rawOptions) {
|
|
10234
|
+
const options = prepareAffiliateAndClient(rawOptions);
|
|
10182
10235
|
const {
|
|
10183
10236
|
inputUtxos,
|
|
10184
10237
|
changeUtxo,
|
|
@@ -11061,7 +11114,8 @@ async function swapUtxo(params, options) {
|
|
|
11061
11114
|
}
|
|
11062
11115
|
};
|
|
11063
11116
|
}
|
|
11064
|
-
async function swapWithChange(inputUtxos, swapAmount, outputMint, recipientAta, minOutputAmount,
|
|
11117
|
+
async function swapWithChange(inputUtxos, swapAmount, outputMint, recipientAta, minOutputAmount, rawOptions, recipientWallet) {
|
|
11118
|
+
const options = prepareAffiliateAndClient(rawOptions);
|
|
11065
11119
|
const owner = await requireOwnerUtxoKeypair(options, "swapWithChange");
|
|
11066
11120
|
const totalInput = sumUtxoAmounts(inputUtxos);
|
|
11067
11121
|
const change = totalInput - swapAmount;
|
|
@@ -11469,7 +11523,8 @@ function createRelayBatchAuthCoordinator(options) {
|
|
|
11469
11523
|
}
|
|
11470
11524
|
|
|
11471
11525
|
// src/flows/transact-batch.ts
|
|
11472
|
-
async function transactBatch(items,
|
|
11526
|
+
async function transactBatch(items, rawOptions) {
|
|
11527
|
+
const options = prepareAffiliateAndClient(rawOptions);
|
|
11473
11528
|
if (items.length === 0) {
|
|
11474
11529
|
return { results: [], approvals: 0 };
|
|
11475
11530
|
}
|
|
@@ -11544,6 +11599,7 @@ var TOKEN_PROGRAM_ID = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
|
11544
11599
|
var SOL_MINT = "So11111111111111111111111111111111111111112";
|
|
11545
11600
|
var USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
11546
11601
|
var USDT_MINT = "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB";
|
|
11602
|
+
var BRS_MINT = "BRSxQRUaGswjLs7ewcH7uXj3r7SgmfKSSLLXyCKHZtUo";
|
|
11547
11603
|
var PUBLIC_AMOUNT_OFFSET = 32;
|
|
11548
11604
|
var EXT_DATA_HASH_OFFSET = 40;
|
|
11549
11605
|
var OUTPUT_COMMITMENT_0_OFFSET = 168;
|
|
@@ -11600,6 +11656,7 @@ function symbolForMint(mint) {
|
|
|
11600
11656
|
if (mint === SOL_MINT) return "SOL";
|
|
11601
11657
|
if (mint === USDC_MINT) return "USDC";
|
|
11602
11658
|
if (mint === USDT_MINT) return "USDT";
|
|
11659
|
+
if (mint === BRS_MINT) return "BRS";
|
|
11603
11660
|
if (!mint || mint.length < 8) return "TOKEN";
|
|
11604
11661
|
return `${mint.slice(0, 4)}...${mint.slice(-4)}`;
|
|
11605
11662
|
}
|
|
@@ -15573,7 +15630,7 @@ async function withShieldRetries(attempt, hooks = {}) {
|
|
|
15573
15630
|
}
|
|
15574
15631
|
|
|
15575
15632
|
// src/index.ts
|
|
15576
|
-
var VERSION = "0.2.
|
|
15633
|
+
var VERSION = "0.2.7";
|
|
15577
15634
|
var SCANNER_SUPPORTS_TRANSACT_SWAP = true;
|
|
15578
15635
|
// Annotate the CommonJS export names for ESM import in node:
|
|
15579
15636
|
0 && (module.exports = {
|
|
@@ -15810,6 +15867,7 @@ var SCANNER_SUPPORTS_TRANSACT_SWAP = true;
|
|
|
15810
15867
|
isTerminalFailure,
|
|
15811
15868
|
isTransactionSigner,
|
|
15812
15869
|
isValidHex,
|
|
15870
|
+
isValidRelayClientId,
|
|
15813
15871
|
isValidRpcUrl,
|
|
15814
15872
|
isValidSolanaAddress,
|
|
15815
15873
|
isWithdrawAmountSufficient,
|
|
@@ -15823,6 +15881,7 @@ var SCANNER_SUPPORTS_TRANSACT_SWAP = true;
|
|
|
15823
15881
|
matchSwapRefundLeaf,
|
|
15824
15882
|
mayRetry,
|
|
15825
15883
|
messageSignerFromCallback,
|
|
15884
|
+
normalizeAffiliateCode,
|
|
15826
15885
|
openRecipientDeliveryNote,
|
|
15827
15886
|
parseAmount,
|
|
15828
15887
|
parseDeliveryCarrierMemo,
|
package/dist/index.d.cts
CHANGED
|
@@ -3589,18 +3589,43 @@ interface TransactOptions {
|
|
|
3589
3589
|
*/
|
|
3590
3590
|
relayAuthBatch?: RelayBatchAuthItemHandle;
|
|
3591
3591
|
/**
|
|
3592
|
-
*
|
|
3592
|
+
* Partner (affiliate) code attached to fee-bearing relay requests (SDK-001).
|
|
3593
3593
|
*
|
|
3594
|
-
*
|
|
3595
|
-
*
|
|
3596
|
-
* (
|
|
3597
|
-
*
|
|
3594
|
+
* Normalised once at the flow boundary (trimmed, lower-cased; see {@link normalizeAffiliateCode}),
|
|
3595
|
+
* then sent as `affiliate_code` and signed inside the relay request, only when it is valid
|
|
3596
|
+
* (`^[a-z0-9_]{3,24}$`) AND the request is fee-bearing: a withdrawal / send to a public address
|
|
3597
|
+
* (`externalAmount < 0` with a recipient) or a swap intake. Deposits, shield-to-shield sends and
|
|
3598
|
+
* the internal merge steps of `partialWithdraw` never carry it, whatever is passed here. A code
|
|
3599
|
+
* that is still invalid after normalising is left out and reported through {@link onWarning};
|
|
3600
|
+
* it never fails the withdrawal or swap. Omitted, every request is byte-identical to one built
|
|
3598
3601
|
* without this option (INV-007). Requires a relay that accepts `affiliate_code`.
|
|
3599
3602
|
*
|
|
3600
|
-
*
|
|
3601
|
-
*
|
|
3603
|
+
* `partialWithdraw`, `fullWithdraw`, `swapUtxo`, `swapWithChange` and `transactBatch` all pass it
|
|
3604
|
+
* down: in a batch one code applies to every fee-bearing item (a per-item `options.affiliateCode`
|
|
3605
|
+
* overrides it).
|
|
3606
|
+
*
|
|
3607
|
+
* @internal For Cloak's own web and mobile apps (spec SDK-001, NG-02, NG-10). Not part of the
|
|
3608
|
+
* public API, not documented, and may change without notice.
|
|
3602
3609
|
*/
|
|
3603
3610
|
affiliateCode?: string;
|
|
3611
|
+
/**
|
|
3612
|
+
* Called with a human-readable message when the SDK adjusts or drops something instead of
|
|
3613
|
+
* failing: today, an `affiliateCode` or `relayClientId` that is not valid. Optional; the flow
|
|
3614
|
+
* behaves the same without it.
|
|
3615
|
+
*/
|
|
3616
|
+
onWarning?: (message: string) => void;
|
|
3617
|
+
/**
|
|
3618
|
+
* Identifies a non-browser client to the relay by sending `X-Cloak-Client: <value>` with
|
|
3619
|
+
* `/transact` and `/transact_swap`. The relay only counts affiliate events from an allowed
|
|
3620
|
+
* browser Origin or from a client id of the exact form `cloak-mobile/(ios|android)/N.N.N`, so
|
|
3621
|
+
* Cloak's own mobile app sets this, e.g. `"cloak-mobile/ios/1.4.0"`. A malformed value is left
|
|
3622
|
+
* out and reported through {@link onWarning}; it never fails the request (INV-006). Browser
|
|
3623
|
+
* callers should leave it unset: a non-safelisted header turns every submission into a CORS
|
|
3624
|
+
* preflight. Wins over a `relayHeaders` entry of the same name.
|
|
3625
|
+
*
|
|
3626
|
+
* @internal For Cloak's own mobile app (spec REL-016, NG-02). Not part of the public API.
|
|
3627
|
+
*/
|
|
3628
|
+
relayClientId?: string;
|
|
3604
3629
|
/**
|
|
3605
3630
|
* Extra HTTP headers sent with this flow's relay submissions (`POST /transact` and
|
|
3606
3631
|
* `POST /transact_swap`), e.g. `{ "X-Cloak-Client": "cloak-mobile/ios/1.4.0" }` (SDK-004).
|
|
@@ -3792,7 +3817,7 @@ interface SubmitTransactToRelayArgs {
|
|
|
3792
3817
|
* builds its own request must `await preflightNullifiers(inputUtxos, connection, programId)` first.
|
|
3793
3818
|
*/
|
|
3794
3819
|
declare function submitTransactToRelay(args: SubmitTransactToRelayArgs): Promise<RelaySubmissionResult>;
|
|
3795
|
-
declare function transact(params: TransactParams,
|
|
3820
|
+
declare function transact(params: TransactParams, rawOptions: TransactOptions): Promise<TransactResult>;
|
|
3796
3821
|
/**
|
|
3797
3822
|
* Execute a shield-to-shield transfer
|
|
3798
3823
|
*
|
|
@@ -3808,7 +3833,7 @@ declare function transact(params: TransactParams, options: TransactOptions): Pro
|
|
|
3808
3833
|
* @param amount Amount to transfer
|
|
3809
3834
|
* @param options Transaction options, including the mandatory `ownerUtxoKeypair`
|
|
3810
3835
|
*/
|
|
3811
|
-
declare function transfer(inputUtxos: Utxo[], recipientPubkey: bigint, amount: bigint,
|
|
3836
|
+
declare function transfer(inputUtxos: Utxo[], recipientPubkey: bigint, amount: bigint, rawOptions: SpendOptions): Promise<TransactResult>;
|
|
3812
3837
|
/**
|
|
3813
3838
|
* Execute a partial withdrawal
|
|
3814
3839
|
*
|
|
@@ -3823,7 +3848,7 @@ declare function transfer(inputUtxos: Utxo[], recipientPubkey: bigint, amount: b
|
|
|
3823
3848
|
* @param withdrawAmount Amount to withdraw
|
|
3824
3849
|
* @param options Transaction options, including the mandatory `ownerUtxoKeypair`
|
|
3825
3850
|
*/
|
|
3826
|
-
declare function partialWithdraw(inputUtxos: Utxo[], recipient: Address, withdrawAmount: bigint,
|
|
3851
|
+
declare function partialWithdraw(inputUtxos: Utxo[], recipient: Address, withdrawAmount: bigint, rawOptions: SpendOptions): Promise<TransactResult>;
|
|
3827
3852
|
/**
|
|
3828
3853
|
* Execute a full withdrawal
|
|
3829
3854
|
*
|
|
@@ -3894,7 +3919,7 @@ interface UtxoSwapResult extends TransactResult {
|
|
|
3894
3919
|
* @param options Transaction options
|
|
3895
3920
|
* @returns UtxoSwapResult with SwapState PDA for executing the swap
|
|
3896
3921
|
*/
|
|
3897
|
-
declare function swapUtxo(params: UtxoSwapParams,
|
|
3922
|
+
declare function swapUtxo(params: UtxoSwapParams, rawOptions: SpendOptions): Promise<UtxoSwapResult>;
|
|
3898
3923
|
/**
|
|
3899
3924
|
* Execute a swap with change
|
|
3900
3925
|
*
|
|
@@ -3907,7 +3932,7 @@ declare function swapUtxo(params: UtxoSwapParams, options: SpendOptions): Promis
|
|
|
3907
3932
|
* @param minOutputAmount Minimum output (slippage protection)
|
|
3908
3933
|
* @param options Transaction options
|
|
3909
3934
|
*/
|
|
3910
|
-
declare function swapWithChange(inputUtxos: Utxo[], swapAmount: bigint, outputMint: Address, recipientAta: Address, minOutputAmount: bigint,
|
|
3935
|
+
declare function swapWithChange(inputUtxos: Utxo[], swapAmount: bigint, outputMint: Address, recipientAta: Address, minOutputAmount: bigint, rawOptions: SpendOptions, recipientWallet?: Address): Promise<UtxoSwapResult>;
|
|
3911
3936
|
|
|
3912
3937
|
/**
|
|
3913
3938
|
* Circuit artifact loading and integrity verification.
|
|
@@ -4206,6 +4231,21 @@ declare function cleanupStalePendingOperations(maxAgeMs?: number): {
|
|
|
4206
4231
|
removedWithdrawals: number;
|
|
4207
4232
|
};
|
|
4208
4233
|
|
|
4234
|
+
/**
|
|
4235
|
+
* Normalise a partner code the way the relay expects it: trimmed and lower-cased. Returns `null`
|
|
4236
|
+
* when the result is still not a valid code (or the input is not a string), so apps can validate a
|
|
4237
|
+
* field before they ever call the SDK.
|
|
4238
|
+
*
|
|
4239
|
+
* @internal For Cloak's own web and mobile apps (spec NG-10). Not part of the public API.
|
|
4240
|
+
*/
|
|
4241
|
+
declare function normalizeAffiliateCode(raw: unknown): string | null;
|
|
4242
|
+
/**
|
|
4243
|
+
* Whether `value` is a well-formed `X-Cloak-Client` value, e.g. `cloak-mobile/ios/1.4.0`.
|
|
4244
|
+
*
|
|
4245
|
+
* @internal For Cloak's own mobile app (spec REL-016). Not part of the public API.
|
|
4246
|
+
*/
|
|
4247
|
+
declare function isValidRelayClientId(value: unknown): value is string;
|
|
4248
|
+
|
|
4209
4249
|
interface TransactBatchItem {
|
|
4210
4250
|
params: TransactParams;
|
|
4211
4251
|
/** Per-item overrides (recipient viewing key, chain-note salt, expected mint, ...). */
|
|
@@ -4230,7 +4270,14 @@ interface TransactBatchResult {
|
|
|
4230
4270
|
/** Wallet approvals raised: 1 for the batch, plus 1 per wave of stale-root re-proves. */
|
|
4231
4271
|
approvals: number;
|
|
4232
4272
|
}
|
|
4233
|
-
|
|
4273
|
+
/**
|
|
4274
|
+
* Partner code semantics: `options.affiliateCode` (and `relayClientId`) apply to every item, and
|
|
4275
|
+
* each item decides for itself whether it is fee-bearing. A withdrawal with a recipient carries the
|
|
4276
|
+
* code; a shield-to-shield send, a deposit or a consolidation step charges no variable fee and
|
|
4277
|
+
* never does. An item may set its own `options.affiliateCode` to override the batch's. The code is
|
|
4278
|
+
* normalised, and an invalid one reported through `onWarning`, once for the whole batch.
|
|
4279
|
+
*/
|
|
4280
|
+
declare function transactBatch(items: readonly TransactBatchItem[], rawOptions: TransactBatchOptions): Promise<TransactBatchResult>;
|
|
4234
4281
|
|
|
4235
4282
|
/**
|
|
4236
4283
|
* Recipient-addressed delivery envelope (CLKD1).
|
|
@@ -6415,8 +6462,8 @@ declare function withShieldRetries<T>(attempt: (attemptNo: number) => Promise<T>
|
|
|
6415
6462
|
* @packageDocumentation
|
|
6416
6463
|
*/
|
|
6417
6464
|
|
|
6418
|
-
declare const VERSION = "0.2.
|
|
6465
|
+
declare const VERSION = "0.2.7";
|
|
6419
6466
|
/** True when scanner supports TransactSwap (tag 1). Check this to verify the correct SDK bundle is loaded. */
|
|
6420
6467
|
declare const SCANNER_SUPPORTS_TRANSACT_SWAP = true;
|
|
6421
6468
|
|
|
6422
|
-
export { BRIDGE_ESCROW_LABEL, BRIDGE_ESCROW_LABEL_V2, BUILD_ALLOWS_LOCAL_ENDPOINTS, type BridgeDeliveryState, type BridgeDeposit, type BridgeDepositState, type BridgeQuoteAssessment, type BridgeQuoteInput, type BridgeRail, type BridgeRailAttestation, type BridgeRailProblem, type BridgeRailQuoteOption, type BridgeRailQuoteRequest, type BridgeRailQuoteResponse, type BridgeRailStatusResult, type BuildRecipientDeliveryNotesParams, CHAIN_NOTE_SALT_BITS, CLEANUP_FEE_BUDGET, CLOAK_PRODUCTION_RELAY_URL, CLOAK_PROGRAM_ID, type ChainNoteTxType, type CircuitVerificationResult, type CleanupResult, type CloakConfig, CloakError, type CloakKeyPair, type CloakNote, type CloakRpc, type CommitmentEntry, type CommitmentsResponse, type CompactChainNote, type ComplianceReport, type ComplianceTxType, type ConfirmSettlementParams, type CreateRecoverableDepositUtxoParams, DEFAULT_CIRCUITS_URL, DEFAULT_TRANSACTION_CIRCUITS_URL, DELIVERY_MEMO_TAG, DELIVERY_REGISTRY_SEED, type DeliveredNote, DepositError, type DepositInstructionParams, type DepositNoteSecrets, type DepositOptions, type DepositOutcome, type DepositRef, type DepositResult, type DepositStatus, type DiscoverOptions, type DiscoverSwapRefundsOptions, type DiscoveredSwapRefund, DoNotRetry, ECONOMIC_MINIMUM, EXPECTED_CIRCUIT_HASHES, type EncodeNoteIndexPageParams, type EncryptedMetadataBundle, type EncryptedNote$1 as EncryptedNote, type ErrorCategory, type ExpandedSpendKey, type ExternalFeePayerAdapter, FEE_BUDGET, FIXED_FEE_LAMPORTS, type FundingPlan, type Groth16Proof, type IndexedRecoveredNote, type IndexedRecoveredNoteKind, InsecureRandomnessError, LAMPORTS_PER_SOL, type LegacyWalletAdapter, type WalletSigner as LegacyWalletSigner, LocalStorageAdapter, type LogLevel, type Logger, type LookupTable, MAINNET_RENT_0, MAINNET_RENT_1, MAX_RECEIVER_INDEX, MERKLE_TREE_HEIGHT, MIN_DEPOSIT_LAMPORTS, MIN_DEPOSIT_SPL_BASE_UNITS, type MasterKey, type MatchChangeNoteParams, type MatchDepositNoteParams, type MatchSwapRefundLeafParams, type MaxLengthArray, MemoryStorageAdapter, type MerkleProof, type MerkleRootResponse, MerkleTree, type MessageSigner, NATIVE_SOL_MINT, NOTE_INDEX_NO_LEAF, NOTE_INDEX_PAGE_SIZE, type Network, type NoteData, type NoteIndexCursor, type NoteIndexDeliveryItem, type NoteIndexFetchOptions, NoteIndexFormatError, type NoteIndexHead, NoteIndexHeadBehindError, type NoteIndexItem, type NoteIndexPage, type NoteIndexRecoveryStats, type NoteIndexSwapRefundItem, type NoteIndexTxItem, ONECLICK_PUBKEY_B58, type OnchainMerkleProof, type ParseNoteIndexPageOptions, type ParsedDeliveryCarrier, type PaymasterTopUpExpectation, type PaymasterTopUpResult, type PendingDeposit, type PendingWithdrawal, type PostFailureVerdict, RECIPIENT_DELIVERY_CIPHERTEXT_LEN, RECIPIENT_DELIVERY_EPHEMERAL_PK_LEN, RECIPIENT_DELIVERY_NONCE_LEN, RECIPIENT_DELIVERY_NOTE_BYTES, RECIPIENT_DELIVERY_PLAINTEXT_LEN, RECIPIENT_DELIVERY_TAG_LEN, RELAY_BATCH_AUTH_MAX_ITEMS, RELAY_ORIGIN_ALLOWLIST, REQUEST_AUTH_BATCH_DOMAIN, REQUEST_AUTH_BATCH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_FUTURE_SKEW_SECONDS, type RecipientDeliveryNote, type RecoverNotesFromIndexParams, type RecoverNotesFromIndexResult, type RecoveredChangeNote, type RecoveredChangeNoteRecord, type RecoveredDepositNote, type RecoveredDepositNoteRecord, type RecoveredSwapRefund, type RelayAuthMode, type RelayAuthPreimage, type RelayAuthSigner, RelayBatchAuthCoordinator, type RelayBatchAuthCoordinatorOptions, type RelayBatchAuthEnvelope, type RelayBatchAuthFields, type RelayBatchAuthItemHandle, RelayInternalError, RelayService, type RelaySubmissionResult, type RentRates, type RetryHooks, type RiskQuoteInstructionResponse, RootNotFoundError, SCANNER_SUPPORTS_TRANSACT_SWAP, SIGN_IN_MESSAGE, SanctionsQuoteError, type ScanOptions, type ScanRecipientDeliveryOptions, type ScanResult, type ScanSummary, type ScannedTransaction, type SettlementConnection, type SettlementContext, type SettlementStatus, type SettlementVerdict, SettlementVerificationError, ShieldPoolErrors, type ShieldPoolPDAs, SimpleWallet, type SpendKey, type SpendOptions, type StorageAdapter, type SubmitTransactToRelayArgs, type SwapOptions, type SwapParams, type SwapRefundAuthorization, type SwapResult, TERMINAL_FAILURE, TRANSACTION_CIRCUITS_VERSION, TRANSACT_AUTH_FIELDS, TRANSACT_SWAP_AUTH_FIELDS, type TransactBatchItem, type TransactBatchItemOutcome, type TransactBatchOptions, type TransactBatchResult, type TransactOptions, type TransactParams, type TransactRequestBodyParams, type TransactResult, TransactionConfirmationError, type TransactionMetadata, type Transfer, type TransferOptions, type TransferResult, type TxStatus, type UserFriendlyError, type Utxo, UtxoAlreadySpentError, type EncryptedNote as UtxoEncryptedNote, type UtxoKeypair, type UtxoSwapParams, type UtxoSwapResult, UtxoWallet, VARIABLE_FEE_DENOMINATOR, VARIABLE_FEE_NUMERATOR, VARIABLE_FEE_RATE, VERSION, type VerifyUtxosResult, type ViewKey, type ViewingKeyPair, WITHDRAW_FEE_BPS, WITHDRAW_FIXED_FEE, type WalletAdapterBridgeOptions, type WalletSigner$1 as WalletSigner, type WalletUtxo, type Web3Module, type WithdrawOptions, type WithdrawSubmissionResult, accountMeta, addressBytes, addressFromBytes, addressFromPublicKey, assertDirectSubmissionLanded, assertInputMints, assertTransactionCircuitIntegrity, assessBridgeQuote, bigintToBytes32$1 as bigintToBytes32, bigintToHex, buildAuthTransactionMessage, buildMerkleTree, buildMerkleTreeFromChain, buildMerkleTreeFromRelay, buildRecipientDeliveryNotes, buildRelayAuthPreimage, buildRelayBatchAuthMessage, buildTransactRequestBody, buildTransactionMessage, bytesToHex, calculateFee, calculateFeeBigint, calculateRelayFee, canRebuildMerkleTreeFromChain, canonicalJson, canonicalPayloadString, chainNoteFromBase64, chainNoteToBase64, classifyPostFailure, classifyRelayError, cleanupReceivingAddress, cleanupStalePendingOperations, clearPendingDeposits, clearPendingWithdrawals, cloakBridgeRail, computeChainNoteHash, computeExtDataHash, computeMerkleRoot, computeNoteIndexChain, computeProofForLatestDeposit, computeProofFromChain, computeSignature, computeSwapRefundCommitment, computeCommitment as computeUtxoCommitment, computeNullifier as computeUtxoNullifier, confirmSignature, confirmTransactSettlement, copyNoteToClipboard, createCloakError, createCloakRpc, createDepositInstruction, createLogger, createRecoverableChangeUtxo, createRecoverableDepositUtxo, createRelayBatchAuthCoordinator, createUtxo, createZeroUtxo, decryptCompactChainNote, decryptComplianceMetadataWithMasterKey, decryptTransactionMetadata, depositFromDerivedKey, deriveBridgeReceiver, deriveChangeNoteBlinding, deriveDepositNoteBlinding, deriveDiversifiedViewingKey, deriveDiversifier, deriveFundingTargets, deriveInputNullifierPdas, deriveLegacyBridgeReceiver, deriveLegacyDepositNoteSecrets, deriveLegacySwapRefundAuthorization, derivePublicKey, deriveSpendKey, deriveSwapRefundAuthorization, deriveSwapRefundBlinding, deriveUserCompliancePublicKey, deriveUserComplianceScalar, deriveUtxoKeypairFromSpendKey, deriveViewKey, deriveViewingKeyFromNk, deriveViewingKeyFromSpendKey, deriveViewingKeyFromUtxoPrivateKey, deserializeUtxo, detectNetworkFromRpcUrl, discoverSwapRefunds, downloadNote, encodeDeliveryCarrierMemo, encodeNoteIndexItem, encodeNoteIndexPage, encodeNoteSimple, encodeRecipientDeliveryNote, encryptCompactChainNote, encryptNoteForRecipient, encryptTransactionMetadata, encryptTransactionMetadataBundle, expandSpendKey, explainRelayAuthRejection, exportKeys, exportNote, exportWalletKeys, fetchAccountBytes, fetchCommitments, fetchLatestBlockhash, fetchLookupTables, fetchNoteIndexHead, fetchNoteIndexPage, fetchRiskQuoteInstruction, fetchRiskQuoteIx, fetchSignaturesForAddress, filterNotesByNetwork, filterWithdrawableNotes, findNoteByCommitment, findProgramAddress, formatAmount, formatComplianceCsv, formatErrorForLogging, formatSol, fullWithdraw, fundReceiverViaPaymaster, generateCloakKeys, generateCommitmentAsync, generateMasterSeed, generateNoteFromWallet, generateUtxoKeypair, generateViewingKeyPair, getAddressExplorerUrl, getChainNoteRegistryPDA, getCircuitsPath, getDeliveryRegistryPDA, getDistributableAmount, getExplorerUrl, getNkFromUtxoPrivateKey, getNullifierPDA, getPendingOperationsSummary, getPoolAuthorityConfigPDA, getPublicKey, getPublicViewKey, getRecipientAmount, getRpcUrlForNetwork, getShieldPoolPDAs, getSwapStatePDA, getViewKey, hasPendingOperations, hexToBigint$1 as hexToBigint, hexToBytes, importKeys, importWalletKeys, isBrowser, isBrowserLike, isDebugEnabled, isMessageSigner, isPlausibleSignature, isReactNative, isRootNotFoundError, isSubmissionOutcomeUnknownResponse, isTerminalFailure, isValidHex, isValidRpcUrl, isValidSolanaAddress, isWithdrawAmountSufficient, isWithdrawable, listBridgeDeposits, loadPendingDeposits, loadPendingWithdrawals, loadVerifiedCircuitArtifacts, matchChangeNote, matchDepositNote, matchSwapRefundLeaf, mayRetry, messageSignerFromCallback, openRecipientDeliveryNote, parseAmount, parseDeliveryCarrierMemo, parseError, parseNote, parseNoteIndexItem, parseNoteIndexPage, parseRelayErrorResponse, parseRelayErrorSignature, parseTransactionError, partialWithdraw, partiallySignTransaction, poseidonHash, preflightCheck, preflightNullifiers, prepareEncryptedOutput, prepareEncryptedOutputForRecipient, programInstruction, proofToBytes, pubkeyToFieldElement, pubkeyToLimbs, randomBytes, randomChangeNoteSalt, randomDepositNoteSalt, randomFieldElement, readMerkleTreeState, readRent, recipientDeliveryNoteToBase64, recoverNotesFromIndex, registerViewingKey, relayRequestDigestHex, removePendingDeposit, removePendingWithdrawal, renderAssessment, resolveCircuitsBase, retryDelayMs, savePendingDeposit, savePendingWithdrawal, scanNotesForWallet, scanRecipientDeliveryNotes, scanTransactions, sdkLogger, selectUtxos, sendInstructions, sendRawTransaction, sendTransaction, serializeAuthTransactionMessage, serializeNote, serializeUtxo, setCircuitsPath, setDebugMode, signCompiledTransaction, signMessageBytes, signRelayAuthPayload, signTransaction, signerFromKeypair, signerFromSecretKey, signerFromWalletAdapter, splitTo2Limbs, submitTransactToRelay, sumUtxoAmounts, swapUtxo, swapWithChange, toAddress, toComplianceReport, transact, transactBatch, transactionBase64, transactionBytes, transactionFromBytes, transactionWireSize, transfer, truncate, tryDecryptNote, updateNoteWithDeposit, updatePendingDeposit, updatePendingWithdrawal, bigintToBytes32 as utxoBigintToBytes32, utxoEquals, hexToBigint as utxoHexToBigint, validateDepositParams, validateNote, validateOutputsSum, validatePaymasterTopUpTransaction, validateRoot, validateTransfers, validateWalletConnected, validateWithdrawableNote, verifyAllCircuits, verifyCircuitIntegrity, verifyQuoteSignature, verifyUtxos, waitForRoot, withShieldRetries, withTiming, withdrawFeeFor };
|
|
6469
|
+
export { BRIDGE_ESCROW_LABEL, BRIDGE_ESCROW_LABEL_V2, BUILD_ALLOWS_LOCAL_ENDPOINTS, type BridgeDeliveryState, type BridgeDeposit, type BridgeDepositState, type BridgeQuoteAssessment, type BridgeQuoteInput, type BridgeRail, type BridgeRailAttestation, type BridgeRailProblem, type BridgeRailQuoteOption, type BridgeRailQuoteRequest, type BridgeRailQuoteResponse, type BridgeRailStatusResult, type BuildRecipientDeliveryNotesParams, CHAIN_NOTE_SALT_BITS, CLEANUP_FEE_BUDGET, CLOAK_PRODUCTION_RELAY_URL, CLOAK_PROGRAM_ID, type ChainNoteTxType, type CircuitVerificationResult, type CleanupResult, type CloakConfig, CloakError, type CloakKeyPair, type CloakNote, type CloakRpc, type CommitmentEntry, type CommitmentsResponse, type CompactChainNote, type ComplianceReport, type ComplianceTxType, type ConfirmSettlementParams, type CreateRecoverableDepositUtxoParams, DEFAULT_CIRCUITS_URL, DEFAULT_TRANSACTION_CIRCUITS_URL, DELIVERY_MEMO_TAG, DELIVERY_REGISTRY_SEED, type DeliveredNote, DepositError, type DepositInstructionParams, type DepositNoteSecrets, type DepositOptions, type DepositOutcome, type DepositRef, type DepositResult, type DepositStatus, type DiscoverOptions, type DiscoverSwapRefundsOptions, type DiscoveredSwapRefund, DoNotRetry, ECONOMIC_MINIMUM, EXPECTED_CIRCUIT_HASHES, type EncodeNoteIndexPageParams, type EncryptedMetadataBundle, type EncryptedNote$1 as EncryptedNote, type ErrorCategory, type ExpandedSpendKey, type ExternalFeePayerAdapter, FEE_BUDGET, FIXED_FEE_LAMPORTS, type FundingPlan, type Groth16Proof, type IndexedRecoveredNote, type IndexedRecoveredNoteKind, InsecureRandomnessError, LAMPORTS_PER_SOL, type LegacyWalletAdapter, type WalletSigner as LegacyWalletSigner, LocalStorageAdapter, type LogLevel, type Logger, type LookupTable, MAINNET_RENT_0, MAINNET_RENT_1, MAX_RECEIVER_INDEX, MERKLE_TREE_HEIGHT, MIN_DEPOSIT_LAMPORTS, MIN_DEPOSIT_SPL_BASE_UNITS, type MasterKey, type MatchChangeNoteParams, type MatchDepositNoteParams, type MatchSwapRefundLeafParams, type MaxLengthArray, MemoryStorageAdapter, type MerkleProof, type MerkleRootResponse, MerkleTree, type MessageSigner, NATIVE_SOL_MINT, NOTE_INDEX_NO_LEAF, NOTE_INDEX_PAGE_SIZE, type Network, type NoteData, type NoteIndexCursor, type NoteIndexDeliveryItem, type NoteIndexFetchOptions, NoteIndexFormatError, type NoteIndexHead, NoteIndexHeadBehindError, type NoteIndexItem, type NoteIndexPage, type NoteIndexRecoveryStats, type NoteIndexSwapRefundItem, type NoteIndexTxItem, ONECLICK_PUBKEY_B58, type OnchainMerkleProof, type ParseNoteIndexPageOptions, type ParsedDeliveryCarrier, type PaymasterTopUpExpectation, type PaymasterTopUpResult, type PendingDeposit, type PendingWithdrawal, type PostFailureVerdict, RECIPIENT_DELIVERY_CIPHERTEXT_LEN, RECIPIENT_DELIVERY_EPHEMERAL_PK_LEN, RECIPIENT_DELIVERY_NONCE_LEN, RECIPIENT_DELIVERY_NOTE_BYTES, RECIPIENT_DELIVERY_PLAINTEXT_LEN, RECIPIENT_DELIVERY_TAG_LEN, RELAY_BATCH_AUTH_MAX_ITEMS, RELAY_ORIGIN_ALLOWLIST, REQUEST_AUTH_BATCH_DOMAIN, REQUEST_AUTH_BATCH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_FUTURE_SKEW_SECONDS, type RecipientDeliveryNote, type RecoverNotesFromIndexParams, type RecoverNotesFromIndexResult, type RecoveredChangeNote, type RecoveredChangeNoteRecord, type RecoveredDepositNote, type RecoveredDepositNoteRecord, type RecoveredSwapRefund, type RelayAuthMode, type RelayAuthPreimage, type RelayAuthSigner, RelayBatchAuthCoordinator, type RelayBatchAuthCoordinatorOptions, type RelayBatchAuthEnvelope, type RelayBatchAuthFields, type RelayBatchAuthItemHandle, RelayInternalError, RelayService, type RelaySubmissionResult, type RentRates, type RetryHooks, type RiskQuoteInstructionResponse, RootNotFoundError, SCANNER_SUPPORTS_TRANSACT_SWAP, SIGN_IN_MESSAGE, SanctionsQuoteError, type ScanOptions, type ScanRecipientDeliveryOptions, type ScanResult, type ScanSummary, type ScannedTransaction, type SettlementConnection, type SettlementContext, type SettlementStatus, type SettlementVerdict, SettlementVerificationError, ShieldPoolErrors, type ShieldPoolPDAs, SimpleWallet, type SpendKey, type SpendOptions, type StorageAdapter, type SubmitTransactToRelayArgs, type SwapOptions, type SwapParams, type SwapRefundAuthorization, type SwapResult, TERMINAL_FAILURE, TRANSACTION_CIRCUITS_VERSION, TRANSACT_AUTH_FIELDS, TRANSACT_SWAP_AUTH_FIELDS, type TransactBatchItem, type TransactBatchItemOutcome, type TransactBatchOptions, type TransactBatchResult, type TransactOptions, type TransactParams, type TransactRequestBodyParams, type TransactResult, TransactionConfirmationError, type TransactionMetadata, type Transfer, type TransferOptions, type TransferResult, type TxStatus, type UserFriendlyError, type Utxo, UtxoAlreadySpentError, type EncryptedNote as UtxoEncryptedNote, type UtxoKeypair, type UtxoSwapParams, type UtxoSwapResult, UtxoWallet, VARIABLE_FEE_DENOMINATOR, VARIABLE_FEE_NUMERATOR, VARIABLE_FEE_RATE, VERSION, type VerifyUtxosResult, type ViewKey, type ViewingKeyPair, WITHDRAW_FEE_BPS, WITHDRAW_FIXED_FEE, type WalletAdapterBridgeOptions, type WalletSigner$1 as WalletSigner, type WalletUtxo, type Web3Module, type WithdrawOptions, type WithdrawSubmissionResult, accountMeta, addressBytes, addressFromBytes, addressFromPublicKey, assertDirectSubmissionLanded, assertInputMints, assertTransactionCircuitIntegrity, assessBridgeQuote, bigintToBytes32$1 as bigintToBytes32, bigintToHex, buildAuthTransactionMessage, buildMerkleTree, buildMerkleTreeFromChain, buildMerkleTreeFromRelay, buildRecipientDeliveryNotes, buildRelayAuthPreimage, buildRelayBatchAuthMessage, buildTransactRequestBody, buildTransactionMessage, bytesToHex, calculateFee, calculateFeeBigint, calculateRelayFee, canRebuildMerkleTreeFromChain, canonicalJson, canonicalPayloadString, chainNoteFromBase64, chainNoteToBase64, classifyPostFailure, classifyRelayError, cleanupReceivingAddress, cleanupStalePendingOperations, clearPendingDeposits, clearPendingWithdrawals, cloakBridgeRail, computeChainNoteHash, computeExtDataHash, computeMerkleRoot, computeNoteIndexChain, computeProofForLatestDeposit, computeProofFromChain, computeSignature, computeSwapRefundCommitment, computeCommitment as computeUtxoCommitment, computeNullifier as computeUtxoNullifier, confirmSignature, confirmTransactSettlement, copyNoteToClipboard, createCloakError, createCloakRpc, createDepositInstruction, createLogger, createRecoverableChangeUtxo, createRecoverableDepositUtxo, createRelayBatchAuthCoordinator, createUtxo, createZeroUtxo, decryptCompactChainNote, decryptComplianceMetadataWithMasterKey, decryptTransactionMetadata, depositFromDerivedKey, deriveBridgeReceiver, deriveChangeNoteBlinding, deriveDepositNoteBlinding, deriveDiversifiedViewingKey, deriveDiversifier, deriveFundingTargets, deriveInputNullifierPdas, deriveLegacyBridgeReceiver, deriveLegacyDepositNoteSecrets, deriveLegacySwapRefundAuthorization, derivePublicKey, deriveSpendKey, deriveSwapRefundAuthorization, deriveSwapRefundBlinding, deriveUserCompliancePublicKey, deriveUserComplianceScalar, deriveUtxoKeypairFromSpendKey, deriveViewKey, deriveViewingKeyFromNk, deriveViewingKeyFromSpendKey, deriveViewingKeyFromUtxoPrivateKey, deserializeUtxo, detectNetworkFromRpcUrl, discoverSwapRefunds, downloadNote, encodeDeliveryCarrierMemo, encodeNoteIndexItem, encodeNoteIndexPage, encodeNoteSimple, encodeRecipientDeliveryNote, encryptCompactChainNote, encryptNoteForRecipient, encryptTransactionMetadata, encryptTransactionMetadataBundle, expandSpendKey, explainRelayAuthRejection, exportKeys, exportNote, exportWalletKeys, fetchAccountBytes, fetchCommitments, fetchLatestBlockhash, fetchLookupTables, fetchNoteIndexHead, fetchNoteIndexPage, fetchRiskQuoteInstruction, fetchRiskQuoteIx, fetchSignaturesForAddress, filterNotesByNetwork, filterWithdrawableNotes, findNoteByCommitment, findProgramAddress, formatAmount, formatComplianceCsv, formatErrorForLogging, formatSol, fullWithdraw, fundReceiverViaPaymaster, generateCloakKeys, generateCommitmentAsync, generateMasterSeed, generateNoteFromWallet, generateUtxoKeypair, generateViewingKeyPair, getAddressExplorerUrl, getChainNoteRegistryPDA, getCircuitsPath, getDeliveryRegistryPDA, getDistributableAmount, getExplorerUrl, getNkFromUtxoPrivateKey, getNullifierPDA, getPendingOperationsSummary, getPoolAuthorityConfigPDA, getPublicKey, getPublicViewKey, getRecipientAmount, getRpcUrlForNetwork, getShieldPoolPDAs, getSwapStatePDA, getViewKey, hasPendingOperations, hexToBigint$1 as hexToBigint, hexToBytes, importKeys, importWalletKeys, isBrowser, isBrowserLike, isDebugEnabled, isMessageSigner, isPlausibleSignature, isReactNative, isRootNotFoundError, isSubmissionOutcomeUnknownResponse, isTerminalFailure, isValidHex, isValidRelayClientId, isValidRpcUrl, isValidSolanaAddress, isWithdrawAmountSufficient, isWithdrawable, listBridgeDeposits, loadPendingDeposits, loadPendingWithdrawals, loadVerifiedCircuitArtifacts, matchChangeNote, matchDepositNote, matchSwapRefundLeaf, mayRetry, messageSignerFromCallback, normalizeAffiliateCode, openRecipientDeliveryNote, parseAmount, parseDeliveryCarrierMemo, parseError, parseNote, parseNoteIndexItem, parseNoteIndexPage, parseRelayErrorResponse, parseRelayErrorSignature, parseTransactionError, partialWithdraw, partiallySignTransaction, poseidonHash, preflightCheck, preflightNullifiers, prepareEncryptedOutput, prepareEncryptedOutputForRecipient, programInstruction, proofToBytes, pubkeyToFieldElement, pubkeyToLimbs, randomBytes, randomChangeNoteSalt, randomDepositNoteSalt, randomFieldElement, readMerkleTreeState, readRent, recipientDeliveryNoteToBase64, recoverNotesFromIndex, registerViewingKey, relayRequestDigestHex, removePendingDeposit, removePendingWithdrawal, renderAssessment, resolveCircuitsBase, retryDelayMs, savePendingDeposit, savePendingWithdrawal, scanNotesForWallet, scanRecipientDeliveryNotes, scanTransactions, sdkLogger, selectUtxos, sendInstructions, sendRawTransaction, sendTransaction, serializeAuthTransactionMessage, serializeNote, serializeUtxo, setCircuitsPath, setDebugMode, signCompiledTransaction, signMessageBytes, signRelayAuthPayload, signTransaction, signerFromKeypair, signerFromSecretKey, signerFromWalletAdapter, splitTo2Limbs, submitTransactToRelay, sumUtxoAmounts, swapUtxo, swapWithChange, toAddress, toComplianceReport, transact, transactBatch, transactionBase64, transactionBytes, transactionFromBytes, transactionWireSize, transfer, truncate, tryDecryptNote, updateNoteWithDeposit, updatePendingDeposit, updatePendingWithdrawal, bigintToBytes32 as utxoBigintToBytes32, utxoEquals, hexToBigint as utxoHexToBigint, validateDepositParams, validateNote, validateOutputsSum, validatePaymasterTopUpTransaction, validateRoot, validateTransfers, validateWalletConnected, validateWithdrawableNote, verifyAllCircuits, verifyCircuitIntegrity, verifyQuoteSignature, verifyUtxos, waitForRoot, withShieldRetries, withTiming, withdrawFeeFor };
|
package/dist/index.d.ts
CHANGED
|
@@ -3589,18 +3589,43 @@ interface TransactOptions {
|
|
|
3589
3589
|
*/
|
|
3590
3590
|
relayAuthBatch?: RelayBatchAuthItemHandle;
|
|
3591
3591
|
/**
|
|
3592
|
-
*
|
|
3592
|
+
* Partner (affiliate) code attached to fee-bearing relay requests (SDK-001).
|
|
3593
3593
|
*
|
|
3594
|
-
*
|
|
3595
|
-
*
|
|
3596
|
-
* (
|
|
3597
|
-
*
|
|
3594
|
+
* Normalised once at the flow boundary (trimmed, lower-cased; see {@link normalizeAffiliateCode}),
|
|
3595
|
+
* then sent as `affiliate_code` and signed inside the relay request, only when it is valid
|
|
3596
|
+
* (`^[a-z0-9_]{3,24}$`) AND the request is fee-bearing: a withdrawal / send to a public address
|
|
3597
|
+
* (`externalAmount < 0` with a recipient) or a swap intake. Deposits, shield-to-shield sends and
|
|
3598
|
+
* the internal merge steps of `partialWithdraw` never carry it, whatever is passed here. A code
|
|
3599
|
+
* that is still invalid after normalising is left out and reported through {@link onWarning};
|
|
3600
|
+
* it never fails the withdrawal or swap. Omitted, every request is byte-identical to one built
|
|
3598
3601
|
* without this option (INV-007). Requires a relay that accepts `affiliate_code`.
|
|
3599
3602
|
*
|
|
3600
|
-
*
|
|
3601
|
-
*
|
|
3603
|
+
* `partialWithdraw`, `fullWithdraw`, `swapUtxo`, `swapWithChange` and `transactBatch` all pass it
|
|
3604
|
+
* down: in a batch one code applies to every fee-bearing item (a per-item `options.affiliateCode`
|
|
3605
|
+
* overrides it).
|
|
3606
|
+
*
|
|
3607
|
+
* @internal For Cloak's own web and mobile apps (spec SDK-001, NG-02, NG-10). Not part of the
|
|
3608
|
+
* public API, not documented, and may change without notice.
|
|
3602
3609
|
*/
|
|
3603
3610
|
affiliateCode?: string;
|
|
3611
|
+
/**
|
|
3612
|
+
* Called with a human-readable message when the SDK adjusts or drops something instead of
|
|
3613
|
+
* failing: today, an `affiliateCode` or `relayClientId` that is not valid. Optional; the flow
|
|
3614
|
+
* behaves the same without it.
|
|
3615
|
+
*/
|
|
3616
|
+
onWarning?: (message: string) => void;
|
|
3617
|
+
/**
|
|
3618
|
+
* Identifies a non-browser client to the relay by sending `X-Cloak-Client: <value>` with
|
|
3619
|
+
* `/transact` and `/transact_swap`. The relay only counts affiliate events from an allowed
|
|
3620
|
+
* browser Origin or from a client id of the exact form `cloak-mobile/(ios|android)/N.N.N`, so
|
|
3621
|
+
* Cloak's own mobile app sets this, e.g. `"cloak-mobile/ios/1.4.0"`. A malformed value is left
|
|
3622
|
+
* out and reported through {@link onWarning}; it never fails the request (INV-006). Browser
|
|
3623
|
+
* callers should leave it unset: a non-safelisted header turns every submission into a CORS
|
|
3624
|
+
* preflight. Wins over a `relayHeaders` entry of the same name.
|
|
3625
|
+
*
|
|
3626
|
+
* @internal For Cloak's own mobile app (spec REL-016, NG-02). Not part of the public API.
|
|
3627
|
+
*/
|
|
3628
|
+
relayClientId?: string;
|
|
3604
3629
|
/**
|
|
3605
3630
|
* Extra HTTP headers sent with this flow's relay submissions (`POST /transact` and
|
|
3606
3631
|
* `POST /transact_swap`), e.g. `{ "X-Cloak-Client": "cloak-mobile/ios/1.4.0" }` (SDK-004).
|
|
@@ -3792,7 +3817,7 @@ interface SubmitTransactToRelayArgs {
|
|
|
3792
3817
|
* builds its own request must `await preflightNullifiers(inputUtxos, connection, programId)` first.
|
|
3793
3818
|
*/
|
|
3794
3819
|
declare function submitTransactToRelay(args: SubmitTransactToRelayArgs): Promise<RelaySubmissionResult>;
|
|
3795
|
-
declare function transact(params: TransactParams,
|
|
3820
|
+
declare function transact(params: TransactParams, rawOptions: TransactOptions): Promise<TransactResult>;
|
|
3796
3821
|
/**
|
|
3797
3822
|
* Execute a shield-to-shield transfer
|
|
3798
3823
|
*
|
|
@@ -3808,7 +3833,7 @@ declare function transact(params: TransactParams, options: TransactOptions): Pro
|
|
|
3808
3833
|
* @param amount Amount to transfer
|
|
3809
3834
|
* @param options Transaction options, including the mandatory `ownerUtxoKeypair`
|
|
3810
3835
|
*/
|
|
3811
|
-
declare function transfer(inputUtxos: Utxo[], recipientPubkey: bigint, amount: bigint,
|
|
3836
|
+
declare function transfer(inputUtxos: Utxo[], recipientPubkey: bigint, amount: bigint, rawOptions: SpendOptions): Promise<TransactResult>;
|
|
3812
3837
|
/**
|
|
3813
3838
|
* Execute a partial withdrawal
|
|
3814
3839
|
*
|
|
@@ -3823,7 +3848,7 @@ declare function transfer(inputUtxos: Utxo[], recipientPubkey: bigint, amount: b
|
|
|
3823
3848
|
* @param withdrawAmount Amount to withdraw
|
|
3824
3849
|
* @param options Transaction options, including the mandatory `ownerUtxoKeypair`
|
|
3825
3850
|
*/
|
|
3826
|
-
declare function partialWithdraw(inputUtxos: Utxo[], recipient: Address, withdrawAmount: bigint,
|
|
3851
|
+
declare function partialWithdraw(inputUtxos: Utxo[], recipient: Address, withdrawAmount: bigint, rawOptions: SpendOptions): Promise<TransactResult>;
|
|
3827
3852
|
/**
|
|
3828
3853
|
* Execute a full withdrawal
|
|
3829
3854
|
*
|
|
@@ -3894,7 +3919,7 @@ interface UtxoSwapResult extends TransactResult {
|
|
|
3894
3919
|
* @param options Transaction options
|
|
3895
3920
|
* @returns UtxoSwapResult with SwapState PDA for executing the swap
|
|
3896
3921
|
*/
|
|
3897
|
-
declare function swapUtxo(params: UtxoSwapParams,
|
|
3922
|
+
declare function swapUtxo(params: UtxoSwapParams, rawOptions: SpendOptions): Promise<UtxoSwapResult>;
|
|
3898
3923
|
/**
|
|
3899
3924
|
* Execute a swap with change
|
|
3900
3925
|
*
|
|
@@ -3907,7 +3932,7 @@ declare function swapUtxo(params: UtxoSwapParams, options: SpendOptions): Promis
|
|
|
3907
3932
|
* @param minOutputAmount Minimum output (slippage protection)
|
|
3908
3933
|
* @param options Transaction options
|
|
3909
3934
|
*/
|
|
3910
|
-
declare function swapWithChange(inputUtxos: Utxo[], swapAmount: bigint, outputMint: Address, recipientAta: Address, minOutputAmount: bigint,
|
|
3935
|
+
declare function swapWithChange(inputUtxos: Utxo[], swapAmount: bigint, outputMint: Address, recipientAta: Address, minOutputAmount: bigint, rawOptions: SpendOptions, recipientWallet?: Address): Promise<UtxoSwapResult>;
|
|
3911
3936
|
|
|
3912
3937
|
/**
|
|
3913
3938
|
* Circuit artifact loading and integrity verification.
|
|
@@ -4206,6 +4231,21 @@ declare function cleanupStalePendingOperations(maxAgeMs?: number): {
|
|
|
4206
4231
|
removedWithdrawals: number;
|
|
4207
4232
|
};
|
|
4208
4233
|
|
|
4234
|
+
/**
|
|
4235
|
+
* Normalise a partner code the way the relay expects it: trimmed and lower-cased. Returns `null`
|
|
4236
|
+
* when the result is still not a valid code (or the input is not a string), so apps can validate a
|
|
4237
|
+
* field before they ever call the SDK.
|
|
4238
|
+
*
|
|
4239
|
+
* @internal For Cloak's own web and mobile apps (spec NG-10). Not part of the public API.
|
|
4240
|
+
*/
|
|
4241
|
+
declare function normalizeAffiliateCode(raw: unknown): string | null;
|
|
4242
|
+
/**
|
|
4243
|
+
* Whether `value` is a well-formed `X-Cloak-Client` value, e.g. `cloak-mobile/ios/1.4.0`.
|
|
4244
|
+
*
|
|
4245
|
+
* @internal For Cloak's own mobile app (spec REL-016). Not part of the public API.
|
|
4246
|
+
*/
|
|
4247
|
+
declare function isValidRelayClientId(value: unknown): value is string;
|
|
4248
|
+
|
|
4209
4249
|
interface TransactBatchItem {
|
|
4210
4250
|
params: TransactParams;
|
|
4211
4251
|
/** Per-item overrides (recipient viewing key, chain-note salt, expected mint, ...). */
|
|
@@ -4230,7 +4270,14 @@ interface TransactBatchResult {
|
|
|
4230
4270
|
/** Wallet approvals raised: 1 for the batch, plus 1 per wave of stale-root re-proves. */
|
|
4231
4271
|
approvals: number;
|
|
4232
4272
|
}
|
|
4233
|
-
|
|
4273
|
+
/**
|
|
4274
|
+
* Partner code semantics: `options.affiliateCode` (and `relayClientId`) apply to every item, and
|
|
4275
|
+
* each item decides for itself whether it is fee-bearing. A withdrawal with a recipient carries the
|
|
4276
|
+
* code; a shield-to-shield send, a deposit or a consolidation step charges no variable fee and
|
|
4277
|
+
* never does. An item may set its own `options.affiliateCode` to override the batch's. The code is
|
|
4278
|
+
* normalised, and an invalid one reported through `onWarning`, once for the whole batch.
|
|
4279
|
+
*/
|
|
4280
|
+
declare function transactBatch(items: readonly TransactBatchItem[], rawOptions: TransactBatchOptions): Promise<TransactBatchResult>;
|
|
4234
4281
|
|
|
4235
4282
|
/**
|
|
4236
4283
|
* Recipient-addressed delivery envelope (CLKD1).
|
|
@@ -6415,8 +6462,8 @@ declare function withShieldRetries<T>(attempt: (attemptNo: number) => Promise<T>
|
|
|
6415
6462
|
* @packageDocumentation
|
|
6416
6463
|
*/
|
|
6417
6464
|
|
|
6418
|
-
declare const VERSION = "0.2.
|
|
6465
|
+
declare const VERSION = "0.2.7";
|
|
6419
6466
|
/** True when scanner supports TransactSwap (tag 1). Check this to verify the correct SDK bundle is loaded. */
|
|
6420
6467
|
declare const SCANNER_SUPPORTS_TRANSACT_SWAP = true;
|
|
6421
6468
|
|
|
6422
|
-
export { BRIDGE_ESCROW_LABEL, BRIDGE_ESCROW_LABEL_V2, BUILD_ALLOWS_LOCAL_ENDPOINTS, type BridgeDeliveryState, type BridgeDeposit, type BridgeDepositState, type BridgeQuoteAssessment, type BridgeQuoteInput, type BridgeRail, type BridgeRailAttestation, type BridgeRailProblem, type BridgeRailQuoteOption, type BridgeRailQuoteRequest, type BridgeRailQuoteResponse, type BridgeRailStatusResult, type BuildRecipientDeliveryNotesParams, CHAIN_NOTE_SALT_BITS, CLEANUP_FEE_BUDGET, CLOAK_PRODUCTION_RELAY_URL, CLOAK_PROGRAM_ID, type ChainNoteTxType, type CircuitVerificationResult, type CleanupResult, type CloakConfig, CloakError, type CloakKeyPair, type CloakNote, type CloakRpc, type CommitmentEntry, type CommitmentsResponse, type CompactChainNote, type ComplianceReport, type ComplianceTxType, type ConfirmSettlementParams, type CreateRecoverableDepositUtxoParams, DEFAULT_CIRCUITS_URL, DEFAULT_TRANSACTION_CIRCUITS_URL, DELIVERY_MEMO_TAG, DELIVERY_REGISTRY_SEED, type DeliveredNote, DepositError, type DepositInstructionParams, type DepositNoteSecrets, type DepositOptions, type DepositOutcome, type DepositRef, type DepositResult, type DepositStatus, type DiscoverOptions, type DiscoverSwapRefundsOptions, type DiscoveredSwapRefund, DoNotRetry, ECONOMIC_MINIMUM, EXPECTED_CIRCUIT_HASHES, type EncodeNoteIndexPageParams, type EncryptedMetadataBundle, type EncryptedNote$1 as EncryptedNote, type ErrorCategory, type ExpandedSpendKey, type ExternalFeePayerAdapter, FEE_BUDGET, FIXED_FEE_LAMPORTS, type FundingPlan, type Groth16Proof, type IndexedRecoveredNote, type IndexedRecoveredNoteKind, InsecureRandomnessError, LAMPORTS_PER_SOL, type LegacyWalletAdapter, type WalletSigner as LegacyWalletSigner, LocalStorageAdapter, type LogLevel, type Logger, type LookupTable, MAINNET_RENT_0, MAINNET_RENT_1, MAX_RECEIVER_INDEX, MERKLE_TREE_HEIGHT, MIN_DEPOSIT_LAMPORTS, MIN_DEPOSIT_SPL_BASE_UNITS, type MasterKey, type MatchChangeNoteParams, type MatchDepositNoteParams, type MatchSwapRefundLeafParams, type MaxLengthArray, MemoryStorageAdapter, type MerkleProof, type MerkleRootResponse, MerkleTree, type MessageSigner, NATIVE_SOL_MINT, NOTE_INDEX_NO_LEAF, NOTE_INDEX_PAGE_SIZE, type Network, type NoteData, type NoteIndexCursor, type NoteIndexDeliveryItem, type NoteIndexFetchOptions, NoteIndexFormatError, type NoteIndexHead, NoteIndexHeadBehindError, type NoteIndexItem, type NoteIndexPage, type NoteIndexRecoveryStats, type NoteIndexSwapRefundItem, type NoteIndexTxItem, ONECLICK_PUBKEY_B58, type OnchainMerkleProof, type ParseNoteIndexPageOptions, type ParsedDeliveryCarrier, type PaymasterTopUpExpectation, type PaymasterTopUpResult, type PendingDeposit, type PendingWithdrawal, type PostFailureVerdict, RECIPIENT_DELIVERY_CIPHERTEXT_LEN, RECIPIENT_DELIVERY_EPHEMERAL_PK_LEN, RECIPIENT_DELIVERY_NONCE_LEN, RECIPIENT_DELIVERY_NOTE_BYTES, RECIPIENT_DELIVERY_PLAINTEXT_LEN, RECIPIENT_DELIVERY_TAG_LEN, RELAY_BATCH_AUTH_MAX_ITEMS, RELAY_ORIGIN_ALLOWLIST, REQUEST_AUTH_BATCH_DOMAIN, REQUEST_AUTH_BATCH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_FUTURE_SKEW_SECONDS, type RecipientDeliveryNote, type RecoverNotesFromIndexParams, type RecoverNotesFromIndexResult, type RecoveredChangeNote, type RecoveredChangeNoteRecord, type RecoveredDepositNote, type RecoveredDepositNoteRecord, type RecoveredSwapRefund, type RelayAuthMode, type RelayAuthPreimage, type RelayAuthSigner, RelayBatchAuthCoordinator, type RelayBatchAuthCoordinatorOptions, type RelayBatchAuthEnvelope, type RelayBatchAuthFields, type RelayBatchAuthItemHandle, RelayInternalError, RelayService, type RelaySubmissionResult, type RentRates, type RetryHooks, type RiskQuoteInstructionResponse, RootNotFoundError, SCANNER_SUPPORTS_TRANSACT_SWAP, SIGN_IN_MESSAGE, SanctionsQuoteError, type ScanOptions, type ScanRecipientDeliveryOptions, type ScanResult, type ScanSummary, type ScannedTransaction, type SettlementConnection, type SettlementContext, type SettlementStatus, type SettlementVerdict, SettlementVerificationError, ShieldPoolErrors, type ShieldPoolPDAs, SimpleWallet, type SpendKey, type SpendOptions, type StorageAdapter, type SubmitTransactToRelayArgs, type SwapOptions, type SwapParams, type SwapRefundAuthorization, type SwapResult, TERMINAL_FAILURE, TRANSACTION_CIRCUITS_VERSION, TRANSACT_AUTH_FIELDS, TRANSACT_SWAP_AUTH_FIELDS, type TransactBatchItem, type TransactBatchItemOutcome, type TransactBatchOptions, type TransactBatchResult, type TransactOptions, type TransactParams, type TransactRequestBodyParams, type TransactResult, TransactionConfirmationError, type TransactionMetadata, type Transfer, type TransferOptions, type TransferResult, type TxStatus, type UserFriendlyError, type Utxo, UtxoAlreadySpentError, type EncryptedNote as UtxoEncryptedNote, type UtxoKeypair, type UtxoSwapParams, type UtxoSwapResult, UtxoWallet, VARIABLE_FEE_DENOMINATOR, VARIABLE_FEE_NUMERATOR, VARIABLE_FEE_RATE, VERSION, type VerifyUtxosResult, type ViewKey, type ViewingKeyPair, WITHDRAW_FEE_BPS, WITHDRAW_FIXED_FEE, type WalletAdapterBridgeOptions, type WalletSigner$1 as WalletSigner, type WalletUtxo, type Web3Module, type WithdrawOptions, type WithdrawSubmissionResult, accountMeta, addressBytes, addressFromBytes, addressFromPublicKey, assertDirectSubmissionLanded, assertInputMints, assertTransactionCircuitIntegrity, assessBridgeQuote, bigintToBytes32$1 as bigintToBytes32, bigintToHex, buildAuthTransactionMessage, buildMerkleTree, buildMerkleTreeFromChain, buildMerkleTreeFromRelay, buildRecipientDeliveryNotes, buildRelayAuthPreimage, buildRelayBatchAuthMessage, buildTransactRequestBody, buildTransactionMessage, bytesToHex, calculateFee, calculateFeeBigint, calculateRelayFee, canRebuildMerkleTreeFromChain, canonicalJson, canonicalPayloadString, chainNoteFromBase64, chainNoteToBase64, classifyPostFailure, classifyRelayError, cleanupReceivingAddress, cleanupStalePendingOperations, clearPendingDeposits, clearPendingWithdrawals, cloakBridgeRail, computeChainNoteHash, computeExtDataHash, computeMerkleRoot, computeNoteIndexChain, computeProofForLatestDeposit, computeProofFromChain, computeSignature, computeSwapRefundCommitment, computeCommitment as computeUtxoCommitment, computeNullifier as computeUtxoNullifier, confirmSignature, confirmTransactSettlement, copyNoteToClipboard, createCloakError, createCloakRpc, createDepositInstruction, createLogger, createRecoverableChangeUtxo, createRecoverableDepositUtxo, createRelayBatchAuthCoordinator, createUtxo, createZeroUtxo, decryptCompactChainNote, decryptComplianceMetadataWithMasterKey, decryptTransactionMetadata, depositFromDerivedKey, deriveBridgeReceiver, deriveChangeNoteBlinding, deriveDepositNoteBlinding, deriveDiversifiedViewingKey, deriveDiversifier, deriveFundingTargets, deriveInputNullifierPdas, deriveLegacyBridgeReceiver, deriveLegacyDepositNoteSecrets, deriveLegacySwapRefundAuthorization, derivePublicKey, deriveSpendKey, deriveSwapRefundAuthorization, deriveSwapRefundBlinding, deriveUserCompliancePublicKey, deriveUserComplianceScalar, deriveUtxoKeypairFromSpendKey, deriveViewKey, deriveViewingKeyFromNk, deriveViewingKeyFromSpendKey, deriveViewingKeyFromUtxoPrivateKey, deserializeUtxo, detectNetworkFromRpcUrl, discoverSwapRefunds, downloadNote, encodeDeliveryCarrierMemo, encodeNoteIndexItem, encodeNoteIndexPage, encodeNoteSimple, encodeRecipientDeliveryNote, encryptCompactChainNote, encryptNoteForRecipient, encryptTransactionMetadata, encryptTransactionMetadataBundle, expandSpendKey, explainRelayAuthRejection, exportKeys, exportNote, exportWalletKeys, fetchAccountBytes, fetchCommitments, fetchLatestBlockhash, fetchLookupTables, fetchNoteIndexHead, fetchNoteIndexPage, fetchRiskQuoteInstruction, fetchRiskQuoteIx, fetchSignaturesForAddress, filterNotesByNetwork, filterWithdrawableNotes, findNoteByCommitment, findProgramAddress, formatAmount, formatComplianceCsv, formatErrorForLogging, formatSol, fullWithdraw, fundReceiverViaPaymaster, generateCloakKeys, generateCommitmentAsync, generateMasterSeed, generateNoteFromWallet, generateUtxoKeypair, generateViewingKeyPair, getAddressExplorerUrl, getChainNoteRegistryPDA, getCircuitsPath, getDeliveryRegistryPDA, getDistributableAmount, getExplorerUrl, getNkFromUtxoPrivateKey, getNullifierPDA, getPendingOperationsSummary, getPoolAuthorityConfigPDA, getPublicKey, getPublicViewKey, getRecipientAmount, getRpcUrlForNetwork, getShieldPoolPDAs, getSwapStatePDA, getViewKey, hasPendingOperations, hexToBigint$1 as hexToBigint, hexToBytes, importKeys, importWalletKeys, isBrowser, isBrowserLike, isDebugEnabled, isMessageSigner, isPlausibleSignature, isReactNative, isRootNotFoundError, isSubmissionOutcomeUnknownResponse, isTerminalFailure, isValidHex, isValidRpcUrl, isValidSolanaAddress, isWithdrawAmountSufficient, isWithdrawable, listBridgeDeposits, loadPendingDeposits, loadPendingWithdrawals, loadVerifiedCircuitArtifacts, matchChangeNote, matchDepositNote, matchSwapRefundLeaf, mayRetry, messageSignerFromCallback, openRecipientDeliveryNote, parseAmount, parseDeliveryCarrierMemo, parseError, parseNote, parseNoteIndexItem, parseNoteIndexPage, parseRelayErrorResponse, parseRelayErrorSignature, parseTransactionError, partialWithdraw, partiallySignTransaction, poseidonHash, preflightCheck, preflightNullifiers, prepareEncryptedOutput, prepareEncryptedOutputForRecipient, programInstruction, proofToBytes, pubkeyToFieldElement, pubkeyToLimbs, randomBytes, randomChangeNoteSalt, randomDepositNoteSalt, randomFieldElement, readMerkleTreeState, readRent, recipientDeliveryNoteToBase64, recoverNotesFromIndex, registerViewingKey, relayRequestDigestHex, removePendingDeposit, removePendingWithdrawal, renderAssessment, resolveCircuitsBase, retryDelayMs, savePendingDeposit, savePendingWithdrawal, scanNotesForWallet, scanRecipientDeliveryNotes, scanTransactions, sdkLogger, selectUtxos, sendInstructions, sendRawTransaction, sendTransaction, serializeAuthTransactionMessage, serializeNote, serializeUtxo, setCircuitsPath, setDebugMode, signCompiledTransaction, signMessageBytes, signRelayAuthPayload, signTransaction, signerFromKeypair, signerFromSecretKey, signerFromWalletAdapter, splitTo2Limbs, submitTransactToRelay, sumUtxoAmounts, swapUtxo, swapWithChange, toAddress, toComplianceReport, transact, transactBatch, transactionBase64, transactionBytes, transactionFromBytes, transactionWireSize, transfer, truncate, tryDecryptNote, updateNoteWithDeposit, updatePendingDeposit, updatePendingWithdrawal, bigintToBytes32 as utxoBigintToBytes32, utxoEquals, hexToBigint as utxoHexToBigint, validateDepositParams, validateNote, validateOutputsSum, validatePaymasterTopUpTransaction, validateRoot, validateTransfers, validateWalletConnected, validateWithdrawableNote, verifyAllCircuits, verifyCircuitIntegrity, verifyQuoteSignature, verifyUtxos, waitForRoot, withShieldRetries, withTiming, withdrawFeeFor };
|
|
6469
|
+
export { BRIDGE_ESCROW_LABEL, BRIDGE_ESCROW_LABEL_V2, BUILD_ALLOWS_LOCAL_ENDPOINTS, type BridgeDeliveryState, type BridgeDeposit, type BridgeDepositState, type BridgeQuoteAssessment, type BridgeQuoteInput, type BridgeRail, type BridgeRailAttestation, type BridgeRailProblem, type BridgeRailQuoteOption, type BridgeRailQuoteRequest, type BridgeRailQuoteResponse, type BridgeRailStatusResult, type BuildRecipientDeliveryNotesParams, CHAIN_NOTE_SALT_BITS, CLEANUP_FEE_BUDGET, CLOAK_PRODUCTION_RELAY_URL, CLOAK_PROGRAM_ID, type ChainNoteTxType, type CircuitVerificationResult, type CleanupResult, type CloakConfig, CloakError, type CloakKeyPair, type CloakNote, type CloakRpc, type CommitmentEntry, type CommitmentsResponse, type CompactChainNote, type ComplianceReport, type ComplianceTxType, type ConfirmSettlementParams, type CreateRecoverableDepositUtxoParams, DEFAULT_CIRCUITS_URL, DEFAULT_TRANSACTION_CIRCUITS_URL, DELIVERY_MEMO_TAG, DELIVERY_REGISTRY_SEED, type DeliveredNote, DepositError, type DepositInstructionParams, type DepositNoteSecrets, type DepositOptions, type DepositOutcome, type DepositRef, type DepositResult, type DepositStatus, type DiscoverOptions, type DiscoverSwapRefundsOptions, type DiscoveredSwapRefund, DoNotRetry, ECONOMIC_MINIMUM, EXPECTED_CIRCUIT_HASHES, type EncodeNoteIndexPageParams, type EncryptedMetadataBundle, type EncryptedNote$1 as EncryptedNote, type ErrorCategory, type ExpandedSpendKey, type ExternalFeePayerAdapter, FEE_BUDGET, FIXED_FEE_LAMPORTS, type FundingPlan, type Groth16Proof, type IndexedRecoveredNote, type IndexedRecoveredNoteKind, InsecureRandomnessError, LAMPORTS_PER_SOL, type LegacyWalletAdapter, type WalletSigner as LegacyWalletSigner, LocalStorageAdapter, type LogLevel, type Logger, type LookupTable, MAINNET_RENT_0, MAINNET_RENT_1, MAX_RECEIVER_INDEX, MERKLE_TREE_HEIGHT, MIN_DEPOSIT_LAMPORTS, MIN_DEPOSIT_SPL_BASE_UNITS, type MasterKey, type MatchChangeNoteParams, type MatchDepositNoteParams, type MatchSwapRefundLeafParams, type MaxLengthArray, MemoryStorageAdapter, type MerkleProof, type MerkleRootResponse, MerkleTree, type MessageSigner, NATIVE_SOL_MINT, NOTE_INDEX_NO_LEAF, NOTE_INDEX_PAGE_SIZE, type Network, type NoteData, type NoteIndexCursor, type NoteIndexDeliveryItem, type NoteIndexFetchOptions, NoteIndexFormatError, type NoteIndexHead, NoteIndexHeadBehindError, type NoteIndexItem, type NoteIndexPage, type NoteIndexRecoveryStats, type NoteIndexSwapRefundItem, type NoteIndexTxItem, ONECLICK_PUBKEY_B58, type OnchainMerkleProof, type ParseNoteIndexPageOptions, type ParsedDeliveryCarrier, type PaymasterTopUpExpectation, type PaymasterTopUpResult, type PendingDeposit, type PendingWithdrawal, type PostFailureVerdict, RECIPIENT_DELIVERY_CIPHERTEXT_LEN, RECIPIENT_DELIVERY_EPHEMERAL_PK_LEN, RECIPIENT_DELIVERY_NONCE_LEN, RECIPIENT_DELIVERY_NOTE_BYTES, RECIPIENT_DELIVERY_PLAINTEXT_LEN, RECIPIENT_DELIVERY_TAG_LEN, RELAY_BATCH_AUTH_MAX_ITEMS, RELAY_ORIGIN_ALLOWLIST, REQUEST_AUTH_BATCH_DOMAIN, REQUEST_AUTH_BATCH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_FUTURE_SKEW_SECONDS, type RecipientDeliveryNote, type RecoverNotesFromIndexParams, type RecoverNotesFromIndexResult, type RecoveredChangeNote, type RecoveredChangeNoteRecord, type RecoveredDepositNote, type RecoveredDepositNoteRecord, type RecoveredSwapRefund, type RelayAuthMode, type RelayAuthPreimage, type RelayAuthSigner, RelayBatchAuthCoordinator, type RelayBatchAuthCoordinatorOptions, type RelayBatchAuthEnvelope, type RelayBatchAuthFields, type RelayBatchAuthItemHandle, RelayInternalError, RelayService, type RelaySubmissionResult, type RentRates, type RetryHooks, type RiskQuoteInstructionResponse, RootNotFoundError, SCANNER_SUPPORTS_TRANSACT_SWAP, SIGN_IN_MESSAGE, SanctionsQuoteError, type ScanOptions, type ScanRecipientDeliveryOptions, type ScanResult, type ScanSummary, type ScannedTransaction, type SettlementConnection, type SettlementContext, type SettlementStatus, type SettlementVerdict, SettlementVerificationError, ShieldPoolErrors, type ShieldPoolPDAs, SimpleWallet, type SpendKey, type SpendOptions, type StorageAdapter, type SubmitTransactToRelayArgs, type SwapOptions, type SwapParams, type SwapRefundAuthorization, type SwapResult, TERMINAL_FAILURE, TRANSACTION_CIRCUITS_VERSION, TRANSACT_AUTH_FIELDS, TRANSACT_SWAP_AUTH_FIELDS, type TransactBatchItem, type TransactBatchItemOutcome, type TransactBatchOptions, type TransactBatchResult, type TransactOptions, type TransactParams, type TransactRequestBodyParams, type TransactResult, TransactionConfirmationError, type TransactionMetadata, type Transfer, type TransferOptions, type TransferResult, type TxStatus, type UserFriendlyError, type Utxo, UtxoAlreadySpentError, type EncryptedNote as UtxoEncryptedNote, type UtxoKeypair, type UtxoSwapParams, type UtxoSwapResult, UtxoWallet, VARIABLE_FEE_DENOMINATOR, VARIABLE_FEE_NUMERATOR, VARIABLE_FEE_RATE, VERSION, type VerifyUtxosResult, type ViewKey, type ViewingKeyPair, WITHDRAW_FEE_BPS, WITHDRAW_FIXED_FEE, type WalletAdapterBridgeOptions, type WalletSigner$1 as WalletSigner, type WalletUtxo, type Web3Module, type WithdrawOptions, type WithdrawSubmissionResult, accountMeta, addressBytes, addressFromBytes, addressFromPublicKey, assertDirectSubmissionLanded, assertInputMints, assertTransactionCircuitIntegrity, assessBridgeQuote, bigintToBytes32$1 as bigintToBytes32, bigintToHex, buildAuthTransactionMessage, buildMerkleTree, buildMerkleTreeFromChain, buildMerkleTreeFromRelay, buildRecipientDeliveryNotes, buildRelayAuthPreimage, buildRelayBatchAuthMessage, buildTransactRequestBody, buildTransactionMessage, bytesToHex, calculateFee, calculateFeeBigint, calculateRelayFee, canRebuildMerkleTreeFromChain, canonicalJson, canonicalPayloadString, chainNoteFromBase64, chainNoteToBase64, classifyPostFailure, classifyRelayError, cleanupReceivingAddress, cleanupStalePendingOperations, clearPendingDeposits, clearPendingWithdrawals, cloakBridgeRail, computeChainNoteHash, computeExtDataHash, computeMerkleRoot, computeNoteIndexChain, computeProofForLatestDeposit, computeProofFromChain, computeSignature, computeSwapRefundCommitment, computeCommitment as computeUtxoCommitment, computeNullifier as computeUtxoNullifier, confirmSignature, confirmTransactSettlement, copyNoteToClipboard, createCloakError, createCloakRpc, createDepositInstruction, createLogger, createRecoverableChangeUtxo, createRecoverableDepositUtxo, createRelayBatchAuthCoordinator, createUtxo, createZeroUtxo, decryptCompactChainNote, decryptComplianceMetadataWithMasterKey, decryptTransactionMetadata, depositFromDerivedKey, deriveBridgeReceiver, deriveChangeNoteBlinding, deriveDepositNoteBlinding, deriveDiversifiedViewingKey, deriveDiversifier, deriveFundingTargets, deriveInputNullifierPdas, deriveLegacyBridgeReceiver, deriveLegacyDepositNoteSecrets, deriveLegacySwapRefundAuthorization, derivePublicKey, deriveSpendKey, deriveSwapRefundAuthorization, deriveSwapRefundBlinding, deriveUserCompliancePublicKey, deriveUserComplianceScalar, deriveUtxoKeypairFromSpendKey, deriveViewKey, deriveViewingKeyFromNk, deriveViewingKeyFromSpendKey, deriveViewingKeyFromUtxoPrivateKey, deserializeUtxo, detectNetworkFromRpcUrl, discoverSwapRefunds, downloadNote, encodeDeliveryCarrierMemo, encodeNoteIndexItem, encodeNoteIndexPage, encodeNoteSimple, encodeRecipientDeliveryNote, encryptCompactChainNote, encryptNoteForRecipient, encryptTransactionMetadata, encryptTransactionMetadataBundle, expandSpendKey, explainRelayAuthRejection, exportKeys, exportNote, exportWalletKeys, fetchAccountBytes, fetchCommitments, fetchLatestBlockhash, fetchLookupTables, fetchNoteIndexHead, fetchNoteIndexPage, fetchRiskQuoteInstruction, fetchRiskQuoteIx, fetchSignaturesForAddress, filterNotesByNetwork, filterWithdrawableNotes, findNoteByCommitment, findProgramAddress, formatAmount, formatComplianceCsv, formatErrorForLogging, formatSol, fullWithdraw, fundReceiverViaPaymaster, generateCloakKeys, generateCommitmentAsync, generateMasterSeed, generateNoteFromWallet, generateUtxoKeypair, generateViewingKeyPair, getAddressExplorerUrl, getChainNoteRegistryPDA, getCircuitsPath, getDeliveryRegistryPDA, getDistributableAmount, getExplorerUrl, getNkFromUtxoPrivateKey, getNullifierPDA, getPendingOperationsSummary, getPoolAuthorityConfigPDA, getPublicKey, getPublicViewKey, getRecipientAmount, getRpcUrlForNetwork, getShieldPoolPDAs, getSwapStatePDA, getViewKey, hasPendingOperations, hexToBigint$1 as hexToBigint, hexToBytes, importKeys, importWalletKeys, isBrowser, isBrowserLike, isDebugEnabled, isMessageSigner, isPlausibleSignature, isReactNative, isRootNotFoundError, isSubmissionOutcomeUnknownResponse, isTerminalFailure, isValidHex, isValidRelayClientId, isValidRpcUrl, isValidSolanaAddress, isWithdrawAmountSufficient, isWithdrawable, listBridgeDeposits, loadPendingDeposits, loadPendingWithdrawals, loadVerifiedCircuitArtifacts, matchChangeNote, matchDepositNote, matchSwapRefundLeaf, mayRetry, messageSignerFromCallback, normalizeAffiliateCode, openRecipientDeliveryNote, parseAmount, parseDeliveryCarrierMemo, parseError, parseNote, parseNoteIndexItem, parseNoteIndexPage, parseRelayErrorResponse, parseRelayErrorSignature, parseTransactionError, partialWithdraw, partiallySignTransaction, poseidonHash, preflightCheck, preflightNullifiers, prepareEncryptedOutput, prepareEncryptedOutputForRecipient, programInstruction, proofToBytes, pubkeyToFieldElement, pubkeyToLimbs, randomBytes, randomChangeNoteSalt, randomDepositNoteSalt, randomFieldElement, readMerkleTreeState, readRent, recipientDeliveryNoteToBase64, recoverNotesFromIndex, registerViewingKey, relayRequestDigestHex, removePendingDeposit, removePendingWithdrawal, renderAssessment, resolveCircuitsBase, retryDelayMs, savePendingDeposit, savePendingWithdrawal, scanNotesForWallet, scanRecipientDeliveryNotes, scanTransactions, sdkLogger, selectUtxos, sendInstructions, sendRawTransaction, sendTransaction, serializeAuthTransactionMessage, serializeNote, serializeUtxo, setCircuitsPath, setDebugMode, signCompiledTransaction, signMessageBytes, signRelayAuthPayload, signTransaction, signerFromKeypair, signerFromSecretKey, signerFromWalletAdapter, splitTo2Limbs, submitTransactToRelay, sumUtxoAmounts, swapUtxo, swapWithChange, toAddress, toComplianceReport, transact, transactBatch, transactionBase64, transactionBytes, transactionFromBytes, transactionWireSize, transfer, truncate, tryDecryptNote, updateNoteWithDeposit, updatePendingDeposit, updatePendingWithdrawal, bigintToBytes32 as utxoBigintToBytes32, utxoEquals, hexToBigint as utxoHexToBigint, validateDepositParams, validateNote, validateOutputsSum, validatePaymasterTopUpTransaction, validateRoot, validateTransfers, validateWalletConnected, validateWithdrawableNote, verifyAllCircuits, verifyCircuitIntegrity, verifyQuoteSignature, verifyUtxos, waitForRoot, withShieldRetries, withTiming, withdrawFeeFor };
|
package/dist/index.js
CHANGED
|
@@ -4643,6 +4643,19 @@ async function preflightCheck(relayUrl, rootHex) {
|
|
|
4643
4643
|
};
|
|
4644
4644
|
}
|
|
4645
4645
|
|
|
4646
|
+
// src/relay/affiliate.ts
|
|
4647
|
+
var AFFILIATE_CODE_PATTERN = /^[a-z0-9_]{3,24}$/;
|
|
4648
|
+
var RELAY_CLIENT_HEADER_NAME = "X-Cloak-Client";
|
|
4649
|
+
var RELAY_CLIENT_HEADER_PATTERN = /^cloak-mobile\/(ios|android)\/\d+\.\d+\.\d+$/;
|
|
4650
|
+
function normalizeAffiliateCode(raw) {
|
|
4651
|
+
if (typeof raw !== "string") return null;
|
|
4652
|
+
const code = raw.trim().toLowerCase();
|
|
4653
|
+
return AFFILIATE_CODE_PATTERN.test(code) ? code : null;
|
|
4654
|
+
}
|
|
4655
|
+
function isValidRelayClientId(value) {
|
|
4656
|
+
return typeof value === "string" && RELAY_CLIENT_HEADER_PATTERN.test(value);
|
|
4657
|
+
}
|
|
4658
|
+
|
|
4646
4659
|
// src/flows/transact.ts
|
|
4647
4660
|
import { createNoopSigner as createNoopSigner2, isKeyPairSigner, isSignerRole } from "@solana/kit";
|
|
4648
4661
|
import {
|
|
@@ -6301,7 +6314,41 @@ function assertInputMints(inputUtxos, expectedMint) {
|
|
|
6301
6314
|
}
|
|
6302
6315
|
}
|
|
6303
6316
|
function affiliateCodeOrUndefined(code) {
|
|
6304
|
-
return
|
|
6317
|
+
return normalizeAffiliateCode(code) ?? void 0;
|
|
6318
|
+
}
|
|
6319
|
+
function prepareAffiliateAndClient(options) {
|
|
6320
|
+
let next = options;
|
|
6321
|
+
const raw = options.affiliateCode;
|
|
6322
|
+
if (raw !== void 0 && raw !== null) {
|
|
6323
|
+
const normalized = normalizeAffiliateCode(raw);
|
|
6324
|
+
if (normalized === null) {
|
|
6325
|
+
if (typeof raw === "string" && raw.trim() !== "") {
|
|
6326
|
+
options.onWarning?.(
|
|
6327
|
+
`affiliateCode ${JSON.stringify(raw)} is not a valid partner code (3-24 characters of a-z, 0-9 or _, after trimming and lower-casing); it was left out of the request.`
|
|
6328
|
+
);
|
|
6329
|
+
}
|
|
6330
|
+
next = { ...next, affiliateCode: void 0 };
|
|
6331
|
+
} else if (normalized !== raw) {
|
|
6332
|
+
next = { ...next, affiliateCode: normalized };
|
|
6333
|
+
}
|
|
6334
|
+
}
|
|
6335
|
+
const clientId = options.relayClientId;
|
|
6336
|
+
if (clientId !== void 0 && clientId !== null && !isValidRelayClientId(clientId)) {
|
|
6337
|
+
if (typeof clientId !== "string" || clientId.trim() !== "") {
|
|
6338
|
+
options.onWarning?.(
|
|
6339
|
+
`relayClientId ${JSON.stringify(clientId)} does not match cloak-mobile/(ios|android)/MAJOR.MINOR.PATCH; no X-Cloak-Client header was sent.`
|
|
6340
|
+
);
|
|
6341
|
+
}
|
|
6342
|
+
next = { ...next, relayClientId: void 0 };
|
|
6343
|
+
} else if (isValidRelayClientId(clientId)) {
|
|
6344
|
+
const headers = {};
|
|
6345
|
+
for (const [name, value] of Object.entries(options.relayHeaders ?? {})) {
|
|
6346
|
+
if (name.toLowerCase() !== RELAY_CLIENT_HEADER_NAME.toLowerCase()) headers[name] = value;
|
|
6347
|
+
}
|
|
6348
|
+
headers[RELAY_CLIENT_HEADER_NAME] = clientId;
|
|
6349
|
+
next = { ...next, relayHeaders: headers };
|
|
6350
|
+
}
|
|
6351
|
+
return next;
|
|
6305
6352
|
}
|
|
6306
6353
|
function parseNkInput(input) {
|
|
6307
6354
|
if (typeof input !== "string") {
|
|
@@ -7956,7 +8003,8 @@ async function submitTransactToRelay(args) {
|
|
|
7956
8003
|
new Error(`Relay submission exhausted ${maxNetworkRetries + 1} attempts without an outcome`)
|
|
7957
8004
|
);
|
|
7958
8005
|
}
|
|
7959
|
-
async function transact(params,
|
|
8006
|
+
async function transact(params, rawOptions) {
|
|
8007
|
+
const options = prepareAffiliateAndClient(rawOptions);
|
|
7960
8008
|
const {
|
|
7961
8009
|
connection,
|
|
7962
8010
|
programId,
|
|
@@ -9077,7 +9125,8 @@ async function transact(params, options) {
|
|
|
9077
9125
|
addressLookupTableAccounts: resultAddressLookupTableAccounts
|
|
9078
9126
|
};
|
|
9079
9127
|
}
|
|
9080
|
-
async function transfer(inputUtxos, recipientPubkey, amount,
|
|
9128
|
+
async function transfer(inputUtxos, recipientPubkey, amount, rawOptions) {
|
|
9129
|
+
const options = prepareAffiliateAndClient(rawOptions);
|
|
9081
9130
|
const owner = await requireOwnerUtxoKeypair(options, "transfer");
|
|
9082
9131
|
const transferNk = await requireWalletNk(options, "transfer");
|
|
9083
9132
|
const inputSum = sumUtxoAmounts(inputUtxos);
|
|
@@ -9148,7 +9197,8 @@ async function transfer(inputUtxos, recipientPubkey, amount, options) {
|
|
|
9148
9197
|
{ ...spendOptions, chainNoteSalt: changeNoteSalt }
|
|
9149
9198
|
);
|
|
9150
9199
|
}
|
|
9151
|
-
async function partialWithdraw(inputUtxos, recipient, withdrawAmount,
|
|
9200
|
+
async function partialWithdraw(inputUtxos, recipient, withdrawAmount, rawOptions) {
|
|
9201
|
+
const options = prepareAffiliateAndClient(rawOptions);
|
|
9152
9202
|
const owner = await requireOwnerUtxoKeypair(options, "partialWithdraw");
|
|
9153
9203
|
const walletNk = await requireWalletNk(options, "partialWithdraw");
|
|
9154
9204
|
const inputSum = sumUtxoAmounts(inputUtxos);
|
|
@@ -9290,7 +9340,8 @@ async function waitForSwapCompletion(relayUrl, requestId, onProgress, maxAttempt
|
|
|
9290
9340
|
}
|
|
9291
9341
|
return null;
|
|
9292
9342
|
}
|
|
9293
|
-
async function swapUtxo(params,
|
|
9343
|
+
async function swapUtxo(params, rawOptions) {
|
|
9344
|
+
const options = prepareAffiliateAndClient(rawOptions);
|
|
9294
9345
|
const {
|
|
9295
9346
|
inputUtxos,
|
|
9296
9347
|
changeUtxo,
|
|
@@ -10173,7 +10224,8 @@ async function swapUtxo(params, options) {
|
|
|
10173
10224
|
}
|
|
10174
10225
|
};
|
|
10175
10226
|
}
|
|
10176
|
-
async function swapWithChange(inputUtxos, swapAmount, outputMint, recipientAta, minOutputAmount,
|
|
10227
|
+
async function swapWithChange(inputUtxos, swapAmount, outputMint, recipientAta, minOutputAmount, rawOptions, recipientWallet) {
|
|
10228
|
+
const options = prepareAffiliateAndClient(rawOptions);
|
|
10177
10229
|
const owner = await requireOwnerUtxoKeypair(options, "swapWithChange");
|
|
10178
10230
|
const totalInput = sumUtxoAmounts(inputUtxos);
|
|
10179
10231
|
const change = totalInput - swapAmount;
|
|
@@ -10578,7 +10630,8 @@ function createRelayBatchAuthCoordinator(options) {
|
|
|
10578
10630
|
}
|
|
10579
10631
|
|
|
10580
10632
|
// src/flows/transact-batch.ts
|
|
10581
|
-
async function transactBatch(items,
|
|
10633
|
+
async function transactBatch(items, rawOptions) {
|
|
10634
|
+
const options = prepareAffiliateAndClient(rawOptions);
|
|
10582
10635
|
if (items.length === 0) {
|
|
10583
10636
|
return { results: [], approvals: 0 };
|
|
10584
10637
|
}
|
|
@@ -10650,6 +10703,7 @@ var TOKEN_PROGRAM_ID = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
|
10650
10703
|
var SOL_MINT = "So11111111111111111111111111111111111111112";
|
|
10651
10704
|
var USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
10652
10705
|
var USDT_MINT = "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB";
|
|
10706
|
+
var BRS_MINT = "BRSxQRUaGswjLs7ewcH7uXj3r7SgmfKSSLLXyCKHZtUo";
|
|
10653
10707
|
var PUBLIC_AMOUNT_OFFSET = 32;
|
|
10654
10708
|
var EXT_DATA_HASH_OFFSET = 40;
|
|
10655
10709
|
var OUTPUT_COMMITMENT_0_OFFSET = 168;
|
|
@@ -10706,6 +10760,7 @@ function symbolForMint(mint) {
|
|
|
10706
10760
|
if (mint === SOL_MINT) return "SOL";
|
|
10707
10761
|
if (mint === USDC_MINT) return "USDC";
|
|
10708
10762
|
if (mint === USDT_MINT) return "USDT";
|
|
10763
|
+
if (mint === BRS_MINT) return "BRS";
|
|
10709
10764
|
if (!mint || mint.length < 8) return "TOKEN";
|
|
10710
10765
|
return `${mint.slice(0, 4)}...${mint.slice(-4)}`;
|
|
10711
10766
|
}
|
|
@@ -14677,7 +14732,7 @@ async function withShieldRetries(attempt, hooks = {}) {
|
|
|
14677
14732
|
}
|
|
14678
14733
|
|
|
14679
14734
|
// src/index.ts
|
|
14680
|
-
var VERSION = "0.2.
|
|
14735
|
+
var VERSION = "0.2.7";
|
|
14681
14736
|
var SCANNER_SUPPORTS_TRANSACT_SWAP = true;
|
|
14682
14737
|
export {
|
|
14683
14738
|
AccountRole,
|
|
@@ -14913,6 +14968,7 @@ export {
|
|
|
14913
14968
|
isTerminalFailure,
|
|
14914
14969
|
isTransactionSigner,
|
|
14915
14970
|
isValidHex,
|
|
14971
|
+
isValidRelayClientId,
|
|
14916
14972
|
isValidRpcUrl,
|
|
14917
14973
|
isValidSolanaAddress,
|
|
14918
14974
|
isWithdrawAmountSufficient,
|
|
@@ -14926,6 +14982,7 @@ export {
|
|
|
14926
14982
|
matchSwapRefundLeaf,
|
|
14927
14983
|
mayRetry,
|
|
14928
14984
|
messageSignerFromCallback,
|
|
14985
|
+
normalizeAffiliateCode,
|
|
14929
14986
|
openRecipientDeliveryNote,
|
|
14930
14987
|
parseAmount,
|
|
14931
14988
|
parseDeliveryCarrierMemo,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloak.dev/sdk",
|
|
3
3
|
"description": "Shield, send, and swap on Solana privately — TypeScript SDK with UTXO-based zero-knowledge transactions",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.7",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.js",
|