@sardis/ramp 0.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/CHANGELOG.md +44 -0
- package/LICENSE +21 -0
- package/README.md +466 -0
- package/dist/index.cjs +667 -0
- package/dist/index.d.cts +416 -0
- package/dist/index.d.ts +416 -0
- package/dist/index.js +643 -0
- package/package.json +87 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for Sardis Fiat Ramp.
|
|
3
|
+
*/
|
|
4
|
+
type FundingMethod = 'bank' | 'card' | 'crypto';
|
|
5
|
+
interface BankAccount {
|
|
6
|
+
accountHolderName: string;
|
|
7
|
+
accountNumber: string;
|
|
8
|
+
routingNumber: string;
|
|
9
|
+
accountType?: 'checking' | 'savings';
|
|
10
|
+
bankName?: string;
|
|
11
|
+
swiftCode?: string;
|
|
12
|
+
iban?: string;
|
|
13
|
+
bankAddress?: string;
|
|
14
|
+
}
|
|
15
|
+
interface MerchantAccount {
|
|
16
|
+
name: string;
|
|
17
|
+
bankAccount: BankAccount;
|
|
18
|
+
merchantId?: string;
|
|
19
|
+
category?: string;
|
|
20
|
+
}
|
|
21
|
+
interface ACHDetails {
|
|
22
|
+
accountNumber: string;
|
|
23
|
+
routingNumber: string;
|
|
24
|
+
bankName: string;
|
|
25
|
+
accountHolder: string;
|
|
26
|
+
reference: string;
|
|
27
|
+
}
|
|
28
|
+
interface WireDetails {
|
|
29
|
+
accountNumber: string;
|
|
30
|
+
routingNumber: string;
|
|
31
|
+
swiftCode: string;
|
|
32
|
+
bankName: string;
|
|
33
|
+
bankAddress: string;
|
|
34
|
+
accountHolder: string;
|
|
35
|
+
reference: string;
|
|
36
|
+
}
|
|
37
|
+
interface FundingResult {
|
|
38
|
+
type: 'crypto' | 'fiat';
|
|
39
|
+
depositAddress?: string;
|
|
40
|
+
chain?: string;
|
|
41
|
+
token?: string;
|
|
42
|
+
paymentLink?: string;
|
|
43
|
+
achInstructions?: ACHDetails;
|
|
44
|
+
wireInstructions?: WireDetails;
|
|
45
|
+
estimatedArrival?: Date;
|
|
46
|
+
feePercent?: number;
|
|
47
|
+
transferId?: string;
|
|
48
|
+
}
|
|
49
|
+
interface WithdrawalResult {
|
|
50
|
+
txHash: string;
|
|
51
|
+
payoutId: string;
|
|
52
|
+
estimatedArrival: Date;
|
|
53
|
+
fee: number;
|
|
54
|
+
status: 'pending' | 'processing' | 'completed' | 'failed';
|
|
55
|
+
}
|
|
56
|
+
interface PaymentResult {
|
|
57
|
+
status: 'completed' | 'pending_approval' | 'failed';
|
|
58
|
+
paymentId?: string;
|
|
59
|
+
merchantReceived?: number;
|
|
60
|
+
fee?: number;
|
|
61
|
+
txHash?: string;
|
|
62
|
+
approvalRequest?: Record<string, unknown>;
|
|
63
|
+
error?: string;
|
|
64
|
+
}
|
|
65
|
+
interface RampConfig {
|
|
66
|
+
/** Sardis API key (required) */
|
|
67
|
+
sardisKey: string;
|
|
68
|
+
/** Bridge API key (required) */
|
|
69
|
+
bridgeKey: string;
|
|
70
|
+
/** Environment - sandbox for testing, production for live (default: sandbox) */
|
|
71
|
+
environment?: 'sandbox' | 'production';
|
|
72
|
+
/** Default chain for new wallets */
|
|
73
|
+
defaultChain?: string;
|
|
74
|
+
/** Custom Sardis API URL (optional, for enterprise deployments) */
|
|
75
|
+
sardisUrl?: string;
|
|
76
|
+
/** Custom Bridge API URL (optional, for testing) */
|
|
77
|
+
bridgeUrl?: string;
|
|
78
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
79
|
+
timeout?: number;
|
|
80
|
+
}
|
|
81
|
+
interface Wallet {
|
|
82
|
+
id: string;
|
|
83
|
+
address: string;
|
|
84
|
+
chain: string;
|
|
85
|
+
balance?: string;
|
|
86
|
+
policy?: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Sardis Fiat Ramp - Bridge integration for fiat on/off ramp.
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
declare class SardisFiatRamp {
|
|
94
|
+
private readonly sardisKey;
|
|
95
|
+
private readonly bridgeKey;
|
|
96
|
+
private readonly bridgeUrl;
|
|
97
|
+
private readonly sardisUrl;
|
|
98
|
+
constructor(config: RampConfig);
|
|
99
|
+
private sardisRequest;
|
|
100
|
+
private bridgeRequest;
|
|
101
|
+
getWallet(walletId: string): Promise<Wallet>;
|
|
102
|
+
/**
|
|
103
|
+
* Fund a Sardis wallet from fiat sources.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const result = await ramp.fundWallet({
|
|
108
|
+
* walletId: 'wallet_123',
|
|
109
|
+
* amountUsd: 100,
|
|
110
|
+
* method: 'bank'
|
|
111
|
+
* })
|
|
112
|
+
* console.log(result.achInstructions?.routingNumber)
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
fundWallet(params: {
|
|
116
|
+
walletId: string;
|
|
117
|
+
amountUsd: number;
|
|
118
|
+
method: FundingMethod;
|
|
119
|
+
}): Promise<FundingResult>;
|
|
120
|
+
/**
|
|
121
|
+
* Withdraw from Sardis wallet to bank account.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* const result = await ramp.withdrawToBank({
|
|
126
|
+
* walletId: 'wallet_123',
|
|
127
|
+
* amountUsd: 50,
|
|
128
|
+
* bankAccount: {
|
|
129
|
+
* accountHolderName: 'John Doe',
|
|
130
|
+
* accountNumber: '1234567890',
|
|
131
|
+
* routingNumber: '021000021'
|
|
132
|
+
* }
|
|
133
|
+
* })
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
withdrawToBank(params: {
|
|
137
|
+
walletId: string;
|
|
138
|
+
amountUsd: number;
|
|
139
|
+
bankAccount: BankAccount;
|
|
140
|
+
}): Promise<WithdrawalResult>;
|
|
141
|
+
/**
|
|
142
|
+
* Pay merchant in USD from crypto wallet.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* const result = await ramp.payMerchantFiat({
|
|
147
|
+
* walletId: 'wallet_123',
|
|
148
|
+
* amountUsd: 99.99,
|
|
149
|
+
* merchant: {
|
|
150
|
+
* name: 'ACME Corp',
|
|
151
|
+
* bankAccount: { ... }
|
|
152
|
+
* }
|
|
153
|
+
* })
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
payMerchantFiat(params: {
|
|
157
|
+
walletId: string;
|
|
158
|
+
amountUsd: number;
|
|
159
|
+
merchant: MerchantAccount;
|
|
160
|
+
}): Promise<PaymentResult>;
|
|
161
|
+
/**
|
|
162
|
+
* Get status of a funding transfer.
|
|
163
|
+
*/
|
|
164
|
+
getFundingStatus(transferId: string): Promise<unknown>;
|
|
165
|
+
/**
|
|
166
|
+
* Get status of a bank withdrawal.
|
|
167
|
+
*/
|
|
168
|
+
getWithdrawalStatus(payoutId: string): Promise<unknown>;
|
|
169
|
+
private chainToBridge;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Sardis Onramper Integration
|
|
174
|
+
*
|
|
175
|
+
* Onramper is a fiat on-ramp aggregator that provides access to
|
|
176
|
+
* 100+ payment providers (Moonpay, Transak, Ramp, Simplex, etc.)
|
|
177
|
+
* through a single API/widget integration.
|
|
178
|
+
*
|
|
179
|
+
* @see https://docs.onramper.com
|
|
180
|
+
*/
|
|
181
|
+
interface OnramperConfig {
|
|
182
|
+
/** Onramper API key */
|
|
183
|
+
apiKey: string;
|
|
184
|
+
/** Sardis API key for wallet operations */
|
|
185
|
+
sardisKey: string;
|
|
186
|
+
/** Environment mode */
|
|
187
|
+
mode?: 'sandbox' | 'production';
|
|
188
|
+
/** Custom Sardis API URL */
|
|
189
|
+
sardisUrl?: string;
|
|
190
|
+
/** Default fiat currency */
|
|
191
|
+
defaultFiat?: string;
|
|
192
|
+
/** Default crypto */
|
|
193
|
+
defaultCrypto?: string;
|
|
194
|
+
}
|
|
195
|
+
interface OnramperQuote {
|
|
196
|
+
id: string;
|
|
197
|
+
provider: string;
|
|
198
|
+
providerLogo?: string;
|
|
199
|
+
sourceAmount: number;
|
|
200
|
+
sourceCurrency: string;
|
|
201
|
+
destinationAmount: number;
|
|
202
|
+
destinationCurrency: string;
|
|
203
|
+
rate: number;
|
|
204
|
+
fees: {
|
|
205
|
+
network: number;
|
|
206
|
+
provider: number;
|
|
207
|
+
total: number;
|
|
208
|
+
};
|
|
209
|
+
paymentMethod: string;
|
|
210
|
+
estimatedTime: string;
|
|
211
|
+
kycRequired: boolean;
|
|
212
|
+
expiresAt: string;
|
|
213
|
+
}
|
|
214
|
+
interface OnramperTransaction {
|
|
215
|
+
id: string;
|
|
216
|
+
externalId?: string;
|
|
217
|
+
provider: string;
|
|
218
|
+
status: 'pending' | 'processing' | 'completed' | 'failed' | 'expired';
|
|
219
|
+
sourceAmount: number;
|
|
220
|
+
sourceCurrency: string;
|
|
221
|
+
destinationAmount: number;
|
|
222
|
+
destinationCurrency: string;
|
|
223
|
+
destinationAddress: string;
|
|
224
|
+
paymentMethod: string;
|
|
225
|
+
txHash?: string;
|
|
226
|
+
createdAt: string;
|
|
227
|
+
updatedAt: string;
|
|
228
|
+
completedAt?: string;
|
|
229
|
+
failureReason?: string;
|
|
230
|
+
}
|
|
231
|
+
interface OnramperWidgetOptions {
|
|
232
|
+
/** Wallet address to receive crypto */
|
|
233
|
+
walletAddress: string;
|
|
234
|
+
/** Network/chain */
|
|
235
|
+
network?: string;
|
|
236
|
+
/** Fiat currency (default: USD) */
|
|
237
|
+
fiatCurrency?: string;
|
|
238
|
+
/** Crypto currency (default: USDC) */
|
|
239
|
+
cryptoCurrency?: string;
|
|
240
|
+
/** Fiat amount */
|
|
241
|
+
fiatAmount?: number;
|
|
242
|
+
/** Crypto amount */
|
|
243
|
+
cryptoAmount?: number;
|
|
244
|
+
/** Payment method filter */
|
|
245
|
+
paymentMethod?: 'creditCard' | 'debitCard' | 'bankTransfer' | 'applePay' | 'googlePay';
|
|
246
|
+
/** Color theme */
|
|
247
|
+
color?: string;
|
|
248
|
+
/** Dark mode */
|
|
249
|
+
darkMode?: boolean;
|
|
250
|
+
/** Supported providers filter */
|
|
251
|
+
onlyProviders?: string[];
|
|
252
|
+
/** Excluded providers */
|
|
253
|
+
excludeProviders?: string[];
|
|
254
|
+
/** Country filter (ISO 3166-1 alpha-2) */
|
|
255
|
+
country?: string;
|
|
256
|
+
/** Language */
|
|
257
|
+
language?: string;
|
|
258
|
+
/** Skip KYC intro */
|
|
259
|
+
skipIntro?: boolean;
|
|
260
|
+
/** Redirect URL after completion */
|
|
261
|
+
redirectUrl?: string;
|
|
262
|
+
/** Partner context for tracking */
|
|
263
|
+
partnerContext?: string;
|
|
264
|
+
}
|
|
265
|
+
interface SupportedAsset {
|
|
266
|
+
code: string;
|
|
267
|
+
name: string;
|
|
268
|
+
network: string;
|
|
269
|
+
symbol: string;
|
|
270
|
+
decimals: number;
|
|
271
|
+
minAmount: number;
|
|
272
|
+
maxAmount: number;
|
|
273
|
+
}
|
|
274
|
+
interface SupportedFiat {
|
|
275
|
+
code: string;
|
|
276
|
+
name: string;
|
|
277
|
+
symbol: string;
|
|
278
|
+
minAmount: number;
|
|
279
|
+
maxAmount: number;
|
|
280
|
+
}
|
|
281
|
+
declare class SardisOnramper {
|
|
282
|
+
private readonly apiKey;
|
|
283
|
+
private readonly sardisKey;
|
|
284
|
+
private readonly sardisUrl;
|
|
285
|
+
private readonly mode;
|
|
286
|
+
private readonly defaultFiat;
|
|
287
|
+
private readonly defaultCrypto;
|
|
288
|
+
constructor(config: OnramperConfig);
|
|
289
|
+
private onramperRequest;
|
|
290
|
+
private sardisRequest;
|
|
291
|
+
/**
|
|
292
|
+
* Get supported fiat currencies
|
|
293
|
+
*/
|
|
294
|
+
getSupportedFiats(): Promise<SupportedFiat[]>;
|
|
295
|
+
/**
|
|
296
|
+
* Get supported crypto assets
|
|
297
|
+
*/
|
|
298
|
+
getSupportedCryptos(network?: string): Promise<SupportedAsset[]>;
|
|
299
|
+
/**
|
|
300
|
+
* Get supported payment methods for a country
|
|
301
|
+
*/
|
|
302
|
+
getSupportedPaymentMethods(country: string): Promise<string[]>;
|
|
303
|
+
/**
|
|
304
|
+
* Get quotes from all available providers
|
|
305
|
+
*/
|
|
306
|
+
getQuotes(params: {
|
|
307
|
+
sourceCurrency: string;
|
|
308
|
+
destinationCurrency: string;
|
|
309
|
+
amount: number;
|
|
310
|
+
type?: 'fiat' | 'crypto';
|
|
311
|
+
paymentMethod?: string;
|
|
312
|
+
country?: string;
|
|
313
|
+
network?: string;
|
|
314
|
+
}): Promise<OnramperQuote[]>;
|
|
315
|
+
/**
|
|
316
|
+
* Get the best quote (lowest total cost)
|
|
317
|
+
*/
|
|
318
|
+
getBestQuote(params: {
|
|
319
|
+
sourceCurrency: string;
|
|
320
|
+
destinationCurrency: string;
|
|
321
|
+
amount: number;
|
|
322
|
+
type?: 'fiat' | 'crypto';
|
|
323
|
+
paymentMethod?: string;
|
|
324
|
+
country?: string;
|
|
325
|
+
network?: string;
|
|
326
|
+
}): Promise<OnramperQuote | null>;
|
|
327
|
+
/**
|
|
328
|
+
* Generate widget URL for embedding or redirect
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```typescript
|
|
332
|
+
* const url = onramper.getWidgetUrl({
|
|
333
|
+
* walletAddress: '0x...',
|
|
334
|
+
* fiatCurrency: 'USD',
|
|
335
|
+
* cryptoCurrency: 'USDC',
|
|
336
|
+
* fiatAmount: 100,
|
|
337
|
+
* network: 'base',
|
|
338
|
+
* })
|
|
339
|
+
* window.open(url, '_blank')
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
getWidgetUrl(options: OnramperWidgetOptions): string;
|
|
343
|
+
/**
|
|
344
|
+
* Generate widget HTML for iframe embedding
|
|
345
|
+
*/
|
|
346
|
+
getWidgetIframe(options: OnramperWidgetOptions & {
|
|
347
|
+
width?: string;
|
|
348
|
+
height?: string;
|
|
349
|
+
}): string;
|
|
350
|
+
/**
|
|
351
|
+
* Get transaction status by Onramper transaction ID
|
|
352
|
+
*/
|
|
353
|
+
getTransaction(transactionId: string): Promise<OnramperTransaction>;
|
|
354
|
+
/**
|
|
355
|
+
* List transactions for a wallet address
|
|
356
|
+
*/
|
|
357
|
+
listTransactions(walletAddress: string, options?: {
|
|
358
|
+
limit?: number;
|
|
359
|
+
offset?: number;
|
|
360
|
+
status?: OnramperTransaction['status'];
|
|
361
|
+
}): Promise<OnramperTransaction[]>;
|
|
362
|
+
/**
|
|
363
|
+
* Fund a Sardis wallet via Onramper widget
|
|
364
|
+
*
|
|
365
|
+
* Returns a widget URL that, when used, will deposit crypto
|
|
366
|
+
* directly to the Sardis wallet.
|
|
367
|
+
*/
|
|
368
|
+
fundWallet(params: {
|
|
369
|
+
walletId: string;
|
|
370
|
+
fiatAmount?: number;
|
|
371
|
+
fiatCurrency?: string;
|
|
372
|
+
cryptoCurrency?: string;
|
|
373
|
+
paymentMethod?: string;
|
|
374
|
+
redirectUrl?: string;
|
|
375
|
+
}): Promise<{
|
|
376
|
+
widgetUrl: string;
|
|
377
|
+
walletAddress: string;
|
|
378
|
+
network: string;
|
|
379
|
+
}>;
|
|
380
|
+
/**
|
|
381
|
+
* Get best quote for funding a Sardis wallet
|
|
382
|
+
*/
|
|
383
|
+
getWalletFundingQuote(params: {
|
|
384
|
+
walletId: string;
|
|
385
|
+
fiatAmount: number;
|
|
386
|
+
fiatCurrency?: string;
|
|
387
|
+
paymentMethod?: string;
|
|
388
|
+
}): Promise<OnramperQuote | null>;
|
|
389
|
+
/**
|
|
390
|
+
* Verify webhook signature from Onramper
|
|
391
|
+
*/
|
|
392
|
+
verifyWebhookSignature(payload: string, signature: string, secret: string): boolean;
|
|
393
|
+
/**
|
|
394
|
+
* Parse webhook payload
|
|
395
|
+
*/
|
|
396
|
+
parseWebhookPayload(payload: string): {
|
|
397
|
+
event: 'transaction.created' | 'transaction.completed' | 'transaction.failed';
|
|
398
|
+
transaction: OnramperTransaction;
|
|
399
|
+
};
|
|
400
|
+
private mapNetwork;
|
|
401
|
+
}
|
|
402
|
+
declare function createOnramper(config: OnramperConfig): SardisOnramper;
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Custom error classes for Sardis Fiat Ramp.
|
|
406
|
+
*/
|
|
407
|
+
declare class PolicyViolation extends Error {
|
|
408
|
+
constructor(message: string);
|
|
409
|
+
}
|
|
410
|
+
declare class RampError extends Error {
|
|
411
|
+
code: string;
|
|
412
|
+
details?: Record<string, unknown>;
|
|
413
|
+
constructor(message: string, code: string, details?: Record<string, unknown>);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
export { type ACHDetails, type BankAccount, type FundingMethod, type FundingResult, type MerchantAccount, type OnramperConfig, type OnramperQuote, type OnramperTransaction, type OnramperWidgetOptions, type PaymentResult, PolicyViolation, type RampConfig, RampError, SardisFiatRamp, SardisOnramper, type SupportedAsset, type SupportedFiat, type Wallet, type WireDetails, type WithdrawalResult, createOnramper };
|