@usdctofiat/offramp 3.0.2 → 3.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.
@@ -1,217 +0,0 @@
1
- import { currencyInfo } from '@zkp2p/sdk';
2
-
3
- type PlatformId = "venmo" | "cashapp" | "chime" | "revolut" | "wise" | "mercadopago" | "zelle" | "paypal" | "monzo" | "n26";
4
- /**
5
- * Extension pre-registration requirement for a platform. When present,
6
- * curator's `/v2/makers/create` rejects the maker until the user has
7
- * registered their handle in the Peer extension at `/verify/<providerId>`.
8
- */
9
- interface PeerExtensionRegistrationInfo {
10
- /** Peer extension provider id. Used to build `/verify/<providerId>`. */
11
- readonly providerId: string;
12
- /** Message shown to the user when curator rejects the maker. */
13
- readonly requiredPrompt: string;
14
- /** Label for the install / connect / verify CTA. */
15
- readonly ctaLabel: string;
16
- /** Optional subtext (e.g. PayPal Business disclaimer). */
17
- readonly ctaSubtext?: string;
18
- /** Minimum Peer extension version required. */
19
- readonly minExtensionVersion: string;
20
- }
21
- interface PlatformEntry {
22
- readonly id: PlatformId;
23
- readonly name: string;
24
- readonly currencies: readonly string[];
25
- readonly identifier: {
26
- readonly label: string;
27
- readonly placeholder: string;
28
- readonly help: string;
29
- };
30
- /** Set for platforms that require Peer extension registration (PayPal, Wise). */
31
- readonly extensionRegistration?: PeerExtensionRegistrationInfo;
32
- validate(input: string): {
33
- valid: boolean;
34
- normalized: string;
35
- error?: string;
36
- };
37
- }
38
- /**
39
- * Extracts the bare PayPal.me username from any accepted input shape
40
- * (`paypal.me/user`, `https://paypal.me/user`, `@user`, `user`). Mirrors the
41
- * upstream zkp2p-clients normalizer so our offchainId hashes identically.
42
- */
43
- declare function normalizePaypalMeUsername(value: string): string;
44
- /** All supported payment platforms. Access via `PLATFORMS.REVOLUT`, `PLATFORMS.WISE`, etc. */
45
- declare const PLATFORMS: {
46
- readonly VENMO: PlatformEntry;
47
- readonly CASHAPP: PlatformEntry;
48
- readonly CHIME: PlatformEntry;
49
- readonly REVOLUT: PlatformEntry;
50
- readonly WISE: PlatformEntry;
51
- readonly MERCADO_PAGO: PlatformEntry;
52
- readonly ZELLE: PlatformEntry;
53
- readonly PAYPAL: PlatformEntry;
54
- readonly MONZO: PlatformEntry;
55
- readonly N26: PlatformEntry;
56
- };
57
- /** Platform key type for PLATFORMS constant. */
58
- type PlatformKey = keyof typeof PLATFORMS;
59
- /** Flat payload accepted by `POST /v2/makers/create`. */
60
- interface PayeeDepositData {
61
- offchainId: string;
62
- telegramUsername?: string;
63
- metadata?: Record<string, string>;
64
- }
65
- /**
66
- * Returns the extension-registration metadata for a platform, or `null` if
67
- * the platform does not require Peer-extension pre-registration. Use this to
68
- * decide whether to surface an "Install / Connect Peer Extension" CTA in
69
- * your UI before calling `offramp()` for PayPal or Wise.
70
- */
71
- declare function getPeerExtensionRegistrationInfo(platform: string): PeerExtensionRegistrationInfo | null;
72
- /**
73
- * True when a failed `/v2/makers/create` response should be treated as
74
- * "maker needs to register in the Peer extension first". Platforms without
75
- * an `extensionRegistration` config always return false. A 400 on a
76
- * registration-required platform is treated as registration required, and
77
- * so is any response whose message contains curator's phrasing.
78
- */
79
- declare function isPeerExtensionRegistrationError(platform: string, message?: string | null, statusCode?: number | null): boolean;
80
-
81
- interface CurrencyEntry {
82
- readonly code: string;
83
- readonly name: string;
84
- readonly symbol: string;
85
- readonly countryCode: string;
86
- }
87
- type CurrencyMap = {
88
- readonly [K in keyof typeof currencyInfo]: CurrencyEntry;
89
- };
90
- /** All supported currencies with metadata. Access via `CURRENCIES.EUR.symbol` etc. */
91
- declare const CURRENCIES: CurrencyMap;
92
-
93
- declare const OFFRAMP_ERROR_CODES: {
94
- readonly VALIDATION: "VALIDATION";
95
- readonly APPROVAL_FAILED: "APPROVAL_FAILED";
96
- readonly REGISTRATION_FAILED: "REGISTRATION_FAILED";
97
- /**
98
- * Curator rejected the maker because the user has not registered this
99
- * handle in the Peer extension yet. Thrown from `offramp()` for PayPal
100
- * and Wise when `/v2/makers/create` returns 400 or a "creating the maker"
101
- * message. Recover by prompting the user through the Peer extension via
102
- * `usePeerExtensionRegistration(platform)` (React) or `peerExtensionSdk`
103
- * directly, then call `offramp()` again.
104
- */
105
- readonly EXTENSION_REGISTRATION_REQUIRED: "EXTENSION_REGISTRATION_REQUIRED";
106
- readonly DEPOSIT_FAILED: "DEPOSIT_FAILED";
107
- readonly CONFIRMATION_FAILED: "CONFIRMATION_FAILED";
108
- readonly DELEGATION_FAILED: "DELEGATION_FAILED";
109
- readonly USER_CANCELLED: "USER_CANCELLED";
110
- readonly UNSUPPORTED: "UNSUPPORTED";
111
- };
112
- type OfframpErrorCode = (typeof OFFRAMP_ERROR_CODES)[keyof typeof OFFRAMP_ERROR_CODES];
113
- interface OfframpParams {
114
- /** USDC amount as decimal string, min 1. */
115
- amount: string;
116
- /** Payment platform — use `PLATFORMS.REVOLUT` etc. */
117
- platform: PlatformEntry;
118
- /** Fiat currency — use `CURRENCIES.EUR` etc. */
119
- currency: CurrencyEntry;
120
- /** Platform-specific identifier (username, email, IBAN). */
121
- identifier: string;
122
- /** Optional: restrict the deposit to this taker wallet (OTC private order). */
123
- otcTaker?: string;
124
- /** Optional SDK-only referral metadata for telemetry attribution. */
125
- referralId?: string;
126
- /** Optional SDK-only integrator metadata for telemetry attribution. */
127
- integratorId?: string;
128
- /** Optional per-wallet key to replay the first successful result for 10 minutes. */
129
- idempotencyKey?: string;
130
- }
131
- interface OfframpResult {
132
- depositId: string;
133
- txHash: string;
134
- /** Whether an existing undelegated deposit was resumed. */
135
- resumed: boolean;
136
- /** OTC link for the taker, present when `otcTaker` was provided. */
137
- otcLink?: string;
138
- }
139
- type OfframpStep = "approving" | "registering" | "depositing" | "confirming" | "delegating" | "restricting" | "resuming" | "done";
140
- type OfframpState = "idle" | "approving" | "registering" | "depositing" | "confirming" | "delegating" | "done" | "error";
141
- interface OfframpProgress {
142
- step: OfframpStep;
143
- txHash?: string;
144
- depositId?: string;
145
- }
146
- type OnProgress = (progress: OfframpProgress) => void;
147
- type DepositStatus = "active" | "empty" | "closed";
148
- interface OfframpQuoteInput {
149
- amount: string;
150
- currency: CurrencyEntry;
151
- platform: PlatformEntry;
152
- }
153
- interface OfframpQuote {
154
- amountUsdc: number;
155
- expectedFiat: number;
156
- effectiveRate: number;
157
- vaultSpreadBps: number;
158
- }
159
- interface OfframpVaultStatus {
160
- rateManagerId: string;
161
- rateManagerAddress: string;
162
- feeRateBps: number;
163
- escrow: string;
164
- isActive: boolean;
165
- }
166
- interface OfframpCreateOptions {
167
- integratorId?: string;
168
- referralId?: string;
169
- telemetry?: boolean;
170
- }
171
- interface DepositInfo {
172
- /** Numeric deposit ID. Pass this to `close()`. */
173
- depositId: string;
174
- /** Composite ID (escrowAddress_depositId). */
175
- compositeId: string;
176
- /** Creation transaction hash. */
177
- txHash?: string;
178
- status: DepositStatus;
179
- remainingUsdc: number;
180
- outstandingUsdc: number;
181
- totalTakenUsdc: number;
182
- fulfilledIntents: number;
183
- paymentMethods: string[];
184
- currencies: string[];
185
- rateSource: string;
186
- delegated: boolean;
187
- escrowAddress: string;
188
- }
189
-
190
- /**
191
- * Error thrown when curator's `/v2/makers/create` returns a non-success
192
- * response. Preserves the HTTP status so callers can distinguish a
193
- * "needs Peer-extension registration" 400 from a transient server error.
194
- *
195
- * `offramp()` re-raises this as an {@link OfframpError} with code
196
- * `EXTENSION_REGISTRATION_REQUIRED` (for PayPal/Wise 400s) or
197
- * `REGISTRATION_FAILED` (for any other curator error); `MakersCreateError`
198
- * is attached as the `cause`.
199
- */
200
- declare class MakersCreateError extends Error {
201
- readonly status: number | null;
202
- readonly body: string;
203
- constructor(message: string, status: number | null, body: string);
204
- }
205
- declare class OfframpError extends Error {
206
- readonly code: OfframpErrorCode;
207
- readonly step?: OfframpStep;
208
- readonly cause?: unknown;
209
- readonly txHash?: string;
210
- readonly depositId?: string;
211
- constructor(message: string, code: OfframpErrorCode, step?: OfframpStep, cause?: unknown, details?: {
212
- txHash?: string;
213
- depositId?: string;
214
- });
215
- }
216
-
217
- export { type CurrencyEntry as C, type DepositInfo as D, MakersCreateError as M, type OfframpParams as O, type PlatformEntry as P, type OnProgress as a, type OfframpResult as b, type OfframpCreateOptions as c, type OfframpQuoteInput as d, type OfframpQuote as e, type OfframpVaultStatus as f, CURRENCIES as g, type DepositStatus as h, OFFRAMP_ERROR_CODES as i, OfframpError as j, type OfframpErrorCode as k, type OfframpProgress as l, type OfframpState as m, type OfframpStep as n, PLATFORMS as o, type PayeeDepositData as p, type PeerExtensionRegistrationInfo as q, type PlatformKey as r, getPeerExtensionRegistrationInfo as s, isPeerExtensionRegistrationError as t, normalizePaypalMeUsername as u };