veilix-sdk 0.2.2 → 0.3.0
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/dist/{VeilixSDK-D1hKisoi.d.ts → VeilixSDK-BfiPKwIa.d.ts} +134 -7
- package/dist/{VeilixSDK-CGbGpth9.d.cts → VeilixSDK-sbYKDbdy.d.cts} +134 -7
- package/dist/circuits/paths.cjs.map +1 -1
- package/dist/circuits/paths.js.map +1 -1
- package/dist/index.cjs +1356 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -3
- package/dist/index.d.ts +42 -3
- package/dist/index.js +1351 -68
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +1350 -67
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1350 -67
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -97,7 +97,7 @@ declare function extDataHash(ext: ExtData): Promise<bigint>;
|
|
|
97
97
|
* `tree` is required when spending notes; deposits only need a `root` from the
|
|
98
98
|
* on-chain root history.
|
|
99
99
|
*/
|
|
100
|
-
declare function proveTransaction({ tree, root, nextIndex, inputs, outputs, ext, circuit, }: {
|
|
100
|
+
declare function proveTransaction({ tree, root, nextIndex, inputs, outputs, ext, extDataHashOverride, circuit, }: {
|
|
101
101
|
tree?: VeilixMerkleTree;
|
|
102
102
|
root?: bigint;
|
|
103
103
|
/** Leaf index the first output will get (defaults to the tree size). */
|
|
@@ -105,6 +105,11 @@ declare function proveTransaction({ tree, root, nextIndex, inputs, outputs, ext,
|
|
|
105
105
|
inputs?: Utxo[];
|
|
106
106
|
outputs?: Utxo[];
|
|
107
107
|
ext: ExtData;
|
|
108
|
+
/**
|
|
109
|
+
* Bind the proof to this hash instead of `extDataHash(ext)` (private swap). `ext`
|
|
110
|
+
* still supplies the mint, `extAmount` and the encrypted outputs.
|
|
111
|
+
*/
|
|
112
|
+
extDataHashOverride?: bigint;
|
|
108
113
|
circuit: CircuitArtifactPaths;
|
|
109
114
|
}): Promise<ProvedTransaction>;
|
|
110
115
|
|
|
@@ -135,8 +140,14 @@ declare function parseSecretNote(note: string): ParsedNote;
|
|
|
135
140
|
* The mint is implied by the tree the output is appended to.
|
|
136
141
|
*/
|
|
137
142
|
declare function encryptNoteOutput(key: Uint8Array, utxo: Utxo): Uint8Array;
|
|
138
|
-
/**
|
|
139
|
-
declare function
|
|
143
|
+
/** `encryptedNote` of a private swap: key and blinding of the asset-B note, no amount. */
|
|
144
|
+
declare function encryptSwapNoteOutput(key: Uint8Array, keypair: VeilixKeypair, blinding: bigint): Uint8Array;
|
|
145
|
+
/**
|
|
146
|
+
* Returns the note if `encryptedOutput` was sealed with `key`, otherwise `null`.
|
|
147
|
+
* A swap output needs `onchainAmount` (the leaf's indexed amount); callers must
|
|
148
|
+
* still check the result against the leaf commitment.
|
|
149
|
+
*/
|
|
150
|
+
declare function decryptNoteOutput(key: Uint8Array, encryptedOutput: Uint8Array, mint: PublicKey | null, index: number, onchainAmount?: bigint | null): Utxo | null;
|
|
140
151
|
/** Truncate each note segment for display. */
|
|
141
152
|
declare function formatNoteForDisplay(note: string, segmentLen?: number): string;
|
|
142
153
|
|
|
@@ -228,7 +239,7 @@ declare function encryptData(key: Uint8Array, plaintext: string): Buffer$1;
|
|
|
228
239
|
declare function decryptData(key: Uint8Array, combined: Uint8Array): string;
|
|
229
240
|
|
|
230
241
|
/**
|
|
231
|
-
* Indexer asset selector: an asset label (`"SOL"`, `"
|
|
242
|
+
* Indexer asset selector: an asset label (`"SOL"`, `"USDC"`, ...), a mint
|
|
232
243
|
* address, or `{ mint }` / `{ asset }`. Defaults to SOL.
|
|
233
244
|
*/
|
|
234
245
|
type IndexerAsset = string | {
|
|
@@ -242,6 +253,8 @@ type IndexedLeaf = {
|
|
|
242
253
|
commitment: string;
|
|
243
254
|
/** `0x`-prefixed hex (may be `"0x"` when empty). Present when requested. */
|
|
244
255
|
encryptedOutput?: string;
|
|
256
|
+
/** Swap output leaves: note amount set on-chain (not inside `encryptedOutput`). */
|
|
257
|
+
amountRaw?: string;
|
|
245
258
|
};
|
|
246
259
|
type TreeState = {
|
|
247
260
|
asset: string;
|
|
@@ -257,7 +270,7 @@ type TreeState = {
|
|
|
257
270
|
synced: boolean;
|
|
258
271
|
};
|
|
259
272
|
type SpentIn = {
|
|
260
|
-
kind: "Deposit" | "Withdraw";
|
|
273
|
+
kind: "Deposit" | "Withdraw" | "Swap" | "onchain";
|
|
261
274
|
signature: string;
|
|
262
275
|
asset?: string;
|
|
263
276
|
[key: string]: unknown;
|
|
@@ -554,6 +567,106 @@ type GetQuoteParams = {
|
|
|
554
567
|
/** Fetch a withdraw quote (relayer + platform fees) from the indexer. */
|
|
555
568
|
declare function getQuote(params: GetQuoteParams): Promise<GetQuoteResponse>;
|
|
556
569
|
|
|
570
|
+
type MintInput = PublicKey | string | null | undefined;
|
|
571
|
+
type SwapQuote = {
|
|
572
|
+
/** Tree mints, `null` for SOL. */
|
|
573
|
+
mintIn: string | null;
|
|
574
|
+
mintOut: string | null;
|
|
575
|
+
/** Base units of `mintIn` spent from the note (fee included). */
|
|
576
|
+
amountIn: string;
|
|
577
|
+
/** Relayer + platform fee, taken from `amountIn` in asset A. */
|
|
578
|
+
fee: string;
|
|
579
|
+
/** `amountIn - fee`, sold on the DEX. */
|
|
580
|
+
swapIn: string;
|
|
581
|
+
/** Expected output in base units of `mintOut`, computed by the SDK from the pool on-chain. */
|
|
582
|
+
amountOut: string;
|
|
583
|
+
/** Output lost to the trade size versus the pool's spot price (0..1). */
|
|
584
|
+
priceImpact: number;
|
|
585
|
+
dexProgram: string;
|
|
586
|
+
pool: string;
|
|
587
|
+
dexFeePercent: number;
|
|
588
|
+
/** Relayer reward account the quote is for. */
|
|
589
|
+
relayer: string;
|
|
590
|
+
relayerUrl: string;
|
|
591
|
+
};
|
|
592
|
+
type GetSwapQuoteParams = {
|
|
593
|
+
mintIn: MintInput;
|
|
594
|
+
mintOut: MintInput;
|
|
595
|
+
/** Base units of `mintIn` to spend (fee included). */
|
|
596
|
+
amountIn: bigint | number | string;
|
|
597
|
+
relayerUrl?: string;
|
|
598
|
+
};
|
|
599
|
+
type SwapParams = {
|
|
600
|
+
/** Secret note of asset A to spend. */
|
|
601
|
+
note: string;
|
|
602
|
+
/** Asset B tree mint (`null` / omitted for SOL). */
|
|
603
|
+
mintOut?: MintInput;
|
|
604
|
+
/** Base units of asset A to swap, fee included. Defaults to the full note. */
|
|
605
|
+
amount?: bigint | number | string;
|
|
606
|
+
/** Max price movement accepted, in basis points (default 100 = 1%). */
|
|
607
|
+
slippageBps?: number;
|
|
608
|
+
relayerUrl?: string;
|
|
609
|
+
};
|
|
610
|
+
type SwapRelayPayload = {
|
|
611
|
+
proof: string;
|
|
612
|
+
root: string;
|
|
613
|
+
inputNullifiers: [string, string];
|
|
614
|
+
outputCommitments: [string, string];
|
|
615
|
+
mintIn?: string;
|
|
616
|
+
mintOut?: string;
|
|
617
|
+
amountIn: string;
|
|
618
|
+
fee: string;
|
|
619
|
+
minAmountOut: string;
|
|
620
|
+
outPubkey: string;
|
|
621
|
+
outBlinding: string;
|
|
622
|
+
relayer: string;
|
|
623
|
+
encryptedOutput1: string;
|
|
624
|
+
encryptedOutput2: string;
|
|
625
|
+
encryptedNote: string;
|
|
626
|
+
};
|
|
627
|
+
type SwapRelayBundle = {
|
|
628
|
+
payload: SwapRelayPayload;
|
|
629
|
+
relayerUrl: string;
|
|
630
|
+
quote: SwapQuote;
|
|
631
|
+
amountIn: bigint;
|
|
632
|
+
fee: bigint;
|
|
633
|
+
minAmountOut: bigint;
|
|
634
|
+
/** Change of asset A (save it like any other note). */
|
|
635
|
+
changeNote: string | null;
|
|
636
|
+
/**
|
|
637
|
+
* Secret of the asset-B note, needed to spend it. The amount is only known once the
|
|
638
|
+
* swap lands; with an encryption key the note is also recoverable by scanning.
|
|
639
|
+
*/
|
|
640
|
+
output: {
|
|
641
|
+
mint: string | null;
|
|
642
|
+
privKey: string;
|
|
643
|
+
blinding: string;
|
|
644
|
+
};
|
|
645
|
+
nullifiers: string[];
|
|
646
|
+
};
|
|
647
|
+
type BuildSwapPayloadOptions = {
|
|
648
|
+
circuitArtifacts?: PreparedCircuitArtifacts;
|
|
649
|
+
tree?: VeilixMerkleTree;
|
|
650
|
+
};
|
|
651
|
+
type SwapResult = {
|
|
652
|
+
txHash: string;
|
|
653
|
+
status: "success" | "failed";
|
|
654
|
+
error?: string;
|
|
655
|
+
/** The asset-B note. Save it: it is the only way to spend the swapped funds. */
|
|
656
|
+
outputNote: string | null;
|
|
657
|
+
changeNote: string | null;
|
|
658
|
+
amountIn: string;
|
|
659
|
+
fee: string;
|
|
660
|
+
amountOut: string | null;
|
|
661
|
+
minAmountOut: string;
|
|
662
|
+
};
|
|
663
|
+
/** Note of the asset-B side once the swap has landed. Checks it against the chain. */
|
|
664
|
+
declare function swapOutputNote(output: SwapRelayBundle["output"], result: {
|
|
665
|
+
amountOut: string;
|
|
666
|
+
outputIndex: number;
|
|
667
|
+
outputCommitment: string;
|
|
668
|
+
}): string;
|
|
669
|
+
|
|
557
670
|
type ResolvedNoteAsset = {
|
|
558
671
|
key: string;
|
|
559
672
|
tokenName: TokenDecimalsSymbol;
|
|
@@ -642,7 +755,7 @@ declare class VeilixSDK {
|
|
|
642
755
|
getRiskApiUrl(): string;
|
|
643
756
|
getTokenMints(): {
|
|
644
757
|
Solana: string;
|
|
645
|
-
Veilix: "GAFN64LvtCBoc5BHncVn3JEJGpq42rUzQjPmvMK2UhZH";
|
|
758
|
+
Veilix: "GAFN64LvtCBoc5BHncVn3JEJGpq42rUzQjPmvMK2UhZH" | "Gmo636w21RBZX9ySVtPYcuYP6f1E5bdW5eBYhvK1bc8J";
|
|
646
759
|
Bitcoin: "" | "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh";
|
|
647
760
|
Ethereum: "" | "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs";
|
|
648
761
|
USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" | "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU";
|
|
@@ -691,6 +804,20 @@ declare class VeilixSDK {
|
|
|
691
804
|
/** Prove a withdrawal without submitting it (see {@link submitWithdrawPayload}). */
|
|
692
805
|
buildWithdrawPayload(params: WithdrawParams, options?: BuildWithdrawPayloadOptions): Promise<WithdrawRelayBundle>;
|
|
693
806
|
submitWithdrawPayload(bundle: WithdrawRelayBundle): Promise<WithdrawResult>;
|
|
807
|
+
/** Fee and expected output of swapping `amountIn` of `mintIn` into `mintOut`. */
|
|
808
|
+
getSwapQuote(params: GetSwapQuoteParams): Promise<{
|
|
809
|
+
quote: SwapQuote;
|
|
810
|
+
relayer: Relayer;
|
|
811
|
+
}>;
|
|
812
|
+
/**
|
|
813
|
+
* Swap a note of asset A into a new shielded note of asset B (`mintOut`, `null` for
|
|
814
|
+
* SOL) through a relayer and an allowlisted DEX. Funds never leave the pool
|
|
815
|
+
* unshielded. Returns the asset-B note and any asset-A change note.
|
|
816
|
+
*/
|
|
817
|
+
swap(params: SwapParams): Promise<SwapResult>;
|
|
818
|
+
/** Prove a swap without submitting it (see {@link submitSwapPayload}). */
|
|
819
|
+
buildSwapPayload(params: SwapParams, options?: BuildSwapPayloadOptions): Promise<SwapRelayBundle>;
|
|
820
|
+
submitSwapPayload(bundle: SwapRelayBundle): Promise<SwapResult>;
|
|
694
821
|
/**
|
|
695
822
|
* Private transfer: deposit one note per item, then withdraw each note in full
|
|
696
823
|
* to its recipient through the indexer submission queue.
|
|
@@ -778,4 +905,4 @@ declare class VeilixSDK {
|
|
|
778
905
|
static getProgramIdForNetwork(network: Network): string;
|
|
779
906
|
}
|
|
780
907
|
|
|
781
|
-
export {
|
|
908
|
+
export { type VeilixTransferResult as $, type SwapResult as A, type BuildDepositTxParams as B, type CommitmentStatus as C, type TokenSymbol as D, type EncryptKeyWallet as E, type FetchWalletBalanceOptions as F, type GenerateDepositParamsResult as G, type TransactionProof as H, type IndexedLeaf as I, type TreeAccountState as J, type TreeState as K, type TxStatus as L, type VeilixMerkleTree as M, type Network as N, VeilixSDK as O, type ParsedNote as P, type Quote as Q, type RelayPayload as R, type ScanOwnedNotesOptions as S, type TokenDecimalsSymbol as T, Utxo as U, VeilixKeypair as V, type VeilixSdkInitOptions as W, type VeilixSdkRuntimeConfig as X, type VeilixTransferDepositFailure as Y, type VeilixTransferItem as Z, type VeilixTransferOptions as _, type BuildRelayPayloadParams as a, type VeilixTransferWithdrawFailure as a0, type WithdrawParams as a1, type WithdrawRelayBundle as a2, type WithdrawResult as a3, type WithdrawStatus as a4, buildMerkleTree as a5, decodeNote as a6, decryptData as a7, decryptNoteOutput as a8, encodeNote as a9, encryptData as aa, encryptNoteOutput as ab, encryptSwapNoteOutput as ac, extDataHash as ad, formatNoteForDisplay as ae, getQuote as af, isLegacyNote as ag, mintToField as ah, parseSecretNote as ai, prepareCircuitArtifacts as aj, proveTransaction as ak, swapOutputNote as al, type BuildSwapPayloadOptions as b, type BuildWithdrawPayloadOptions as c, type ExtData as d, type GetQuoteParams as e, type GetQuoteResponse as f, type GetSwapQuoteParams as g, type IndexerAsset as h, NOTE_PREFIX as i, type NoteStatus as j, type NullifierStatus as k, type PlatformFeeWallet as l, type PoolTransaction as m, type PreparedCircuitArtifacts as n, type ProvedTransaction as o, type QuoteRelayer as p, type QuoteTransaction as q, type Relayer as r, type RelayerJob as s, type ResolvedNoteAsset as t, type Submission as u, type SubmissionItem as v, type SwapParams as w, type SwapQuote as x, type SwapRelayBundle as y, type SwapRelayPayload as z };
|
|
@@ -97,7 +97,7 @@ declare function extDataHash(ext: ExtData): Promise<bigint>;
|
|
|
97
97
|
* `tree` is required when spending notes; deposits only need a `root` from the
|
|
98
98
|
* on-chain root history.
|
|
99
99
|
*/
|
|
100
|
-
declare function proveTransaction({ tree, root, nextIndex, inputs, outputs, ext, circuit, }: {
|
|
100
|
+
declare function proveTransaction({ tree, root, nextIndex, inputs, outputs, ext, extDataHashOverride, circuit, }: {
|
|
101
101
|
tree?: VeilixMerkleTree;
|
|
102
102
|
root?: bigint;
|
|
103
103
|
/** Leaf index the first output will get (defaults to the tree size). */
|
|
@@ -105,6 +105,11 @@ declare function proveTransaction({ tree, root, nextIndex, inputs, outputs, ext,
|
|
|
105
105
|
inputs?: Utxo[];
|
|
106
106
|
outputs?: Utxo[];
|
|
107
107
|
ext: ExtData;
|
|
108
|
+
/**
|
|
109
|
+
* Bind the proof to this hash instead of `extDataHash(ext)` (private swap). `ext`
|
|
110
|
+
* still supplies the mint, `extAmount` and the encrypted outputs.
|
|
111
|
+
*/
|
|
112
|
+
extDataHashOverride?: bigint;
|
|
108
113
|
circuit: CircuitArtifactPaths;
|
|
109
114
|
}): Promise<ProvedTransaction>;
|
|
110
115
|
|
|
@@ -135,8 +140,14 @@ declare function parseSecretNote(note: string): ParsedNote;
|
|
|
135
140
|
* The mint is implied by the tree the output is appended to.
|
|
136
141
|
*/
|
|
137
142
|
declare function encryptNoteOutput(key: Uint8Array, utxo: Utxo): Uint8Array;
|
|
138
|
-
/**
|
|
139
|
-
declare function
|
|
143
|
+
/** `encryptedNote` of a private swap: key and blinding of the asset-B note, no amount. */
|
|
144
|
+
declare function encryptSwapNoteOutput(key: Uint8Array, keypair: VeilixKeypair, blinding: bigint): Uint8Array;
|
|
145
|
+
/**
|
|
146
|
+
* Returns the note if `encryptedOutput` was sealed with `key`, otherwise `null`.
|
|
147
|
+
* A swap output needs `onchainAmount` (the leaf's indexed amount); callers must
|
|
148
|
+
* still check the result against the leaf commitment.
|
|
149
|
+
*/
|
|
150
|
+
declare function decryptNoteOutput(key: Uint8Array, encryptedOutput: Uint8Array, mint: PublicKey | null, index: number, onchainAmount?: bigint | null): Utxo | null;
|
|
140
151
|
/** Truncate each note segment for display. */
|
|
141
152
|
declare function formatNoteForDisplay(note: string, segmentLen?: number): string;
|
|
142
153
|
|
|
@@ -228,7 +239,7 @@ declare function encryptData(key: Uint8Array, plaintext: string): Buffer$1;
|
|
|
228
239
|
declare function decryptData(key: Uint8Array, combined: Uint8Array): string;
|
|
229
240
|
|
|
230
241
|
/**
|
|
231
|
-
* Indexer asset selector: an asset label (`"SOL"`, `"
|
|
242
|
+
* Indexer asset selector: an asset label (`"SOL"`, `"USDC"`, ...), a mint
|
|
232
243
|
* address, or `{ mint }` / `{ asset }`. Defaults to SOL.
|
|
233
244
|
*/
|
|
234
245
|
type IndexerAsset = string | {
|
|
@@ -242,6 +253,8 @@ type IndexedLeaf = {
|
|
|
242
253
|
commitment: string;
|
|
243
254
|
/** `0x`-prefixed hex (may be `"0x"` when empty). Present when requested. */
|
|
244
255
|
encryptedOutput?: string;
|
|
256
|
+
/** Swap output leaves: note amount set on-chain (not inside `encryptedOutput`). */
|
|
257
|
+
amountRaw?: string;
|
|
245
258
|
};
|
|
246
259
|
type TreeState = {
|
|
247
260
|
asset: string;
|
|
@@ -257,7 +270,7 @@ type TreeState = {
|
|
|
257
270
|
synced: boolean;
|
|
258
271
|
};
|
|
259
272
|
type SpentIn = {
|
|
260
|
-
kind: "Deposit" | "Withdraw";
|
|
273
|
+
kind: "Deposit" | "Withdraw" | "Swap" | "onchain";
|
|
261
274
|
signature: string;
|
|
262
275
|
asset?: string;
|
|
263
276
|
[key: string]: unknown;
|
|
@@ -554,6 +567,106 @@ type GetQuoteParams = {
|
|
|
554
567
|
/** Fetch a withdraw quote (relayer + platform fees) from the indexer. */
|
|
555
568
|
declare function getQuote(params: GetQuoteParams): Promise<GetQuoteResponse>;
|
|
556
569
|
|
|
570
|
+
type MintInput = PublicKey | string | null | undefined;
|
|
571
|
+
type SwapQuote = {
|
|
572
|
+
/** Tree mints, `null` for SOL. */
|
|
573
|
+
mintIn: string | null;
|
|
574
|
+
mintOut: string | null;
|
|
575
|
+
/** Base units of `mintIn` spent from the note (fee included). */
|
|
576
|
+
amountIn: string;
|
|
577
|
+
/** Relayer + platform fee, taken from `amountIn` in asset A. */
|
|
578
|
+
fee: string;
|
|
579
|
+
/** `amountIn - fee`, sold on the DEX. */
|
|
580
|
+
swapIn: string;
|
|
581
|
+
/** Expected output in base units of `mintOut`, computed by the SDK from the pool on-chain. */
|
|
582
|
+
amountOut: string;
|
|
583
|
+
/** Output lost to the trade size versus the pool's spot price (0..1). */
|
|
584
|
+
priceImpact: number;
|
|
585
|
+
dexProgram: string;
|
|
586
|
+
pool: string;
|
|
587
|
+
dexFeePercent: number;
|
|
588
|
+
/** Relayer reward account the quote is for. */
|
|
589
|
+
relayer: string;
|
|
590
|
+
relayerUrl: string;
|
|
591
|
+
};
|
|
592
|
+
type GetSwapQuoteParams = {
|
|
593
|
+
mintIn: MintInput;
|
|
594
|
+
mintOut: MintInput;
|
|
595
|
+
/** Base units of `mintIn` to spend (fee included). */
|
|
596
|
+
amountIn: bigint | number | string;
|
|
597
|
+
relayerUrl?: string;
|
|
598
|
+
};
|
|
599
|
+
type SwapParams = {
|
|
600
|
+
/** Secret note of asset A to spend. */
|
|
601
|
+
note: string;
|
|
602
|
+
/** Asset B tree mint (`null` / omitted for SOL). */
|
|
603
|
+
mintOut?: MintInput;
|
|
604
|
+
/** Base units of asset A to swap, fee included. Defaults to the full note. */
|
|
605
|
+
amount?: bigint | number | string;
|
|
606
|
+
/** Max price movement accepted, in basis points (default 100 = 1%). */
|
|
607
|
+
slippageBps?: number;
|
|
608
|
+
relayerUrl?: string;
|
|
609
|
+
};
|
|
610
|
+
type SwapRelayPayload = {
|
|
611
|
+
proof: string;
|
|
612
|
+
root: string;
|
|
613
|
+
inputNullifiers: [string, string];
|
|
614
|
+
outputCommitments: [string, string];
|
|
615
|
+
mintIn?: string;
|
|
616
|
+
mintOut?: string;
|
|
617
|
+
amountIn: string;
|
|
618
|
+
fee: string;
|
|
619
|
+
minAmountOut: string;
|
|
620
|
+
outPubkey: string;
|
|
621
|
+
outBlinding: string;
|
|
622
|
+
relayer: string;
|
|
623
|
+
encryptedOutput1: string;
|
|
624
|
+
encryptedOutput2: string;
|
|
625
|
+
encryptedNote: string;
|
|
626
|
+
};
|
|
627
|
+
type SwapRelayBundle = {
|
|
628
|
+
payload: SwapRelayPayload;
|
|
629
|
+
relayerUrl: string;
|
|
630
|
+
quote: SwapQuote;
|
|
631
|
+
amountIn: bigint;
|
|
632
|
+
fee: bigint;
|
|
633
|
+
minAmountOut: bigint;
|
|
634
|
+
/** Change of asset A (save it like any other note). */
|
|
635
|
+
changeNote: string | null;
|
|
636
|
+
/**
|
|
637
|
+
* Secret of the asset-B note, needed to spend it. The amount is only known once the
|
|
638
|
+
* swap lands; with an encryption key the note is also recoverable by scanning.
|
|
639
|
+
*/
|
|
640
|
+
output: {
|
|
641
|
+
mint: string | null;
|
|
642
|
+
privKey: string;
|
|
643
|
+
blinding: string;
|
|
644
|
+
};
|
|
645
|
+
nullifiers: string[];
|
|
646
|
+
};
|
|
647
|
+
type BuildSwapPayloadOptions = {
|
|
648
|
+
circuitArtifacts?: PreparedCircuitArtifacts;
|
|
649
|
+
tree?: VeilixMerkleTree;
|
|
650
|
+
};
|
|
651
|
+
type SwapResult = {
|
|
652
|
+
txHash: string;
|
|
653
|
+
status: "success" | "failed";
|
|
654
|
+
error?: string;
|
|
655
|
+
/** The asset-B note. Save it: it is the only way to spend the swapped funds. */
|
|
656
|
+
outputNote: string | null;
|
|
657
|
+
changeNote: string | null;
|
|
658
|
+
amountIn: string;
|
|
659
|
+
fee: string;
|
|
660
|
+
amountOut: string | null;
|
|
661
|
+
minAmountOut: string;
|
|
662
|
+
};
|
|
663
|
+
/** Note of the asset-B side once the swap has landed. Checks it against the chain. */
|
|
664
|
+
declare function swapOutputNote(output: SwapRelayBundle["output"], result: {
|
|
665
|
+
amountOut: string;
|
|
666
|
+
outputIndex: number;
|
|
667
|
+
outputCommitment: string;
|
|
668
|
+
}): string;
|
|
669
|
+
|
|
557
670
|
type ResolvedNoteAsset = {
|
|
558
671
|
key: string;
|
|
559
672
|
tokenName: TokenDecimalsSymbol;
|
|
@@ -642,7 +755,7 @@ declare class VeilixSDK {
|
|
|
642
755
|
getRiskApiUrl(): string;
|
|
643
756
|
getTokenMints(): {
|
|
644
757
|
Solana: string;
|
|
645
|
-
Veilix: "GAFN64LvtCBoc5BHncVn3JEJGpq42rUzQjPmvMK2UhZH";
|
|
758
|
+
Veilix: "GAFN64LvtCBoc5BHncVn3JEJGpq42rUzQjPmvMK2UhZH" | "Gmo636w21RBZX9ySVtPYcuYP6f1E5bdW5eBYhvK1bc8J";
|
|
646
759
|
Bitcoin: "" | "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh";
|
|
647
760
|
Ethereum: "" | "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs";
|
|
648
761
|
USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" | "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU";
|
|
@@ -691,6 +804,20 @@ declare class VeilixSDK {
|
|
|
691
804
|
/** Prove a withdrawal without submitting it (see {@link submitWithdrawPayload}). */
|
|
692
805
|
buildWithdrawPayload(params: WithdrawParams, options?: BuildWithdrawPayloadOptions): Promise<WithdrawRelayBundle>;
|
|
693
806
|
submitWithdrawPayload(bundle: WithdrawRelayBundle): Promise<WithdrawResult>;
|
|
807
|
+
/** Fee and expected output of swapping `amountIn` of `mintIn` into `mintOut`. */
|
|
808
|
+
getSwapQuote(params: GetSwapQuoteParams): Promise<{
|
|
809
|
+
quote: SwapQuote;
|
|
810
|
+
relayer: Relayer;
|
|
811
|
+
}>;
|
|
812
|
+
/**
|
|
813
|
+
* Swap a note of asset A into a new shielded note of asset B (`mintOut`, `null` for
|
|
814
|
+
* SOL) through a relayer and an allowlisted DEX. Funds never leave the pool
|
|
815
|
+
* unshielded. Returns the asset-B note and any asset-A change note.
|
|
816
|
+
*/
|
|
817
|
+
swap(params: SwapParams): Promise<SwapResult>;
|
|
818
|
+
/** Prove a swap without submitting it (see {@link submitSwapPayload}). */
|
|
819
|
+
buildSwapPayload(params: SwapParams, options?: BuildSwapPayloadOptions): Promise<SwapRelayBundle>;
|
|
820
|
+
submitSwapPayload(bundle: SwapRelayBundle): Promise<SwapResult>;
|
|
694
821
|
/**
|
|
695
822
|
* Private transfer: deposit one note per item, then withdraw each note in full
|
|
696
823
|
* to its recipient through the indexer submission queue.
|
|
@@ -778,4 +905,4 @@ declare class VeilixSDK {
|
|
|
778
905
|
static getProgramIdForNetwork(network: Network): string;
|
|
779
906
|
}
|
|
780
907
|
|
|
781
|
-
export {
|
|
908
|
+
export { type VeilixTransferResult as $, type SwapResult as A, type BuildDepositTxParams as B, type CommitmentStatus as C, type TokenSymbol as D, type EncryptKeyWallet as E, type FetchWalletBalanceOptions as F, type GenerateDepositParamsResult as G, type TransactionProof as H, type IndexedLeaf as I, type TreeAccountState as J, type TreeState as K, type TxStatus as L, type VeilixMerkleTree as M, type Network as N, VeilixSDK as O, type ParsedNote as P, type Quote as Q, type RelayPayload as R, type ScanOwnedNotesOptions as S, type TokenDecimalsSymbol as T, Utxo as U, VeilixKeypair as V, type VeilixSdkInitOptions as W, type VeilixSdkRuntimeConfig as X, type VeilixTransferDepositFailure as Y, type VeilixTransferItem as Z, type VeilixTransferOptions as _, type BuildRelayPayloadParams as a, type VeilixTransferWithdrawFailure as a0, type WithdrawParams as a1, type WithdrawRelayBundle as a2, type WithdrawResult as a3, type WithdrawStatus as a4, buildMerkleTree as a5, decodeNote as a6, decryptData as a7, decryptNoteOutput as a8, encodeNote as a9, encryptData as aa, encryptNoteOutput as ab, encryptSwapNoteOutput as ac, extDataHash as ad, formatNoteForDisplay as ae, getQuote as af, isLegacyNote as ag, mintToField as ah, parseSecretNote as ai, prepareCircuitArtifacts as aj, proveTransaction as ak, swapOutputNote as al, type BuildSwapPayloadOptions as b, type BuildWithdrawPayloadOptions as c, type ExtData as d, type GetQuoteParams as e, type GetQuoteResponse as f, type GetSwapQuoteParams as g, type IndexerAsset as h, NOTE_PREFIX as i, type NoteStatus as j, type NullifierStatus as k, type PlatformFeeWallet as l, type PoolTransaction as m, type PreparedCircuitArtifacts as n, type ProvedTransaction as o, type QuoteRelayer as p, type QuoteTransaction as q, type Relayer as r, type RelayerJob as s, type ResolvedNoteAsset as t, type Submission as u, type SubmissionItem as v, type SwapParams as w, type SwapQuote as x, type SwapRelayBundle as y, type SwapRelayPayload as z };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../package.json","../../src/circuits/constants.ts","../../src/circuits/paths.ts"],"names":[],"mappings":";;;;AAAA,IAAA,eAAA,GAAA;AAAA,EACE,IAAA,EAAQ,YAmGV,CAAA;;;ACjGO,IAAM,eAAe,eAAA,CAAY;AAMjC,IAAM,qBAAA,GAAwB;AAC9B,IAAM,qBAAA,GAAwB;AAK9B,IAAM,uBAAA,GAA0B;AAAA,EACrC,IAAA,EAAM,kEAAA;AAAA,EACN,IAAA,EAAM;AACR;AAGO,IAAM,wBAAA,GAA2B;AAUjC,IAAM,mBAAA,GAAsB,YAAA;AAC5B,IAAM,mBAAA,GAAsB,OAAA;AAQ5B,SAAS,4BAA4B,IAAA,EAA4B;AACtE,EAAA,MAAM,OAAO,IAAA,CAAK,QAAA,CAAS,GAAG,CAAA,GAAI,IAAA,GAAO,GAAG,IAAI,CAAA,CAAA,CAAA;AAChD,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,SAAA,EAAY,qBAAqB,CAAA,CAAA;AAAA,IAC9C,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,SAAA,EAAY,qBAAqB,CAAA;AAAA,GAChD;AACF;AASO,SAAS,wBAAA,GAAmC;AACjD,EAAA,OAAO,CAAA,6BAAA,EAAgC,mBAAmB,CAAA,CAAA,EAAI,mBAAmB,CAAA,eAAA,CAAA;AACnF;AAGO,SAAS,yBAAA,GAA0C;AACxD,EAAA,MAAM,OAAO,wBAAA,EAAyB;AAC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,IAAI,GAAA,CAAI,CAAA,EAAA,EAAK,qBAAqB,CAAA,CAAA,EAAI,2PAAe,CAAA,CAAE;AAAA,GAC/D;AACF","file":"paths.cjs","sourcesContent":["{\n \"name\": \"veilix-sdk\",\n \"version\": \"0.2.2\",\n \"description\": \"Veilix Privacy SDK\",\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"sideEffects\": false,\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/index.d.cts\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"./circuits/paths\": {\n \"import\": \"./dist/circuits/paths.js\",\n \"require\": \"./dist/circuits/paths.cjs\",\n \"default\": \"./dist/circuits/paths.js\"\n },\n \"./circuits/*\": \"./dist/circuits/*\",\n \"./vite\": {\n \"import\": {\n \"types\": \"./dist/vite/index.d.ts\",\n \"default\": \"./dist/vite/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/vite/index.d.cts\",\n \"default\": \"./dist/vite/index.cjs\"\n }\n },\n \"./react\": {\n \"import\": {\n \"types\": \"./dist/react/index.d.ts\",\n \"default\": \"./dist/react/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/react/index.d.cts\",\n \"default\": \"./dist/react/index.cjs\"\n }\n },\n \"./package.json\": \"./package.json\"\n },\n \"peerDependencies\": {\n \"@solana/wallet-adapter-react\": \">=0.15.0\",\n \"react\": \">=18\"\n },\n \"peerDependenciesMeta\": {\n \"@solana/wallet-adapter-react\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"prepare:snarkjs\": \"node scripts/prepare-snarkjs.mjs\",\n \"build\": \"npm run prepare:snarkjs && tsup\",\n \"dev\": \"npm run prepare:snarkjs && tsup --watch\",\n \"typecheck\": \"npm run prepare:snarkjs && tsc --noEmit\",\n \"prepublishOnly\": \"npm run build\"\n },\n \"keywords\": [\n \"veilix-sdk\",\n \"sdk\"\n ],\n \"license\": \"MIT\",\n \"devDependencies\": {\n \"@solana/wallet-adapter-react\": \"^0.15.39\",\n \"@types/bn.js\": \"^5.2.0\",\n \"@types/node\": \"^26.0.0\",\n \"@types/react\": \"^19.1.8\",\n \"react\": \"^19.1.0\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^5.8.3\"\n },\n \"engines\": {\n \"node\": \">=18\"\n },\n \"dependencies\": {\n \"@coral-xyz/anchor\": \"^0.31.1\",\n \"@solana/spl-token\": \"^0.4.14\",\n \"@solana/web3.js\": \"^1.98.4\",\n \"@switchboard-xyz/common\": \"^5.8.1\",\n \"@switchboard-xyz/on-demand\": \"^3.10.1\",\n \"bn.js\": \"^5.2.5\",\n \"buffer\": \"^6.0.3\",\n \"ffjavascript\": \"^0.3.1\",\n \"fixed-merkle-tree\": \"^0.7.3\",\n \"poseidon-hash\": \"^1.0.1\",\n \"tweetnacl\": \"^1.0.3\"\n }\n}\n","import packageJson from \"../../package.json\";\n\n/** npm package name (used to load the standalone circuits module). */\nexport const PACKAGE_NAME = packageJson.name;\n\n/** Published npm version (pins CDN circuit URLs in production). */\nexport const PACKAGE_VERSION = packageJson.version;\n\n/** Withdraw circuit artifact filenames (published under `veilix-sdk/circuits/`). */\nexport const WITHDRAW_CIRCUIT_WASM = \"withdraw.wasm\";\nexport const WITHDRAW_CIRCUIT_ZKEY = \"withdraw.zkey\";\n/**\n * Pinned SHA-256 hashes for the published withdraw circuit artifacts.\n * These are verified in-browser before passing artifacts to snarkjs.\n */\nexport const WITHDRAW_CIRCUIT_SHA256 = {\n wasm: \"5f9eb88bcbc1b3dd5669dad6fdd3b91d59dd2d617ad0b34827af8a498d13fa60\",\n zkey: \"73e0d2328eca8f48024b69b42d659b68d7dd2f067d762079e859ffff34360a1a\",\n} as const;\n\n/** Optional self-hosted path convention (opt-in via `circuitPathsBase`). */\nexport const SELF_HOSTED_CIRCUIT_BASE = \"/circuits/\";\n\n/**\n * Stable published source for the pinned circuit artifacts.\n *\n * Decoupled from {@link PACKAGE_VERSION} on purpose: the withdraw circuit is a\n * fixed cryptographic artifact, so SDK code releases must not change where the\n * verified circuits are fetched from. Bump these together with\n * {@link WITHDRAW_CIRCUIT_SHA256} only when the circuit itself changes.\n */\nexport const CIRCUIT_CDN_PACKAGE = \"veilix-sdk\";\nexport const CIRCUIT_CDN_VERSION = \"0.2.0\";\n\nexport type CircuitPaths = {\n wasm: string;\n zkey: string;\n};\n\n/** Resolve circuit URLs when the caller knows the package `dist/` root. */\nexport function resolveCircuitPathsFromBase(base: string): CircuitPaths {\n const root = base.endsWith(\"/\") ? base : `${base}/`;\n return {\n wasm: `${root}circuits/${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${root}circuits/${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n}\n\n/**\n * Base URL for circuit files on jsDelivr.\n *\n * Pinned to {@link CIRCUIT_CDN_PACKAGE}@{@link CIRCUIT_CDN_VERSION} (not the\n * current SDK version) so the bytes always match {@link WITHDRAW_CIRCUIT_SHA256}.\n * This URL is independent of the consuming app's origin/domain.\n */\nexport function resolveNpmCdnCircuitBase(): string {\n return `https://cdn.jsdelivr.net/npm/${CIRCUIT_CDN_PACKAGE}@${CIRCUIT_CDN_VERSION}/dist/circuits/`;\n}\n\n/** Trusted jsDelivr fallback paths for pinned withdraw circuit artifacts. */\nexport function resolveNpmCdnCircuitPaths(): CircuitPaths {\n const base = resolveNpmCdnCircuitBase();\n return {\n wasm: `${base}${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${base}${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n}\n\nfunction isLocalDevHost(hostname: string): boolean {\n return (\n hostname === \"localhost\" ||\n hostname === \"127.0.0.1\" ||\n hostname === \"[::1]\"\n );\n}\n\n/**\n * Browser circuit URLs.\n *\n * - Local dev (Vite): `/node_modules/<pkg>/dist/circuits/` — Vite serves node_modules.\n * - Production: pinned, domain-independent jsDelivr CDN (verified by SHA-256 before use).\n *\n * The production default does not depend on the app's own origin/domain, so it\n * works on any deployed host with no copy step. Artifacts are always integrity\n * checked before proving (see {@link WITHDRAW_CIRCUIT_SHA256}). To self-host\n * instead, pass {@link VeilixSdkInitOptions.circuitPathsBase} (e.g. `\"/circuits/\"`);\n * it is verified too and falls back to the CDN if unavailable.\n */\nexport function resolveBrowserCircuitPaths(\n baseOverride?: string\n): CircuitPaths | null {\n if (typeof window === \"undefined\") {\n return null;\n }\n\n if (baseOverride !== undefined) {\n return resolveCircuitPathsFromBase(baseOverride);\n }\n\n if (isLocalDevHost(window.location.hostname)) {\n const base = `/node_modules/${PACKAGE_NAME}/dist/circuits/`;\n return {\n wasm: `${base}${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${base}${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n }\n\n return resolveNpmCdnCircuitPaths();\n}\n","import {\n WITHDRAW_CIRCUIT_WASM,\n WITHDRAW_CIRCUIT_ZKEY,\n resolveBrowserCircuitPaths,\n resolveCircuitPathsFromBase,\n type CircuitPaths,\n} from \"./constants\";\n\nexport {\n PACKAGE_NAME,\n SELF_HOSTED_CIRCUIT_BASE,\n WITHDRAW_CIRCUIT_SHA256,\n WITHDRAW_CIRCUIT_WASM,\n WITHDRAW_CIRCUIT_ZKEY,\n resolveBrowserCircuitPaths,\n resolveCircuitPathsFromBase,\n resolveNpmCdnCircuitPaths,\n resolveNpmCdnCircuitBase,\n type CircuitPaths,\n} from \"./constants\";\n\n/**\n * Resolve default Groth16 circuit URLs.\n *\n * Published as `veilix-sdk/circuits/paths` so `import.meta.url` stays next to\n * `withdraw.wasm` and `withdraw.zkey` in `dist/circuits/` (Node / unbundled ESM).\n *\n * In the browser, defaults to `/node_modules/<pkg>/dist/circuits/` on localhost\n * and the pinned, SHA-256-verified jsDelivr CDN in production (domain-independent).\n * Override via {@link VeilixSdkInitOptions.circuitPathsBase},\n * {@link resolveCircuitPathsFromBase}, or {@link GenerateWithdrawProofOptions}.\n */\nexport function resolveCircuitPaths(base?: string): CircuitPaths {\n if (base !== undefined) {\n return resolveCircuitPathsFromBase(base);\n }\n\n const browser = resolveBrowserCircuitPaths();\n if (browser) {\n return browser;\n }\n\n return {\n wasm: new URL(`./${WITHDRAW_CIRCUIT_WASM}`, import.meta.url).href,\n zkey: new URL(`./${WITHDRAW_CIRCUIT_ZKEY}`, import.meta.url).href,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../package.json","../../src/circuits/constants.ts","../../src/circuits/paths.ts"],"names":[],"mappings":";;;;AAAA,IAAA,eAAA,GAAA;AAAA,EACE,IAAA,EAAQ,YAmGV,CAAA;;;ACjGO,IAAM,eAAe,eAAA,CAAY;AAMjC,IAAM,qBAAA,GAAwB;AAC9B,IAAM,qBAAA,GAAwB;AAK9B,IAAM,uBAAA,GAA0B;AAAA,EACrC,IAAA,EAAM,kEAAA;AAAA,EACN,IAAA,EAAM;AACR;AAGO,IAAM,wBAAA,GAA2B;AAUjC,IAAM,mBAAA,GAAsB,YAAA;AAC5B,IAAM,mBAAA,GAAsB,OAAA;AAQ5B,SAAS,4BAA4B,IAAA,EAA4B;AACtE,EAAA,MAAM,OAAO,IAAA,CAAK,QAAA,CAAS,GAAG,CAAA,GAAI,IAAA,GAAO,GAAG,IAAI,CAAA,CAAA,CAAA;AAChD,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,SAAA,EAAY,qBAAqB,CAAA,CAAA;AAAA,IAC9C,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,SAAA,EAAY,qBAAqB,CAAA;AAAA,GAChD;AACF;AASO,SAAS,wBAAA,GAAmC;AACjD,EAAA,OAAO,CAAA,6BAAA,EAAgC,mBAAmB,CAAA,CAAA,EAAI,mBAAmB,CAAA,eAAA,CAAA;AACnF;AAGO,SAAS,yBAAA,GAA0C;AACxD,EAAA,MAAM,OAAO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IAC7D,IAAA,EAAM,IAAI,GAAA,CAAI,CAAA,EAAA,EAAK,qBAAqB,CAAA,CAAA,EAAI,2PAAe,CAAA,CAAE;AAAA,GAC/D;AACF","file":"paths.cjs","sourcesContent":["{\n \"name\": \"veilix-sdk\",\n \"version\": \"0.3.0\",\n \"description\": \"Veilix Privacy SDK\",\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"sideEffects\": false,\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/index.d.cts\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"./circuits/paths\": {\n \"import\": \"./dist/circuits/paths.js\",\n \"require\": \"./dist/circuits/paths.cjs\",\n \"default\": \"./dist/circuits/paths.js\"\n },\n \"./circuits/*\": \"./dist/circuits/*\",\n \"./vite\": {\n \"import\": {\n \"types\": \"./dist/vite/index.d.ts\",\n \"default\": \"./dist/vite/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/vite/index.d.cts\",\n \"default\": \"./dist/vite/index.cjs\"\n }\n },\n \"./react\": {\n \"import\": {\n \"types\": \"./dist/react/index.d.ts\",\n \"default\": \"./dist/react/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/react/index.d.cts\",\n \"default\": \"./dist/react/index.cjs\"\n }\n },\n \"./package.json\": \"./package.json\"\n },\n \"peerDependencies\": {\n \"@solana/wallet-adapter-react\": \">=0.15.0\",\n \"react\": \">=18\"\n },\n \"peerDependenciesMeta\": {\n \"@solana/wallet-adapter-react\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"prepare:snarkjs\": \"node scripts/prepare-snarkjs.mjs\",\n \"build\": \"npm run prepare:snarkjs && tsup\",\n \"dev\": \"npm run prepare:snarkjs && tsup --watch\",\n \"typecheck\": \"npm run prepare:snarkjs && tsc --noEmit\",\n \"prepublishOnly\": \"npm run build\"\n },\n \"keywords\": [\n \"veilix-sdk\",\n \"sdk\"\n ],\n \"license\": \"MIT\",\n \"devDependencies\": {\n \"@solana/wallet-adapter-react\": \"^0.15.39\",\n \"@types/bn.js\": \"^5.2.0\",\n \"@types/node\": \"^26.0.0\",\n \"@types/react\": \"^19.1.8\",\n \"react\": \"^19.1.0\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^5.8.3\"\n },\n \"engines\": {\n \"node\": \">=18\"\n },\n \"dependencies\": {\n \"@coral-xyz/anchor\": \"^0.31.1\",\n \"@solana/spl-token\": \"^0.4.14\",\n \"@solana/web3.js\": \"^1.98.4\",\n \"@switchboard-xyz/common\": \"^5.8.1\",\n \"@switchboard-xyz/on-demand\": \"^3.10.1\",\n \"bn.js\": \"^5.2.5\",\n \"buffer\": \"^6.0.3\",\n \"ffjavascript\": \"^0.3.1\",\n \"fixed-merkle-tree\": \"^0.7.3\",\n \"poseidon-hash\": \"^1.0.1\",\n \"tweetnacl\": \"^1.0.3\"\n }\n}\n","import packageJson from \"../../package.json\";\n\n/** npm package name (used to load the standalone circuits module). */\nexport const PACKAGE_NAME = packageJson.name;\n\n/** Published npm version (pins CDN circuit URLs in production). */\nexport const PACKAGE_VERSION = packageJson.version;\n\n/** Withdraw circuit artifact filenames (published under `veilix-sdk/circuits/`). */\nexport const WITHDRAW_CIRCUIT_WASM = \"withdraw.wasm\";\nexport const WITHDRAW_CIRCUIT_ZKEY = \"withdraw.zkey\";\n/**\n * Pinned SHA-256 hashes for the published withdraw circuit artifacts.\n * These are verified in-browser before passing artifacts to snarkjs.\n */\nexport const WITHDRAW_CIRCUIT_SHA256 = {\n wasm: \"5f9eb88bcbc1b3dd5669dad6fdd3b91d59dd2d617ad0b34827af8a498d13fa60\",\n zkey: \"73e0d2328eca8f48024b69b42d659b68d7dd2f067d762079e859ffff34360a1a\",\n} as const;\n\n/** Optional self-hosted path convention (opt-in via `circuitPathsBase`). */\nexport const SELF_HOSTED_CIRCUIT_BASE = \"/circuits/\";\n\n/**\n * Stable published source for the pinned circuit artifacts.\n *\n * Decoupled from {@link PACKAGE_VERSION} on purpose: the withdraw circuit is a\n * fixed cryptographic artifact, so SDK code releases must not change where the\n * verified circuits are fetched from. Bump these together with\n * {@link WITHDRAW_CIRCUIT_SHA256} only when the circuit itself changes.\n */\nexport const CIRCUIT_CDN_PACKAGE = \"veilix-sdk\";\nexport const CIRCUIT_CDN_VERSION = \"0.2.0\";\n\nexport type CircuitPaths = {\n wasm: string;\n zkey: string;\n};\n\n/** Resolve circuit URLs when the caller knows the package `dist/` root. */\nexport function resolveCircuitPathsFromBase(base: string): CircuitPaths {\n const root = base.endsWith(\"/\") ? base : `${base}/`;\n return {\n wasm: `${root}circuits/${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${root}circuits/${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n}\n\n/**\n * Base URL for circuit files on jsDelivr.\n *\n * Pinned to {@link CIRCUIT_CDN_PACKAGE}@{@link CIRCUIT_CDN_VERSION} (not the\n * current SDK version) so the bytes always match {@link WITHDRAW_CIRCUIT_SHA256}.\n * This URL is independent of the consuming app's origin/domain.\n */\nexport function resolveNpmCdnCircuitBase(): string {\n return `https://cdn.jsdelivr.net/npm/${CIRCUIT_CDN_PACKAGE}@${CIRCUIT_CDN_VERSION}/dist/circuits/`;\n}\n\n/** Trusted jsDelivr fallback paths for pinned withdraw circuit artifacts. */\nexport function resolveNpmCdnCircuitPaths(): CircuitPaths {\n const base = resolveNpmCdnCircuitBase();\n return {\n wasm: `${base}${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${base}${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n}\n\nfunction isLocalDevHost(hostname: string): boolean {\n return (\n hostname === \"localhost\" ||\n hostname === \"127.0.0.1\" ||\n hostname === \"[::1]\"\n );\n}\n\n/**\n * Browser circuit URLs.\n *\n * - Local dev (Vite): `/node_modules/<pkg>/dist/circuits/` — Vite serves node_modules.\n * - Production: pinned, domain-independent jsDelivr CDN (verified by SHA-256 before use).\n *\n * The production default does not depend on the app's own origin/domain, so it\n * works on any deployed host with no copy step. Artifacts are always integrity\n * checked before proving (see {@link WITHDRAW_CIRCUIT_SHA256}). To self-host\n * instead, pass {@link VeilixSdkInitOptions.circuitPathsBase} (e.g. `\"/circuits/\"`);\n * it is verified too and falls back to the CDN if unavailable.\n */\nexport function resolveBrowserCircuitPaths(\n baseOverride?: string\n): CircuitPaths | null {\n if (typeof window === \"undefined\") {\n return null;\n }\n\n if (baseOverride !== undefined) {\n return resolveCircuitPathsFromBase(baseOverride);\n }\n\n if (isLocalDevHost(window.location.hostname)) {\n const base = `/node_modules/${PACKAGE_NAME}/dist/circuits/`;\n return {\n wasm: `${base}${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${base}${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n }\n\n return resolveNpmCdnCircuitPaths();\n}\n","import {\n WITHDRAW_CIRCUIT_WASM,\n WITHDRAW_CIRCUIT_ZKEY,\n resolveBrowserCircuitPaths,\n resolveCircuitPathsFromBase,\n type CircuitPaths,\n} from \"./constants\";\n\nexport {\n PACKAGE_NAME,\n SELF_HOSTED_CIRCUIT_BASE,\n WITHDRAW_CIRCUIT_SHA256,\n WITHDRAW_CIRCUIT_WASM,\n WITHDRAW_CIRCUIT_ZKEY,\n resolveBrowserCircuitPaths,\n resolveCircuitPathsFromBase,\n resolveNpmCdnCircuitPaths,\n resolveNpmCdnCircuitBase,\n type CircuitPaths,\n} from \"./constants\";\n\n/**\n * Resolve default Groth16 circuit URLs.\n *\n * Published as `veilix-sdk/circuits/paths` so `import.meta.url` stays next to\n * `withdraw.wasm` and `withdraw.zkey` in `dist/circuits/` (Node / unbundled ESM).\n *\n * In the browser, defaults to `/node_modules/<pkg>/dist/circuits/` on localhost\n * and the pinned, SHA-256-verified jsDelivr CDN in production (domain-independent).\n * Override via {@link VeilixSdkInitOptions.circuitPathsBase},\n * {@link resolveCircuitPathsFromBase}, or {@link GenerateWithdrawProofOptions}.\n */\nexport function resolveCircuitPaths(base?: string): CircuitPaths {\n if (base !== undefined) {\n return resolveCircuitPathsFromBase(base);\n }\n\n const browser = resolveBrowserCircuitPaths();\n if (browser) {\n return browser;\n }\n\n return {\n wasm: new URL(`./${WITHDRAW_CIRCUIT_WASM}`, import.meta.url).href,\n zkey: new URL(`./${WITHDRAW_CIRCUIT_ZKEY}`, import.meta.url).href,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../package.json","../../src/circuits/constants.ts","../../src/circuits/paths.ts"],"names":[],"mappings":";AAAA,IAAA,eAAA,GAAA;AAAA,EACE,IAAA,EAAQ,YAmGV,CAAA;;;ACjGO,IAAM,eAAe,eAAA,CAAY;AAMjC,IAAM,qBAAA,GAAwB;AAC9B,IAAM,qBAAA,GAAwB;AAK9B,IAAM,uBAAA,GAA0B;AAAA,EACrC,IAAA,EAAM,kEAAA;AAAA,EACN,IAAA,EAAM;AACR;AAGO,IAAM,wBAAA,GAA2B;AAUjC,IAAM,mBAAA,GAAsB,YAAA;AAC5B,IAAM,mBAAA,GAAsB,OAAA;AAQ5B,SAAS,4BAA4B,IAAA,EAA4B;AACtE,EAAA,MAAM,OAAO,IAAA,CAAK,QAAA,CAAS,GAAG,CAAA,GAAI,IAAA,GAAO,GAAG,IAAI,CAAA,CAAA,CAAA;AAChD,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,SAAA,EAAY,qBAAqB,CAAA,CAAA;AAAA,IAC9C,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,SAAA,EAAY,qBAAqB,CAAA;AAAA,GAChD;AACF;AASO,SAAS,wBAAA,GAAmC;AACjD,EAAA,OAAO,CAAA,6BAAA,EAAgC,mBAAmB,CAAA,CAAA,EAAI,mBAAmB,CAAA,eAAA,CAAA;AACnF;AAGO,SAAS,y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AAI,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA,CAAE,IAAA;AAAA,IAC7D,IAAA,EAAM,IAAI,GAAA,CAAI,CAAA,EAAA,EAAK,qBAAqB,CAAA,CAAA,EAAI,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA,CAAE;AAAA,GAC/D;AACF","file":"paths.js","sourcesContent":["{\n \"name\": \"veilix-sdk\",\n \"version\": \"0.2.2\",\n \"description\": \"Veilix Privacy SDK\",\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"sideEffects\": false,\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/index.d.cts\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"./circuits/paths\": {\n \"import\": \"./dist/circuits/paths.js\",\n \"require\": \"./dist/circuits/paths.cjs\",\n \"default\": \"./dist/circuits/paths.js\"\n },\n \"./circuits/*\": \"./dist/circuits/*\",\n \"./vite\": {\n \"import\": {\n \"types\": \"./dist/vite/index.d.ts\",\n \"default\": \"./dist/vite/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/vite/index.d.cts\",\n \"default\": \"./dist/vite/index.cjs\"\n }\n },\n \"./react\": {\n \"import\": {\n \"types\": \"./dist/react/index.d.ts\",\n \"default\": \"./dist/react/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/react/index.d.cts\",\n \"default\": \"./dist/react/index.cjs\"\n }\n },\n \"./package.json\": \"./package.json\"\n },\n \"peerDependencies\": {\n \"@solana/wallet-adapter-react\": \">=0.15.0\",\n \"react\": \">=18\"\n },\n \"peerDependenciesMeta\": {\n \"@solana/wallet-adapter-react\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"prepare:snarkjs\": \"node scripts/prepare-snarkjs.mjs\",\n \"build\": \"npm run prepare:snarkjs && tsup\",\n \"dev\": \"npm run prepare:snarkjs && tsup --watch\",\n \"typecheck\": \"npm run prepare:snarkjs && tsc --noEmit\",\n \"prepublishOnly\": \"npm run build\"\n },\n \"keywords\": [\n \"veilix-sdk\",\n \"sdk\"\n ],\n \"license\": \"MIT\",\n \"devDependencies\": {\n \"@solana/wallet-adapter-react\": \"^0.15.39\",\n \"@types/bn.js\": \"^5.2.0\",\n \"@types/node\": \"^26.0.0\",\n \"@types/react\": \"^19.1.8\",\n \"react\": \"^19.1.0\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^5.8.3\"\n },\n \"engines\": {\n \"node\": \">=18\"\n },\n \"dependencies\": {\n \"@coral-xyz/anchor\": \"^0.31.1\",\n \"@solana/spl-token\": \"^0.4.14\",\n \"@solana/web3.js\": \"^1.98.4\",\n \"@switchboard-xyz/common\": \"^5.8.1\",\n \"@switchboard-xyz/on-demand\": \"^3.10.1\",\n \"bn.js\": \"^5.2.5\",\n \"buffer\": \"^6.0.3\",\n \"ffjavascript\": \"^0.3.1\",\n \"fixed-merkle-tree\": \"^0.7.3\",\n \"poseidon-hash\": \"^1.0.1\",\n \"tweetnacl\": \"^1.0.3\"\n }\n}\n","import packageJson from \"../../package.json\";\n\n/** npm package name (used to load the standalone circuits module). */\nexport const PACKAGE_NAME = packageJson.name;\n\n/** Published npm version (pins CDN circuit URLs in production). */\nexport const PACKAGE_VERSION = packageJson.version;\n\n/** Withdraw circuit artifact filenames (published under `veilix-sdk/circuits/`). */\nexport const WITHDRAW_CIRCUIT_WASM = \"withdraw.wasm\";\nexport const WITHDRAW_CIRCUIT_ZKEY = \"withdraw.zkey\";\n/**\n * Pinned SHA-256 hashes for the published withdraw circuit artifacts.\n * These are verified in-browser before passing artifacts to snarkjs.\n */\nexport const WITHDRAW_CIRCUIT_SHA256 = {\n wasm: \"5f9eb88bcbc1b3dd5669dad6fdd3b91d59dd2d617ad0b34827af8a498d13fa60\",\n zkey: \"73e0d2328eca8f48024b69b42d659b68d7dd2f067d762079e859ffff34360a1a\",\n} as const;\n\n/** Optional self-hosted path convention (opt-in via `circuitPathsBase`). */\nexport const SELF_HOSTED_CIRCUIT_BASE = \"/circuits/\";\n\n/**\n * Stable published source for the pinned circuit artifacts.\n *\n * Decoupled from {@link PACKAGE_VERSION} on purpose: the withdraw circuit is a\n * fixed cryptographic artifact, so SDK code releases must not change where the\n * verified circuits are fetched from. Bump these together with\n * {@link WITHDRAW_CIRCUIT_SHA256} only when the circuit itself changes.\n */\nexport const CIRCUIT_CDN_PACKAGE = \"veilix-sdk\";\nexport const CIRCUIT_CDN_VERSION = \"0.2.0\";\n\nexport type CircuitPaths = {\n wasm: string;\n zkey: string;\n};\n\n/** Resolve circuit URLs when the caller knows the package `dist/` root. */\nexport function resolveCircuitPathsFromBase(base: string): CircuitPaths {\n const root = base.endsWith(\"/\") ? base : `${base}/`;\n return {\n wasm: `${root}circuits/${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${root}circuits/${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n}\n\n/**\n * Base URL for circuit files on jsDelivr.\n *\n * Pinned to {@link CIRCUIT_CDN_PACKAGE}@{@link CIRCUIT_CDN_VERSION} (not the\n * current SDK version) so the bytes always match {@link WITHDRAW_CIRCUIT_SHA256}.\n * This URL is independent of the consuming app's origin/domain.\n */\nexport function resolveNpmCdnCircuitBase(): string {\n return `https://cdn.jsdelivr.net/npm/${CIRCUIT_CDN_PACKAGE}@${CIRCUIT_CDN_VERSION}/dist/circuits/`;\n}\n\n/** Trusted jsDelivr fallback paths for pinned withdraw circuit artifacts. */\nexport function resolveNpmCdnCircuitPaths(): CircuitPaths {\n const base = resolveNpmCdnCircuitBase();\n return {\n wasm: `${base}${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${base}${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n}\n\nfunction isLocalDevHost(hostname: string): boolean {\n return (\n hostname === \"localhost\" ||\n hostname === \"127.0.0.1\" ||\n hostname === \"[::1]\"\n );\n}\n\n/**\n * Browser circuit URLs.\n *\n * - Local dev (Vite): `/node_modules/<pkg>/dist/circuits/` — Vite serves node_modules.\n * - Production: pinned, domain-independent jsDelivr CDN (verified by SHA-256 before use).\n *\n * The production default does not depend on the app's own origin/domain, so it\n * works on any deployed host with no copy step. Artifacts are always integrity\n * checked before proving (see {@link WITHDRAW_CIRCUIT_SHA256}). To self-host\n * instead, pass {@link VeilixSdkInitOptions.circuitPathsBase} (e.g. `\"/circuits/\"`);\n * it is verified too and falls back to the CDN if unavailable.\n */\nexport function resolveBrowserCircuitPaths(\n baseOverride?: string\n): CircuitPaths | null {\n if (typeof window === \"undefined\") {\n return null;\n }\n\n if (baseOverride !== undefined) {\n return resolveCircuitPathsFromBase(baseOverride);\n }\n\n if (isLocalDevHost(window.location.hostname)) {\n const base = `/node_modules/${PACKAGE_NAME}/dist/circuits/`;\n return {\n wasm: `${base}${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${base}${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n }\n\n return resolveNpmCdnCircuitPaths();\n}\n","import {\n WITHDRAW_CIRCUIT_WASM,\n WITHDRAW_CIRCUIT_ZKEY,\n resolveBrowserCircuitPaths,\n resolveCircuitPathsFromBase,\n type CircuitPaths,\n} from \"./constants\";\n\nexport {\n PACKAGE_NAME,\n SELF_HOSTED_CIRCUIT_BASE,\n WITHDRAW_CIRCUIT_SHA256,\n WITHDRAW_CIRCUIT_WASM,\n WITHDRAW_CIRCUIT_ZKEY,\n resolveBrowserCircuitPaths,\n resolveCircuitPathsFromBase,\n resolveNpmCdnCircuitPaths,\n resolveNpmCdnCircuitBase,\n type CircuitPaths,\n} from \"./constants\";\n\n/**\n * Resolve default Groth16 circuit URLs.\n *\n * Published as `veilix-sdk/circuits/paths` so `import.meta.url` stays next to\n * `withdraw.wasm` and `withdraw.zkey` in `dist/circuits/` (Node / unbundled ESM).\n *\n * In the browser, defaults to `/node_modules/<pkg>/dist/circuits/` on localhost\n * and the pinned, SHA-256-verified jsDelivr CDN in production (domain-independent).\n * Override via {@link VeilixSdkInitOptions.circuitPathsBase},\n * {@link resolveCircuitPathsFromBase}, or {@link GenerateWithdrawProofOptions}.\n */\nexport function resolveCircuitPaths(base?: string): CircuitPaths {\n if (base !== undefined) {\n return resolveCircuitPathsFromBase(base);\n }\n\n const browser = resolveBrowserCircuitPaths();\n if (browser) {\n return browser;\n }\n\n return {\n wasm: new URL(`./${WITHDRAW_CIRCUIT_WASM}`, import.meta.url).href,\n zkey: new URL(`./${WITHDRAW_CIRCUIT_ZKEY}`, import.meta.url).href,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../package.json","../../src/circuits/constants.ts","../../src/circuits/paths.ts"],"names":[],"mappings":";AAAA,IAAA,eAAA,GAAA;AAAA,EACE,IAAA,EAAQ,YAmGV,CAAA;;;ACjGO,IAAM,eAAe,eAAA,CAAY;AAMjC,IAAM,qBAAA,GAAwB;AAC9B,IAAM,qBAAA,GAAwB;AAK9B,IAAM,uBAAA,GAA0B;AAAA,EACrC,IAAA,EAAM,kEAAA;AAAA,EACN,IAAA,EAAM;AACR;AAGO,IAAM,wBAAA,GAA2B;AAUjC,IAAM,mBAAA,GAAsB,YAAA;AAC5B,IAAM,mBAAA,GAAsB,OAAA;AAQ5B,SAAS,4BAA4B,IAAA,EAA4B;AACtE,EAAA,MAAM,OAAO,IAAA,CAAK,QAAA,CAAS,GAAG,CAAA,GAAI,IAAA,GAAO,GAAG,IAAI,CAAA,CAAA,CAAA;AAChD,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,SAAA,EAAY,qBAAqB,CAAA,CAAA;AAAA,IAC9C,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,SAAA,EAAY,qBAAqB,CAAA;AAAA,GAChD;AACF;AASO,SAAS,wBAAA,GAAmC;AACjD,EAAA,OAAO,CAAA,6BAAA,EAAgC,mBAAmB,CAAA,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IAAI,GAAA,CAAI,CAAA,EAAA,EAAK,qBAAqB,CAAA,CAAA,EAAI,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA,CAAE,IAAA;AAAA,IAC7D,IAAA,EAAM,IAAI,GAAA,CAAI,CAAA,EAAA,EAAK,qBAAqB,CAAA,CAAA,EAAI,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA,CAAE;AAAA,GAC/D;AACF","file":"paths.js","sourcesContent":["{\n \"name\": \"veilix-sdk\",\n \"version\": \"0.3.0\",\n \"description\": \"Veilix Privacy SDK\",\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"sideEffects\": false,\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/index.d.cts\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"./circuits/paths\": {\n \"import\": \"./dist/circuits/paths.js\",\n \"require\": \"./dist/circuits/paths.cjs\",\n \"default\": \"./dist/circuits/paths.js\"\n },\n \"./circuits/*\": \"./dist/circuits/*\",\n \"./vite\": {\n \"import\": {\n \"types\": \"./dist/vite/index.d.ts\",\n \"default\": \"./dist/vite/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/vite/index.d.cts\",\n \"default\": \"./dist/vite/index.cjs\"\n }\n },\n \"./react\": {\n \"import\": {\n \"types\": \"./dist/react/index.d.ts\",\n \"default\": \"./dist/react/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/react/index.d.cts\",\n \"default\": \"./dist/react/index.cjs\"\n }\n },\n \"./package.json\": \"./package.json\"\n },\n \"peerDependencies\": {\n \"@solana/wallet-adapter-react\": \">=0.15.0\",\n \"react\": \">=18\"\n },\n \"peerDependenciesMeta\": {\n \"@solana/wallet-adapter-react\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"prepare:snarkjs\": \"node scripts/prepare-snarkjs.mjs\",\n \"build\": \"npm run prepare:snarkjs && tsup\",\n \"dev\": \"npm run prepare:snarkjs && tsup --watch\",\n \"typecheck\": \"npm run prepare:snarkjs && tsc --noEmit\",\n \"prepublishOnly\": \"npm run build\"\n },\n \"keywords\": [\n \"veilix-sdk\",\n \"sdk\"\n ],\n \"license\": \"MIT\",\n \"devDependencies\": {\n \"@solana/wallet-adapter-react\": \"^0.15.39\",\n \"@types/bn.js\": \"^5.2.0\",\n \"@types/node\": \"^26.0.0\",\n \"@types/react\": \"^19.1.8\",\n \"react\": \"^19.1.0\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^5.8.3\"\n },\n \"engines\": {\n \"node\": \">=18\"\n },\n \"dependencies\": {\n \"@coral-xyz/anchor\": \"^0.31.1\",\n \"@solana/spl-token\": \"^0.4.14\",\n \"@solana/web3.js\": \"^1.98.4\",\n \"@switchboard-xyz/common\": \"^5.8.1\",\n \"@switchboard-xyz/on-demand\": \"^3.10.1\",\n \"bn.js\": \"^5.2.5\",\n \"buffer\": \"^6.0.3\",\n \"ffjavascript\": \"^0.3.1\",\n \"fixed-merkle-tree\": \"^0.7.3\",\n \"poseidon-hash\": \"^1.0.1\",\n \"tweetnacl\": \"^1.0.3\"\n }\n}\n","import packageJson from \"../../package.json\";\n\n/** npm package name (used to load the standalone circuits module). */\nexport const PACKAGE_NAME = packageJson.name;\n\n/** Published npm version (pins CDN circuit URLs in production). */\nexport const PACKAGE_VERSION = packageJson.version;\n\n/** Withdraw circuit artifact filenames (published under `veilix-sdk/circuits/`). */\nexport const WITHDRAW_CIRCUIT_WASM = \"withdraw.wasm\";\nexport const WITHDRAW_CIRCUIT_ZKEY = \"withdraw.zkey\";\n/**\n * Pinned SHA-256 hashes for the published withdraw circuit artifacts.\n * These are verified in-browser before passing artifacts to snarkjs.\n */\nexport const WITHDRAW_CIRCUIT_SHA256 = {\n wasm: \"5f9eb88bcbc1b3dd5669dad6fdd3b91d59dd2d617ad0b34827af8a498d13fa60\",\n zkey: \"73e0d2328eca8f48024b69b42d659b68d7dd2f067d762079e859ffff34360a1a\",\n} as const;\n\n/** Optional self-hosted path convention (opt-in via `circuitPathsBase`). */\nexport const SELF_HOSTED_CIRCUIT_BASE = \"/circuits/\";\n\n/**\n * Stable published source for the pinned circuit artifacts.\n *\n * Decoupled from {@link PACKAGE_VERSION} on purpose: the withdraw circuit is a\n * fixed cryptographic artifact, so SDK code releases must not change where the\n * verified circuits are fetched from. Bump these together with\n * {@link WITHDRAW_CIRCUIT_SHA256} only when the circuit itself changes.\n */\nexport const CIRCUIT_CDN_PACKAGE = \"veilix-sdk\";\nexport const CIRCUIT_CDN_VERSION = \"0.2.0\";\n\nexport type CircuitPaths = {\n wasm: string;\n zkey: string;\n};\n\n/** Resolve circuit URLs when the caller knows the package `dist/` root. */\nexport function resolveCircuitPathsFromBase(base: string): CircuitPaths {\n const root = base.endsWith(\"/\") ? base : `${base}/`;\n return {\n wasm: `${root}circuits/${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${root}circuits/${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n}\n\n/**\n * Base URL for circuit files on jsDelivr.\n *\n * Pinned to {@link CIRCUIT_CDN_PACKAGE}@{@link CIRCUIT_CDN_VERSION} (not the\n * current SDK version) so the bytes always match {@link WITHDRAW_CIRCUIT_SHA256}.\n * This URL is independent of the consuming app's origin/domain.\n */\nexport function resolveNpmCdnCircuitBase(): string {\n return `https://cdn.jsdelivr.net/npm/${CIRCUIT_CDN_PACKAGE}@${CIRCUIT_CDN_VERSION}/dist/circuits/`;\n}\n\n/** Trusted jsDelivr fallback paths for pinned withdraw circuit artifacts. */\nexport function resolveNpmCdnCircuitPaths(): CircuitPaths {\n const base = resolveNpmCdnCircuitBase();\n return {\n wasm: `${base}${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${base}${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n}\n\nfunction isLocalDevHost(hostname: string): boolean {\n return (\n hostname === \"localhost\" ||\n hostname === \"127.0.0.1\" ||\n hostname === \"[::1]\"\n );\n}\n\n/**\n * Browser circuit URLs.\n *\n * - Local dev (Vite): `/node_modules/<pkg>/dist/circuits/` — Vite serves node_modules.\n * - Production: pinned, domain-independent jsDelivr CDN (verified by SHA-256 before use).\n *\n * The production default does not depend on the app's own origin/domain, so it\n * works on any deployed host with no copy step. Artifacts are always integrity\n * checked before proving (see {@link WITHDRAW_CIRCUIT_SHA256}). To self-host\n * instead, pass {@link VeilixSdkInitOptions.circuitPathsBase} (e.g. `\"/circuits/\"`);\n * it is verified too and falls back to the CDN if unavailable.\n */\nexport function resolveBrowserCircuitPaths(\n baseOverride?: string\n): CircuitPaths | null {\n if (typeof window === \"undefined\") {\n return null;\n }\n\n if (baseOverride !== undefined) {\n return resolveCircuitPathsFromBase(baseOverride);\n }\n\n if (isLocalDevHost(window.location.hostname)) {\n const base = `/node_modules/${PACKAGE_NAME}/dist/circuits/`;\n return {\n wasm: `${base}${WITHDRAW_CIRCUIT_WASM}`,\n zkey: `${base}${WITHDRAW_CIRCUIT_ZKEY}`,\n };\n }\n\n return resolveNpmCdnCircuitPaths();\n}\n","import {\n WITHDRAW_CIRCUIT_WASM,\n WITHDRAW_CIRCUIT_ZKEY,\n resolveBrowserCircuitPaths,\n resolveCircuitPathsFromBase,\n type CircuitPaths,\n} from \"./constants\";\n\nexport {\n PACKAGE_NAME,\n SELF_HOSTED_CIRCUIT_BASE,\n WITHDRAW_CIRCUIT_SHA256,\n WITHDRAW_CIRCUIT_WASM,\n WITHDRAW_CIRCUIT_ZKEY,\n resolveBrowserCircuitPaths,\n resolveCircuitPathsFromBase,\n resolveNpmCdnCircuitPaths,\n resolveNpmCdnCircuitBase,\n type CircuitPaths,\n} from \"./constants\";\n\n/**\n * Resolve default Groth16 circuit URLs.\n *\n * Published as `veilix-sdk/circuits/paths` so `import.meta.url` stays next to\n * `withdraw.wasm` and `withdraw.zkey` in `dist/circuits/` (Node / unbundled ESM).\n *\n * In the browser, defaults to `/node_modules/<pkg>/dist/circuits/` on localhost\n * and the pinned, SHA-256-verified jsDelivr CDN in production (domain-independent).\n * Override via {@link VeilixSdkInitOptions.circuitPathsBase},\n * {@link resolveCircuitPathsFromBase}, or {@link GenerateWithdrawProofOptions}.\n */\nexport function resolveCircuitPaths(base?: string): CircuitPaths {\n if (base !== undefined) {\n return resolveCircuitPathsFromBase(base);\n }\n\n const browser = resolveBrowserCircuitPaths();\n if (browser) {\n return browser;\n }\n\n return {\n wasm: new URL(`./${WITHDRAW_CIRCUIT_WASM}`, import.meta.url).href,\n zkey: new URL(`./${WITHDRAW_CIRCUIT_ZKEY}`, import.meta.url).href,\n };\n}\n"]}
|