@usdctofiat/offramp 3.1.0 → 4.1.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 { h as OfframpParams, p as OnProgress, l as OfframpResult, e as OfframpCreateOptions, k as OfframpQuoteInput, j as OfframpQuote, o as OfframpVaultStatus, L as PlatformEntry, c as CurrencyEntry, D as DepositInfo } from './errors-DzTiflBh.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 PeerAuthenticateParams, t as PeerBuyerTeePaymentCapture, u as PeerBuyerTeePaymentParams, v as PeerConnectionStatus, w as PeerExtensionApi, x as PeerExtensionRegistrationInfo, y as PeerExtensionSdk, z as PeerExtensionSdkOptions, A as PeerExtensionState, B as PeerExtensionWindow, E as PeerMetadataCaptureMode, F as PeerMetadataMessage, G as PeerMetadataMessageCallback, H as PeerMetadataProviderConfig, I as PeerMetadataRow, J as PeerSarCredentialBundle, K as PeerSarCredentialCapture, N as PlatformKey, Q as PlatformLimits, R as PlatformTier, S as completePeerExtensionRegistration, T as createPeerExtensionSdk, U as getPeerExtensionRegistrationAuthParams, V as getPeerExtensionRegistrationInfo, W as getPeerExtensionState, X as getPlatformLimits, Y as isPeerExtensionAvailable, Z as isPeerExtensionMetadataBridgeAvailable, _ as isPeerExtensionRegistrationError, $ as isValidIBAN, a0 as normalizePaypalMeUsername, a1 as openPeerExtensionInstallPage, a2 as peerExtensionSdk } from './errors-DzTiflBh.cjs';
4
- export { PEER_EXTENSION_CHROME_URL, PeerExtensionOnrampParams, PeerOnrampPreparedTransactionCallback, PeerOnrampPreparedTransactionResult } 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,6 +23,78 @@ 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
+ * Chrome Web Store listing opened by `openInstallPage()`. Defaults to the
69
+ * USDCtoFiat Verify listing; pass `PEER_EXTENSION_CHROME_URL` (re-exported
70
+ * from `@zkp2p/sdk`) to target the legacy PeerAuth listing, or any custom
71
+ * branded-extension listing.
72
+ */
73
+ installUrl?: string;
74
+ };
75
+ /**
76
+ * Default install target: the USDCtoFiat Verify extension (branded fork of
77
+ * PeerAuth implementing the same window.peer interface).
78
+ */
79
+ declare const DEFAULT_EXTENSION_INSTALL_URL = "https://chromewebstore.google.com/detail/usdctofiat-verify/lfkmdfifolhcfjmhklmckigfngghmpdf";
80
+ type PeerExtensionSdk = {
81
+ requestConnection(): Promise<boolean>;
82
+ checkConnectionStatus(): Promise<PeerConnectionStatus>;
83
+ getVersion(): Promise<string>;
84
+ authenticate(params: PeerAuthenticateParams): void;
85
+ onMetadataMessage(callback: PeerMetadataMessageCallback): () => void;
86
+ isAvailable(): boolean;
87
+ openInstallPage(): void;
88
+ getState(): Promise<PeerExtensionState>;
89
+ };
90
+ type PeerExtensionState = "needs_install" | "needs_connection" | "ready";
91
+ declare const isPeerExtensionAvailable: (options?: PeerExtensionSdkOptions) => boolean;
92
+ declare const isPeerExtensionMetadataBridgeAvailable: (options?: PeerExtensionSdkOptions) => boolean;
93
+ declare const openPeerExtensionInstallPage: (options?: PeerExtensionSdkOptions) => void;
94
+ declare const getPeerExtensionState: (options?: PeerExtensionSdkOptions) => Promise<PeerExtensionState>;
95
+ declare const createPeerExtensionSdk: (options?: PeerExtensionSdkOptions) => PeerExtensionSdk;
96
+ declare const peerExtensionSdk: PeerExtensionSdk;
97
+
25
98
  /**
26
99
  * Create a USDC-to-fiat offramp deposit and delegate it to the vault.
27
100
  *
@@ -110,4 +183,4 @@ declare function disableOtc(walletClient: WalletClient, depositId: string, escro
110
183
  */
