@usdctofiat/offramp 3.0.3 → 4.0.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/index.d.cts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { WalletClient } from 'viem';
2
- import { f as OfframpParams, n as OnProgress, j as OfframpResult, c as OfframpCreateOptions, i as OfframpQuoteInput, h as OfframpQuote, m as OfframpVaultStatus, r as PlatformEntry, a as CurrencyEntry, D as DepositInfo } from './errors-D9bV_DWE.cjs';
3
- export { C as CURRENCIES, b as DepositStatus, M as MakersCreateError, O as OFFRAMP_ERROR_CODES, d as OfframpError, e as OfframpErrorCode, g as OfframpProgress, k as OfframpState, l as OfframpStep, P as PLATFORMS, o as PLATFORM_LIMITS, p as PayeeDepositData, q as PeerExtensionRegistrationInfo, s as PlatformKey, t as PlatformLimits, u as PlatformTier, v as getPeerExtensionRegistrationInfo, w as getPlatformLimits, x as isPeerExtensionRegistrationError, y as isValidIBAN, z as normalizePaypalMeUsername } from './errors-D9bV_DWE.cjs';
4
- export { PEER_EXTENSION_CHROME_URL, PeerConnectionStatus, PeerExtensionApi, PeerExtensionOnrampParams, PeerExtensionSdk, PeerExtensionSdkOptions, PeerExtensionState, PeerExtensionWindow, PeerOnrampPreparedTransactionCallback, PeerOnrampPreparedTransactionResult, createPeerExtensionSdk, getPeerExtensionState, isPeerExtensionAvailable, openPeerExtensionInstallPage, peerExtensionSdk } from '@zkp2p/sdk';
2
+ import { h as OfframpParams, p as OnProgress, l as OfframpResult, e as OfframpCreateOptions, k as OfframpQuoteInput, j as OfframpQuote, o as OfframpVaultStatus, t as PlatformEntry, c as CurrencyEntry, D as DepositInfo } from './errors-DYCRKcnY.cjs';
3
+ export { C as CURRENCIES, a as CompletePeerExtensionRegistrationInput, b as CompletePeerExtensionRegistrationResult, d as DepositStatus, M as MakersCreateError, O as OFFRAMP_ERROR_CODES, f as OfframpError, g as OfframpErrorCode, i as OfframpProgress, m as OfframpState, n as OfframpStep, P as PLATFORMS, q as PLATFORM_LIMITS, r as PayeeDepositData, s as PeerExtensionRegistrationInfo, u as PlatformKey, v as PlatformLimits, w as PlatformTier, x as completePeerExtensionRegistration, y as getPeerExtensionRegistrationAuthParams, z as getPeerExtensionRegistrationInfo, A as getPlatformLimits, B as isPeerExtensionRegistrationError, E as isValidIBAN, F as normalizePaypalMeUsername } from './errors-DYCRKcnY.cjs';
4
+ import { PeerConnectionStatus, PeerAuthenticateParams, PeerMetadataMessageCallback, SellerCredentialBundle } from '@zkp2p/sdk';
5
+ export { PEER_EXTENSION_CHROME_URL, PeerAuthenticateParams, PeerBuyerTeePaymentCapture, PeerBuyerTeePaymentParams, PeerConnectionStatus, PeerMetadataCaptureMode, PeerMetadataMessage, PeerMetadataMessageCallback, PeerMetadataProviderConfig, PeerMetadataRow, PeerSarCredentialCapture } from '@zkp2p/sdk';
5
6
 
6
7
  type TelemetryEventName = "sdk.init" | "sdk.createDeposit.start" | "sdk.createDeposit.progress" | "sdk.createDeposit.success" | "sdk.createDeposit.error";
