@sip-protocol/sdk 0.2.2 → 0.2.4

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/index.d.mts CHANGED
@@ -301,6 +301,20 @@ declare function getErrorMessage(error: unknown): string;
301
301
  * The mock proofs are clearly marked and will be rejected by any real verifier.
302
302
  */
303
303
 
304
+ /**
305
+ * Configuration options for MockProofProvider
306
+ */
307
+ interface MockProofProviderOptions {
308
+ /**
309
+ * Suppress the console warning about mock usage.
310
+ *
311
+ * Use this ONLY for SSR fallback scenarios where the mock provider
312
+ * is a placeholder and real proofs will be generated client-side.
313
+ *
314
+ * @default false
315
+ */
316
+ silent?: boolean;
317
+ }
304
318
  /**
305
319
  * Mock Proof Provider for testing
306
320
  *
@@ -316,16 +330,29 @@ declare function getErrorMessage(error: unknown): string;
316
330
  * // ... other params
317
331
  * })
318
332
  * ```
333
+ *
334
+ * @example
335
+ * ```typescript
336
+ * // SSR fallback (silent mode)
337
+ * const ssrFallback = new MockProofProvider({ silent: true })
338
+ * ```
319
339
  */
320
340
  declare class MockProofProvider implements ProofProvider {
321
341
  readonly framework: ProofFramework;
322
342
  private _isReady;
323
343
  private _warningShown;
344
+ private _silent;
345
+ /**
346
+ * Create a new MockProofProvider
347
+ *
348
+ * @param options - Configuration options
349
+ */
350
+ constructor(options?: MockProofProviderOptions);
324
351
  get isReady(): boolean;
325
352
  /**
326
353
  * Initialize the mock provider
327
354
  *
328
- * Logs a warning to console about mock usage.
355
+ * Logs a warning to console about mock usage (unless silent mode is enabled).
329
356
  */
330
357
  initialize(): Promise<void>;
331
358
  /**
@@ -1530,9 +1557,10 @@ declare class SIP {
1530
1557
  *
1531
1558
  * @param params - Intent parameters (CreateIntentParams for production, ShieldedIntent/CreateIntentParams for demo)
1532
1559
  * @param recipientMetaAddress - Optional stealth meta-address for privacy modes
1560
+ * @param senderAddress - Optional sender wallet address for cross-curve refunds
1533
1561
  * @returns Array of quotes (with deposit info in production mode)
1534
1562
  */
1535
- getQuotes(params: CreateIntentParams | ShieldedIntent, recipientMetaAddress?: StealthMetaAddress | string): Promise<ProductionQuote[]>;
1563
+ getQuotes(params: CreateIntentParams | ShieldedIntent, recipientMetaAddress?: StealthMetaAddress | string, senderAddress?: string): Promise<ProductionQuote[]>;
1536
1564
  /**
1537
1565
  * Execute an intent with a selected quote
1538
1566
  *
package/dist/index.d.ts CHANGED
@@ -301,6 +301,20 @@ declare function getErrorMessage(error: unknown): string;
301
301
  * The mock proofs are clearly marked and will be rejected by any real verifier.
302
302
  */
303
303
 
304
+ /**
305
+ * Configuration options for MockProofProvider
306
+ */
307
+ interface MockProofProviderOptions {
308
+ /**
309
+ * Suppress the console warning about mock usage.
310
+ *
311
+ * Use this ONLY for SSR fallback scenarios where the mock provider
312
+ * is a placeholder and real proofs will be generated client-side.
313
+ *
314
+ * @default false
315
+ */
316
+ silent?: boolean;
317
+ }
304
318
  /**
305
319
  * Mock Proof Provider for testing
306
320
  *
@@ -316,16 +330,29 @@ declare function getErrorMessage(error: unknown): string;
316
330
  * // ... other params
317
331
  * })
318
332
  * ```
333
+ *
334
+ * @example
335
+ * ```typescript
336
+ * // SSR fallback (silent mode)
337
+ * const ssrFallback = new MockProofProvider({ silent: true })
338
+ * ```
319
339
  */
320
340
  declare class MockProofProvider implements ProofProvider {
321
341
  readonly framework: ProofFramework;
322
342
  private _isReady;
323
343
  private _warningShown;
344
+ private _silent;
345
+ /**
346
+ * Create a new MockProofProvider
347
+ *
348
+ * @param options - Configuration options
349
+ */
350
+ constructor(options?: MockProofProviderOptions);
324
351
  get isReady(): boolean;
325
352
  /**
326
353
  * Initialize the mock provider
327
354
  *
328
- * Logs a warning to console about mock usage.
355
+ * Logs a warning to console about mock usage (unless silent mode is enabled).
329
356
  */
330
357
  initialize(): Promise<void>;
331
358
  /**
@@ -1530,9 +1557,10 @@ declare class SIP {
1530
1557
  *
1531
1558
  * @param params - Intent parameters (CreateIntentParams for production, ShieldedIntent/CreateIntentParams for demo)
1532
1559
  * @param recipientMetaAddress - Optional stealth meta-address for privacy modes
1560
+ * @param senderAddress - Optional sender wallet address for cross-curve refunds
1533
1561
  * @returns Array of quotes (with deposit info in production mode)
1534
1562
  */
1535
- getQuotes(params: CreateIntentParams | ShieldedIntent, recipientMetaAddress?: StealthMetaAddress | string): Promise<ProductionQuote[]>;
1563
+ getQuotes(params: CreateIntentParams | ShieldedIntent, recipientMetaAddress?: StealthMetaAddress | string, senderAddress?: string): Promise<ProductionQuote[]>;
1536
1564
  /**
1537
1565
  * Execute an intent with a selected quote
1538
1566
  *
package/dist/index.js CHANGED
@@ -2884,9 +2884,10 @@ var SIP = class {
2884
2884
  *
2885
2885
  * @param params - Intent parameters (CreateIntentParams for production, ShieldedIntent/CreateIntentParams for demo)
2886
2886
  * @param recipientMetaAddress - Optional stealth meta-address for privacy modes
2887
+ * @param senderAddress - Optional sender wallet address for cross-curve refunds
2887
2888
  * @returns Array of quotes (with deposit info in production mode)
2888
2889
  */
2889
- async getQuotes(params, recipientMetaAddress) {
2890
+ async getQuotes(params, recipientMetaAddress, senderAddress) {
2890
2891
  if (this.isProductionMode()) {
2891
2892
  if (!("input" in params)) {
2892
2893
  throw new ValidationError(
@@ -2894,7 +2895,7 @@ var SIP = class {
2894
2895
  "params"
2895
2896
  );
2896
2897
  }
2897
- return this.getQuotesProduction(params, recipientMetaAddress);
2898
+ return this.getQuotesProduction(params, recipientMetaAddress, senderAddress);
2898
2899
  }
2899
2900
  return this.getQuotesDemo(params);
2900
2901
  }
@@ -2934,7 +2935,7 @@ var SIP = class {
2934
2935
  return this.config.network;
2935
2936
  }
2936
2937
  // ─── Production Mode Implementation ─────────────────────────────────────────
2937
- async getQuotesProduction(params, recipientMetaAddress) {
2938
+ async getQuotesProduction(params, recipientMetaAddress, senderAddress) {
2938
2939
  if (!this.intentsAdapter) {
2939
2940
  throw new ValidationError(
2940
2941
  "NEAR Intents adapter not configured. Set intentsAdapter in config for production mode.",
@@ -2961,7 +2962,7 @@ var SIP = class {
2961
2962
  const prepared = await this.intentsAdapter.prepareSwap(
2962
2963
  swapRequest,
2963
2964
  metaAddr,
2964
- this.wallet?.address
2965
+ senderAddress ?? this.wallet?.address
2965
2966
  );
2966
2967
  const rawQuote = await this.intentsAdapter.getQuote(prepared);
2967
2968
  this.pendingSwaps.set(requestId, {
@@ -3144,16 +3145,25 @@ var MockProofProvider = class {
3144
3145
  framework = "mock";
3145
3146
  _isReady = false;
3146
3147
  _warningShown = false;
3148
+ _silent;
3149
+ /**
3150
+ * Create a new MockProofProvider
3151
+ *
3152
+ * @param options - Configuration options
3153
+ */
3154
+ constructor(options) {
3155
+ this._silent = options?.silent ?? false;
3156
+ }
3147
3157
  get isReady() {
3148
3158
  return this._isReady;
3149
3159
  }
3150
3160
  /**
3151
3161
  * Initialize the mock provider
3152
3162
  *
3153
- * Logs a warning to console about mock usage.
3163
+ * Logs a warning to console about mock usage (unless silent mode is enabled).
3154
3164
  */
3155
3165
  async initialize() {
3156
- if (!this._warningShown) {
3166
+ if (!this._warningShown && !this._silent) {
3157
3167
  console.warn(WARNING_MESSAGE);
3158
3168
  this._warningShown = true;
3159
3169
  }
package/dist/index.mjs CHANGED
@@ -197,7 +197,7 @@ import {
197
197
  walletRegistry,
198
198
  withSecureBuffer,
199
199
  withSecureBufferSync
200
- } from "./chunk-DU7LQDD2.mjs";
200
+ } from "./chunk-VXSHK7US.mjs";
201
201
  import {
202
202
  CryptoError,
203
203
  EncryptionNotImplementedError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sip-protocol/sdk",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Core SDK for Shielded Intents Protocol - Privacy layer for cross-chain transactions",
5
5
  "author": "SIP Protocol <hello@sip-protocol.org>",
6
6
  "homepage": "https://sip-protocol.org",
@@ -36,6 +36,17 @@
36
36
  "dist",
37
37
  "src"
38
38
  ],
39
+ "scripts": {
40
+ "build": "tsup src/index.ts src/browser.ts src/proofs/noir.ts --format cjs,esm --dts",
41
+ "dev": "tsup src/index.ts src/browser.ts src/proofs/noir.ts --format cjs,esm --dts --watch",
42
+ "lint": "eslint --ext .ts src/",
43
+ "typecheck": "tsc --noEmit",
44
+ "clean": "rm -rf dist",
45
+ "test": "vitest",
46
+ "test:coverage": "vitest run --coverage",
47
+ "bench": "vitest bench --config vitest.bench.config.ts",
48
+ "bench:json": "vitest bench --config vitest.bench.config.ts --outputJson benchmarks/results.json"
49
+ },
39
50
  "dependencies": {
40
51
  "@aztec/bb.js": "^0.63.1",
41
52
  "@noble/ciphers": "^2.0.1",
@@ -60,16 +71,5 @@
60
71
  "stealth-addresses",
61
72
  "zcash"
62
73
  ],
63
- "license": "MIT",
64
- "scripts": {
65
- "build": "tsup src/index.ts src/browser.ts src/proofs/noir.ts --format cjs,esm --dts",
66
- "dev": "tsup src/index.ts src/browser.ts src/proofs/noir.ts --format cjs,esm --dts --watch",
67
- "lint": "eslint --ext .ts src/",
68
- "typecheck": "tsc --noEmit",
69
- "clean": "rm -rf dist",
70
- "test": "vitest",
71
- "test:coverage": "vitest run --coverage",
72
- "bench": "vitest bench --config vitest.bench.config.ts",
73
- "bench:json": "vitest bench --config vitest.bench.config.ts --outputJson benchmarks/results.json"
74
- }
75
- }
74
+ "license": "MIT"
75
+ }
@@ -46,6 +46,7 @@ export { ProofGenerationError } from './interface'
46
46
 
47
47
  // Mock provider (testing only)
48
48
  export { MockProofProvider } from './mock'
49
+ export type { MockProofProviderOptions } from './mock'
49
50
 
50
51
  // NOTE: NoirProofProvider is NOT exported from main entry to avoid bundling WASM
51
52
  // in server-side builds (e.g., Next.js SSR). Import directly if needed:
@@ -44,6 +44,21 @@ const WARNING_MESSAGE = `
44
44
  ╚══════════════════════════════════════════════════════════════╝
45
45
  `
46
46
 
47
+ /**
48
+ * Configuration options for MockProofProvider
49
+ */
50
+ export interface MockProofProviderOptions {
51
+ /**
52
+ * Suppress the console warning about mock usage.
53
+ *
54
+ * Use this ONLY for SSR fallback scenarios where the mock provider
55
+ * is a placeholder and real proofs will be generated client-side.
56
+ *
57
+ * @default false
58
+ */
59
+ silent?: boolean
60
+ }
61
+
47
62
  /**
48
63
  * Mock Proof Provider for testing
49
64
  *
@@ -59,11 +74,27 @@ const WARNING_MESSAGE = `
59
74
  * // ... other params
60
75
  * })
61
76
  * ```
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * // SSR fallback (silent mode)
81
+ * const ssrFallback = new MockProofProvider({ silent: true })
82
+ * ```
62
83
  */
63
84
  export class MockProofProvider implements ProofProvider {
64
85
  readonly framework: ProofFramework = 'mock'
65
86
  private _isReady = false
66
87
  private _warningShown = false
88
+ private _silent: boolean
89
+
90
+ /**
91
+ * Create a new MockProofProvider
92
+ *
93
+ * @param options - Configuration options
94
+ */
95
+ constructor(options?: MockProofProviderOptions) {
96
+ this._silent = options?.silent ?? false
97
+ }
67
98
 
68
99
  get isReady(): boolean {
69
100
  return this._isReady
@@ -72,10 +103,10 @@ export class MockProofProvider implements ProofProvider {
72
103
  /**
73
104
  * Initialize the mock provider
74
105
  *
75
- * Logs a warning to console about mock usage.
106
+ * Logs a warning to console about mock usage (unless silent mode is enabled).
76
107
  */
77
108
  async initialize(): Promise<void> {
78
- if (!this._warningShown) {
109
+ if (!this._warningShown && !this._silent) {
79
110
  console.warn(WARNING_MESSAGE)
80
111
  this._warningShown = true
81
112
  }
package/src/sip.ts CHANGED
@@ -320,11 +320,13 @@ export class SIP {
320
320
  *
321
321
  * @param params - Intent parameters (CreateIntentParams for production, ShieldedIntent/CreateIntentParams for demo)
322
322
  * @param recipientMetaAddress - Optional stealth meta-address for privacy modes
323
+ * @param senderAddress - Optional sender wallet address for cross-curve refunds
323
324
  * @returns Array of quotes (with deposit info in production mode)
324
325
  */
325
326
  async getQuotes(
326
327
  params: CreateIntentParams | ShieldedIntent,
327
328
  recipientMetaAddress?: StealthMetaAddress | string,
329
+ senderAddress?: string,
328
330
  ): Promise<ProductionQuote[]> {
329
331
  // Production mode - use real NEAR Intents
330
332
  if (this.isProductionMode()) {
@@ -335,7 +337,7 @@ export class SIP {
335
337
  'params'
336
338
  )
337
339
  }
338
- return this.getQuotesProduction(params, recipientMetaAddress)
340
+ return this.getQuotesProduction(params, recipientMetaAddress, senderAddress)
339
341
  }
340
342
 
341
343
  // Demo mode - return mock quotes
@@ -400,6 +402,7 @@ export class SIP {
400
402
  private async getQuotesProduction(
401
403
  params: CreateIntentParams,
402
404
  recipientMetaAddress?: StealthMetaAddress | string,
405
+ senderAddress?: string,
403
406
  ): Promise<ProductionQuote[]> {
404
407
  if (!this.intentsAdapter) {
405
408
  throw new ValidationError(
@@ -437,10 +440,11 @@ export class SIP {
437
440
 
438
441
  try {
439
442
  // Get quote from 1Click API
443
+ // Use provided senderAddress or fallback to connected wallet address (for cross-curve refunds)
440
444
  const prepared = await this.intentsAdapter.prepareSwap(
441
445
  swapRequest,
442
446
  metaAddr,
443
- this.wallet?.address,
447
+ senderAddress ?? this.wallet?.address,
444
448
  )
445
449
  const rawQuote = await this.intentsAdapter.getQuote(prepared)
446
450
 
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 RECTOR Labs
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.