111
184
  declare function getOtcLink(depositId: string, escrowAddress?: string): string;
112
185
 
113
- 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 };
186
+ export { CurrencyEntry, DEFAULT_EXTENSION_INSTALL_URL, 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 { h as OfframpParams, p as OnProgress, l as OfframpResult, e as OfframpCreateOptions, k as OfframpQuoteInput, j as OfframpQuote, o as OfframpVaultStatus, L as PlatformEntry, c as CurrencyEntry, D as DepositInfo } from './errors-DzTiflBh.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 PeerAuthenticateParams, t as PeerBuyerTeePaymentCapture, u as PeerBuyerTeePaymentParams, v as PeerConnectionStatus, w as PeerExtensionApi, x as PeerExtensionRegistrationInfo, y as PeerExtensionSdk, z as PeerExtensionSdkOptions, A as PeerExtensionState, B as PeerExtensionWindow, E as PeerMetadataCaptureMode, F as PeerMetadataMessage, G as PeerMetadataMessageCallback, H as PeerMetadataProviderConfig, I as PeerMetadataRow, J as PeerSarCredentialBundle, K as PeerSarCredentialCapture, N as PlatformKey, Q as PlatformLimits, R as PlatformTier, S as completePeerExtensionRegistration, T as createPeerExtensionSdk, U as getPeerExtensionRegistrationAuthParams, V as getPeerExtensionRegistrationInfo, W as getPeerExtensionState, X as getPlatformLimits, Y as isPeerExtensionAvailable, Z as isPeerExtensionMetadataBridgeAvailable, _ as isPeerExtensionRegistrationError, $ as isValidIBAN, a0 as normalizePaypalMeUsername, a1 as openPeerExtensionInstallPage, a2 as peerExtensionSdk } from './errors-DzTiflBh.js';
4
- export { PEER_EXTENSION_CHROME_URL, PeerExtensionOnrampParams, PeerOnrampPreparedTransactionCallback, PeerOnrampPreparedTransactionResult } 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,6 +23,78 @@ 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
+ * Chrome Web Store listing opened by `openInstallPage()`. Defaults to the
69
+ * USDCtoFiat Verify listing; pass `PEER_EXTENSION_CHROME_URL` (re-exported
70
+ * from `@zkp2p/sdk`) to target the legacy PeerAuth listing, or any custom
71
+ * branded-extension listing.
72
+ */
73
+ installUrl?: string;
74
+ };
75
+ /**
76
+ * Default install target: the USDCtoFiat Verify extension (branded fork of
77
+ * PeerAuth implementing the same window.peer interface).
78
+ */
79
+ declare const DEFAULT_EXTENSION_INSTALL_URL = "https://chromewebstore.google.com/detail/usdctofiat-verify/lfkmdfifolhcfjmhklmckigfngghmpdf";
80
+ type PeerExtensionSdk = {
81
+ requestConnection(): Promise<boolean>;
82
+ checkConnectionStatus(): Promise<PeerConnectionStatus>;
83
+ getVersion(): Promise<string>;
84
+ authenticate(params: PeerAuthenticateParams): void;
85
+ onMetadataMessage(callback: PeerMetadataMessageCallback): () => void;
86
+ isAvailable(): boolean;
87
+ openInstallPage(): void;
88
+ getState(): Promise<PeerExtensionState>;
89
+ };
90
+ type PeerExtensionState = "needs_install" | "needs_connection" | "ready";
91
+ declare const isPeerExtensionAvailable: (options?: PeerExtensionSdkOptions) => boolean;
92
+ declare const isPeerExtensionMetadataBridgeAvailable: (options?: PeerExtensionSdkOptions) => boolean;
93
+ declare const openPeerExtensionInstallPage: (options?: PeerExtensionSdkOptions) => void;
94
+ declare const getPeerExtensionState: (options?: PeerExtensionSdkOptions) => Promise<PeerExtensionState>;
95
+ declare const createPeerExtensionSdk: (options?: PeerExtensionSdkOptions) => PeerExtensionSdk;
96
+ declare const peerExtensionSdk: PeerExtensionSdk;
97
+
25
98
  /**
26
99
  * Create a USDC-to-fiat offramp deposit and delegate it to the vault.
27
100
  *
@@ -110,4 +183,4 @@ declare function disableOtc(walletClient: WalletClient, depositId: string, escro
110
183
  */
