veilix-sdk 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,390 @@
1
+ import { PublicKey, Keypair, Connection, TransactionInstruction, Transaction } from '@solana/web3.js';
2
+ import { OracleJob } from '@switchboard-xyz/common';
3
+ import { Program } from '@coral-xyz/anchor';
4
+ import { Wallet } from '@coral-xyz/anchor/dist/cjs/provider';
5
+ import { C as CircuitPaths } from './constants-9OPXLj27.js';
6
+
7
+ type IndexerAsset = string | {
8
+ mint?: string;
9
+ asset?: string;
10
+ } | null;
11
+
12
+ /** Frontend wallet adapter or backend {@link Keypair}. */
13
+ type EncryptKeyWallet = Keypair | {
14
+ signMessage: (message: Uint8Array) => Promise<Uint8Array> | Uint8Array;
15
+ };
16
+ type BuildDepositTxParams = {
17
+ senderPublicKey: PublicKey | string;
18
+ /** Pre-generated secret note from {@link generateDepositParams}. */
19
+ note: string;
20
+ onChainBackup?: boolean;
21
+ computeUnitPrice?: number;
22
+ tempSigner?: PublicKey | string;
23
+ };
24
+ type FetchWalletBalanceOptions = {
25
+ includeDeposits?: boolean;
26
+ indexerAsset?: IndexerAsset;
27
+ };
28
+ type BuildRelayPayloadParams = {
29
+ args: unknown[];
30
+ proofHex: string;
31
+ denomination: number | bigint | string;
32
+ withdrawAddress: unknown;
33
+ relayerPubkey: unknown;
34
+ mint?: unknown;
35
+ };
36
+ type RelayPayload = Record<string, unknown>;
37
+
38
+ type DepositParams = {
39
+ nullifier: string;
40
+ secret: string;
41
+ amount: string;
42
+ commitment: string;
43
+ nullifierHash: string;
44
+ mint: string | null;
45
+ };
46
+ type GenerateDepositParamsResult = {
47
+ params: DepositParams;
48
+ note: string;
49
+ };
50
+ type PreparedCircuitArtifacts = {
51
+ wasmPath: string;
52
+ zkeyPath: string;
53
+ /** Revokes the browser object URLs. `null` outside the browser. */
54
+ cleanup: (() => void) | null;
55
+ };
56
+ type GenerateWithdrawProofOptions = {
57
+ /** Override WASM path/URL (for bundled frontends, use a Vite `?url` import). */
58
+ circuitWasmPath?: string;
59
+ /** Override zkey path/URL (for bundled frontends, use a Vite `?url` import). */
60
+ circuitZkeyPath?: string;
61
+ /**
62
+ * Artifacts already fetched and verified by {@link prepareCircuitArtifacts}.
63
+ * Skips the download and takes precedence over the path overrides; the caller
64
+ * stays responsible for calling `cleanup`.
65
+ */
66
+ circuitArtifacts?: PreparedCircuitArtifacts;
67
+ };
68
+ /**
69
+ * Fetch and integrity-check the withdraw circuit artifacts once so that several
70
+ * proofs can share them. Call `cleanup` after the last proof has settled.
71
+ */
72
+ declare const prepareCircuitArtifacts: (circuitWasmPath?: string, circuitZkeyPath?: string) => Promise<PreparedCircuitArtifacts>;
73
+
74
+ type Network = "mainnet" | "devnet";
75
+ declare const MAINNET_TOKEN_MINTS: {
76
+ readonly Veilix: "3jSL5nnnYcRLmTqFmwvY1Mikh42fQsT7p7NvXPYzanon";
77
+ readonly Bitcoin: "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh";
78
+ readonly Ethereum: "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs";
79
+ readonly USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
80
+ };
81
+ type TokenSymbol = keyof typeof MAINNET_TOKEN_MINTS;
82
+ declare const TOKEN_DECIMALS: {
83
+ readonly Solana: 9;
84
+ readonly Veilix: 9;
85
+ readonly Ethereum: 8;
86
+ readonly Bitcoin: 8;
87
+ readonly USDC: 6;
88
+ };
89
+ type TokenDecimalsSymbol = keyof typeof TOKEN_DECIMALS;
90
+ /** Supported deposit denominations per token (same on mainnet and devnet). */
91
+ declare const DEPOSIT_AMOUNTS: {
92
+ readonly Solana: readonly [0.1, 1, 5, 10, 50, 100, 500];
93
+ readonly Veilix: readonly [10000, 50000, 100000, 500000, 1000000, 10000000];
94
+ readonly Bitcoin: readonly [0.01, 0.05, 0.1, 0.5, 1, 5];
95
+ readonly Ethereum: readonly [0.1, 1, 10, 50, 100, 500];
96
+ readonly USDC: readonly [1, 10, 50, 100, 1000, 10000, 100000, 1000000];
97
+ };
98
+ type DepositTokenSymbol = keyof typeof DEPOSIT_AMOUNTS;
99
+
100
+ type Relayer = {
101
+ isValid: true;
102
+ label: string;
103
+ url: string;
104
+ key: number;
105
+ value: string;
106
+ fee: unknown;
107
+ recentActivities: unknown;
108
+ userPubkey: unknown;
109
+ workers: unknown;
110
+ totalFeeEarningsSol: unknown;
111
+ totalWithdrawCount: unknown;
112
+ stakedAmount: unknown;
113
+ volume24hSol: unknown;
114
+ volume7dSol: unknown;
115
+ };
116
+
117
+ interface VeilixSdkInitOptions {
118
+ /** Range API key (frontend: VITE_RANGE_API_KEY). */
119
+ rangeApiKey: string;
120
+ /** Wallet for Anchor provider transactions. */
121
+ wallet: Wallet;
122
+ /**
123
+ * Solana JSON-RPC endpoint (Node/scripts). Omit when passing {@link connection}
124
+ * from `@solana/wallet-adapter-react` (`useConnection()`).
125
+ */
126
+ rpcEndpoint?: string;
127
+ /** Existing connection (e.g. `useConnection()` in React). */
128
+ connection?: Connection;
129
+ /**
130
+ * Cluster override when the RPC URL does not contain `devnet` / `mainnet` hints
131
+ * (common with private RPC providers).
132
+ */
133
+ network: Network;
134
+ /**
135
+ * Base URL/path for withdraw circuit artifacts in the browser.
136
+ * Defaults to `/node_modules/<pkg>/dist/circuits/` on localhost and the
137
+ * pinned, SHA-256-verified jsDelivr CDN in production (domain-independent).
138
+ * Set this to self-host instead, e.g. `"/circuits/"` (verified, with CDN fallback)
139
+ * or `"https://cdn.example.com/veilix/circuits/"`.
140
+ */
141
+ circuitPathsBase?: string;
142
+ }
143
+ interface VeilixSdkRuntimeConfig {
144
+ rangeApiKey: string;
145
+ rpcEndpoint: string;
146
+ /** Cluster inferred from {@link rpcEndpoint}. */
147
+ network: Network;
148
+ programId: string;
149
+ /** Active relayers for {@link network}, loaded at SDK initialization. */
150
+ relayers: Relayer[];
151
+ connection: Connection;
152
+ wallet: Wallet;
153
+ program: Program;
154
+ /** Set by {@link VeilixSDK.getEncryptionKey}; required for on-chain note backup. */
155
+ encryptKey?: Uint8Array;
156
+ /** Resolved withdraw circuit wasm/zkey URLs for browser proof generation. */
157
+ circuitPaths?: CircuitPaths;
158
+ }
159
+
160
+ type WithdrawParams = {
161
+ /** Secret note from the original deposit. */
162
+ note: string;
163
+ /** Withdrawal recipient public key. */
164
+ recipient: PublicKey | string;
165
+ /** Mode for normal withdraw or veilix transfer. */
166
+ veilixTransferMode?: boolean;
167
+ };
168
+ type WithdrawStatus = "success" | "failed";
169
+ type WithdrawResult = {
170
+ txHash: string;
171
+ status: WithdrawStatus;
172
+ };
173
+
174
+ type QuoteRelayer = {
175
+ url: string;
176
+ [key: string]: unknown;
177
+ };
178
+ type QuoteTransaction = Record<string, unknown>;
179
+ type QuoteSplit = {
180
+ denomination: number;
181
+ totalRelayerFee: number;
182
+ relayer: QuoteRelayer;
183
+ transaction: QuoteTransaction;
184
+ };
185
+ type Quote = {
186
+ amount: number;
187
+ transactionCount: number;
188
+ recipientAmount: number;
189
+ totalRelayerFee: number;
190
+ etaSeconds: number;
191
+ splits: QuoteSplit[];
192
+ platformFee?: number;
193
+ };
194
+ type GetQuoteResponse = {
195
+ success: boolean;
196
+ quote: Quote;
197
+ };
198
+ type GetQuoteParams = {
199
+ amount: number | string;
200
+ amountLamports: number | string | bigint;
201
+ recipient: PublicKey | string;
202
+ /** Indexer asset label (default `SOL`). */
203
+ asset?: string;
204
+ /** Cluster for the quote (default active SDK network). */
205
+ network?: Network;
206
+ };
207
+ /** Fetch a withdraw quote from the indexer. Requires SDK init or an active instance context. */
208
+ declare function getQuote(params: GetQuoteParams): Promise<GetQuoteResponse>;
209
+
210
+ type ResolvedNoteAsset = {
211
+ key: string;
212
+ tokenName: TokenDecimalsSymbol;
213
+ unit: string;
214
+ multiplier: bigint;
215
+ mint: string | null;
216
+ poolAmounts: readonly number[];
217
+ decimals: number;
218
+ };
219
+
220
+ type VeilixTransferItem = {
221
+ mint: PublicKey;
222
+ /** Human-readable token amount (e.g. `"1.5"` SOL). */
223
+ amount: string;
224
+ recipient: PublicKey;
225
+ };
226
+ type VeilixTransferDepositFailure = {
227
+ amount: string;
228
+ mint: string;
229
+ recipient: string;
230
+ };
231
+ type VeilixTransferWithdrawFailure = {
232
+ note: string;
233
+ recipient: string;
234
+ };
235
+ type VeilixTransferResult = {
236
+ error: boolean;
237
+ depositFailed: VeilixTransferDepositFailure[];
238
+ withdrawFailed: VeilixTransferWithdrawFailure[];
239
+ depositSuccess: string[];
240
+ };
241
+ type VeilixTransferOptions = {
242
+ /** When true, all withdraws use the same randomly selected relayer. */
243
+ uniqueRelayer?: boolean;
244
+ };
245
+
246
+ /**
247
+ * Veilix SDK client. Create one instance per configuration (network, RPC, API keys).
248
+ *
249
+ * @example
250
+ * ```js
251
+ * const { VeilixSDK } = require('veilix-sdk');
252
+ * const sdk = await VeilixSDK.create({
253
+ * rangeApiKey: process.env.RANGE_API_KEY,
254
+ * rpcEndpoint: 'https://api.devnet.solana.com',
255
+ * wallet,
256
+ * });
257
+ * console.log(sdk.config.relayers);
258
+ * ```
259
+ *
260
+ * @example React (wallet-adapter)
261
+ * ```tsx
262
+ * import { useVeilixSdk } from 'veilix-sdk/react';
263
+ *
264
+ * function MyComponent() {
265
+ * const sdk = useVeilixSdk({ rangeApiKey: import.meta.env.VITE_RANGE_API_KEY });
266
+ * if (!sdk) return null;
267
+ * // ...
268
+ * }
269
+ * ```
270
+ *
271
+ * @example
272
+ * ```ts
273
+ * import { VeilixSDK } from 'veilix-sdk';
274
+ * const sdk = await VeilixSDK.create({ rangeApiKey, rpcEndpoint, wallet });
275
+ * await sdk.getEncryptionKey(wallet);
276
+ * const { note } = sdk.generateDepositParams(1_000_000_000n, null);
277
+ * await sdk.buildDepositTx({ senderPublicKey: wallet.publicKey, note, onChainBackup: true });
278
+ * ```
279
+ */
280
+ declare class VeilixSDK {
281
+ static readonly VERSION = "0.0.1";
282
+ readonly config: VeilixSdkRuntimeConfig;
283
+ private constructor();
284
+ /** Create an SDK instance (loads relayers for the inferred network). */
285
+ static create(options: VeilixSdkInitOptions): Promise<VeilixSDK>;
286
+ private run;
287
+ private runAsync;
288
+ getConfig(): VeilixSdkRuntimeConfig;
289
+ getRangeApiKey(): string;
290
+ getRpcEndpoint(): string;
291
+ getNetwork(): Network;
292
+ getProgramIdString(): string;
293
+ /** Encryption key derived by {@link getEncryptionKey}; undefined until set. */
294
+ get encryptKey(): Uint8Array | undefined;
295
+ /** Relayers loaded at initialization; use {@link fetchRelayers} to refresh. */
296
+ get relayers(): Relayer[];
297
+ getIndexerUrl(): string;
298
+ getRiskApiUrl(): string;
299
+ getTokenMints(): {
300
+ Solana: string;
301
+ Veilix: "3jSL5nnnYcRLmTqFmwvY1Mikh42fQsT7p7NvXPYzanon" | "ARCxcL6oX2pd4bKmUxhdoARaaHdKU6TJrTTthPANPQtQ";
302
+ Bitcoin: "" | "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh";
303
+ Ethereum: "" | "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs";
304
+ USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" | "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU";
305
+ };
306
+ getVeilixTokenMint(): string;
307
+ getTokenMint(symbol: TokenSymbol): string;
308
+ getDepositAmounts(symbol: DepositTokenSymbol): readonly number[];
309
+ getTokenDecimals(symbol: TokenDecimalsSymbol): number;
310
+ resolveCircuitPaths(base?: string): Promise<CircuitPaths>;
311
+ getRangeRiskScoreJob(address: string): OracleJob;
312
+ getOracleQuote(payer: Keypair | PublicKey, addressToCheck: string): Promise<{
313
+ queueAccount: PublicKey;
314
+ sigVerifyIx: TransactionInstruction;
315
+ }>;
316
+ getProgramId(): PublicKey;
317
+ getPoolPDA(denominationLamports: number | bigint): [PublicKey, number];
318
+ getTokenPoolPDA(mint: PublicKey | string, denominationSmallestUnits: number | bigint): [PublicKey, number];
319
+ getTreasuryPDA(): [PublicKey, number];
320
+ getCommitmentPDA(commitmentBigInt: bigint | number | string): [PublicKey, number];
321
+ getNullifierPDA(nullifierHashBigInt: bigint | number | string): [PublicKey, number];
322
+ getNetworkStatePDA(): [PublicKey, number];
323
+ buildDepositTx(params: BuildDepositTxParams): Promise<{
324
+ tx: Transaction;
325
+ note: string;
326
+ }>;
327
+ /**
328
+ * Withdraw to `recipient` using a secret `note`.
329
+ * Relayer is chosen at random from {@link config.relayers}, or by {@link WithdrawParams.relayerIdx}.
330
+ */
331
+ withdraw(params: WithdrawParams, relayerIdx?: number): Promise<WithdrawResult>;
332
+ /**
333
+ * Private transfer: deposit into the pool (split by supported denominations),
334
+ * then withdraw each successful note to the recipient.
335
+ *
336
+ * Requires {@link getEncryptionKey} before calling (deposits use on-chain backup).
337
+ *
338
+ * @param tempKeypair Ephemeral keypair co-signed on deposit instructions.
339
+ */
340
+ veilixTransfer(items: VeilixTransferItem[], tempKeypair: Keypair): Promise<VeilixTransferResult>;
341
+ /** Validate a withdraw recipient against the risk API. */
342
+ assertWithdrawRecipientAllowed(address: string): Promise<void>;
343
+ /** Resolve the token asset encoded in a secret note. */
344
+ resolveNoteAsset(amount: string, mint?: string | null, tokenNameHint?: TokenDecimalsSymbol): ResolvedNoteAsset;
345
+ fetchPlatformFee(): Promise<string>;
346
+ /** Fetch a withdraw quote from the indexer. */
347
+ getQuote(params: GetQuoteParams): Promise<GetQuoteResponse>;
348
+ fetchCommitments(denomination: number | bigint | string, indexerAsset?: IndexerAsset): Promise<unknown>;
349
+ validateNullifier(nullifierHash: string, indexerAsset?: IndexerAsset): Promise<unknown>;
350
+ fetchTxStatus(commitmentHex: string, nullifierHashHex: string, indexerAsset?: IndexerAsset): Promise<unknown>;
351
+ fetchDepositCountByCommitment(commitment: string, denomination: number | bigint | string, indexerAsset?: IndexerAsset): Promise<unknown>;
352
+ fetchWalletBalance(wallet: string, options?: FetchWalletBalanceOptions): Promise<unknown>;
353
+ /** Re-fetch relayers from the indexer and update {@link config.relayers}. */
354
+ fetchRelayers(): Promise<Relayer[]>;
355
+ fetchLatestTransactions(type?: string, indexerAsset?: IndexerAsset): Promise<unknown>;
356
+ fetchTxCounts(type?: string, indexerAsset?: IndexerAsset): Promise<unknown>;
357
+ normalizePubkeyString(value: unknown): string;
358
+ buildRelayPayload(params: BuildRelayPayloadParams): RelayPayload;
359
+ submitToRelayer(relayerUrl: string, payload: RelayPayload): Promise<unknown>;
360
+ pollRelayerJob(relayerUrl: string, jobId: string, maxWaitMs?: number): Promise<unknown>;
361
+ /**
362
+ * Derives the note encryption key from a wallet signature and stores it on
363
+ * {@link config.encryptKey}. Required before {@link buildDepositTx} with
364
+ * `onChainBackup: true`.
365
+ *
366
+ * Accepts a frontend wallet adapter (`signMessage`) or a backend {@link Keypair}.
367
+ */
368
+ getEncryptionKey(wallet: EncryptKeyWallet): Promise<Uint8Array>;
369
+ encryptData(key: Uint8Array, plaintext: string): Uint8Array<ArrayBufferLike>;
370
+ decryptData(key: Uint8Array, combined: Uint8Array): string;
371
+ generateRandomFieldElement(): bigint;
372
+ createCommitment(nullifier: bigint | number | string, secret: bigint | number | string): bigint;
373
+ createNullifierHash(nullifier: bigint | number | string): bigint;
374
+ generateDepositParams(amountLamports: bigint | number | string, mint?: string | null): GenerateDepositParamsResult;
375
+ parseSecretNote(note: string): Record<string, string>;
376
+ publicKeyToFieldElement(publicKeyBytes: Uint8Array | number[]): bigint;
377
+ amountToFieldElement(amount: bigint | number | string): bigint;
378
+ generateMerkleProof(depositParams: Record<string, unknown>, leaves: unknown[]): unknown;
379
+ generateWithdrawProof(depositParams: Record<string, unknown>, leaves: unknown[], recipient: PublicKey | string, relayer: PublicKey | string, fee: bigint | number | string, refund: bigint | number | string, options?: GenerateWithdrawProofOptions): Promise<unknown>;
380
+ convertProofToBytes(proof: unknown): Promise<number[] | Uint8Array<ArrayBufferLike>>;
381
+ to32ByteBuffer(bigInt: bigint | number | string): Uint8Array<ArrayBufferLike>;
382
+ toFixedHex(value: bigint | number | string, length?: number): string;
383
+ toFieldElementHex(value: bigint | number | string): string;
384
+ formatNoteForDisplay(note: string, segmentLen?: number): string;
385
+ appendIndexerAsset(params: URLSearchParams, indexerAsset?: IndexerAsset): void;
386
+ /** Program ID for a cluster without an SDK instance. */
387
+ static getProgramIdForNetwork(network: Network): string;
388
+ }
389
+
390
+ export { type BuildDepositTxParams as B, type DepositTokenSymbol as D, type EncryptKeyWallet as E, type FetchWalletBalanceOptions as F, type GenerateDepositParamsResult as G, type IndexerAsset as I, type Network as N, type PreparedCircuitArtifacts as P, type Quote as Q, type RelayPayload as R, type TokenDecimalsSymbol as T, VeilixSDK as V, type WithdrawParams as W, type BuildRelayPayloadParams as a, type GenerateWithdrawProofOptions as b, type GetQuoteParams as c, type GetQuoteResponse as d, type QuoteRelayer as e, type QuoteSplit as f, type QuoteTransaction as g, type Relayer as h, type ResolvedNoteAsset as i, type TokenSymbol as j, type VeilixSdkInitOptions as k, type VeilixSdkRuntimeConfig as l, type VeilixTransferDepositFailure as m, type VeilixTransferItem as n, type VeilixTransferOptions as o, type VeilixTransferResult as p, type VeilixTransferWithdrawFailure as q, type WithdrawResult as r, type WithdrawStatus as s, getQuote as t, prepareCircuitArtifacts as u };
@@ -0,0 +1,82 @@
1
+ 'use strict';
2
+
3
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
4
+ // package.json
5
+ var package_default = {
6
+ name: "veilix-sdk"};
7
+
8
+ // src/circuits/constants.ts
9
+ var PACKAGE_NAME = package_default.name;
10
+ var WITHDRAW_CIRCUIT_WASM = "withdraw.wasm";
11
+ var WITHDRAW_CIRCUIT_ZKEY = "withdraw.zkey";
12
+ var WITHDRAW_CIRCUIT_SHA256 = {
13
+ wasm: "2565a8dd94b0b3cb9ec6d415933ab05ed5d32ac07165b71be6bcf31615fc0330",
14
+ zkey: "64a4d915099f6fe6bfa06e151c254843be8773c7991c742260019dc5184e5d82"
15
+ };
16
+ var SELF_HOSTED_CIRCUIT_BASE = "/circuits/";
17
+ var CIRCUIT_CDN_PACKAGE = "veilix-sdk";
18
+ var CIRCUIT_CDN_VERSION = "0.0.2";
19
+ function resolveCircuitPathsFromBase(base) {
20
+ const root = base.endsWith("/") ? base : `${base}/`;
21
+ return {
22
+ wasm: `${root}circuits/${WITHDRAW_CIRCUIT_WASM}`,
23
+ zkey: `${root}circuits/${WITHDRAW_CIRCUIT_ZKEY}`
24
+ };
25
+ }
26
+ function resolveNpmCdnCircuitBase() {
27
+ return `https://cdn.jsdelivr.net/npm/${CIRCUIT_CDN_PACKAGE}@${CIRCUIT_CDN_VERSION}/dist/circuits/`;
28
+ }
29
+ function resolveNpmCdnCircuitPaths() {
30
+ const base = resolveNpmCdnCircuitBase();
31
+ return {
32
+ wasm: `${base}${WITHDRAW_CIRCUIT_WASM}`,
33
+ zkey: `${base}${WITHDRAW_CIRCUIT_ZKEY}`
34
+ };
35
+ }
36
+ function isLocalDevHost(hostname) {
37
+ return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]";
38
+ }
39
+ function resolveBrowserCircuitPaths(baseOverride) {
40
+ if (typeof window === "undefined") {
41
+ return null;
42
+ }
43
+ if (baseOverride !== void 0) {
44
+ return resolveCircuitPathsFromBase(baseOverride);
45
+ }
46
+ if (isLocalDevHost(window.location.hostname)) {
47
+ const base = `/node_modules/${PACKAGE_NAME}/dist/circuits/`;
48
+ return {
49
+ wasm: `${base}${WITHDRAW_CIRCUIT_WASM}`,
50
+ zkey: `${base}${WITHDRAW_CIRCUIT_ZKEY}`
51
+ };
52
+ }
53
+ return resolveNpmCdnCircuitPaths();
54
+ }
55
+
56
+ // src/circuits/paths.ts
57
+ function resolveCircuitPaths(base) {
58
+ if (base !== void 0) {
59
+ return resolveCircuitPathsFromBase(base);
60
+ }
61
+ const browser = resolveBrowserCircuitPaths();
62
+ if (browser) {
63
+ return browser;
64
+ }
65
+ return {
66
+ wasm: new URL(`./${WITHDRAW_CIRCUIT_WASM}`, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('paths.cjs', document.baseURI).href))).href,
67
+ zkey: new URL(`./${WITHDRAW_CIRCUIT_ZKEY}`, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('paths.cjs', document.baseURI).href))).href
68
+ };
69
+ }
70
+
71
+ exports.PACKAGE_NAME = PACKAGE_NAME;
72
+ exports.SELF_HOSTED_CIRCUIT_BASE = SELF_HOSTED_CIRCUIT_BASE;
73
+ exports.WITHDRAW_CIRCUIT_SHA256 = WITHDRAW_CIRCUIT_SHA256;
74
+ exports.WITHDRAW_CIRCUIT_WASM = WITHDRAW_CIRCUIT_WASM;
75
+ exports.WITHDRAW_CIRCUIT_ZKEY = WITHDRAW_CIRCUIT_ZKEY;
76
+ exports.resolveBrowserCircuitPaths = resolveBrowserCircuitPaths;
77
+ exports.resolveCircuitPaths = resolveCircuitPaths;
78
+ exports.resolveCircuitPathsFromBase = resolveCircuitPathsFromBase;
79
+ exports.resolveNpmCdnCircuitBase = resolveNpmCdnCircuitBase;
80
+ exports.resolveNpmCdnCircuitPaths = resolveNpmCdnCircuitPaths;
81
+ //# sourceMappingURL=paths.cjs.map
82
+ //# sourceMappingURL=paths.cjs.map
@@ -0,0 +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,YAiGV,CAAA;;;AC/FO,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;AACtC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,EAAG,qBAAqB,CAAA,CAAA;AAAA,IACrC,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,EAAG,qBAAqB,CAAA;AAAA,GACvC;AACF;AAEA,SAAS,eAAe,QAAA,EAA2B;AACjD,EAAA,OACE,QAAA,KAAa,WAAA,IACb,QAAA,KAAa,WAAA,IACb,QAAA,KAAa,OAAA;AAEjB;AAcO,SAAS,2BACd,YAAA,EACqB;AACrB,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACjC,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IAAI,iBAAiB,MAAA,EAAW;AAC9B,IAAA,OAAO,4BAA4B,YAAY,CAAA;AAAA,EACjD;AAEA,EAAA,IAAI,cAAA,CAAe,MAAA,CAAO,QAAA,CAAS,QAAQ,CAAA,EAAG;AAC5C,IAAA,MAAM,IAAA,GAAO,iBAAiB,YAAY,CAAA,eAAA,CAAA;AAC1C,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,EAAG,qBAAqB,CAAA,CAAA;AAAA,MACrC,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,EAAG,qBAAqB,CAAA;AAAA,KACvC;AAAA,EACF;AAEA,EAAA,OAAO,yBAAA,EAA0B;AACnC;;;AC5EO,SAAS,oBAAoB,IAAA,EAA6B;AAC/D,EAAA,IAAI,SAAS,MAAA,EAAW;AACtB,IAAA,OAAO,4BAA4B,IAAI,CAAA;AAAA,EACzC;AAEA,EAAA,MAAM,UAAU,0BAAA,EAA2B;AAC3C,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,OAAO,OAAA;AAAA,EACT;AAEA,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,IAAI,GAAA,CAAI,CAAA,EAAA,EAAK,qBAAqB,CAAA,CAAA,EAAI,2PAAe,CAAA,CAAE,IAAA;AAAA,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.0.1\",\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/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 \"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: \"2565a8dd94b0b3cb9ec6d415933ab05ed5d32ac07165b71be6bcf31615fc0330\",\n zkey: \"64a4d915099f6fe6bfa06e151c254843be8773c7991c742260019dc5184e5d82\",\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.0.2\";\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"]}
@@ -0,0 +1,17 @@
1
+ import { C as CircuitPaths } from '../constants-9OPXLj27.cjs';
2
+ export { P as PACKAGE_NAME, S as SELF_HOSTED_CIRCUIT_BASE, W as WITHDRAW_CIRCUIT_SHA256, a as WITHDRAW_CIRCUIT_WASM, b as WITHDRAW_CIRCUIT_ZKEY, r as resolveBrowserCircuitPaths, c as resolveCircuitPathsFromBase, d as resolveNpmCdnCircuitBase, e as resolveNpmCdnCircuitPaths } from '../constants-9OPXLj27.cjs';
3
+
4
+ /**
5
+ * Resolve default Groth16 circuit URLs.
6
+ *
7
+ * Published as `veilix-sdk/circuits/paths` so `import.meta.url` stays next to
8
+ * `withdraw.wasm` and `withdraw.zkey` in `dist/circuits/` (Node / unbundled ESM).
9
+ *
10
+ * In the browser, defaults to `/node_modules/<pkg>/dist/circuits/` on localhost
11
+ * and the pinned, SHA-256-verified jsDelivr CDN in production (domain-independent).
12
+ * Override via {@link VeilixSdkInitOptions.circuitPathsBase},
13
+ * {@link resolveCircuitPathsFromBase}, or {@link GenerateWithdrawProofOptions}.
14
+ */
15
+ declare function resolveCircuitPaths(base?: string): CircuitPaths;
16
+
17
+ export { CircuitPaths, resolveCircuitPaths };
@@ -0,0 +1,17 @@
1
+ import { C as CircuitPaths } from '../constants-9OPXLj27.js';
2
+ export { P as PACKAGE_NAME, S as SELF_HOSTED_CIRCUIT_BASE, W as WITHDRAW_CIRCUIT_SHA256, a as WITHDRAW_CIRCUIT_WASM, b as WITHDRAW_CIRCUIT_ZKEY, r as resolveBrowserCircuitPaths, c as resolveCircuitPathsFromBase, d as resolveNpmCdnCircuitBase, e as resolveNpmCdnCircuitPaths } from '../constants-9OPXLj27.js';
3
+
4
+ /**
5
+ * Resolve default Groth16 circuit URLs.
6
+ *
7
+ * Published as `veilix-sdk/circuits/paths` so `import.meta.url` stays next to
8
+ * `withdraw.wasm` and `withdraw.zkey` in `dist/circuits/` (Node / unbundled ESM).
9
+ *
10
+ * In the browser, defaults to `/node_modules/<pkg>/dist/circuits/` on localhost
11
+ * and the pinned, SHA-256-verified jsDelivr CDN in production (domain-independent).
12
+ * Override via {@link VeilixSdkInitOptions.circuitPathsBase},
13
+ * {@link resolveCircuitPathsFromBase}, or {@link GenerateWithdrawProofOptions}.
14
+ */
15
+ declare function resolveCircuitPaths(base?: string): CircuitPaths;
16
+
17
+ export { CircuitPaths, resolveCircuitPaths };
@@ -0,0 +1,70 @@
1
+ // package.json
2
+ var package_default = {
3
+ name: "veilix-sdk"};
4
+
5
+ // src/circuits/constants.ts
6
+ var PACKAGE_NAME = package_default.name;
7
+ var WITHDRAW_CIRCUIT_WASM = "withdraw.wasm";
8
+ var WITHDRAW_CIRCUIT_ZKEY = "withdraw.zkey";
9
+ var WITHDRAW_CIRCUIT_SHA256 = {
10
+ wasm: "2565a8dd94b0b3cb9ec6d415933ab05ed5d32ac07165b71be6bcf31615fc0330",
11
+ zkey: "64a4d915099f6fe6bfa06e151c254843be8773c7991c742260019dc5184e5d82"
12
+ };
13
+ var SELF_HOSTED_CIRCUIT_BASE = "/circuits/";
14
+ var CIRCUIT_CDN_PACKAGE = "veilix-sdk";
15
+ var CIRCUIT_CDN_VERSION = "0.0.2";
16
+ function resolveCircuitPathsFromBase(base) {
17
+ const root = base.endsWith("/") ? base : `${base}/`;
18
+ return {
19
+ wasm: `${root}circuits/${WITHDRAW_CIRCUIT_WASM}`,
20
+ zkey: `${root}circuits/${WITHDRAW_CIRCUIT_ZKEY}`
21
+ };
22
+ }
23
+ function resolveNpmCdnCircuitBase() {
24
+ return `https://cdn.jsdelivr.net/npm/${CIRCUIT_CDN_PACKAGE}@${CIRCUIT_CDN_VERSION}/dist/circuits/`;
25
+ }
26
+ function resolveNpmCdnCircuitPaths() {
27
+ const base = resolveNpmCdnCircuitBase();
28
+ return {
29
+ wasm: `${base}${WITHDRAW_CIRCUIT_WASM}`,
30
+ zkey: `${base}${WITHDRAW_CIRCUIT_ZKEY}`
31
+ };
32
+ }
33
+ function isLocalDevHost(hostname) {
34
+ return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]";
35
+ }
36
+ function resolveBrowserCircuitPaths(baseOverride) {
37
+ if (typeof window === "undefined") {
38
+ return null;
39
+ }
40
+ if (baseOverride !== void 0) {
41
+ return resolveCircuitPathsFromBase(baseOverride);
42
+ }
43
+ if (isLocalDevHost(window.location.hostname)) {
44
+ const base = `/node_modules/${PACKAGE_NAME}/dist/circuits/`;
45
+ return {
46
+ wasm: `${base}${WITHDRAW_CIRCUIT_WASM}`,
47
+ zkey: `${base}${WITHDRAW_CIRCUIT_ZKEY}`
48
+ };
49
+ }
50
+ return resolveNpmCdnCircuitPaths();
51
+ }
52
+
53
+ // src/circuits/paths.ts
54
+ function resolveCircuitPaths(base) {
55
+ if (base !== void 0) {
56
+ return resolveCircuitPathsFromBase(base);
57
+ }
58
+ const browser = resolveBrowserCircuitPaths();
59
+ if (browser) {
60
+ return browser;
61
+ }
62
+ return {
63
+ wasm: new URL(`./${WITHDRAW_CIRCUIT_WASM}`, import.meta.url).href,
64
+ zkey: new URL(`./${WITHDRAW_CIRCUIT_ZKEY}`, import.meta.url).href
65
+ };
66
+ }
67
+
68
+ export { PACKAGE_NAME, SELF_HOSTED_CIRCUIT_BASE, WITHDRAW_CIRCUIT_SHA256, WITHDRAW_CIRCUIT_WASM, WITHDRAW_CIRCUIT_ZKEY, resolveBrowserCircuitPaths, resolveCircuitPaths, resolveCircuitPathsFromBase, resolveNpmCdnCircuitBase, resolveNpmCdnCircuitPaths };
69
+ //# sourceMappingURL=paths.js.map
70
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +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,YAiGV,CAAA;;;AC/FO,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;AACtC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,EAAG,qBAAqB,CAAA,CAAA;AAAA,IACrC,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,EAAG,qBAAqB,CAAA;AAAA,GACvC;AACF;AAEA,SAAS,eAAe,QAAA,EAA2B;AACjD,EAAA,OACE,QAAA,KAAa,WAAA,IACb,QAAA,KAAa,WAAA,IACb,QAAA,KAAa,OAAA;AAEjB;AAcO,SAAS,2BACd,YAAA,EACqB;AACrB,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACjC,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IAAI,iBAAiB,MAAA,EAAW;AAC9B,IAAA,OAAO,4BAA4B,YAAY,CAAA;AAAA,EACjD;AAEA,EAAA,IAAI,cAAA,CAAe,MAAA,CAAO,QAAA,CAAS,QAAQ,CAAA,EAAG;AAC5C,IAAA,MAAM,IAAA,GAAO,iBAAiB,YAAY,CAAA,eAAA,CAAA;AAC1C,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,EAAG,qBAAqB,CAAA,CAAA;AAAA,MACrC,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,EAAG,qBAAqB,CAAA;AAAA,KACvC;AAAA,EACF;AAEA,EAAA,OAAO,yBAAA,EAA0B;AACnC;;;AC5EO,SAAS,oBAAoB,IAAA,EAA6B;AAC/D,EAAA,IAAI,SAAS,MAAA,EAAW;AACtB,IAAA,OAAO,4BAA4B,IAAI,CAAA;AAAA,EACzC;AAEA,EAAA,MAAM,UAAU,0BAAA,EAA2B;AAC3C,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,OAAO,OAAA;AAAA,EACT;AAEA,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,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.0.1\",\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/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 \"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: \"2565a8dd94b0b3cb9ec6d415933ab05ed5d32ac07165b71be6bcf31615fc0330\",\n zkey: \"64a4d915099f6fe6bfa06e151c254843be8773c7991c742260019dc5184e5d82\",\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.0.2\";\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"]}
Binary file
Binary file