@unifold/core 0.1.67 → 0.1.68-beta.1
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.mts +527 -14
- package/dist/index.d.ts +527 -14
- package/dist/index.js +681 -194
- package/dist/index.mjs +656 -194
- package/package.json +11 -2
package/dist/index.js
CHANGED
|
@@ -21,11 +21,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
ActionType: () => ActionType,
|
|
24
|
+
CheckoutEventType: () => CheckoutEventType,
|
|
24
25
|
DepositEventType: () => DepositEventType,
|
|
25
26
|
ExecutionStatus: () => ExecutionStatus,
|
|
26
27
|
IneligibilityReason: () => IneligibilityReason,
|
|
27
28
|
IntegrationProvider: () => IntegrationProvider,
|
|
28
29
|
SOLANA_USDC_ADDRESS: () => SOLANA_USDC_ADDRESS,
|
|
30
|
+
StripeApiResponseError: () => StripeApiResponseError,
|
|
29
31
|
WithdrawEventType: () => WithdrawEventType,
|
|
30
32
|
authenticateIntegrationOAuth: () => authenticateIntegrationOAuth,
|
|
31
33
|
buildHypercoreTransaction: () => buildHypercoreTransaction,
|
|
@@ -33,19 +35,25 @@ __export(index_exports, {
|
|
|
33
35
|
checkHypercoreActivation: () => checkHypercoreActivation,
|
|
34
36
|
confirmIntegrationTransfer: () => confirmIntegrationTransfer,
|
|
35
37
|
createCashAppSession: () => createCashAppSession,
|
|
38
|
+
createCoinbaseApplePaySession: () => createCoinbaseApplePaySession,
|
|
36
39
|
createDepositAddress: () => createDepositAddress,
|
|
37
40
|
createExchangeSession: () => createExchangeSession,
|
|
38
41
|
createIntegrationTransfer: () => createIntegrationTransfer,
|
|
39
42
|
createOnrampSession: () => createOnrampSession,
|
|
43
|
+
createOnrampVerificationSession: () => createOnrampVerificationSession,
|
|
44
|
+
exchangeOnrampVerificationToken: () => exchangeOnrampVerificationToken,
|
|
40
45
|
formatStablecoinAmount: () => formatStablecoinAmount,
|
|
41
46
|
generateKSUID: () => generateKSUID,
|
|
42
47
|
generatePrefixedKSUID: () => generatePrefixedKSUID,
|
|
43
48
|
getAddressBalance: () => getAddressBalance,
|
|
44
49
|
getAddressBalances: () => getAddressBalances,
|
|
45
50
|
getApiBaseUrl: () => getApiBaseUrl,
|
|
51
|
+
getApplePayProviders: () => getApplePayProviders,
|
|
52
|
+
getBankTransferProviders: () => getBankTransferProviders,
|
|
46
53
|
getCashAppLimits: () => getCashAppLimits,
|
|
47
54
|
getCashAppSessionStatus: () => getCashAppSessionStatus,
|
|
48
55
|
getChainName: () => getChainName,
|
|
56
|
+
getCoinbaseLegalAgreements: () => getCoinbaseLegalAgreements,
|
|
49
57
|
getDefaultOnrampToken: () => getDefaultOnrampToken,
|
|
50
58
|
getDepositAddress: () => getDepositAddress,
|
|
51
59
|
getDepositQuote: () => getDepositQuote,
|
|
@@ -61,6 +69,7 @@ __export(index_exports, {
|
|
|
61
69
|
getIpAddress: () => getIpAddress,
|
|
62
70
|
getOnrampQuotes: () => getOnrampQuotes,
|
|
63
71
|
getOnrampSessionStartUrl: () => getOnrampSessionStartUrl,
|
|
72
|
+
getOnrampVerificationSession: () => getOnrampVerificationSession,
|
|
64
73
|
getPreferredIconUrl: () => getPreferredIconUrl,
|
|
65
74
|
getProjectConfig: () => getProjectConfig,
|
|
66
75
|
getSupportedDepositTokens: () => getSupportedDepositTokens,
|
|
@@ -77,10 +86,26 @@ __export(index_exports, {
|
|
|
77
86
|
retrievePaymentIntent: () => retrievePaymentIntent,
|
|
78
87
|
revokeIntegrationToken: () => revokeIntegrationToken,
|
|
79
88
|
sendHypercoreTransaction: () => sendHypercoreTransaction,
|
|
89
|
+
sendOnrampVerificationOtp: () => sendOnrampVerificationOtp,
|
|
80
90
|
sendSolanaTransaction: () => sendSolanaTransaction,
|
|
81
91
|
setApiConfig: () => setApiConfig,
|
|
82
92
|
startIntegrationOAuth: () => startIntegrationOAuth,
|
|
93
|
+
stripeConfirmSession: () => stripeConfirmSession,
|
|
94
|
+
stripeCreateAuthIntent: () => stripeCreateAuthIntent,
|
|
95
|
+
stripeCreateSession: () => stripeCreateSession,
|
|
96
|
+
stripeExchangeTokens: () => stripeExchangeTokens,
|
|
97
|
+
stripeGetConfig: () => stripeGetConfig,
|
|
98
|
+
stripeGetCustomer: () => stripeGetCustomer,
|
|
99
|
+
stripeGetDefaultToken: () => stripeGetDefaultToken,
|
|
100
|
+
stripeGetQuotes: () => stripeGetQuotes,
|
|
101
|
+
stripeGetSession: () => stripeGetSession,
|
|
102
|
+
stripeGetTransactionLimits: () => stripeGetTransactionLimits,
|
|
103
|
+
stripeListPaymentTokens: () => stripeListPaymentTokens,
|
|
104
|
+
stripeListWallets: () => stripeListWallets,
|
|
105
|
+
stripeRefreshQuote: () => stripeRefreshQuote,
|
|
106
|
+
stripeRefreshToken: () => stripeRefreshToken,
|
|
83
107
|
useUserIp: () => useUserIp,
|
|
108
|
+
verifyOnrampVerificationOtp: () => verifyOnrampVerificationOtp,
|
|
84
109
|
verifyRecipientAddress: () => verifyRecipientAddress
|
|
85
110
|
});
|
|
86
111
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -215,18 +240,15 @@ async function createDepositAddress(overrides, publishableKey) {
|
|
|
215
240
|
async function getDepositAddress(params, publishableKey) {
|
|
216
241
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
217
242
|
validatePublishableKey(pk);
|
|
218
|
-
const response = await fetch(
|
|
219
|
-
|
|
220
|
-
{
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
body: JSON.stringify(params)
|
|
228
|
-
}
|
|
229
|
-
);
|
|
243
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/deposit_addresses/existing`, {
|
|
244
|
+
method: "POST",
|
|
245
|
+
headers: {
|
|
246
|
+
accept: "application/json",
|
|
247
|
+
"x-publishable-key": pk,
|
|
248
|
+
"Content-Type": "application/json"
|
|
249
|
+
},
|
|
250
|
+
body: JSON.stringify(params)
|
|
251
|
+
});
|
|
230
252
|
if (!response.ok) {
|
|
231
253
|
throw new Error(`Failed to get deposit addresses: ${response.statusText}`);
|
|
232
254
|
}
|
|
@@ -252,18 +274,15 @@ async function queryExecutions(externalUserId, publishableKey, actionType = "dep
|
|
|
252
274
|
external_user_id: externalUserId,
|
|
253
275
|
action_type: actionType
|
|
254
276
|
};
|
|
255
|
-
const response = await fetch(
|
|
256
|
-
|
|
257
|
-
{
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
body: JSON.stringify(body)
|
|
265
|
-
}
|
|
266
|
-
);
|
|
277
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/direct_executions/query`, {
|
|
278
|
+
method: "POST",
|
|
279
|
+
headers: {
|
|
280
|
+
accept: "application/json",
|
|
281
|
+
"x-publishable-key": pk,
|
|
282
|
+
"Content-Type": "application/json"
|
|
283
|
+
},
|
|
284
|
+
body: JSON.stringify(body)
|
|
285
|
+
});
|
|
267
286
|
if (!response.ok) {
|
|
268
287
|
throw new Error(`Failed to query executions: ${response.statusText}`);
|
|
269
288
|
}
|
|
@@ -272,18 +291,15 @@ async function queryExecutions(externalUserId, publishableKey, actionType = "dep
|
|
|
272
291
|
async function pollDirectExecutions(request, publishableKey) {
|
|
273
292
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
274
293
|
validatePublishableKey(pk);
|
|
275
|
-
const response = await fetch(
|
|
276
|
-
|
|
277
|
-
{
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
body: JSON.stringify(request)
|
|
285
|
-
}
|
|
286
|
-
);
|
|
294
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/direct_executions/poll`, {
|
|
295
|
+
method: "POST",
|
|
296
|
+
headers: {
|
|
297
|
+
accept: "application/json",
|
|
298
|
+
"x-publishable-key": pk,
|
|
299
|
+
"Content-Type": "application/json"
|
|
300
|
+
},
|
|
301
|
+
body: JSON.stringify(request)
|
|
302
|
+
});
|
|
287
303
|
if (!response.ok) {
|
|
288
304
|
throw new Error(`Failed to poll direct executions: ${response.statusText}`);
|
|
289
305
|
}
|
|
@@ -309,9 +325,7 @@ async function getSupportedDestinationTokens(publishableKey, options) {
|
|
|
309
325
|
}
|
|
310
326
|
});
|
|
311
327
|
if (!response.ok) {
|
|
312
|
-
throw new Error(
|
|
313
|
-
`Failed to fetch supported destination tokens: ${response.statusText}`
|
|
314
|
-
);
|
|
328
|
+
throw new Error(`Failed to fetch supported destination tokens: ${response.statusText}`);
|
|
315
329
|
}
|
|
316
330
|
return response.json();
|
|
317
331
|
}
|
|
@@ -340,9 +354,7 @@ async function getSupportedDepositTokens(publishableKey, options) {
|
|
|
340
354
|
}
|
|
341
355
|
});
|
|
342
356
|
if (!response.ok) {
|
|
343
|
-
throw new Error(
|
|
344
|
-
`Failed to fetch supported deposit tokens: ${response.statusText}`
|
|
345
|
-
);
|
|
357
|
+
throw new Error(`Failed to fetch supported deposit tokens: ${response.statusText}`);
|
|
346
358
|
}
|
|
347
359
|
return response.json();
|
|
348
360
|
}
|
|
@@ -354,16 +366,13 @@ async function getTokenMetadata(request, publishableKey) {
|
|
|
354
366
|
chainId: request.chain_id,
|
|
355
367
|
tokenAddress: request.token_address
|
|
356
368
|
});
|
|
357
|
-
const response = await fetch(
|
|
358
|
-
|
|
359
|
-
{
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
accept: "application/json",
|
|
363
|
-
"x-publishable-key": pk
|
|
364
|
-
}
|
|
369
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/tokens/token?${params.toString()}`, {
|
|
370
|
+
method: "GET",
|
|
371
|
+
headers: {
|
|
372
|
+
accept: "application/json",
|
|
373
|
+
"x-publishable-key": pk
|
|
365
374
|
}
|
|
366
|
-
);
|
|
375
|
+
});
|
|
367
376
|
if (!response.ok) {
|
|
368
377
|
throw new Error(`Failed to fetch token metadata: ${response.statusText}`);
|
|
369
378
|
}
|
|
@@ -382,16 +391,13 @@ function getPreferredIconUrl(iconUrls, preferredFormat = "svg") {
|
|
|
382
391
|
async function getFiatCurrencies(publishableKey) {
|
|
383
392
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
384
393
|
validatePublishableKey(pk);
|
|
385
|
-
const response = await fetch(
|
|
386
|
-
|
|
387
|
-
{
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
accept: "application/json",
|
|
391
|
-
"x-publishable-key": pk
|
|
392
|
-
}
|
|
394
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/onramps/fiat_currencies`, {
|
|
395
|
+
method: "GET",
|
|
396
|
+
headers: {
|
|
397
|
+
accept: "application/json",
|
|
398
|
+
"x-publishable-key": pk
|
|
393
399
|
}
|
|
394
|
-
);
|
|
400
|
+
});
|
|
395
401
|
if (!response.ok) {
|
|
396
402
|
throw new Error(`Failed to fetch fiat currencies: ${response.statusText}`);
|
|
397
403
|
}
|
|
@@ -400,18 +406,15 @@ async function getFiatCurrencies(publishableKey) {
|
|
|
400
406
|
async function getOnrampQuotes(request, publishableKey) {
|
|
401
407
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
402
408
|
validatePublishableKey(pk);
|
|
403
|
-
const response = await fetch(
|
|
404
|
-
|
|
405
|
-
{
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
body: JSON.stringify(request)
|
|
413
|
-
}
|
|
414
|
-
);
|
|
409
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/onramps/quotes`, {
|
|
410
|
+
method: "POST",
|
|
411
|
+
headers: {
|
|
412
|
+
accept: "application/json",
|
|
413
|
+
"x-publishable-key": pk,
|
|
414
|
+
"Content-Type": "application/json"
|
|
415
|
+
},
|
|
416
|
+
body: JSON.stringify(request)
|
|
417
|
+
});
|
|
415
418
|
if (!response.ok) {
|
|
416
419
|
throw new Error(`Failed to fetch onramp quotes: ${response.statusText}`);
|
|
417
420
|
}
|
|
@@ -420,23 +423,57 @@ async function getOnrampQuotes(request, publishableKey) {
|
|
|
420
423
|
async function createOnrampSession(request, publishableKey) {
|
|
421
424
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
422
425
|
validatePublishableKey(pk);
|
|
423
|
-
const response = await fetch(
|
|
424
|
-
|
|
425
|
-
{
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
body: JSON.stringify(request)
|
|
433
|
-
}
|
|
434
|
-
);
|
|
426
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/onramps/sessions`, {
|
|
427
|
+
method: "POST",
|
|
428
|
+
headers: {
|
|
429
|
+
accept: "application/json",
|
|
430
|
+
"x-publishable-key": pk,
|
|
431
|
+
"Content-Type": "application/json"
|
|
432
|
+
},
|
|
433
|
+
body: JSON.stringify(request)
|
|
434
|
+
});
|
|
435
435
|
if (!response.ok) {
|
|
436
436
|
throw new Error(`Failed to create onramp session: ${response.statusText}`);
|
|
437
437
|
}
|
|
438
438
|
return response.json();
|
|
439
439
|
}
|
|
440
|
+
async function getBankTransferProviders(publishableKey, options = {}) {
|
|
441
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
442
|
+
validatePublishableKey(pk);
|
|
443
|
+
const params = new URLSearchParams();
|
|
444
|
+
if (options.countryCode) {
|
|
445
|
+
params.set("country_code", options.countryCode);
|
|
446
|
+
}
|
|
447
|
+
const queryString = params.toString();
|
|
448
|
+
const url = `${API_BASE_URL}/v1/public/onramps/bank_transfer/providers${queryString ? `?${queryString}` : ""}`;
|
|
449
|
+
const response = await fetch(url, {
|
|
450
|
+
method: "GET",
|
|
451
|
+
headers: {
|
|
452
|
+
accept: "application/json",
|
|
453
|
+
"x-publishable-key": pk
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
if (!response.ok) {
|
|
457
|
+
throw new Error(`Failed to fetch bank-transfer providers: ${response.statusText}`);
|
|
458
|
+
}
|
|
459
|
+
return response.json();
|
|
460
|
+
}
|
|
461
|
+
async function getApplePayProviders(publishableKey) {
|
|
462
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
463
|
+
validatePublishableKey(pk);
|
|
464
|
+
const url = `${API_BASE_URL}/v1/public/onramps/apple_pay/providers`;
|
|
465
|
+
const response = await fetch(url, {
|
|
466
|
+
method: "GET",
|
|
467
|
+
headers: {
|
|
468
|
+
accept: "application/json",
|
|
469
|
+
"x-publishable-key": pk
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
if (!response.ok) {
|
|
473
|
+
throw new Error(`Failed to fetch Apple Pay providers: ${response.statusText}`);
|
|
474
|
+
}
|
|
475
|
+
return response.json();
|
|
476
|
+
}
|
|
440
477
|
function getOnrampSessionStartUrl(request, publishableKey) {
|
|
441
478
|
const params = new URLSearchParams();
|
|
442
479
|
params.append("publishable_key", publishableKey);
|
|
@@ -454,6 +491,9 @@ function getOnrampSessionStartUrl(request, publishableKey) {
|
|
|
454
491
|
if (request.email) {
|
|
455
492
|
params.append("email", request.email);
|
|
456
493
|
}
|
|
494
|
+
if (request.payment_method) {
|
|
495
|
+
params.append("payment_method", request.payment_method);
|
|
496
|
+
}
|
|
457
497
|
return `${API_BASE_URL}/v1/public/onramps/sessions/start?${params.toString()}`;
|
|
458
498
|
}
|
|
459
499
|
async function getDefaultOnrampToken(params, publishableKey) {
|
|
@@ -503,10 +543,18 @@ function getChainName(chains, chainType, chainId) {
|
|
|
503
543
|
if (!chainType) return chainId || "Unknown";
|
|
504
544
|
return chainType.charAt(0).toUpperCase() + chainType.slice(1);
|
|
505
545
|
}
|
|
506
|
-
async function getProjectConfig(publishableKey) {
|
|
546
|
+
async function getProjectConfig(publishableKey, options) {
|
|
507
547
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
508
548
|
validatePublishableKey(pk);
|
|
509
|
-
const
|
|
549
|
+
const params = new URLSearchParams();
|
|
550
|
+
if (options?.countryCode) {
|
|
551
|
+
params.set("country_code", options.countryCode);
|
|
552
|
+
}
|
|
553
|
+
if (options?.subdivisionCode) {
|
|
554
|
+
params.set("subdivision_code", options.subdivisionCode);
|
|
555
|
+
}
|
|
556
|
+
const queryString = params.toString();
|
|
557
|
+
const url = `${API_BASE_URL}/v1/public/projects/config${queryString ? `?${queryString}` : ""}`;
|
|
510
558
|
const response = await fetch(url, {
|
|
511
559
|
method: "GET",
|
|
512
560
|
headers: {
|
|
@@ -528,9 +576,7 @@ async function getIpAddress() {
|
|
|
528
576
|
}
|
|
529
577
|
});
|
|
530
578
|
if (!response.ok) {
|
|
531
|
-
throw new Error(
|
|
532
|
-
`Failed to fetch IP address information: ${response.statusText}`
|
|
533
|
-
);
|
|
579
|
+
throw new Error(`Failed to fetch IP address information: ${response.statusText}`);
|
|
534
580
|
}
|
|
535
581
|
return response.json();
|
|
536
582
|
}
|
|
@@ -632,31 +678,24 @@ async function verifyRecipientAddress(request, publishableKey) {
|
|
|
632
678
|
body: JSON.stringify(request)
|
|
633
679
|
});
|
|
634
680
|
if (!response.ok) {
|
|
635
|
-
throw new Error(
|
|
636
|
-
`Failed to verify recipient address: ${response.statusText}`
|
|
637
|
-
);
|
|
681
|
+
throw new Error(`Failed to verify recipient address: ${response.statusText}`);
|
|
638
682
|
}
|
|
639
683
|
return response.json();
|
|
640
684
|
}
|
|
641
685
|
async function checkHypercoreActivation(request, publishableKey) {
|
|
642
686
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
643
687
|
validatePublishableKey(pk);
|
|
644
|
-
const response = await fetch(
|
|
645
|
-
|
|
646
|
-
{
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
body: JSON.stringify(request)
|
|
654
|
-
}
|
|
655
|
-
);
|
|
688
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/addresses/hypercore/activation`, {
|
|
689
|
+
method: "POST",
|
|
690
|
+
headers: {
|
|
691
|
+
accept: "application/json",
|
|
692
|
+
"x-publishable-key": pk,
|
|
693
|
+
"Content-Type": "application/json"
|
|
694
|
+
},
|
|
695
|
+
body: JSON.stringify(request)
|
|
696
|
+
});
|
|
656
697
|
if (!response.ok) {
|
|
657
|
-
throw new Error(
|
|
658
|
-
`HyperCore activation check failed: ${response.statusText}`
|
|
659
|
-
);
|
|
698
|
+
throw new Error(`HyperCore activation check failed: ${response.statusText}`);
|
|
660
699
|
}
|
|
661
700
|
return response.json();
|
|
662
701
|
}
|
|
@@ -664,7 +703,8 @@ async function getExchanges(query, publishableKey) {
|
|
|
664
703
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
665
704
|
validatePublishableKey(pk);
|
|
666
705
|
const params = new URLSearchParams();
|
|
667
|
-
if (query?.destination_currency)
|
|
706
|
+
if (query?.destination_currency)
|
|
707
|
+
params.append("destination_currency", query.destination_currency);
|
|
668
708
|
if (query?.destination_network) params.append("destination_network", query.destination_network);
|
|
669
709
|
const queryString = params.toString();
|
|
670
710
|
const url = `${API_BASE_URL}/v1/public/onramps/exchanges${queryString ? `?${queryString}` : ""}`;
|
|
@@ -684,18 +724,15 @@ async function getExchanges(query, publishableKey) {
|
|
|
684
724
|
async function createExchangeSession(request, publishableKey) {
|
|
685
725
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
686
726
|
validatePublishableKey(pk);
|
|
687
|
-
const response = await fetch(
|
|
688
|
-
|
|
689
|
-
{
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
body: JSON.stringify(request)
|
|
697
|
-
}
|
|
698
|
-
);
|
|
727
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/onramps/exchanges/sessions`, {
|
|
728
|
+
method: "POST",
|
|
729
|
+
headers: {
|
|
730
|
+
accept: "application/json",
|
|
731
|
+
"x-publishable-key": pk,
|
|
732
|
+
"Content-Type": "application/json"
|
|
733
|
+
},
|
|
734
|
+
body: JSON.stringify(request)
|
|
735
|
+
});
|
|
699
736
|
if (!response.ok) {
|
|
700
737
|
throw new Error(`Failed to create exchange session: ${response.statusText}`);
|
|
701
738
|
}
|
|
@@ -848,15 +885,18 @@ async function confirmIntegrationTransfer(transferId, accessToken, mfaCode, publ
|
|
|
848
885
|
validatePublishableKey(pk);
|
|
849
886
|
const body = { access_token: accessToken };
|
|
850
887
|
if (mfaCode) body.mfa_code = mfaCode;
|
|
851
|
-
const response = await fetch(
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
888
|
+
const response = await fetch(
|
|
889
|
+
`${API_BASE_URL}/v1/public/integrations/transfers/${transferId}/confirm`,
|
|
890
|
+
{
|
|
891
|
+
method: "POST",
|
|
892
|
+
headers: {
|
|
893
|
+
accept: "application/json",
|
|
894
|
+
"x-publishable-key": pk,
|
|
895
|
+
"Content-Type": "application/json"
|
|
896
|
+
},
|
|
897
|
+
body: JSON.stringify(body)
|
|
898
|
+
}
|
|
899
|
+
);
|
|
860
900
|
if (!response.ok) {
|
|
861
901
|
const err = await response.json().catch(() => ({ message: response.statusText }));
|
|
862
902
|
throw new Error(`Failed to confirm transfer: ${err.message || response.statusText}`);
|
|
@@ -895,9 +935,7 @@ async function buildSolanaTransaction(request, publishableKey) {
|
|
|
895
935
|
});
|
|
896
936
|
if (!response.ok) {
|
|
897
937
|
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
898
|
-
throw new Error(
|
|
899
|
-
`Failed to build Solana transaction: ${error.message || response.statusText}`
|
|
900
|
-
);
|
|
938
|
+
throw new Error(`Failed to build Solana transaction: ${error.message || response.statusText}`);
|
|
901
939
|
}
|
|
902
940
|
return response.json();
|
|
903
941
|
}
|
|
@@ -915,62 +953,110 @@ async function sendSolanaTransaction(request, publishableKey) {
|
|
|
915
953
|
});
|
|
916
954
|
if (!response.ok) {
|
|
917
955
|
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
918
|
-
throw new Error(
|
|
919
|
-
`Failed to send Solana transaction: ${error.message || response.statusText}`
|
|
920
|
-
);
|
|
956
|
+
throw new Error(`Failed to send Solana transaction: ${error.message || response.statusText}`);
|
|
921
957
|
}
|
|
922
958
|
return response.json();
|
|
923
959
|
}
|
|
924
960
|
async function retrievePaymentIntent(clientSecret, publishableKey) {
|
|
925
961
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
926
962
|
validatePublishableKey(pk);
|
|
927
|
-
const response = await fetch(
|
|
928
|
-
|
|
929
|
-
{
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
}
|
|
938
|
-
|
|
963
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/payment_intents/retrieve`, {
|
|
964
|
+
method: "POST",
|
|
965
|
+
headers: {
|
|
966
|
+
accept: "application/json",
|
|
967
|
+
"x-publishable-key": pk,
|
|
968
|
+
"Content-Type": "application/json"
|
|
969
|
+
},
|
|
970
|
+
body: JSON.stringify({ client_secret: clientSecret })
|
|
971
|
+
});
|
|
972
|
+
if (!response.ok) {
|
|
973
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
974
|
+
throw new Error(`Failed to retrieve payment intent: ${error.message || response.statusText}`);
|
|
975
|
+
}
|
|
976
|
+
return response.json();
|
|
977
|
+
}
|
|
978
|
+
async function listPaymentIntentExecutions(clientSecret, publishableKey) {
|
|
979
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
980
|
+
validatePublishableKey(pk);
|
|
981
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/payment_intents/executions`, {
|
|
982
|
+
method: "POST",
|
|
983
|
+
headers: {
|
|
984
|
+
accept: "application/json",
|
|
985
|
+
"x-publishable-key": pk,
|
|
986
|
+
"Content-Type": "application/json"
|
|
987
|
+
},
|
|
988
|
+
body: JSON.stringify({ client_secret: clientSecret })
|
|
989
|
+
});
|
|
939
990
|
if (!response.ok) {
|
|
940
991
|
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
941
992
|
throw new Error(
|
|
942
|
-
`Failed to
|
|
993
|
+
`Failed to list payment intent executions: ${error.message || response.statusText}`
|
|
943
994
|
);
|
|
944
995
|
}
|
|
945
996
|
return response.json();
|
|
946
997
|
}
|
|
947
|
-
async function
|
|
998
|
+
async function getDepositQuote(request, publishableKey) {
|
|
999
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1000
|
+
validatePublishableKey(pk);
|
|
1001
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/quotes`, {
|
|
1002
|
+
method: "POST",
|
|
1003
|
+
headers: {
|
|
1004
|
+
accept: "application/json",
|
|
1005
|
+
"x-publishable-key": pk,
|
|
1006
|
+
"Content-Type": "application/json"
|
|
1007
|
+
},
|
|
1008
|
+
body: JSON.stringify(request)
|
|
1009
|
+
});
|
|
1010
|
+
if (!response.ok) {
|
|
1011
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
1012
|
+
throw new Error(`Failed to get deposit quote: ${error.message || response.statusText}`);
|
|
1013
|
+
}
|
|
1014
|
+
const json = await response.json();
|
|
1015
|
+
return json.data;
|
|
1016
|
+
}
|
|
1017
|
+
async function buildHypercoreTransaction(request, publishableKey) {
|
|
1018
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1019
|
+
validatePublishableKey(pk);
|
|
1020
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/transactions/hypercore/build`, {
|
|
1021
|
+
method: "POST",
|
|
1022
|
+
headers: {
|
|
1023
|
+
accept: "application/json",
|
|
1024
|
+
"x-publishable-key": pk,
|
|
1025
|
+
"Content-Type": "application/json"
|
|
1026
|
+
},
|
|
1027
|
+
body: JSON.stringify(request)
|
|
1028
|
+
});
|
|
1029
|
+
if (!response.ok) {
|
|
1030
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
1031
|
+
throw new Error(
|
|
1032
|
+
`Failed to build HyperCore transaction: ${error.message || response.statusText}`
|
|
1033
|
+
);
|
|
1034
|
+
}
|
|
1035
|
+
return response.json();
|
|
1036
|
+
}
|
|
1037
|
+
async function getCashAppLimits(currency = "usd", publishableKey) {
|
|
948
1038
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
949
1039
|
validatePublishableKey(pk);
|
|
950
1040
|
const response = await fetch(
|
|
951
|
-
`${API_BASE_URL}/v1/public/
|
|
1041
|
+
`${API_BASE_URL}/v1/public/onramps/cashapp/limits?currency=${encodeURIComponent(currency)}`,
|
|
952
1042
|
{
|
|
953
|
-
method: "
|
|
1043
|
+
method: "GET",
|
|
954
1044
|
headers: {
|
|
955
1045
|
accept: "application/json",
|
|
956
|
-
"x-publishable-key": pk
|
|
957
|
-
|
|
958
|
-
},
|
|
959
|
-
body: JSON.stringify({ client_secret: clientSecret })
|
|
1046
|
+
"x-publishable-key": pk
|
|
1047
|
+
}
|
|
960
1048
|
}
|
|
961
1049
|
);
|
|
962
1050
|
if (!response.ok) {
|
|
963
1051
|
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
964
|
-
throw new Error(
|
|
965
|
-
`Failed to list payment intent executions: ${error.message || response.statusText}`
|
|
966
|
-
);
|
|
1052
|
+
throw new Error(`Failed to get Cash App limits: ${error.message || response.statusText}`);
|
|
967
1053
|
}
|
|
968
1054
|
return response.json();
|
|
969
1055
|
}
|
|
970
|
-
async function
|
|
1056
|
+
async function createCashAppSession(request, publishableKey) {
|
|
971
1057
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
972
1058
|
validatePublishableKey(pk);
|
|
973
|
-
const response = await fetch(`${API_BASE_URL}/v1/public/
|
|
1059
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/onramps/cashapp/sessions`, {
|
|
974
1060
|
method: "POST",
|
|
975
1061
|
headers: {
|
|
976
1062
|
accept: "application/json",
|
|
@@ -981,41 +1067,42 @@ async function getDepositQuote(request, publishableKey) {
|
|
|
981
1067
|
});
|
|
982
1068
|
if (!response.ok) {
|
|
983
1069
|
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
984
|
-
throw new Error(
|
|
985
|
-
`Failed to get deposit quote: ${error.message || response.statusText}`
|
|
986
|
-
);
|
|
1070
|
+
throw new Error(`Failed to create Cash App session: ${error.message || response.statusText}`);
|
|
987
1071
|
}
|
|
988
|
-
|
|
989
|
-
return json.data;
|
|
1072
|
+
return response.json();
|
|
990
1073
|
}
|
|
991
|
-
async function
|
|
1074
|
+
async function getCashAppSessionStatus(externalId, publishableKey) {
|
|
992
1075
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
993
1076
|
validatePublishableKey(pk);
|
|
994
1077
|
const response = await fetch(
|
|
995
|
-
`${API_BASE_URL}/v1/public/
|
|
1078
|
+
`${API_BASE_URL}/v1/public/onramps/cashapp/sessions/${encodeURIComponent(externalId)}/status`,
|
|
996
1079
|
{
|
|
997
|
-
method: "
|
|
1080
|
+
method: "GET",
|
|
998
1081
|
headers: {
|
|
999
1082
|
accept: "application/json",
|
|
1000
|
-
"x-publishable-key": pk
|
|
1001
|
-
|
|
1002
|
-
},
|
|
1003
|
-
body: JSON.stringify(request)
|
|
1083
|
+
"x-publishable-key": pk
|
|
1084
|
+
}
|
|
1004
1085
|
}
|
|
1005
1086
|
);
|
|
1006
1087
|
if (!response.ok) {
|
|
1007
1088
|
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
1008
1089
|
throw new Error(
|
|
1009
|
-
`Failed to
|
|
1090
|
+
`Failed to get Cash App session status: ${error.message || response.statusText}`
|
|
1010
1091
|
);
|
|
1011
1092
|
}
|
|
1012
1093
|
return response.json();
|
|
1013
1094
|
}
|
|
1014
|
-
async function
|
|
1095
|
+
async function stripeGetDefaultToken(params, publishableKey) {
|
|
1015
1096
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1016
1097
|
validatePublishableKey(pk);
|
|
1098
|
+
const query = new URLSearchParams({
|
|
1099
|
+
token_address: params.tokenAddress,
|
|
1100
|
+
chain_id: params.chainId,
|
|
1101
|
+
chain_type: params.chainType
|
|
1102
|
+
});
|
|
1103
|
+
if (params.countryCode) query.append("country_code", params.countryCode);
|
|
1017
1104
|
const response = await fetch(
|
|
1018
|
-
`${API_BASE_URL}/
|
|
1105
|
+
`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/default_token?${query.toString()}`,
|
|
1019
1106
|
{
|
|
1020
1107
|
method: "GET",
|
|
1021
1108
|
headers: {
|
|
@@ -1026,71 +1113,315 @@ async function getCashAppLimits(currency = "usd", publishableKey) {
|
|
|
1026
1113
|
);
|
|
1027
1114
|
if (!response.ok) {
|
|
1028
1115
|
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
1029
|
-
|
|
1030
|
-
`Failed to get Cash App limits: ${error.message || response.statusText}`
|
|
1031
|
-
);
|
|
1116
|
+
throwStripeError("Failed to get Stripe default token", response, error);
|
|
1032
1117
|
}
|
|
1033
1118
|
return response.json();
|
|
1034
1119
|
}
|
|
1035
|
-
|
|
1120
|
+
var HEADLESS_STRIPE_BASE = "/v1/public/onramps/headless/stripe";
|
|
1121
|
+
var StripeApiResponseError = class extends Error {
|
|
1122
|
+
constructor(message, statusCode, stripeCode, errorType) {
|
|
1123
|
+
super(message);
|
|
1124
|
+
this.statusCode = statusCode;
|
|
1125
|
+
this.stripeCode = stripeCode;
|
|
1126
|
+
this.errorType = errorType;
|
|
1127
|
+
this.name = "StripeApiResponseError";
|
|
1128
|
+
}
|
|
1129
|
+
};
|
|
1130
|
+
function throwStripeError(prefix, response, error) {
|
|
1131
|
+
const stripeError = error.details?.stripe_error;
|
|
1132
|
+
const detailMessage = stripeError?.message || error.message || response.statusText;
|
|
1133
|
+
throw new StripeApiResponseError(
|
|
1134
|
+
`${prefix}: ${detailMessage}`,
|
|
1135
|
+
response.status,
|
|
1136
|
+
stripeError?.code,
|
|
1137
|
+
error.error_type
|
|
1138
|
+
);
|
|
1139
|
+
}
|
|
1140
|
+
async function stripeGetConfig(publishableKey) {
|
|
1141
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1142
|
+
validatePublishableKey(pk);
|
|
1143
|
+
const response = await fetch(`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/config`, {
|
|
1144
|
+
method: "GET",
|
|
1145
|
+
headers: {
|
|
1146
|
+
accept: "application/json",
|
|
1147
|
+
"x-publishable-key": pk
|
|
1148
|
+
}
|
|
1149
|
+
});
|
|
1150
|
+
if (!response.ok) {
|
|
1151
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
1152
|
+
throwStripeError("Failed to get Stripe config", response, error);
|
|
1153
|
+
}
|
|
1154
|
+
return response.json();
|
|
1155
|
+
}
|
|
1156
|
+
async function stripeCreateAuthIntent(email, publishableKey) {
|
|
1157
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1158
|
+
validatePublishableKey(pk);
|
|
1159
|
+
const response = await fetch(`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/oauth/start`, {
|
|
1160
|
+
method: "POST",
|
|
1161
|
+
headers: {
|
|
1162
|
+
accept: "application/json",
|
|
1163
|
+
"x-publishable-key": pk,
|
|
1164
|
+
"Content-Type": "application/json"
|
|
1165
|
+
},
|
|
1166
|
+
body: JSON.stringify({ email })
|
|
1167
|
+
});
|
|
1168
|
+
if (!response.ok) {
|
|
1169
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
1170
|
+
throwStripeError("Failed to create Stripe auth intent", response, error);
|
|
1171
|
+
}
|
|
1172
|
+
return response.json();
|
|
1173
|
+
}
|
|
1174
|
+
async function stripeExchangeTokens(authIntentId, publishableKey) {
|
|
1175
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1176
|
+
validatePublishableKey(pk);
|
|
1177
|
+
const response = await fetch(`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/oauth/token`, {
|
|
1178
|
+
method: "POST",
|
|
1179
|
+
headers: {
|
|
1180
|
+
accept: "application/json",
|
|
1181
|
+
"x-publishable-key": pk,
|
|
1182
|
+
"Content-Type": "application/json"
|
|
1183
|
+
},
|
|
1184
|
+
body: JSON.stringify({ auth_intent_id: authIntentId })
|
|
1185
|
+
});
|
|
1186
|
+
if (!response.ok) {
|
|
1187
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
1188
|
+
throwStripeError("Failed to exchange Stripe tokens", response, error);
|
|
1189
|
+
}
|
|
1190
|
+
return response.json();
|
|
1191
|
+
}
|
|
1192
|
+
async function stripeRefreshToken(refreshToken, publishableKey) {
|
|
1193
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1194
|
+
validatePublishableKey(pk);
|
|
1195
|
+
const response = await fetch(`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/oauth/token/refresh`, {
|
|
1196
|
+
method: "POST",
|
|
1197
|
+
headers: {
|
|
1198
|
+
accept: "application/json",
|
|
1199
|
+
"x-publishable-key": pk,
|
|
1200
|
+
"Content-Type": "application/json"
|
|
1201
|
+
},
|
|
1202
|
+
body: JSON.stringify({ refresh_token: refreshToken })
|
|
1203
|
+
});
|
|
1204
|
+
if (!response.ok) {
|
|
1205
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
1206
|
+
throwStripeError("Failed to refresh Stripe token", response, error);
|
|
1207
|
+
}
|
|
1208
|
+
return response.json();
|
|
1209
|
+
}
|
|
1210
|
+
async function stripeGetCustomer(customerId, oauthToken, publishableKey) {
|
|
1036
1211
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1037
1212
|
validatePublishableKey(pk);
|
|
1038
1213
|
const response = await fetch(
|
|
1039
|
-
`${API_BASE_URL}/
|
|
1214
|
+
`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/customers/${encodeURIComponent(customerId)}`,
|
|
1040
1215
|
{
|
|
1041
|
-
method: "
|
|
1216
|
+
method: "GET",
|
|
1042
1217
|
headers: {
|
|
1043
1218
|
accept: "application/json",
|
|
1044
1219
|
"x-publishable-key": pk,
|
|
1045
|
-
"
|
|
1046
|
-
}
|
|
1047
|
-
body: JSON.stringify(request)
|
|
1220
|
+
"x-stripe-oauth-token": oauthToken
|
|
1221
|
+
}
|
|
1048
1222
|
}
|
|
1049
1223
|
);
|
|
1050
1224
|
if (!response.ok) {
|
|
1051
1225
|
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
1052
|
-
|
|
1053
|
-
`Failed to create Cash App session: ${error.message || response.statusText}`
|
|
1054
|
-
);
|
|
1226
|
+
throwStripeError("Failed to get Stripe customer", response, error);
|
|
1055
1227
|
}
|
|
1056
1228
|
return response.json();
|
|
1057
1229
|
}
|
|
1058
|
-
async function
|
|
1230
|
+
async function stripeListWallets(customerId, oauthToken, publishableKey) {
|
|
1059
1231
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1060
1232
|
validatePublishableKey(pk);
|
|
1061
1233
|
const response = await fetch(
|
|
1062
|
-
`${API_BASE_URL}/
|
|
1234
|
+
`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/customers/${encodeURIComponent(customerId)}/wallet_addresses`,
|
|
1063
1235
|
{
|
|
1064
1236
|
method: "GET",
|
|
1065
1237
|
headers: {
|
|
1066
1238
|
accept: "application/json",
|
|
1067
|
-
"x-publishable-key": pk
|
|
1239
|
+
"x-publishable-key": pk,
|
|
1240
|
+
"x-stripe-oauth-token": oauthToken
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
);
|
|
1244
|
+
if (!response.ok) {
|
|
1245
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
1246
|
+
throwStripeError("Failed to list Stripe wallets", response, error);
|
|
1247
|
+
}
|
|
1248
|
+
return response.json();
|
|
1249
|
+
}
|
|
1250
|
+
async function stripeListPaymentTokens(customerId, oauthToken, publishableKey) {
|
|
1251
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1252
|
+
validatePublishableKey(pk);
|
|
1253
|
+
const response = await fetch(
|
|
1254
|
+
`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/customers/${encodeURIComponent(customerId)}/payment_tokens`,
|
|
1255
|
+
{
|
|
1256
|
+
method: "GET",
|
|
1257
|
+
headers: {
|
|
1258
|
+
accept: "application/json",
|
|
1259
|
+
"x-publishable-key": pk,
|
|
1260
|
+
"x-stripe-oauth-token": oauthToken
|
|
1068
1261
|
}
|
|
1069
1262
|
}
|
|
1070
1263
|
);
|
|
1071
1264
|
if (!response.ok) {
|
|
1072
1265
|
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
1073
1266
|
throw new Error(
|
|
1074
|
-
`Failed to
|
|
1267
|
+
`Failed to list Stripe payment tokens: ${error.message || response.statusText}`
|
|
1075
1268
|
);
|
|
1076
1269
|
}
|
|
1077
1270
|
return response.json();
|
|
1078
1271
|
}
|
|
1079
|
-
async function
|
|
1272
|
+
async function stripeCreateSession(request, oauthToken, publishableKey) {
|
|
1273
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1274
|
+
validatePublishableKey(pk);
|
|
1275
|
+
const response = await fetch(`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/sessions`, {
|
|
1276
|
+
method: "POST",
|
|
1277
|
+
headers: {
|
|
1278
|
+
accept: "application/json",
|
|
1279
|
+
"x-publishable-key": pk,
|
|
1280
|
+
"x-stripe-oauth-token": oauthToken,
|
|
1281
|
+
"Content-Type": "application/json"
|
|
1282
|
+
},
|
|
1283
|
+
body: JSON.stringify({
|
|
1284
|
+
crypto_customer_id: request.cryptoCustomerId,
|
|
1285
|
+
payment_token: request.paymentToken,
|
|
1286
|
+
source_amount: request.sourceAmount,
|
|
1287
|
+
source_currency: request.sourceCurrency,
|
|
1288
|
+
destination_currency: request.destinationCurrency,
|
|
1289
|
+
destination_network: request.destinationNetwork,
|
|
1290
|
+
wallet_address: request.walletAddress
|
|
1291
|
+
})
|
|
1292
|
+
});
|
|
1293
|
+
if (!response.ok) {
|
|
1294
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
1295
|
+
throwStripeError("Failed to create Stripe session", response, error);
|
|
1296
|
+
}
|
|
1297
|
+
return response.json();
|
|
1298
|
+
}
|
|
1299
|
+
async function stripeConfirmSession(sessionId, oauthToken, request, publishableKey) {
|
|
1080
1300
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1081
1301
|
validatePublishableKey(pk);
|
|
1082
1302
|
const response = await fetch(
|
|
1083
|
-
`${API_BASE_URL}/
|
|
1303
|
+
`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/sessions/${encodeURIComponent(sessionId)}/confirm`,
|
|
1084
1304
|
{
|
|
1085
1305
|
method: "POST",
|
|
1086
1306
|
headers: {
|
|
1087
1307
|
accept: "application/json",
|
|
1088
1308
|
"x-publishable-key": pk,
|
|
1309
|
+
"x-stripe-oauth-token": oauthToken,
|
|
1089
1310
|
"Content-Type": "application/json"
|
|
1090
1311
|
},
|
|
1091
|
-
body: JSON.stringify(request)
|
|
1312
|
+
body: JSON.stringify(request?.mandateData ? { mandate_data: request.mandateData } : {})
|
|
1313
|
+
}
|
|
1314
|
+
);
|
|
1315
|
+
if (!response.ok) {
|
|
1316
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
1317
|
+
throwStripeError("Failed to confirm Stripe session", response, error);
|
|
1318
|
+
}
|
|
1319
|
+
return response.json();
|
|
1320
|
+
}
|
|
1321
|
+
async function stripeRefreshQuote(sessionId, oauthToken, publishableKey) {
|
|
1322
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1323
|
+
validatePublishableKey(pk);
|
|
1324
|
+
const response = await fetch(
|
|
1325
|
+
`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/sessions/${encodeURIComponent(sessionId)}/quote/refresh`,
|
|
1326
|
+
{
|
|
1327
|
+
method: "POST",
|
|
1328
|
+
headers: {
|
|
1329
|
+
accept: "application/json",
|
|
1330
|
+
"x-publishable-key": pk,
|
|
1331
|
+
"x-stripe-oauth-token": oauthToken
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
);
|
|
1335
|
+
if (!response.ok) {
|
|
1336
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
1337
|
+
throwStripeError("Failed to refresh Stripe quote", response, error);
|
|
1338
|
+
}
|
|
1339
|
+
return response.json();
|
|
1340
|
+
}
|
|
1341
|
+
async function stripeGetSession(sessionId, oauthToken, publishableKey) {
|
|
1342
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1343
|
+
validatePublishableKey(pk);
|
|
1344
|
+
const response = await fetch(
|
|
1345
|
+
`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/sessions/${encodeURIComponent(sessionId)}`,
|
|
1346
|
+
{
|
|
1347
|
+
method: "GET",
|
|
1348
|
+
headers: {
|
|
1349
|
+
accept: "application/json",
|
|
1350
|
+
"x-publishable-key": pk,
|
|
1351
|
+
"x-stripe-oauth-token": oauthToken
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
);
|
|
1355
|
+
if (!response.ok) {
|
|
1356
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
1357
|
+
throwStripeError("Failed to get Stripe session", response, error);
|
|
1358
|
+
}
|
|
1359
|
+
return response.json();
|
|
1360
|
+
}
|
|
1361
|
+
async function stripeGetQuotes(request, oauthToken, publishableKey) {
|
|
1362
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1363
|
+
validatePublishableKey(pk);
|
|
1364
|
+
const headers = {
|
|
1365
|
+
accept: "application/json",
|
|
1366
|
+
"x-publishable-key": pk,
|
|
1367
|
+
"Content-Type": "application/json"
|
|
1368
|
+
};
|
|
1369
|
+
if (oauthToken) headers["x-stripe-oauth-token"] = oauthToken;
|
|
1370
|
+
const response = await fetch(`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/quotes`, {
|
|
1371
|
+
method: "POST",
|
|
1372
|
+
headers,
|
|
1373
|
+
body: JSON.stringify({
|
|
1374
|
+
source_amount: request.sourceAmount,
|
|
1375
|
+
source_currency: request.sourceCurrency,
|
|
1376
|
+
destination_currency: request.destinationCurrency,
|
|
1377
|
+
destination_network: request.destinationNetwork
|
|
1378
|
+
})
|
|
1379
|
+
});
|
|
1380
|
+
if (!response.ok) {
|
|
1381
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
1382
|
+
throwStripeError("Failed to get Stripe quotes", response, error);
|
|
1383
|
+
}
|
|
1384
|
+
return response.json();
|
|
1385
|
+
}
|
|
1386
|
+
async function stripeGetTransactionLimits(params, oauthToken, publishableKey) {
|
|
1387
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1388
|
+
validatePublishableKey(pk);
|
|
1389
|
+
const query = new URLSearchParams({
|
|
1390
|
+
crypto_customer_id: params.cryptoCustomerId,
|
|
1391
|
+
destination_network: params.destinationNetwork,
|
|
1392
|
+
wallet_address: params.walletAddress
|
|
1393
|
+
});
|
|
1394
|
+
if (params.destinationTag) query.append("destination_tag", params.destinationTag);
|
|
1395
|
+
if (params.refresh) query.append("refresh", "true");
|
|
1396
|
+
const response = await fetch(
|
|
1397
|
+
`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/transaction_limits?${query.toString()}`,
|
|
1398
|
+
{
|
|
1399
|
+
method: "GET",
|
|
1400
|
+
headers: {
|
|
1401
|
+
accept: "application/json",
|
|
1402
|
+
"x-publishable-key": pk,
|
|
1403
|
+
"x-stripe-oauth-token": oauthToken
|
|
1404
|
+
}
|
|
1092
1405
|
}
|
|
1093
1406
|
);
|
|
1407
|
+
if (!response.ok) {
|
|
1408
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
1409
|
+
throwStripeError("Failed to get Stripe transaction limits", response, error);
|
|
1410
|
+
}
|
|
1411
|
+
return response.json();
|
|
1412
|
+
}
|
|
1413
|
+
async function sendHypercoreTransaction(request, publishableKey) {
|
|
1414
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1415
|
+
validatePublishableKey(pk);
|
|
1416
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/transactions/hypercore/send`, {
|
|
1417
|
+
method: "POST",
|
|
1418
|
+
headers: {
|
|
1419
|
+
accept: "application/json",
|
|
1420
|
+
"x-publishable-key": pk,
|
|
1421
|
+
"Content-Type": "application/json"
|
|
1422
|
+
},
|
|
1423
|
+
body: JSON.stringify(request)
|
|
1424
|
+
});
|
|
1094
1425
|
if (!response.ok) {
|
|
1095
1426
|
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
1096
1427
|
throw new Error(
|
|
@@ -1099,6 +1430,133 @@ async function sendHypercoreTransaction(request, publishableKey) {
|
|
|
1099
1430
|
}
|
|
1100
1431
|
return response.json();
|
|
1101
1432
|
}
|
|
1433
|
+
async function getCoinbaseLegalAgreements(publishableKey) {
|
|
1434
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1435
|
+
validatePublishableKey(pk);
|
|
1436
|
+
const response = await fetch(
|
|
1437
|
+
`${API_BASE_URL}/v1/public/onramps/headless/coinbase/legal_agreements`,
|
|
1438
|
+
{
|
|
1439
|
+
method: "GET",
|
|
1440
|
+
headers: { accept: "application/json", "x-publishable-key": pk }
|
|
1441
|
+
}
|
|
1442
|
+
);
|
|
1443
|
+
if (!response.ok) {
|
|
1444
|
+
throw new Error(`Failed to fetch Coinbase legal agreements: ${response.statusText}`);
|
|
1445
|
+
}
|
|
1446
|
+
return response.json();
|
|
1447
|
+
}
|
|
1448
|
+
var VERIFICATION_BASE = "/v1/public/onramps/verification_sessions";
|
|
1449
|
+
async function jsonOrThrow(response, label) {
|
|
1450
|
+
if (!response.ok) {
|
|
1451
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
1452
|
+
const body = error;
|
|
1453
|
+
const tag = body.error_type ? ` [${body.error_type}]` : "";
|
|
1454
|
+
throw new Error(`${label}${tag}: ${body.message || response.statusText}`);
|
|
1455
|
+
}
|
|
1456
|
+
return response.json();
|
|
1457
|
+
}
|
|
1458
|
+
async function createOnrampVerificationSession(request, publishableKey) {
|
|
1459
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1460
|
+
validatePublishableKey(pk);
|
|
1461
|
+
const response = await fetch(`${API_BASE_URL}${VERIFICATION_BASE}`, {
|
|
1462
|
+
method: "POST",
|
|
1463
|
+
headers: {
|
|
1464
|
+
accept: "application/json",
|
|
1465
|
+
"x-publishable-key": pk,
|
|
1466
|
+
"Content-Type": "application/json"
|
|
1467
|
+
},
|
|
1468
|
+
body: JSON.stringify(request)
|
|
1469
|
+
});
|
|
1470
|
+
return jsonOrThrow(response, "Failed to create verification session");
|
|
1471
|
+
}
|
|
1472
|
+
async function postVerificationAction(id, factor, action, body, publishableKey) {
|
|
1473
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1474
|
+
validatePublishableKey(pk);
|
|
1475
|
+
const response = await fetch(
|
|
1476
|
+
`${API_BASE_URL}${VERIFICATION_BASE}/${encodeURIComponent(id)}/${factor}/${action}`,
|
|
1477
|
+
{
|
|
1478
|
+
method: "POST",
|
|
1479
|
+
headers: {
|
|
1480
|
+
accept: "application/json",
|
|
1481
|
+
"x-publishable-key": pk,
|
|
1482
|
+
"Content-Type": "application/json"
|
|
1483
|
+
},
|
|
1484
|
+
body: JSON.stringify(body)
|
|
1485
|
+
}
|
|
1486
|
+
);
|
|
1487
|
+
return jsonOrThrow(response, `Failed to ${action} ${factor} OTP`);
|
|
1488
|
+
}
|
|
1489
|
+
async function sendOnrampVerificationOtp(id, factor, clientSecret, publishableKey) {
|
|
1490
|
+
return postVerificationAction(
|
|
1491
|
+
id,
|
|
1492
|
+
factor,
|
|
1493
|
+
"send",
|
|
1494
|
+
{ client_secret: clientSecret },
|
|
1495
|
+
publishableKey
|
|
1496
|
+
);
|
|
1497
|
+
}
|
|
1498
|
+
async function verifyOnrampVerificationOtp(id, factor, clientSecret, code, publishableKey) {
|
|
1499
|
+
return postVerificationAction(
|
|
1500
|
+
id,
|
|
1501
|
+
factor,
|
|
1502
|
+
"verify",
|
|
1503
|
+
{ client_secret: clientSecret, code },
|
|
1504
|
+
publishableKey
|
|
1505
|
+
);
|
|
1506
|
+
}
|
|
1507
|
+
async function exchangeOnrampVerificationToken(id, clientSecret, publishableKey) {
|
|
1508
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1509
|
+
validatePublishableKey(pk);
|
|
1510
|
+
const response = await fetch(
|
|
1511
|
+
`${API_BASE_URL}${VERIFICATION_BASE}/${encodeURIComponent(id)}/token`,
|
|
1512
|
+
{
|
|
1513
|
+
method: "POST",
|
|
1514
|
+
headers: {
|
|
1515
|
+
accept: "application/json",
|
|
1516
|
+
"x-publishable-key": pk,
|
|
1517
|
+
"Content-Type": "application/json"
|
|
1518
|
+
},
|
|
1519
|
+
body: JSON.stringify({ client_secret: clientSecret })
|
|
1520
|
+
}
|
|
1521
|
+
);
|
|
1522
|
+
return jsonOrThrow(
|
|
1523
|
+
response,
|
|
1524
|
+
"Failed to exchange verification token"
|
|
1525
|
+
);
|
|
1526
|
+
}
|
|
1527
|
+
async function getOnrampVerificationSession(id, clientSecret, publishableKey) {
|
|
1528
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1529
|
+
validatePublishableKey(pk);
|
|
1530
|
+
const url = new URL(`${API_BASE_URL}${VERIFICATION_BASE}/${encodeURIComponent(id)}`);
|
|
1531
|
+
url.searchParams.set("client_secret", clientSecret);
|
|
1532
|
+
const response = await fetch(url.toString(), {
|
|
1533
|
+
method: "GET",
|
|
1534
|
+
headers: { accept: "application/json", "x-publishable-key": pk }
|
|
1535
|
+
});
|
|
1536
|
+
return jsonOrThrow(response, "Failed to fetch verification session");
|
|
1537
|
+
}
|
|
1538
|
+
async function createCoinbaseApplePaySession(request, onrampToken, publishableKey, signal) {
|
|
1539
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1540
|
+
validatePublishableKey(pk);
|
|
1541
|
+
const response = await fetch(
|
|
1542
|
+
`${API_BASE_URL}/v1/public/onramps/headless/coinbase/apple_pay/sessions`,
|
|
1543
|
+
{
|
|
1544
|
+
method: "POST",
|
|
1545
|
+
headers: {
|
|
1546
|
+
accept: "application/json",
|
|
1547
|
+
"x-publishable-key": pk,
|
|
1548
|
+
"Content-Type": "application/json",
|
|
1549
|
+
"x-onramp-token": onrampToken
|
|
1550
|
+
},
|
|
1551
|
+
body: JSON.stringify(request),
|
|
1552
|
+
signal
|
|
1553
|
+
}
|
|
1554
|
+
);
|
|
1555
|
+
return jsonOrThrow(
|
|
1556
|
+
response,
|
|
1557
|
+
"Failed to create Apple Pay session"
|
|
1558
|
+
);
|
|
1559
|
+
}
|
|
1102
1560
|
|
|
1103
1561
|
// src/lib/events.ts
|
|
1104
1562
|
var DepositEventType = /* @__PURE__ */ ((DepositEventType2) => {
|
|
@@ -1110,6 +1568,10 @@ var WithdrawEventType = /* @__PURE__ */ ((WithdrawEventType2) => {
|
|
|
1110
1568
|
WithdrawEventType2["DIRECT_EXECUTION_SUCCEEDED"] = "direct_execution.succeeded";
|
|
1111
1569
|
return WithdrawEventType2;
|
|
1112
1570
|
})(WithdrawEventType || {});
|
|
1571
|
+
var CheckoutEventType = /* @__PURE__ */ ((CheckoutEventType2) => {
|
|
1572
|
+
CheckoutEventType2["PAYMENT_INTENT_SUCCEEDED"] = "payment_intent.succeeded";
|
|
1573
|
+
return CheckoutEventType2;
|
|
1574
|
+
})(CheckoutEventType || {});
|
|
1113
1575
|
|
|
1114
1576
|
// src/hooks/use-user-ip.ts
|
|
1115
1577
|
var import_react_query = require("@tanstack/react-query");
|
|
@@ -1245,11 +1707,13 @@ var i18n = en_default;
|
|
|
1245
1707
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1246
1708
|
0 && (module.exports = {
|
|
1247
1709
|
ActionType,
|
|
1710
|
+
CheckoutEventType,
|
|
1248
1711
|
DepositEventType,
|
|
1249
1712
|
ExecutionStatus,
|
|
1250
1713
|
IneligibilityReason,
|
|
1251
1714
|
IntegrationProvider,
|
|
1252
1715
|
SOLANA_USDC_ADDRESS,
|
|
1716
|
+
StripeApiResponseError,
|
|
1253
1717
|
WithdrawEventType,
|
|
1254
1718
|
authenticateIntegrationOAuth,
|
|
1255
1719
|
buildHypercoreTransaction,
|
|
@@ -1257,19 +1721,25 @@ var i18n = en_default;
|
|
|
1257
1721
|
checkHypercoreActivation,
|
|
1258
1722
|
confirmIntegrationTransfer,
|
|
1259
1723
|
createCashAppSession,
|
|
1724
|
+
createCoinbaseApplePaySession,
|
|
1260
1725
|
createDepositAddress,
|
|
1261
1726
|
createExchangeSession,
|
|
1262
1727
|
createIntegrationTransfer,
|
|
1263
1728
|
createOnrampSession,
|
|
1729
|
+
createOnrampVerificationSession,
|
|
1730
|
+
exchangeOnrampVerificationToken,
|
|
1264
1731
|
formatStablecoinAmount,
|
|
1265
1732
|
generateKSUID,
|
|
1266
1733
|
generatePrefixedKSUID,
|
|
1267
1734
|
getAddressBalance,
|
|
1268
1735
|
getAddressBalances,
|
|
1269
1736
|
getApiBaseUrl,
|
|
1737
|
+
getApplePayProviders,
|
|
1738
|
+
getBankTransferProviders,
|
|
1270
1739
|
getCashAppLimits,
|
|
1271
1740
|
getCashAppSessionStatus,
|
|
1272
1741
|
getChainName,
|
|
1742
|
+
getCoinbaseLegalAgreements,
|
|
1273
1743
|
getDefaultOnrampToken,
|
|
1274
1744
|
getDepositAddress,
|
|
1275
1745
|
getDepositQuote,
|
|
@@ -1285,6 +1755,7 @@ var i18n = en_default;
|
|
|
1285
1755
|
getIpAddress,
|
|
1286
1756
|
getOnrampQuotes,
|
|
1287
1757
|
getOnrampSessionStartUrl,
|
|
1758
|
+
getOnrampVerificationSession,
|
|
1288
1759
|
getPreferredIconUrl,
|
|
1289
1760
|
getProjectConfig,
|
|
1290
1761
|
getSupportedDepositTokens,
|
|
@@ -1301,9 +1772,25 @@ var i18n = en_default;
|
|
|
1301
1772
|
retrievePaymentIntent,
|
|
1302
1773
|
revokeIntegrationToken,
|
|
1303
1774
|
sendHypercoreTransaction,
|
|
1775
|
+
sendOnrampVerificationOtp,
|
|
1304
1776
|
sendSolanaTransaction,
|
|
1305
1777
|
setApiConfig,
|
|
1306
1778
|
startIntegrationOAuth,
|
|
1779
|
+
stripeConfirmSession,
|
|
1780
|
+
stripeCreateAuthIntent,
|
|
1781
|
+
stripeCreateSession,
|
|
1782
|
+
stripeExchangeTokens,
|
|
1783
|
+
stripeGetConfig,
|
|
1784
|
+
stripeGetCustomer,
|
|
1785
|
+
stripeGetDefaultToken,
|
|
1786
|
+
stripeGetQuotes,
|
|
1787
|
+
stripeGetSession,
|
|
1788
|
+
stripeGetTransactionLimits,
|
|
1789
|
+
stripeListPaymentTokens,
|
|
1790
|
+
stripeListWallets,
|
|
1791
|
+
stripeRefreshQuote,
|
|
1792
|
+
stripeRefreshToken,
|
|
1307
1793
|
useUserIp,
|
|
1794
|
+
verifyOnrampVerificationOtp,
|
|
1308
1795
|
verifyRecipientAddress
|
|
1309
1796
|
});
|