@usdctofiat/offramp 4.0.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/{chunk-QMO7HTBZ.js → chunk-PL7GZI4K.js} +7 -4
- package/dist/{chunk-QMO7HTBZ.js.map → chunk-PL7GZI4K.js.map} +1 -1
- package/dist/index.cjs +7 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +12 -3
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +3 -3
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -64,7 +64,19 @@ type PeerExtensionWindow = Window & {
|
|
|
64
64
|
};
|
|
65
65
|
type PeerExtensionSdkOptions = {
|
|
66
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;
|
|
67
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";
|
|
68
80
|
type PeerExtensionSdk = {
|
|
69
81
|
requestConnection(): Promise<boolean>;
|
|
70
82
|
checkConnectionStatus(): Promise<PeerConnectionStatus>;
|
|
@@ -171,4 +183,4 @@ declare function disableOtc(walletClient: WalletClient, depositId: string, escro
|
|
|
171
183
|
*/
|
|
172
184
|
declare function getOtcLink(depositId: string, escrowAddress?: string): string;
|
|
173
185
|
|
|
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 };
|
|
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
|
@@ -64,7 +64,19 @@ type PeerExtensionWindow = Window & {
|
|
|
64
64
|
};
|
|
65
65
|
type PeerExtensionSdkOptions = {
|
|
66
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;
|
|
67
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";
|
|
68
80
|
type PeerExtensionSdk = {
|
|
69
81
|
requestConnection(): Promise<boolean>;
|
|
70
82
|
checkConnectionStatus(): Promise<PeerConnectionStatus>;
|
|
@@ -171,4 +183,4 @@ declare function disableOtc(walletClient: WalletClient, depositId: string, escro
|
|
|
171
183
|
*/
|
|
172
184
|
declare function getOtcLink(depositId: string, escrowAddress?: string): string;
|
|
173
185
|
|
|
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 };
|
|
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-
|
|
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":"
|
|
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 = "4.
|
|
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";
|
|
@@ -1602,6 +1602,7 @@ var import_react2 = require("react");
|
|
|
1602
1602
|
|
|
1603
1603
|
// src/extension.ts
|
|
1604
1604
|
var import_sdk7 = require("@zkp2p/sdk");
|
|
1605
|
+
var DEFAULT_EXTENSION_INSTALL_URL = "https://chromewebstore.google.com/detail/usdctofiat-verify/lfkmdfifolhcfjmhklmckigfngghmpdf";
|
|
1605
1606
|
var resolveWindow = (options) => {
|
|
1606
1607
|
if (options?.window) {
|
|
1607
1608
|
return options.window;
|
|
@@ -1637,6 +1638,14 @@ var isPeerExtensionMetadataBridgeAvailable = (options) => {
|
|
|
1637
1638
|
const resolvedWindow = resolveWindow(options);
|
|
1638
1639
|
return Boolean(resolvedWindow?.peer && hasHeadlessMetadataBridge(resolvedWindow.peer));
|
|
1639
1640
|
};
|
|
1641
|
+
var openPeerExtensionInstallPage = (options) => {
|
|
1642
|
+
const resolvedWindow = resolveWindow(options);
|
|
1643
|
+
if (!resolvedWindow) {
|
|
1644
|
+
throw new Error("Peer extension SDK requires a browser window.");
|
|
1645
|
+
}
|
|
1646
|
+
const installUrl = options?.installUrl ?? DEFAULT_EXTENSION_INSTALL_URL;
|
|
1647
|
+
resolvedWindow.open(installUrl, "_blank", "noopener,noreferrer");
|
|
1648
|
+
};
|
|
1640
1649
|
var createPeerExtensionSdk = (options = {}) => {
|
|
1641
1650
|
const sdk = (0, import_sdk7.createPeerExtensionSdk)(options);
|
|
1642
1651
|
return {
|
|
@@ -1646,7 +1655,7 @@ var createPeerExtensionSdk = (options = {}) => {
|
|
|
1646
1655
|
getVersion: () => requirePeer(options).getVersion(),
|
|
1647
1656
|
authenticate: (params) => requirePeerMetadataBridge(options).authenticate(params),
|
|
1648
1657
|
onMetadataMessage: (callback) => requirePeerMetadataBridge(options).onMetadataMessage(callback),
|
|
1649
|
-
openInstallPage: () =>
|
|
1658
|
+
openInstallPage: () => openPeerExtensionInstallPage(options),
|
|
1650
1659
|
getState: () => sdk.getState()
|
|
1651
1660
|
};
|
|
1652
1661
|
};
|
|
@@ -1723,7 +1732,7 @@ function usePeerExtensionRegistration(platform) {
|
|
|
1723
1732
|
peerExtensionSdk.openInstallPage();
|
|
1724
1733
|
} catch {
|
|
1725
1734
|
if (typeof window !== "undefined") {
|
|
1726
|
-
window.open(
|
|
1735
|
+
window.open(DEFAULT_EXTENSION_INSTALL_URL, "_blank", "noopener,noreferrer");
|
|
1727
1736
|
}
|
|
1728
1737
|
}
|
|
1729
1738
|
}, []);
|