7
8
  interface TelemetryContext {
@@ -22,13 +23,73 @@ declare function emitEvent(name: TelemetryEventName, payload?: Record<string, un
22
23
  declare function sendTelemetryEvent(name: TelemetryEventName, payload?: Record<string, unknown>): void;
23
24
  declare function createTelemetryContext(options: CreateTelemetryContextOptions): TelemetryContext;
24
25
 
26
+ /**
27
+ * Peer browser-extension surface for PayPal + Wise makers. Drive the
28
+ * headless metadata bridge via `usePeerExtensionRegistration` in
29
+ * `@usdctofiat/offramp/react`, or manually:
30
+ *
31
+ * ```ts
32
+ * import {
33
+ * completePeerExtensionRegistration,
34
+ * isPeerExtensionMetadataBridgeAvailable,
35
+ * peerExtensionSdk,
36
+ * } from "@usdctofiat/offramp";
37
+ *
38
+ * const state = await peerExtensionSdk.getState();
39
+ * if (state === "needs_install" || !isPeerExtensionMetadataBridgeAvailable()) {
40
+ * peerExtensionSdk.openInstallPage();
41
+ * } else if (state === "needs_connection") {
42
+ * await peerExtensionSdk.requestConnection();
43
+ * } else {
44
+ * peerExtensionSdk.authenticate({
45
+ * actionType: "transfer_paypal",
46
+ * captureMode: "sellerCredential",
47
+ * platform: "paypal",
48
+ * });
49
+ * // Pass the captured metadata to completePeerExtensionRegistration(...), then retry.
50
+ * }
51
+ * ```
52
+ */
53
+
54
+ type PeerSarCredentialBundle = SellerCredentialBundle;
55
+ type PeerExtensionApi = {
56
+ requestConnection(): Promise<boolean>;
57
+ checkConnectionStatus(): Promise<PeerConnectionStatus>;
58
+ getVersion(): Promise<string>;
59
+ authenticate?: (params: PeerAuthenticateParams) => void;
60
+ onMetadataMessage?: (callback: PeerMetadataMessageCallback) => () => void;
61
+ };
62
+ type PeerExtensionWindow = Window & {
63
+ peer?: PeerExtensionApi;
64
+ };
65
+ type PeerExtensionSdkOptions = {
66
+ window?: PeerExtensionWindow;
67
+ };
68
+ type PeerExtensionSdk = {
69
+ requestConnection(): Promise<boolean>;
70
+ checkConnectionStatus(): Promise<PeerConnectionStatus>;
71
+ getVersion(): Promise<string>;
72
+ authenticate(params: PeerAuthenticateParams): void;
73
+ onMetadataMessage(callback: PeerMetadataMessageCallback): () => void;
74
+ isAvailable(): boolean;
75
+ openInstallPage(): void;
76
+ getState(): Promise<PeerExtensionState>;
77
+ };
78
+ type PeerExtensionState = "needs_install" | "needs_connection" | "ready";
79
+ declare const isPeerExtensionAvailable: (options?: PeerExtensionSdkOptions) => boolean;
80
+ declare const isPeerExtensionMetadataBridgeAvailable: (options?: PeerExtensionSdkOptions) => boolean;
81
+ declare const openPeerExtensionInstallPage: (options?: PeerExtensionSdkOptions) => void;
82
+ declare const getPeerExtensionState: (options?: PeerExtensionSdkOptions) => Promise<PeerExtensionState>;
83
+ declare const createPeerExtensionSdk: (options?: PeerExtensionSdkOptions) => PeerExtensionSdk;
84
+ declare const peerExtensionSdk: PeerExtensionSdk;
85
+
25
86
  /**
26
87
  * Create a USDC-to-fiat offramp deposit and delegate it to the vault.
27
88
  *
28
89
  * **Resumable**: if an existing undelegated deposit is found for this wallet,
29
90
  * the flow skips directly to delegation instead of creating a new deposit.
30
91
  */
31
- declare function offramp(walletClient: WalletClient, params: OfframpParams, onProgress?: OnProgress, telemetryContext?: TelemetryContext): Promise<OfframpResult>;
92
+ declare function offramp(walletClient: WalletClient, params: OfframpParams, onProgress?: OnProgress, telemetryContext?: TelemetryContext, apiBaseUrl?: string): Promise<OfframpResult>;
32
93
 
33
94
  interface OfframpConstructorOptions extends OfframpCreateOptions {
34
95
  walletClient: WalletClient;
@@ -36,6 +97,7 @@ interface OfframpConstructorOptions extends OfframpCreateOptions {
36
97
  declare class Offramp {
37
98
  private readonly walletClient;
38
99
  private readonly telemetry;
100
+ private readonly apiBaseUrl?;
39
101
  constructor(options: OfframpConstructorOptions);
40
102
  createDeposit(params: OfframpParams, onProgress?: OnProgress): Promise<OfframpResult>;
41
103
  getQuote(input: OfframpQuoteInput): OfframpQuote;
@@ -82,7 +144,10 @@ interface EnableOtcResult {
82
144
  * Make a deposit private so only one taker wallet can trade against it.
83
145
  *
84
146
  * Sets the WhitelistPreIntentHook on the deposit and whitelists the taker.
85
- * If the deposit already has a different taker whitelisted, replaces it.
147
+ * The hook stores its whitelist as a membership-only mapping with no
148
+ * enumeration, so a taker that was previously whitelisted is NOT removed when
149
+ * a new one is added — both stay whitelisted. To switch to a single new taker,
150
+ * remove the prior one explicitly (or `disableOtc` first) before calling this.
86
151
  *
87
152
  * @param walletClient - viem WalletClient with the deposit owner's account
88
153
  * @param depositId - The numeric deposit ID (from `OfframpResult.depositId`)
@@ -106,4 +171,4 @@ declare function disableOtc(walletClient: WalletClient, depositId: string, escro
106
171
  */
107
172
  declare function getOtcLink(depositId: string, escrowAddress?: string): string;
108
173
 
109
- export { CurrencyEntry, DepositInfo, ESCROW_ADDRESS, type EnableOtcResult, Offramp, OfframpCreateOptions, OfframpParams, OfframpQuote, OfframpQuoteInput, OfframpResult, OfframpVaultStatus, OnProgress, PlatformEntry, close, createOfframp, createTelemetryContext, delegate, deposits, disableOtc, emitEvent, enableOtc, getOtcLink, offramp, sanitizeAttributionId, sendTelemetryEvent, undelegate };
174
+ export { CurrencyEntry, DepositInfo, ESCROW_ADDRESS, type EnableOtcResult, Offramp, OfframpCreateOptions, OfframpParams, OfframpQuote, OfframpQuoteInput, OfframpResult, OfframpVaultStatus, OnProgress, type PeerExtensionApi, type PeerExtensionSdk, type PeerExtensionSdkOptions, type PeerExtensionState, type PeerExtensionWindow, type PeerSarCredentialBundle, PlatformEntry, close, createOfframp, createPeerExtensionSdk, createTelemetryContext, delegate, deposits, disableOtc, emitEvent, enableOtc, getOtcLink, getPeerExtensionState, isPeerExtensionAvailable, isPeerExtensionMetadataBridgeAvailable, offramp, openPeerExtensionInstallPage, peerExtensionSdk, sanitizeAttributionId, sendTelemetryEvent, undelegate };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { WalletClient } from 'viem';
2
- import { f as OfframpParams, n as OnProgress, j as OfframpResult, c as OfframpCreateOptions, i as OfframpQuoteInput, h as OfframpQuote, m as OfframpVaultStatus, r as PlatformEntry, a as CurrencyEntry, D as DepositInfo } from './errors-D9bV_DWE.js';
3
- export { C as CURRENCIES, b as DepositStatus, M as MakersCreateError, O as OFFRAMP_ERROR_CODES, d as OfframpError, e as OfframpErrorCode, g as OfframpProgress, k as OfframpState, l as OfframpStep, P as PLATFORMS, o as PLATFORM_LIMITS, p as PayeeDepositData, q as PeerExtensionRegistrationInfo, s as PlatformKey, t as PlatformLimits, u as PlatformTier, v as getPeerExtensionRegistrationInfo, w as getPlatformLimits, x as isPeerExtensionRegistrationError, y as isValidIBAN, z as normalizePaypalMeUsername } from './errors-D9bV_DWE.js';
4
- export { PEER_EXTENSION_CHROME_URL, PeerConnectionStatus, PeerExtensionApi, PeerExtensionOnrampParams, PeerExtensionSdk, PeerExtensionSdkOptions, PeerExtensionState, PeerExtensionWindow, PeerOnrampPreparedTransactionCallback, PeerOnrampPreparedTransactionResult, createPeerExtensionSdk, getPeerExtensionState, isPeerExtensionAvailable, openPeerExtensionInstallPage, peerExtensionSdk } from '@zkp2p/sdk';
2
+ import { h as OfframpParams, p as OnProgress, l as OfframpResult, e as OfframpCreateOptions, k as OfframpQuoteInput, j as OfframpQuote, o as OfframpVaultStatus, t as PlatformEntry, c as CurrencyEntry, D as DepositInfo } from './errors-DYCRKcnY.js';
3
+ export { C as CURRENCIES, a as CompletePeerExtensionRegistrationInput, b as CompletePeerExtensionRegistrationResult, d as DepositStatus, M as MakersCreateError, O as OFFRAMP_ERROR_CODES, f as OfframpError, g as OfframpErrorCode, i as OfframpProgress, m as OfframpState, n as OfframpStep, P as PLATFORMS, q as PLATFORM_LIMITS, r as PayeeDepositData, s as PeerExtensionRegistrationInfo, u as PlatformKey, v as PlatformLimits, w as PlatformTier, x as completePeerExtensionRegistration, y as getPeerExtensionRegistrationAuthParams, z as getPeerExtensionRegistrationInfo, A as getPlatformLimits, B as isPeerExtensionRegistrationError, E as isValidIBAN, F as normalizePaypalMeUsername } from './errors-DYCRKcnY.js';
4
+ import { PeerConnectionStatus, PeerAuthenticateParams, PeerMetadataMessageCallback, SellerCredentialBundle } from '@zkp2p/sdk';
5
+ export { PEER_EXTENSION_CHROME_URL, PeerAuthenticateParams, PeerBuyerTeePaymentCapture, PeerBuyerTeePaymentParams, PeerConnectionStatus, PeerMetadataCaptureMode, PeerMetadataMessage, PeerMetadataMessageCallback, PeerMetadataProviderConfig, PeerMetadataRow, PeerSarCredentialCapture } from '@zkp2p/sdk';
5
6
 
6
7
  type TelemetryEventName = "sdk.init" | "sdk.createDeposit.start" | "sdk.createDeposit.progress" | "sdk.createDeposit.success" | "sdk.createDeposit.error";
7
8
  interface TelemetryContext {
@@ -22,13 +23,73 @@ declare function emitEvent(name: TelemetryEventName, payload?: Record<string, un
22
23
  declare function sendTelemetryEvent(name: TelemetryEventName, payload?: Record<string, unknown>): void;
23
24
  declare function createTelemetryContext(options: CreateTelemetryContextOptions): TelemetryContext;
24
25
 
26
+ /**
27
+ * Peer browser-extension surface for PayPal + Wise makers. Drive the
28
+ * headless metadata bridge via `usePeerExtensionRegistration` in
29
+ * `@usdctofiat/offramp/react`, or manually:
30
+ *
31
+ * ```ts
32
+ * import {
33
+ * completePeerExtensionRegistration,
34
+ * isPeerExtensionMetadataBridgeAvailable,
35
+ * peerExtensionSdk,
36
+ * } from "@usdctofiat/offramp";
37
+ *
38
+ * const state = await peerExtensionSdk.getState();
39
+ * if (state === "needs_install" || !isPeerExtensionMetadataBridgeAvailable()) {
40
+ * peerExtensionSdk.openInstallPage();
41
+ * } else if (state === "needs_connection") {
42
+ * await peerExtensionSdk.requestConnection();
43
+ * } else {
44
+ * peerExtensionSdk.authenticate({
45
+ * actionType: "transfer_paypal",
46
+ * captureMode: "sellerCredential",
47
+ * platform: "paypal",
48
+ * });
49
+ * // Pass the captured metadata to completePeerExtensionRegistration(...), then retry.
50
+ * }
51
+ * ```
52
+ */
53
+
54
+ type PeerSarCredentialBundle = SellerCredentialBundle;
55
+ type PeerExtensionApi = {
56
+ requestConnection(): Promise<boolean>;
57
+ checkConnectionStatus(): Promise<PeerConnectionStatus>;
58
+ getVersion(): Promise<string>;
59
+ authenticate?: (params: PeerAuthenticateParams) => void;
60
+ onMetadataMessage?: (callback: PeerMetadataMessageCallback) => () => void;
61
+ };
62
+ type PeerExtensionWindow = Window & {
63
+ peer?: PeerExtensionApi;
64
+ };
65
+ type PeerExtensionSdkOptions = {
66
+ window?: PeerExtensionWindow;
67
+ };
68
+ type PeerExtensionSdk = {
69
+ requestConnection(): Promise<boolean>;
70
+ checkConnectionStatus(): Promise<PeerConnectionStatus>;
71
+ getVersion(): Promise<string>;
72
+ authenticate(params: PeerAuthenticateParams): void;
73
+ onMetadataMessage(callback: PeerMetadataMessageCallback): () => void;
74
+ isAvailable(): boolean;
75
+ openInstallPage(): void;
76
+ getState(): Promise<PeerExtensionState>;
77
+ };
78
+ type PeerExtensionState = "needs_install" | "needs_connection" | "ready";
79
+ declare const isPeerExtensionAvailable: (options?: PeerExtensionSdkOptions) => boolean;
80
+ declare const isPeerExtensionMetadataBridgeAvailable: (options?: PeerExtensionSdkOptions) => boolean;
81
+ declare const openPeerExtensionInstallPage: (options?: PeerExtensionSdkOptions) => void;
82
+ declare const getPeerExtensionState: (options?: PeerExtensionSdkOptions) => Promise<PeerExtensionState>;
83
+ declare const createPeerExtensionSdk: (options?: PeerExtensionSdkOptions) => PeerExtensionSdk;
84
+ declare const peerExtensionSdk: PeerExtensionSdk;
85
+
25
86
  /**
26
87
  * Create a USDC-to-fiat offramp deposit and delegate it to the vault.
27
88
  *
28
89
  * **Resumable**: if an existing undelegated deposit is found for this wallet,
29
90
  * the flow skips directly to delegation instead of creating a new deposit.
30
91
  */
31
- declare function offramp(walletClient: WalletClient, params: OfframpParams, onProgress?: OnProgress, telemetryContext?: TelemetryContext): Promise<OfframpResult>;
92
+ declare function offramp(walletClient: WalletClient, params: OfframpParams, onProgress?: OnProgress, telemetryContext?: TelemetryContext, apiBaseUrl?: string): Promise<OfframpResult>;
32
93
 
33
94
  interface OfframpConstructorOptions extends OfframpCreateOptions {
34
95
  walletClient: WalletClient;
@@ -36,6 +97,7 @@ interface OfframpConstructorOptions extends OfframpCreateOptions {
36
97
  declare class Offramp {
37
98
  private readonly walletClient;
38
99
  private readonly telemetry;
100
+ private readonly apiBaseUrl?;
39
101
  constructor(options: OfframpConstructorOptions);
40
102
  createDeposit(params: OfframpParams, onProgress?: OnProgress): Promise<OfframpResult>;
41
103
  getQuote(input: OfframpQuoteInput): OfframpQuote;
@@ -82,7 +144,10 @@ interface EnableOtcResult {
82
144
  * Make a deposit private so only one taker wallet can trade against it.
83
145
  *
84
146
  * Sets the WhitelistPreIntentHook on the deposit and whitelists the taker.
85
- * If the deposit already has a different taker whitelisted, replaces it.
147
+ * The hook stores its whitelist as a membership-only mapping with no
148
+ * enumeration, so a taker that was previously whitelisted is NOT removed when
149
+ * a new one is added — both stay whitelisted. To switch to a single new taker,
150
+ * remove the prior one explicitly (or `disableOtc` first) before calling this.
86
151
  *
87
152
  * @param walletClient - viem WalletClient with the deposit owner's account
88
153
  * @param depositId - The numeric deposit ID (from `OfframpResult.depositId`)
@@ -106,4 +171,4 @@ declare function disableOtc(walletClient: WalletClient, depositId: string, escro
106
171
  */
107
172
  declare function getOtcLink(depositId: string, escrowAddress?: string): string;
108
173
 
109
- export { CurrencyEntry, DepositInfo, ESCROW_ADDRESS, type EnableOtcResult, Offramp, OfframpCreateOptions, OfframpParams, OfframpQuote, OfframpQuoteInput, OfframpResult, OfframpVaultStatus, OnProgress, PlatformEntry, close, createOfframp, createTelemetryContext, delegate, deposits, disableOtc, emitEvent, enableOtc, getOtcLink, offramp, sanitizeAttributionId, sendTelemetryEvent, undelegate };
174
+ export { CurrencyEntry, DepositInfo, ESCROW_ADDRESS, type EnableOtcResult, Offramp, OfframpCreateOptions, OfframpParams, OfframpQuote, OfframpQuoteInput, OfframpResult, OfframpVaultStatus, OnProgress, type PeerExtensionApi, type PeerExtensionSdk, type PeerExtensionSdkOptions, type PeerExtensionState, type PeerExtensionWindow, type PeerSarCredentialBundle, PlatformEntry, close, createOfframp, createPeerExtensionSdk, createTelemetryContext, delegate, deposits, disableOtc, emitEvent, enableOtc, getOtcLink, getPeerExtensionState, isPeerExtensionAvailable, isPeerExtensionMetadataBridgeAvailable, offramp, openPeerExtensionInstallPage, peerExtensionSdk, sanitizeAttributionId, sendTelemetryEvent, undelegate };
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  PLATFORMS,
9
9
  PLATFORM_LIMITS,
10
10
  close,
11
+ completePeerExtensionRegistration,
11
12
  createOfframp,
12
13
  createPeerExtensionSdk,
13
14
  createTelemetryContext,
@@ -17,10 +18,12 @@ import {
17
18
  emitEvent,
18
19
  enableOtc,
19
20
  getOtcLink,
21
+ getPeerExtensionRegistrationAuthParams,
20
22
  getPeerExtensionRegistrationInfo,
21
23
  getPeerExtensionState,
22
24
  getPlatformLimits,
23
25
  isPeerExtensionAvailable,
26
+ isPeerExtensionMetadataBridgeAvailable,
24
27
  isPeerExtensionRegistrationError,
25
28
  isValidIBAN,
26
29
  normalizePaypalMeUsername,
@@ -30,7 +33,7 @@ import {
30
33
  sanitizeAttributionId,
31
34
  sendTelemetryEvent,
32
35
  undelegate
33
- } from "./chunk-4KKKDDES.js";
36
+ } from "./chunk-QMO7HTBZ.js";
34
37
 
35
38
  // src/types.ts
36
39
  var OFFRAMP_ERROR_CODES = {
@@ -42,8 +45,8 @@ var OFFRAMP_ERROR_CODES = {
42
45
  * handle in the Peer extension yet. Thrown from `offramp()` for PayPal
43
46
  * and Wise when `/v2/makers/create` returns 400 or a "creating the maker"
44
47
  * message. Recover by prompting the user through the Peer extension via
45
- * `usePeerExtensionRegistration(platform)` (React) or `peerExtensionSdk`
46
- * directly, then call `offramp()` again.
48
+ * `usePeerExtensionRegistration(platform)` (React) or
49
+ * `completePeerExtensionRegistration(...)`, then retrying `offramp()`.
47
50
  */
48
51
  EXTENSION_REGISTRATION_REQUIRED: "EXTENSION_REGISTRATION_REQUIRED",
49
52
  DEPOSIT_FAILED: "DEPOSIT_FAILED",
@@ -63,6 +66,7 @@ export {
63
66
  PLATFORMS,
64
67
  PLATFORM_LIMITS,
65
68
  close,
69
+ completePeerExtensionRegistration,
66
70
  createOfframp,
67
71
  createPeerExtensionSdk,
68
72
  createTelemetryContext,
@@ -72,10 +76,12 @@ export {
72
76
  emitEvent,
73
77
  enableOtc,
74
78
  getOtcLink,
79
+ getPeerExtensionRegistrationAuthParams,
75
80
  getPeerExtensionRegistrationInfo,
76
81
  getPeerExtensionState,
77
82
  getPlatformLimits,
78
83
  isPeerExtensionAvailable,
84
+ isPeerExtensionMetadataBridgeAvailable,
79
85
  isPeerExtensionRegistrationError,
80
86
  isValidIBAN,
81
87
  normalizePaypalMeUsername,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { PlatformEntry } from \"./platforms\";\nimport type { CurrencyEntry } from \"./currencies\";\n\nexport const OFFRAMP_ERROR_CODES = {\n VALIDATION: \"VALIDATION\",\n APPROVAL_FAILED: \"APPROVAL_FAILED\",\n REGISTRATION_FAILED: \"REGISTRATION_FAILED\",\n /**\n * Curator rejected the maker because the user has not registered this\n * handle in the Peer extension yet. Thrown from `offramp()` for PayPal\n * and Wise when `/v2/makers/create` returns 400 or a \"creating the maker\"\n * message. Recover by prompting the user through the Peer extension via\n * `usePeerExtensionRegistration(platform)` (React) or `peerExtensionSdk`\n * directly, then call `offramp()` again.\n */\n EXTENSION_REGISTRATION_REQUIRED: \"EXTENSION_REGISTRATION_REQUIRED\",\n DEPOSIT_FAILED: \"DEPOSIT_FAILED\",\n CONFIRMATION_FAILED: \"CONFIRMATION_FAILED\",\n DELEGATION_FAILED: \"DELEGATION_FAILED\",\n USER_CANCELLED: \"USER_CANCELLED\",\n UNSUPPORTED: \"UNSUPPORTED\",\n} as const;\n\nexport type OfframpErrorCode = (typeof OFFRAMP_ERROR_CODES)[keyof typeof OFFRAMP_ERROR_CODES];\n\nexport interface OfframpParams {\n /** USDC amount as decimal string, min 1. */\n amount: string;\n /** Payment platform — use `PLATFORMS.REVOLUT` etc. */\n platform: PlatformEntry;\n /** Fiat currency — use `CURRENCIES.EUR` etc. */\n currency: CurrencyEntry;\n /** Platform-specific identifier (username, email, IBAN). */\n identifier: string;\n /** Optional: restrict the deposit to this taker wallet (OTC private order). */\n otcTaker?: string;\n /** Optional SDK-only referral metadata for telemetry attribution. */\n referralId?: string;\n /** Optional SDK-only integrator metadata for telemetry attribution. */\n integratorId?: string;\n /** Optional per-wallet key to replay the first successful result for 10 minutes. */\n idempotencyKey?: string;\n}\n\nexport interface OfframpResult {\n depositId: string;\n txHash: string;\n /** Whether an existing undelegated deposit was resumed. */\n resumed: boolean;\n /** OTC link for the taker, present when `otcTaker` was provided. */\n otcLink?: string;\n}\n\nexport type OfframpStep =\n | \"approving\"\n | \"registering\"\n | \"depositing\"\n | \"confirming\"\n | \"delegating\"\n | \"restricting\"\n | \"resuming\"\n | \"done\";\n\nexport type OfframpState =\n | \"idle\"\n | \"approving\"\n | \"registering\"\n | \"depositing\"\n | \"confirming\"\n | \"delegating\"\n | \"done\"\n | \"error\";\n\nexport interface OfframpProgress {\n step: OfframpStep;\n txHash?: string;\n depositId?: string;\n}\n\nexport type OnProgress = (progress: OfframpProgress) => void;\n\nexport type DepositStatus = \"active\" | \"empty\" | \"closed\";\n\nexport interface OfframpQuoteInput {\n amount: string;\n currency: CurrencyEntry;\n platform: PlatformEntry;\n}\n\nexport interface OfframpQuote {\n amountUsdc: number;\n expectedFiat: number;\n effectiveRate: number;\n vaultSpreadBps: number;\n}\n\nexport interface OfframpVaultStatus {\n rateManagerId: string;\n rateManagerAddress: string;\n feeRateBps: number;\n escrow: string;\n isActive: boolean;\n}\n\nexport interface OfframpCreateOptions {\n integratorId?: string;\n referralId?: string;\n telemetry?: boolean;\n}\n\nexport interface DepositInfo {\n /** Numeric deposit ID. Pass this to `close()`. */\n depositId: string;\n /** Composite ID (escrowAddress_depositId). */\n compositeId: string;\n /** Creation transaction hash. */\n txHash?: string;\n status: DepositStatus;\n remainingUsdc: number;\n outstandingUsdc: number;\n totalTakenUsdc: number;\n fulfilledIntents: number;\n paymentMethods: string[];\n currencies: string[];\n rateSource: string;\n delegated: boolean;\n escrowAddress: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAM,sBAAsB;AAAA,EACjC,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASrB,iCAAiC;AAAA,EACjC,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,aAAa;AACf;","names":[]}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { PlatformEntry } from \"./platforms\";\nimport type { CurrencyEntry } from \"./currencies\";\n\nexport const OFFRAMP_ERROR_CODES = {\n VALIDATION: \"VALIDATION\",\n APPROVAL_FAILED: \"APPROVAL_FAILED\",\n REGISTRATION_FAILED: \"REGISTRATION_FAILED\",\n /**\n * Curator rejected the maker because the user has not registered this\n * handle in the Peer extension yet. Thrown from `offramp()` for PayPal\n * and Wise when `/v2/makers/create` returns 400 or a \"creating the maker\"\n * message. Recover by prompting the user through the Peer extension via\n * `usePeerExtensionRegistration(platform)` (React) or\n * `completePeerExtensionRegistration(...)`, then retrying `offramp()`.\n */\n EXTENSION_REGISTRATION_REQUIRED: \"EXTENSION_REGISTRATION_REQUIRED\",\n DEPOSIT_FAILED: \"DEPOSIT_FAILED\",\n CONFIRMATION_FAILED: \"CONFIRMATION_FAILED\",\n DELEGATION_FAILED: \"DELEGATION_FAILED\",\n USER_CANCELLED: \"USER_CANCELLED\",\n UNSUPPORTED: \"UNSUPPORTED\",\n} as const;\n\nexport type OfframpErrorCode = (typeof OFFRAMP_ERROR_CODES)[keyof typeof OFFRAMP_ERROR_CODES];\n\nexport interface OfframpParams {\n /** USDC amount as decimal string, min 1. */\n amount: string;\n /** Payment platform — use `PLATFORMS.REVOLUT` etc. */\n platform: PlatformEntry;\n /** Fiat currency — use `CURRENCIES.EUR` etc. */\n currency: CurrencyEntry;\n /** Platform-specific identifier (username, email, IBAN). */\n identifier: string;\n /** Optional: restrict the deposit to this taker wallet (OTC private order). */\n otcTaker?: string;\n /** Optional SDK-only referral metadata for telemetry attribution. */\n referralId?: string;\n /** Optional SDK-only integrator metadata for telemetry attribution. */\n integratorId?: string;\n /**\n * Optional per-wallet key to replay the first successful result for 10 minutes.\n *\n * Browser-only: the replay cache is backed by `sessionStorage` and is a no-op\n * in Node/worker runtimes (no duplicate protection there). It is honored only\n * by the `Offramp` class (`createDeposit`) / the `useOfframp` hook — the\n * standalone `offramp()` function ignores it. For server-side dedup, call\n * `deposits(walletAddress)` and reuse an existing open deposit before creating\n * a new one (the SDK's own resume behavior does this for the delegation step).\n */\n idempotencyKey?: string;\n}\n\nexport interface OfframpResult {\n depositId: string;\n txHash: string;\n /** Whether an existing undelegated deposit was resumed. */\n resumed: boolean;\n /** OTC link for the taker, present when `otcTaker` was provided. */\n otcLink?: string;\n}\n\nexport type OfframpStep =\n | \"approving\"\n | \"registering\"\n | \"depositing\"\n | \"confirming\"\n | \"delegating\"\n | \"restricting\"\n | \"resuming\"\n | \"done\";\n\nexport type OfframpState =\n | \"idle\"\n | \"approving\"\n | \"registering\"\n | \"depositing\"\n | \"confirming\"\n | \"delegating\"\n | \"done\"\n | \"error\";\n\nexport interface OfframpProgress {\n step: OfframpStep;\n txHash?: string;\n depositId?: string;\n}\n\nexport type OnProgress = (progress: OfframpProgress) => void;\n\nexport type DepositStatus = \"active\" | \"empty\" | \"closed\";\n\nexport interface OfframpQuoteInput {\n amount: string;\n currency: CurrencyEntry;\n platform: PlatformEntry;\n}\n\nexport interface OfframpQuote {\n amountUsdc: number;\n expectedFiat: number;\n effectiveRate: number;\n vaultSpreadBps: number;\n}\n\nexport interface OfframpVaultStatus {\n rateManagerId: string;\n rateManagerAddress: string;\n /**\n * Delegate vault manager fee in basis points (currently 10 = 0.10%). Charged\n * by the vault's rate manager on each fill and deducted from the USDC released\n * to the buyer; not added to the maker's deposit cost. See the README \"Fees\".\n */\n feeRateBps: number;\n escrow: string;\n isActive: boolean;\n}\n\nexport interface OfframpCreateOptions {\n integratorId?: string;\n referralId?: string;\n telemetry?: boolean;\n /**\n * Override the curator REST base URL (default `https://api.zkp2p.xyz`) used\n * for maker registration/validation and the SDK's REST calls. For\n * testing/proxying/mocking only — the indexer and Base RPC always target\n * mainnet. Honored by the `Offramp` class (`createDeposit`); absent ⇒ default\n * behavior is unchanged.\n */\n apiBaseUrl?: string;\n}\n\nexport interface DepositInfo {\n /** Numeric deposit ID. Pass this to `close()`. */\n depositId: string;\n /** Composite ID (escrowAddress_depositId). */\n compositeId: string;\n /** Creation transaction hash. */\n txHash?: string;\n status: DepositStatus;\n remainingUsdc: number;\n outstandingUsdc: number;\n totalTakenUsdc: number;\n fulfilledIntents: number;\n paymentMethods: string[];\n currencies: string[];\n rateSource: string;\n delegated: boolean;\n escrowAddress: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAM,sBAAsB;AAAA,EACjC,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASrB,iCAAiC;AAAA,EACjC,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,aAAa;AACf;","names":[]}