111
184
  declare function getOtcLink(depositId: string, escrowAddress?: string): string;
112
185
 
113
- 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 };
186
+ export { CurrencyEntry, DEFAULT_EXTENSION_INSTALL_URL, 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
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  CURRENCIES,
3
+ DEFAULT_EXTENSION_INSTALL_URL,
3
4
  ESCROW_ADDRESS,
4
5
  MakersCreateError,
5
6
  Offramp,
@@ -33,7 +34,7 @@ import {
33
34
  sanitizeAttributionId,
34
35
  sendTelemetryEvent,
35
36
  undelegate
36
- } from "./chunk-XQ7HOLLB.js";
37
+ } from "./chunk-PL7GZI4K.js";
37
38
 
38
39
  // src/types.ts
39
40
  var OFFRAMP_ERROR_CODES = {
@@ -57,6 +58,7 @@ var OFFRAMP_ERROR_CODES = {
57
58
  };
58
59
  export {
59
60
  CURRENCIES,
61
+ DEFAULT_EXTENSION_INSTALL_URL,
60
62
  ESCROW_ADDRESS,
61
63
  MakersCreateError,
62
64
  OFFRAMP_ERROR_CODES,
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\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":[]}
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":[]}
package/dist/react.cjs CHANGED
@@ -40,7 +40,7 @@ var import_react = require("react");
40
40
 
41
41
  // src/config.ts
42
42
  var import_sdk = require("@zkp2p/sdk");
43
- var SDK_VERSION = "3.1.0";
43
+ var SDK_VERSION = "4.1.0";
44
44
  var BASE_CHAIN_ID = 8453;
45
45
  var RUNTIME_ENV = "production";
46
46
  var API_BASE_URL = "https://api.zkp2p.xyz";
@@ -552,39 +552,9 @@ function requireSarCredentialCapture(capturedMetadata) {
552
552
  }
553
553
  return capture;
554
554
  }
555
- async function uploadSellerCredentialBundle(processorName, payeeHash, bundle) {
556
- const controller = new AbortController();
557
- const timeout = setTimeout(() => controller.abort(), PAYEE_REGISTRATION_TIMEOUT_MS);
558
- try {
559
- const res = await fetch(
560
- `${API_BASE_URL}/v2/makers/${encodeURIComponent(processorName)}/${encodeURIComponent(payeeHash)}/seller-credential`,
561
- {
562
- method: "POST",
563
- headers: { "Content-Type": "application/json" },
564
- body: JSON.stringify(bundle),
565
- signal: controller.signal
566
- }
567
- );
568
- if (!res.ok) {
569
- const txt = await res.text().catch(() => "");
570
- let detail = txt || res.statusText;
571
- try {
572
- const parsed = JSON.parse(txt);
573
- if (typeof parsed.message === "string" && parsed.message.trim()) {
574
- detail = parsed.message;
575
- }
576
- } catch {
577
- }
578
- throw new Error(`seller-credential upload failed (${res.status}): ${detail}`);
579
- }
580
- const json = await res.json();
581
- if (!json.success || !json.responseObject) {
582
- throw new Error(json.message || "seller-credential upload returned no status.");
583
- }
584
- return json;
585
- } finally {
586
- clearTimeout(timeout);
587
- }
555
+ async function uploadSellerCredentialBundle(processorName, offchainId, bundle) {
556
+ const params = processorName === "wise" ? { platform: "wise", bundle } : { platform: processorName, offchainId, bundle };
557
+ return (0, import_sdk3.apiUploadSellerCredentialBundle)(params, API_BASE_URL, PAYEE_REGISTRATION_TIMEOUT_MS);
588
558
  }
589
559
  async function completePeerExtensionRegistration(input) {
590
560
  const processorName = resolveRegistrationProcessor(input.platform);
@@ -606,13 +576,10 @@ async function completePeerExtensionRegistration(input) {
606
576
  if (payload.offchainId !== validation.normalized) {
607
577
  throw new Error("Seller credential offchainId does not match registration identifier.");
608
578
  }
609
- const hashedOnchainId = processorName === "wise" ? bundle.payeeIdHash : await postMakerCreate(processorName, payload);
610
- if (hashedOnchainId.toLowerCase() !== bundle.payeeIdHash.toLowerCase()) {
611
- throw new Error("Seller credential payee hash does not match registered payee details.");
612
- }
579
+ const hashedOnchainId = bundle.payeeIdHash;
613
580
  const sellerCredentialResponse = await uploadSellerCredentialBundle(
614
581
  processorName,
615
- hashedOnchainId,
582
+ payload.offchainId,
616
583
  bundle
617
584
  );
618
585
  return {
@@ -1635,6 +1602,7 @@ var import_react2 = require("react");
1635
1602
 
1636
1603
  // src/extension.ts
1637
1604
  var import_sdk7 = require("@zkp2p/sdk");
1605
+ var DEFAULT_EXTENSION_INSTALL_URL = "https://chromewebstore.google.com/detail/usdctofiat-verify/lfkmdfifolhcfjmhklmckigfngghmpdf";
1638
1606
  var resolveWindow = (options) => {
1639
1607
  if (options?.window) {
1640
1608
  return options.window;
@@ -1675,23 +1643,11 @@ var openPeerExtensionInstallPage = (options) => {
1675
1643
  if (!resolvedWindow) {
1676
1644
  throw new Error("Peer extension SDK requires a browser window.");
1677
1645
  }
1678
- resolvedWindow.open(import_sdk7.PEER_EXTENSION_CHROME_URL, "_blank", "noopener,noreferrer");
1679
- };
1680
- var getPeerExtensionState = async (options) => {
1681
- if (!isPeerExtensionAvailable(options)) {
1682
- return "needs_install";
1683
- }
1684
- try {
1685
- const status = await requirePeer(options).checkConnectionStatus();
1686
- return status === "connected" ? "ready" : "needs_connection";
1687
- } catch {
1688
- return "needs_connection";
1689
- }
1646
+ const installUrl = options?.installUrl ?? DEFAULT_EXTENSION_INSTALL_URL;
1647
+ resolvedWindow.open(installUrl, "_blank", "noopener,noreferrer");
1690
1648
  };
1691
1649
  var createPeerExtensionSdk = (options = {}) => {
1692
- const legacySdk = (0, import_sdk7.createPeerExtensionSdk)(
1693
- options
1694
- );
1650
+ const sdk = (0, import_sdk7.createPeerExtensionSdk)(options);
1695
1651
  return {
1696
1652
  isAvailable: () => isPeerExtensionAvailable(options),
1697
1653
  requestConnection: () => requirePeer(options).requestConnection(),
@@ -1699,11 +1655,8 @@ var createPeerExtensionSdk = (options = {}) => {
1699
1655
  getVersion: () => requirePeer(options).getVersion(),
1700
1656
  authenticate: (params) => requirePeerMetadataBridge(options).authenticate(params),
1701
1657
  onMetadataMessage: (callback) => requirePeerMetadataBridge(options).onMetadataMessage(callback),
1702
- openSidebar: (route) => legacySdk.openSidebar(route),
1703
- onramp: (params, callback) => legacySdk.onramp(params, callback),
1704
- getOnrampTransaction: (intentHash) => legacySdk.getOnrampTransaction(intentHash),
1705
1658
  openInstallPage: () => openPeerExtensionInstallPage(options),
1706
- getState: () => getPeerExtensionState(options)
1659
+ getState: () => sdk.getState()
1707
1660
  };
1708
1661
  };
1709
1662
  var peerExtensionSdk = createPeerExtensionSdk();
@@ -1779,7 +1732,7 @@ function usePeerExtensionRegistration(platform) {
1779
1732
  peerExtensionSdk.openInstallPage();
1780
1733
  } catch {
1781
1734
  if (typeof window !== "undefined") {
1782
- window.open(import_sdk7.PEER_EXTENSION_CHROME_URL, "_blank", "noopener,noreferrer");
1735
+ window.open(DEFAULT_EXTENSION_INSTALL_URL, "_blank", "noopener,noreferrer");
1783
1736
  }
1784
1737
  }
1785
1738
  }, []);