@unifold/core 0.1.71-beta.2 → 0.1.72
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/README.md +9 -0
- package/dist/index.d.mts +465 -59
- package/dist/index.d.ts +465 -59
- package/dist/index.js +307 -125
- package/dist/index.mjs +297 -125
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -47,6 +47,8 @@ __export(index_exports, {
|
|
|
47
47
|
confirmIntegrationTransfer: () => confirmIntegrationTransfer,
|
|
48
48
|
createCashAppSession: () => createCashAppSession,
|
|
49
49
|
createCoinbaseApplePaySession: () => createCoinbaseApplePaySession,
|
|
50
|
+
createCoinbaseGooglePaySession: () => createCoinbaseGooglePaySession,
|
|
51
|
+
createCoinbaseWalletPaySession: () => createCoinbaseWalletPaySession,
|
|
50
52
|
createDepositAddress: () => createDepositAddress,
|
|
51
53
|
createExchangeSession: () => createExchangeSession,
|
|
52
54
|
createIntegrationTransfer: () => createIntegrationTransfer,
|
|
@@ -68,6 +70,7 @@ __export(index_exports, {
|
|
|
68
70
|
getChainName: () => getChainName,
|
|
69
71
|
getCoinbaseApplePayLimits: () => getCoinbaseApplePayLimits,
|
|
70
72
|
getCoinbaseLegalAgreements: () => getCoinbaseLegalAgreements,
|
|
73
|
+
getCoinbaseWalletPayLimits: () => getCoinbaseWalletPayLimits,
|
|
71
74
|
getDefaultOnrampToken: () => getDefaultOnrampToken,
|
|
72
75
|
getDepositAddress: () => getDepositAddress,
|
|
73
76
|
getDepositQuote: () => getDepositQuote,
|
|
@@ -76,6 +79,8 @@ __export(index_exports, {
|
|
|
76
79
|
getExternalWallets: () => getExternalWallets,
|
|
77
80
|
getFiatCurrencies: () => getFiatCurrencies,
|
|
78
81
|
getFiatExchangeRates: () => getFiatExchangeRates,
|
|
82
|
+
getGooglePayLimitUpgradeStatus: () => getGooglePayLimitUpgradeStatus,
|
|
83
|
+
getGooglePayProviders: () => getGooglePayProviders,
|
|
79
84
|
getIconUrl: () => getIconUrl,
|
|
80
85
|
getIconUrlWithCdn: () => getIconUrlWithCdn,
|
|
81
86
|
getIntegrationExchanges: () => getIntegrationExchanges,
|
|
@@ -94,9 +99,13 @@ __export(index_exports, {
|
|
|
94
99
|
getTokenMetadata: () => getTokenMetadata,
|
|
95
100
|
getWalletByChainType: () => getWalletByChainType,
|
|
96
101
|
getWalletMobileDeepLink: () => getWalletMobileDeepLink,
|
|
102
|
+
getWalletPayLimitUpgradeStatus: () => getWalletPayLimitUpgradeStatus,
|
|
103
|
+
getWalletPayProviders: () => getWalletPayProviders,
|
|
97
104
|
i18n: () => i18n,
|
|
98
105
|
isApplePayLimitReached: () => isApplePayLimitReached,
|
|
99
106
|
isDepositAddressValidationError: () => isDepositAddressValidationError,
|
|
107
|
+
isGooglePayLimitReached: () => isGooglePayLimitReached,
|
|
108
|
+
isWalletPayLimitReached: () => isWalletPayLimitReached,
|
|
100
109
|
listPaymentIntentExecutions: () => listPaymentIntentExecutions,
|
|
101
110
|
mapDirectExecution: () => mapDirectExecution,
|
|
102
111
|
mapWalletToDepositAddress: () => mapWalletToDepositAddress,
|
|
@@ -104,6 +113,7 @@ __export(index_exports, {
|
|
|
104
113
|
queryExecutions: () => queryExecutions,
|
|
105
114
|
refreshIntegrationToken: () => refreshIntegrationToken,
|
|
106
115
|
requestCoinbaseApplePayLimitUpgrade: () => requestCoinbaseApplePayLimitUpgrade,
|
|
116
|
+
requestCoinbaseWalletPayLimitUpgrade: () => requestCoinbaseWalletPayLimitUpgrade,
|
|
107
117
|
retrievePaymentIntent: () => retrievePaymentIntent,
|
|
108
118
|
revokeIntegrationToken: () => revokeIntegrationToken,
|
|
109
119
|
sendHypercoreTransaction: () => sendHypercoreTransaction,
|
|
@@ -169,7 +179,70 @@ function generatePrefixedKSUID(prefix) {
|
|
|
169
179
|
return `${prefix}_${generateKSUID()}`;
|
|
170
180
|
}
|
|
171
181
|
|
|
182
|
+
// src/lib/client-headers.ts
|
|
183
|
+
var SDK_VERSION = true ? "0.1.72" : "0.0.0-dev";
|
|
184
|
+
var CLIENT_VERSION_HEADER = "x-unifold-client-version";
|
|
185
|
+
var CLIENT_USER_AGENT_HEADER = "x-unifold-client-user-agent";
|
|
186
|
+
function detectRuntime() {
|
|
187
|
+
if (typeof navigator !== "undefined") {
|
|
188
|
+
const nav = navigator;
|
|
189
|
+
return {
|
|
190
|
+
lang: "js",
|
|
191
|
+
// The browser already sends its real `User-Agent` automatically, so we
|
|
192
|
+
// keep this compact rather than duplicating the full UA string.
|
|
193
|
+
langVersion: nav.platform || "browser",
|
|
194
|
+
platform: nav.platform || "browser"
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
try {
|
|
198
|
+
const proc = globalThis.process;
|
|
199
|
+
if (proc?.versions?.node) {
|
|
200
|
+
return {
|
|
201
|
+
lang: "node",
|
|
202
|
+
langVersion: proc.versions.node,
|
|
203
|
+
platform: `${proc.platform ?? "unknown"} ${proc.arch ?? ""}`.trim()
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
} catch {
|
|
207
|
+
}
|
|
208
|
+
return { lang: "js", langVersion: "unknown", platform: "unknown" };
|
|
209
|
+
}
|
|
210
|
+
var cachedHeaders;
|
|
211
|
+
function getClientHeaders() {
|
|
212
|
+
if (cachedHeaders) {
|
|
213
|
+
return cachedHeaders;
|
|
214
|
+
}
|
|
215
|
+
const runtime = detectRuntime();
|
|
216
|
+
const userAgent = {
|
|
217
|
+
bindings_version: SDK_VERSION,
|
|
218
|
+
lang: runtime.lang,
|
|
219
|
+
lang_version: runtime.langVersion,
|
|
220
|
+
platform: runtime.platform,
|
|
221
|
+
publisher: "unifold"
|
|
222
|
+
};
|
|
223
|
+
cachedHeaders = {
|
|
224
|
+
[CLIENT_VERSION_HEADER]: `unifold-js/${SDK_VERSION}`,
|
|
225
|
+
[CLIENT_USER_AGENT_HEADER]: JSON.stringify(userAgent)
|
|
226
|
+
};
|
|
227
|
+
return cachedHeaders;
|
|
228
|
+
}
|
|
229
|
+
|
|
172
230
|
// src/lib/api.ts
|
|
231
|
+
function apiFetch(input, init = {}) {
|
|
232
|
+
let clientHeaders = {};
|
|
233
|
+
try {
|
|
234
|
+
clientHeaders = getClientHeaders();
|
|
235
|
+
} catch {
|
|
236
|
+
clientHeaders = {};
|
|
237
|
+
}
|
|
238
|
+
return globalThis.fetch(input, {
|
|
239
|
+
...init,
|
|
240
|
+
headers: {
|
|
241
|
+
...clientHeaders,
|
|
242
|
+
...init.headers
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
173
246
|
var API_BASE_URL = (() => {
|
|
174
247
|
try {
|
|
175
248
|
return process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.unifold.io";
|
|
@@ -254,7 +327,7 @@ async function createDepositAddress(overrides, publishableKey) {
|
|
|
254
327
|
};
|
|
255
328
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
256
329
|
validatePublishableKey(pk);
|
|
257
|
-
const response = await
|
|
330
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/deposit_addresses`, {
|
|
258
331
|
method: "POST",
|
|
259
332
|
headers: {
|
|
260
333
|
accept: "application/json",
|
|
@@ -278,7 +351,7 @@ async function createDepositAddress(overrides, publishableKey) {
|
|
|
278
351
|
async function getDepositAddress(params, publishableKey) {
|
|
279
352
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
280
353
|
validatePublishableKey(pk);
|
|
281
|
-
const response = await
|
|
354
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/deposit_addresses/existing`, {
|
|
282
355
|
method: "POST",
|
|
283
356
|
headers: {
|
|
284
357
|
accept: "application/json",
|
|
@@ -312,7 +385,7 @@ async function queryExecutions(externalUserId, publishableKey, actionType = "dep
|
|
|
312
385
|
external_user_id: externalUserId,
|
|
313
386
|
action_type: actionType
|
|
314
387
|
};
|
|
315
|
-
const response = await
|
|
388
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/direct_executions/query`, {
|
|
316
389
|
method: "POST",
|
|
317
390
|
headers: {
|
|
318
391
|
accept: "application/json",
|
|
@@ -329,7 +402,7 @@ async function queryExecutions(externalUserId, publishableKey, actionType = "dep
|
|
|
329
402
|
async function pollDirectExecutions(request, publishableKey) {
|
|
330
403
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
331
404
|
validatePublishableKey(pk);
|
|
332
|
-
const response = await
|
|
405
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/direct_executions/poll`, {
|
|
333
406
|
method: "POST",
|
|
334
407
|
headers: {
|
|
335
408
|
accept: "application/json",
|
|
@@ -355,7 +428,7 @@ async function getSupportedDestinationTokens(publishableKey, options) {
|
|
|
355
428
|
if (qs) {
|
|
356
429
|
url = `${url}?${qs}`;
|
|
357
430
|
}
|
|
358
|
-
const response = await
|
|
431
|
+
const response = await apiFetch(url, {
|
|
359
432
|
method: "GET",
|
|
360
433
|
headers: {
|
|
361
434
|
accept: "application/json",
|
|
@@ -384,7 +457,7 @@ async function getSupportedDepositTokens(publishableKey, options) {
|
|
|
384
457
|
if (qs) {
|
|
385
458
|
url = `${url}?${qs}`;
|
|
386
459
|
}
|
|
387
|
-
const response = await
|
|
460
|
+
const response = await apiFetch(url, {
|
|
388
461
|
method: "GET",
|
|
389
462
|
headers: {
|
|
390
463
|
accept: "application/json",
|
|
@@ -404,7 +477,7 @@ async function getTokenMetadata(request, publishableKey) {
|
|
|
404
477
|
chainId: request.chain_id,
|
|
405
478
|
tokenAddress: request.token_address
|
|
406
479
|
});
|
|
407
|
-
const response = await
|
|
480
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/tokens/token?${params.toString()}`, {
|
|
408
481
|
method: "GET",
|
|
409
482
|
headers: {
|
|
410
483
|
accept: "application/json",
|
|
@@ -429,7 +502,7 @@ function getPreferredIconUrl(iconUrls, preferredFormat = "svg") {
|
|
|
429
502
|
async function getFiatCurrencies(publishableKey) {
|
|
430
503
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
431
504
|
validatePublishableKey(pk);
|
|
432
|
-
const response = await
|
|
505
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/onramps/fiat_currencies`, {
|
|
433
506
|
method: "GET",
|
|
434
507
|
headers: {
|
|
435
508
|
accept: "application/json",
|
|
@@ -450,7 +523,7 @@ async function getFiatExchangeRates(options = {}, publishableKey) {
|
|
|
450
523
|
}
|
|
451
524
|
const queryString = params.toString();
|
|
452
525
|
const url = `${API_BASE_URL}/v1/public/exchange_rates/fiat_currencies${queryString ? `?${queryString}` : ""}`;
|
|
453
|
-
const response = await
|
|
526
|
+
const response = await apiFetch(url, {
|
|
454
527
|
method: "GET",
|
|
455
528
|
headers: {
|
|
456
529
|
accept: "application/json",
|
|
@@ -465,7 +538,7 @@ async function getFiatExchangeRates(options = {}, publishableKey) {
|
|
|
465
538
|
async function getOnrampQuotes(request, publishableKey) {
|
|
466
539
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
467
540
|
validatePublishableKey(pk);
|
|
468
|
-
const response = await
|
|
541
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/onramps/quotes`, {
|
|
469
542
|
method: "POST",
|
|
470
543
|
headers: {
|
|
471
544
|
accept: "application/json",
|
|
@@ -482,7 +555,7 @@ async function getOnrampQuotes(request, publishableKey) {
|
|
|
482
555
|
async function createOnrampSession(request, publishableKey) {
|
|
483
556
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
484
557
|
validatePublishableKey(pk);
|
|
485
|
-
const response = await
|
|
558
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/onramps/sessions`, {
|
|
486
559
|
method: "POST",
|
|
487
560
|
headers: {
|
|
488
561
|
accept: "application/json",
|
|
@@ -505,7 +578,7 @@ async function getBankTransferProviders(publishableKey, options = {}) {
|
|
|
505
578
|
}
|
|
506
579
|
const queryString = params.toString();
|
|
507
580
|
const url = `${API_BASE_URL}/v1/public/onramps/bank_transfer/providers${queryString ? `?${queryString}` : ""}`;
|
|
508
|
-
const response = await
|
|
581
|
+
const response = await apiFetch(url, {
|
|
509
582
|
method: "GET",
|
|
510
583
|
headers: {
|
|
511
584
|
accept: "application/json",
|
|
@@ -517,21 +590,57 @@ async function getBankTransferProviders(publishableKey, options = {}) {
|
|
|
517
590
|
}
|
|
518
591
|
return response.json();
|
|
519
592
|
}
|
|
520
|
-
|
|
593
|
+
var usesLegacyWalletPayRoutes = false;
|
|
594
|
+
async function fetchWalletPayRoute(current, legacy) {
|
|
595
|
+
if (usesLegacyWalletPayRoutes && legacy) {
|
|
596
|
+
return apiFetch(legacy.url, legacy.init);
|
|
597
|
+
}
|
|
598
|
+
const response = await apiFetch(current.url, current.init);
|
|
599
|
+
if (response.status !== 404 || !legacy) return response;
|
|
600
|
+
usesLegacyWalletPayRoutes = true;
|
|
601
|
+
return apiFetch(legacy.url, legacy.init);
|
|
602
|
+
}
|
|
603
|
+
async function getWalletPayProviders(method, publishableKey) {
|
|
521
604
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
522
605
|
validatePublishableKey(pk);
|
|
523
|
-
const
|
|
524
|
-
const response = await fetch(url, {
|
|
606
|
+
const init = {
|
|
525
607
|
method: "GET",
|
|
526
608
|
headers: {
|
|
527
609
|
accept: "application/json",
|
|
528
610
|
"x-publishable-key": pk
|
|
529
611
|
}
|
|
530
|
-
}
|
|
612
|
+
};
|
|
613
|
+
const response = await fetchWalletPayRoute(
|
|
614
|
+
{
|
|
615
|
+
url: `${API_BASE_URL}/v1/public/onramps/wallet_pay/providers?payment_method_type=${method}`,
|
|
616
|
+
init
|
|
617
|
+
},
|
|
618
|
+
method === "apple_pay" ? { url: `${API_BASE_URL}/v1/public/onramps/apple_pay/providers`, init } : null
|
|
619
|
+
);
|
|
531
620
|
if (!response.ok) {
|
|
532
|
-
throw new Error(
|
|
621
|
+
throw new Error(
|
|
622
|
+
`Failed to fetch ${WALLET_PAY_LABEL[method]} providers: ${response.statusText}`
|
|
623
|
+
);
|
|
533
624
|
}
|
|
534
|
-
|
|
625
|
+
const payload = await response.json();
|
|
626
|
+
return {
|
|
627
|
+
// The route this can fall back to reports the same values under the older
|
|
628
|
+
// `payment_methods` name, so fold both into one field rather than making
|
|
629
|
+
// callers know which generation of the API answered.
|
|
630
|
+
data: (payload.data ?? []).map((provider) => {
|
|
631
|
+
const { payment_methods: legacy, payment_method_types: current, ...rest } = provider;
|
|
632
|
+
return {
|
|
633
|
+
...rest,
|
|
634
|
+
payment_method_types: current ?? legacy ?? []
|
|
635
|
+
};
|
|
636
|
+
})
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
function getApplePayProviders(publishableKey) {
|
|
640
|
+
return getWalletPayProviders("apple_pay", publishableKey);
|
|
641
|
+
}
|
|
642
|
+
function getGooglePayProviders(publishableKey) {
|
|
643
|
+
return getWalletPayProviders("google_pay", publishableKey);
|
|
535
644
|
}
|
|
536
645
|
function getOnrampSessionStartUrl(request, publishableKey) {
|
|
537
646
|
const params = new URLSearchParams();
|
|
@@ -567,7 +676,7 @@ async function getDefaultOnrampToken(params, publishableKey) {
|
|
|
567
676
|
queryParams.append("token_address", params.token_address);
|
|
568
677
|
queryParams.append("chain_id", params.chain_id);
|
|
569
678
|
queryParams.append("chain_type", params.chain_type);
|
|
570
|
-
const response = await
|
|
679
|
+
const response = await apiFetch(
|
|
571
680
|
`${API_BASE_URL}/v1/public/onramps/default_token?${queryParams.toString()}`,
|
|
572
681
|
{
|
|
573
682
|
method: "GET",
|
|
@@ -583,7 +692,7 @@ async function getDefaultOnrampToken(params, publishableKey) {
|
|
|
583
692
|
return response.json();
|
|
584
693
|
}
|
|
585
694
|
async function getTokenChains() {
|
|
586
|
-
const response = await
|
|
695
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/tokens/chains`, {
|
|
587
696
|
method: "GET",
|
|
588
697
|
headers: {
|
|
589
698
|
accept: "application/json"
|
|
@@ -617,7 +726,7 @@ async function getProjectConfig(publishableKey, options) {
|
|
|
617
726
|
}
|
|
618
727
|
const queryString = params.toString();
|
|
619
728
|
const url = `${API_BASE_URL}/v1/public/projects/config${queryString ? `?${queryString}` : ""}`;
|
|
620
|
-
const response = await
|
|
729
|
+
const response = await apiFetch(url, {
|
|
621
730
|
method: "GET",
|
|
622
731
|
headers: {
|
|
623
732
|
accept: "application/json",
|
|
@@ -633,7 +742,7 @@ async function getProjectConfig(publishableKey, options) {
|
|
|
633
742
|
async function getPublicIncident(publishableKey) {
|
|
634
743
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
635
744
|
validatePublishableKey(pk);
|
|
636
|
-
const response = await
|
|
745
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/projects/incident`, {
|
|
637
746
|
method: "GET",
|
|
638
747
|
headers: {
|
|
639
748
|
accept: "application/json",
|
|
@@ -646,7 +755,7 @@ async function getPublicIncident(publishableKey) {
|
|
|
646
755
|
return response.json();
|
|
647
756
|
}
|
|
648
757
|
async function getIpAddress() {
|
|
649
|
-
const response = await
|
|
758
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/ip_address`, {
|
|
650
759
|
method: "GET",
|
|
651
760
|
headers: {
|
|
652
761
|
accept: "application/json"
|
|
@@ -666,7 +775,7 @@ async function getAddressBalances(address, chainType, publishableKey) {
|
|
|
666
775
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
667
776
|
validatePublishableKey(pk);
|
|
668
777
|
const url = `${API_BASE_URL}/v1/public/addresses/balances`;
|
|
669
|
-
const response = await
|
|
778
|
+
const response = await apiFetch(url, {
|
|
670
779
|
method: "POST",
|
|
671
780
|
headers: {
|
|
672
781
|
"Content-Type": "application/json",
|
|
@@ -687,7 +796,7 @@ async function getAddressBalances(address, chainType, publishableKey) {
|
|
|
687
796
|
async function getExternalWallets(publishableKey) {
|
|
688
797
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
689
798
|
validatePublishableKey(pk);
|
|
690
|
-
const response = await
|
|
799
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/external_wallets`, {
|
|
691
800
|
method: "GET",
|
|
692
801
|
headers: {
|
|
693
802
|
accept: "application/json",
|
|
@@ -703,7 +812,7 @@ async function getExternalWallets(publishableKey) {
|
|
|
703
812
|
async function getWalletMobileDeepLink(wallet, depositAddresses, publishableKey, amountUsd) {
|
|
704
813
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
705
814
|
validatePublishableKey(pk);
|
|
706
|
-
const response = await
|
|
815
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/external_wallets/mobile_deeplink`, {
|
|
707
816
|
method: "POST",
|
|
708
817
|
headers: {
|
|
709
818
|
"Content-Type": "application/json",
|
|
@@ -726,7 +835,7 @@ async function getAddressBalance(address, chainType, chainId, tokenAddress, publ
|
|
|
726
835
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
727
836
|
validatePublishableKey(pk);
|
|
728
837
|
const url = `${API_BASE_URL}/v1/public/addresses/balance`;
|
|
729
|
-
const response = await
|
|
838
|
+
const response = await apiFetch(url, {
|
|
730
839
|
method: "POST",
|
|
731
840
|
headers: {
|
|
732
841
|
"Content-Type": "application/json",
|
|
@@ -749,7 +858,7 @@ async function getAddressBalance(address, chainType, chainId, tokenAddress, publ
|
|
|
749
858
|
async function verifyRecipientAddress(request, publishableKey) {
|
|
750
859
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
751
860
|
validatePublishableKey(pk);
|
|
752
|
-
const response = await
|
|
861
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/addresses/verify`, {
|
|
753
862
|
method: "POST",
|
|
754
863
|
headers: {
|
|
755
864
|
accept: "application/json",
|
|
@@ -775,7 +884,7 @@ async function verifyRecipientAddress(request, publishableKey) {
|
|
|
775
884
|
async function checkHypercoreActivation(request, publishableKey) {
|
|
776
885
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
777
886
|
validatePublishableKey(pk);
|
|
778
|
-
const response = await
|
|
887
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/addresses/hypercore/activation`, {
|
|
779
888
|
method: "POST",
|
|
780
889
|
headers: {
|
|
781
890
|
accept: "application/json",
|
|
@@ -798,7 +907,7 @@ async function getExchanges(query, publishableKey) {
|
|
|
798
907
|
if (query?.destination_network) params.append("destination_network", query.destination_network);
|
|
799
908
|
const queryString = params.toString();
|
|
800
909
|
const url = `${API_BASE_URL}/v1/public/onramps/exchanges${queryString ? `?${queryString}` : ""}`;
|
|
801
|
-
const response = await
|
|
910
|
+
const response = await apiFetch(url, {
|
|
802
911
|
method: "GET",
|
|
803
912
|
headers: {
|
|
804
913
|
accept: "application/json",
|
|
@@ -814,7 +923,7 @@ async function getExchanges(query, publishableKey) {
|
|
|
814
923
|
async function createExchangeSession(request, publishableKey) {
|
|
815
924
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
816
925
|
validatePublishableKey(pk);
|
|
817
|
-
const response = await
|
|
926
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/onramps/exchanges/sessions`, {
|
|
818
927
|
method: "POST",
|
|
819
928
|
headers: {
|
|
820
929
|
accept: "application/json",
|
|
@@ -852,7 +961,7 @@ function getExchangeSessionStartUrl(request, publishableKey) {
|
|
|
852
961
|
async function getIntegrationExchanges(publishableKey) {
|
|
853
962
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
854
963
|
validatePublishableKey(pk);
|
|
855
|
-
const response = await
|
|
964
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/integrations/oauth/exchanges`, {
|
|
856
965
|
method: "GET",
|
|
857
966
|
headers: {
|
|
858
967
|
accept: "application/json",
|
|
@@ -867,7 +976,7 @@ async function getIntegrationExchanges(publishableKey) {
|
|
|
867
976
|
async function startIntegrationOAuth(publishableKey) {
|
|
868
977
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
869
978
|
validatePublishableKey(pk);
|
|
870
|
-
const response = await
|
|
979
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/integrations/oauth/coinbase/start`, {
|
|
871
980
|
method: "POST",
|
|
872
981
|
headers: {
|
|
873
982
|
accept: "application/json",
|
|
@@ -887,7 +996,7 @@ var IntegrationProvider = /* @__PURE__ */ ((IntegrationProvider2) => {
|
|
|
887
996
|
async function authenticateIntegrationOAuth(params, publishableKey) {
|
|
888
997
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
889
998
|
validatePublishableKey(pk);
|
|
890
|
-
const response = await
|
|
999
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/integrations/oauth/authenticate`, {
|
|
891
1000
|
method: "POST",
|
|
892
1001
|
headers: {
|
|
893
1002
|
accept: "application/json",
|
|
@@ -904,7 +1013,7 @@ async function authenticateIntegrationOAuth(params, publishableKey) {
|
|
|
904
1013
|
async function refreshIntegrationToken(accessToken, publishableKey) {
|
|
905
1014
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
906
1015
|
validatePublishableKey(pk);
|
|
907
|
-
const response = await
|
|
1016
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/integrations/token/refresh`, {
|
|
908
1017
|
method: "POST",
|
|
909
1018
|
headers: {
|
|
910
1019
|
accept: "application/json",
|
|
@@ -921,7 +1030,7 @@ async function refreshIntegrationToken(accessToken, publishableKey) {
|
|
|
921
1030
|
async function revokeIntegrationToken(accessToken, publishableKey) {
|
|
922
1031
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
923
1032
|
validatePublishableKey(pk);
|
|
924
|
-
await
|
|
1033
|
+
await apiFetch(`${API_BASE_URL}/v1/public/integrations/token/revoke`, {
|
|
925
1034
|
method: "POST",
|
|
926
1035
|
headers: {
|
|
927
1036
|
accept: "application/json",
|
|
@@ -935,7 +1044,7 @@ async function revokeIntegrationToken(accessToken, publishableKey) {
|
|
|
935
1044
|
async function getIntegrationHoldings(provider, accessToken, publishableKey) {
|
|
936
1045
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
937
1046
|
validatePublishableKey(pk);
|
|
938
|
-
const response = await
|
|
1047
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/integrations/holdings`, {
|
|
939
1048
|
method: "POST",
|
|
940
1049
|
headers: {
|
|
941
1050
|
accept: "application/json",
|
|
@@ -955,7 +1064,7 @@ async function getIntegrationHoldings(provider, accessToken, publishableKey) {
|
|
|
955
1064
|
async function createIntegrationTransfer(params, publishableKey) {
|
|
956
1065
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
957
1066
|
validatePublishableKey(pk);
|
|
958
|
-
const response = await
|
|
1067
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/integrations/transfers`, {
|
|
959
1068
|
method: "POST",
|
|
960
1069
|
headers: {
|
|
961
1070
|
accept: "application/json",
|
|
@@ -975,7 +1084,7 @@ async function confirmIntegrationTransfer(transferId, accessToken, mfaCode, publ
|
|
|
975
1084
|
validatePublishableKey(pk);
|
|
976
1085
|
const body = { access_token: accessToken };
|
|
977
1086
|
if (mfaCode) body.mfa_code = mfaCode;
|
|
978
|
-
const response = await
|
|
1087
|
+
const response = await apiFetch(
|
|
979
1088
|
`${API_BASE_URL}/v1/public/integrations/transfers/${transferId}/confirm`,
|
|
980
1089
|
{
|
|
981
1090
|
method: "POST",
|
|
@@ -996,15 +1105,18 @@ async function confirmIntegrationTransfer(transferId, accessToken, mfaCode, publ
|
|
|
996
1105
|
async function getIntegrationTransferDefaultToken(params, publishableKey) {
|
|
997
1106
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
998
1107
|
validatePublishableKey(pk);
|
|
999
|
-
const response = await
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1108
|
+
const response = await apiFetch(
|
|
1109
|
+
`${API_BASE_URL}/v1/public/integrations/transfers/default_token`,
|
|
1110
|
+
{
|
|
1111
|
+
method: "POST",
|
|
1112
|
+
headers: {
|
|
1113
|
+
accept: "application/json",
|
|
1114
|
+
"x-publishable-key": pk,
|
|
1115
|
+
"Content-Type": "application/json"
|
|
1116
|
+
},
|
|
1117
|
+
body: JSON.stringify(params)
|
|
1118
|
+
}
|
|
1119
|
+
);
|
|
1008
1120
|
if (!response.ok) {
|
|
1009
1121
|
const err = await response.json().catch(() => ({ message: response.statusText }));
|
|
1010
1122
|
throw new Error(`Failed to get transfer default token: ${err.message || response.statusText}`);
|
|
@@ -1014,7 +1126,7 @@ async function getIntegrationTransferDefaultToken(params, publishableKey) {
|
|
|
1014
1126
|
async function buildSolanaTransaction(request, publishableKey) {
|
|
1015
1127
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1016
1128
|
validatePublishableKey(pk);
|
|
1017
|
-
const response = await
|
|
1129
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/transactions/solana/build`, {
|
|
1018
1130
|
method: "POST",
|
|
1019
1131
|
headers: {
|
|
1020
1132
|
accept: "application/json",
|
|
@@ -1032,7 +1144,7 @@ async function buildSolanaTransaction(request, publishableKey) {
|
|
|
1032
1144
|
async function sendSolanaTransaction(request, publishableKey) {
|
|
1033
1145
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1034
1146
|
validatePublishableKey(pk);
|
|
1035
|
-
const response = await
|
|
1147
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/transactions/solana/send`, {
|
|
1036
1148
|
method: "POST",
|
|
1037
1149
|
headers: {
|
|
1038
1150
|
accept: "application/json",
|
|
@@ -1050,7 +1162,7 @@ async function sendSolanaTransaction(request, publishableKey) {
|
|
|
1050
1162
|
async function retrievePaymentIntent(clientSecret, publishableKey) {
|
|
1051
1163
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1052
1164
|
validatePublishableKey(pk);
|
|
1053
|
-
const response = await
|
|
1165
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/payment_intents/retrieve`, {
|
|
1054
1166
|
method: "POST",
|
|
1055
1167
|
headers: {
|
|
1056
1168
|
accept: "application/json",
|
|
@@ -1068,7 +1180,7 @@ async function retrievePaymentIntent(clientSecret, publishableKey) {
|
|
|
1068
1180
|
async function listPaymentIntentExecutions(clientSecret, publishableKey) {
|
|
1069
1181
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1070
1182
|
validatePublishableKey(pk);
|
|
1071
|
-
const response = await
|
|
1183
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/payment_intents/executions`, {
|
|
1072
1184
|
method: "POST",
|
|
1073
1185
|
headers: {
|
|
1074
1186
|
accept: "application/json",
|
|
@@ -1088,7 +1200,7 @@ async function listPaymentIntentExecutions(clientSecret, publishableKey) {
|
|
|
1088
1200
|
async function getDepositQuote(request, publishableKey) {
|
|
1089
1201
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1090
1202
|
validatePublishableKey(pk);
|
|
1091
|
-
const response = await
|
|
1203
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/quotes`, {
|
|
1092
1204
|
method: "POST",
|
|
1093
1205
|
headers: {
|
|
1094
1206
|
accept: "application/json",
|
|
@@ -1107,7 +1219,7 @@ async function getDepositQuote(request, publishableKey) {
|
|
|
1107
1219
|
async function buildHypercoreTransaction(request, publishableKey) {
|
|
1108
1220
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1109
1221
|
validatePublishableKey(pk);
|
|
1110
|
-
const response = await
|
|
1222
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/transactions/hypercore/build`, {
|
|
1111
1223
|
method: "POST",
|
|
1112
1224
|
headers: {
|
|
1113
1225
|
accept: "application/json",
|
|
@@ -1127,7 +1239,7 @@ async function buildHypercoreTransaction(request, publishableKey) {
|
|
|
1127
1239
|
async function getCashAppLimits(currency = "usd", publishableKey) {
|
|
1128
1240
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1129
1241
|
validatePublishableKey(pk);
|
|
1130
|
-
const response = await
|
|
1242
|
+
const response = await apiFetch(
|
|
1131
1243
|
`${API_BASE_URL}/v1/public/onramps/cashapp/limits?currency=${encodeURIComponent(currency)}`,
|
|
1132
1244
|
{
|
|
1133
1245
|
method: "GET",
|
|
@@ -1146,7 +1258,7 @@ async function getCashAppLimits(currency = "usd", publishableKey) {
|
|
|
1146
1258
|
async function createCashAppSession(request, publishableKey) {
|
|
1147
1259
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1148
1260
|
validatePublishableKey(pk);
|
|
1149
|
-
const response = await
|
|
1261
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/onramps/cashapp/sessions`, {
|
|
1150
1262
|
method: "POST",
|
|
1151
1263
|
headers: {
|
|
1152
1264
|
accept: "application/json",
|
|
@@ -1164,7 +1276,7 @@ async function createCashAppSession(request, publishableKey) {
|
|
|
1164
1276
|
async function getCashAppSessionStatus(externalId, publishableKey) {
|
|
1165
1277
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1166
1278
|
validatePublishableKey(pk);
|
|
1167
|
-
const response = await
|
|
1279
|
+
const response = await apiFetch(
|
|
1168
1280
|
`${API_BASE_URL}/v1/public/onramps/cashapp/sessions/${encodeURIComponent(externalId)}/status`,
|
|
1169
1281
|
{
|
|
1170
1282
|
method: "GET",
|
|
@@ -1192,7 +1304,7 @@ async function stripeGetDefaultToken(params, publishableKey) {
|
|
|
1192
1304
|
});
|
|
1193
1305
|
if (params.countryCode) query.append("country_code", params.countryCode);
|
|
1194
1306
|
if (params.subdivisionCode) query.append("subdivision_code", params.subdivisionCode);
|
|
1195
|
-
const response = await
|
|
1307
|
+
const response = await apiFetch(
|
|
1196
1308
|
`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/default_token?${query.toString()}`,
|
|
1197
1309
|
{
|
|
1198
1310
|
method: "GET",
|
|
@@ -1233,7 +1345,7 @@ function throwStripeError(prefix, response, error) {
|
|
|
1233
1345
|
async function stripeGetConfig(publishableKey) {
|
|
1234
1346
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1235
1347
|
validatePublishableKey(pk);
|
|
1236
|
-
const response = await
|
|
1348
|
+
const response = await apiFetch(`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/config`, {
|
|
1237
1349
|
method: "GET",
|
|
1238
1350
|
headers: {
|
|
1239
1351
|
accept: "application/json",
|
|
@@ -1249,7 +1361,7 @@ async function stripeGetConfig(publishableKey) {
|
|
|
1249
1361
|
async function stripeCreateAuthIntent(email, publishableKey) {
|
|
1250
1362
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1251
1363
|
validatePublishableKey(pk);
|
|
1252
|
-
const response = await
|
|
1364
|
+
const response = await apiFetch(`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/oauth/start`, {
|
|
1253
1365
|
method: "POST",
|
|
1254
1366
|
headers: {
|
|
1255
1367
|
accept: "application/json",
|
|
@@ -1264,17 +1376,20 @@ async function stripeCreateAuthIntent(email, publishableKey) {
|
|
|
1264
1376
|
}
|
|
1265
1377
|
return response.json();
|
|
1266
1378
|
}
|
|
1267
|
-
async function stripeExchangeTokens(authIntentId, publishableKey) {
|
|
1379
|
+
async function stripeExchangeTokens(authIntentId, publishableKey, cryptoCustomerId) {
|
|
1268
1380
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1269
1381
|
validatePublishableKey(pk);
|
|
1270
|
-
const response = await
|
|
1382
|
+
const response = await apiFetch(`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/oauth/token`, {
|
|
1271
1383
|
method: "POST",
|
|
1272
1384
|
headers: {
|
|
1273
1385
|
accept: "application/json",
|
|
1274
1386
|
"x-publishable-key": pk,
|
|
1275
1387
|
"Content-Type": "application/json"
|
|
1276
1388
|
},
|
|
1277
|
-
body: JSON.stringify({
|
|
1389
|
+
body: JSON.stringify({
|
|
1390
|
+
auth_intent_id: authIntentId,
|
|
1391
|
+
...cryptoCustomerId ? { crypto_customer_id: cryptoCustomerId } : {}
|
|
1392
|
+
})
|
|
1278
1393
|
});
|
|
1279
1394
|
if (!response.ok) {
|
|
1280
1395
|
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
@@ -1285,7 +1400,7 @@ async function stripeExchangeTokens(authIntentId, publishableKey) {
|
|
|
1285
1400
|
async function stripeRefreshToken(refreshToken, publishableKey) {
|
|
1286
1401
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1287
1402
|
validatePublishableKey(pk);
|
|
1288
|
-
const response = await
|
|
1403
|
+
const response = await apiFetch(`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/oauth/token/refresh`, {
|
|
1289
1404
|
method: "POST",
|
|
1290
1405
|
headers: {
|
|
1291
1406
|
accept: "application/json",
|
|
@@ -1303,7 +1418,7 @@ async function stripeRefreshToken(refreshToken, publishableKey) {
|
|
|
1303
1418
|
async function stripeGetCustomer(customerId, oauthToken, publishableKey) {
|
|
1304
1419
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1305
1420
|
validatePublishableKey(pk);
|
|
1306
|
-
const response = await
|
|
1421
|
+
const response = await apiFetch(
|
|
1307
1422
|
`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/customers/${encodeURIComponent(customerId)}`,
|
|
1308
1423
|
{
|
|
1309
1424
|
method: "GET",
|
|
@@ -1323,7 +1438,7 @@ async function stripeGetCustomer(customerId, oauthToken, publishableKey) {
|
|
|
1323
1438
|
async function stripeListWallets(customerId, oauthToken, publishableKey) {
|
|
1324
1439
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1325
1440
|
validatePublishableKey(pk);
|
|
1326
|
-
const response = await
|
|
1441
|
+
const response = await apiFetch(
|
|
1327
1442
|
`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/customers/${encodeURIComponent(customerId)}/wallet_addresses`,
|
|
1328
1443
|
{
|
|
1329
1444
|
method: "GET",
|
|
@@ -1343,7 +1458,7 @@ async function stripeListWallets(customerId, oauthToken, publishableKey) {
|
|
|
1343
1458
|
async function stripeListPaymentTokens(customerId, oauthToken, publishableKey) {
|
|
1344
1459
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1345
1460
|
validatePublishableKey(pk);
|
|
1346
|
-
const response = await
|
|
1461
|
+
const response = await apiFetch(
|
|
1347
1462
|
`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/customers/${encodeURIComponent(customerId)}/payment_tokens`,
|
|
1348
1463
|
{
|
|
1349
1464
|
method: "GET",
|
|
@@ -1365,7 +1480,7 @@ async function stripeListPaymentTokens(customerId, oauthToken, publishableKey) {
|
|
|
1365
1480
|
async function stripeCreateSession(request, oauthToken, publishableKey) {
|
|
1366
1481
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1367
1482
|
validatePublishableKey(pk);
|
|
1368
|
-
const response = await
|
|
1483
|
+
const response = await apiFetch(`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/sessions`, {
|
|
1369
1484
|
method: "POST",
|
|
1370
1485
|
headers: {
|
|
1371
1486
|
accept: "application/json",
|
|
@@ -1392,7 +1507,7 @@ async function stripeCreateSession(request, oauthToken, publishableKey) {
|
|
|
1392
1507
|
async function stripeConfirmSession(sessionId, oauthToken, request, publishableKey) {
|
|
1393
1508
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1394
1509
|
validatePublishableKey(pk);
|
|
1395
|
-
const response = await
|
|
1510
|
+
const response = await apiFetch(
|
|
1396
1511
|
`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/sessions/${encodeURIComponent(sessionId)}/confirm`,
|
|
1397
1512
|
{
|
|
1398
1513
|
method: "POST",
|
|
@@ -1414,7 +1529,7 @@ async function stripeConfirmSession(sessionId, oauthToken, request, publishableK
|
|
|
1414
1529
|
async function stripeRefreshQuote(sessionId, oauthToken, publishableKey) {
|
|
1415
1530
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1416
1531
|
validatePublishableKey(pk);
|
|
1417
|
-
const response = await
|
|
1532
|
+
const response = await apiFetch(
|
|
1418
1533
|
`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/sessions/${encodeURIComponent(sessionId)}/quote/refresh`,
|
|
1419
1534
|
{
|
|
1420
1535
|
method: "POST",
|
|
@@ -1434,7 +1549,7 @@ async function stripeRefreshQuote(sessionId, oauthToken, publishableKey) {
|
|
|
1434
1549
|
async function stripeGetSession(sessionId, oauthToken, publishableKey) {
|
|
1435
1550
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1436
1551
|
validatePublishableKey(pk);
|
|
1437
|
-
const response = await
|
|
1552
|
+
const response = await apiFetch(
|
|
1438
1553
|
`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/sessions/${encodeURIComponent(sessionId)}`,
|
|
1439
1554
|
{
|
|
1440
1555
|
method: "GET",
|
|
@@ -1460,7 +1575,7 @@ async function stripeGetQuotes(request, oauthToken, publishableKey) {
|
|
|
1460
1575
|
"Content-Type": "application/json"
|
|
1461
1576
|
};
|
|
1462
1577
|
if (oauthToken) headers["x-stripe-oauth-token"] = oauthToken;
|
|
1463
|
-
const response = await
|
|
1578
|
+
const response = await apiFetch(`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/quotes`, {
|
|
1464
1579
|
method: "POST",
|
|
1465
1580
|
headers,
|
|
1466
1581
|
body: JSON.stringify({
|
|
@@ -1486,7 +1601,7 @@ async function stripeGetTransactionLimits(params, oauthToken, publishableKey) {
|
|
|
1486
1601
|
});
|
|
1487
1602
|
if (params.destinationTag) query.append("destination_tag", params.destinationTag);
|
|
1488
1603
|
if (params.refresh) query.append("refresh", "true");
|
|
1489
|
-
const response = await
|
|
1604
|
+
const response = await apiFetch(
|
|
1490
1605
|
`${API_BASE_URL}${HEADLESS_STRIPE_BASE}/transaction_limits?${query.toString()}`,
|
|
1491
1606
|
{
|
|
1492
1607
|
method: "GET",
|
|
@@ -1506,7 +1621,7 @@ async function stripeGetTransactionLimits(params, oauthToken, publishableKey) {
|
|
|
1506
1621
|
async function sendHypercoreTransaction(request, publishableKey) {
|
|
1507
1622
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1508
1623
|
validatePublishableKey(pk);
|
|
1509
|
-
const response = await
|
|
1624
|
+
const response = await apiFetch(`${API_BASE_URL}/v1/public/transactions/hypercore/send`, {
|
|
1510
1625
|
method: "POST",
|
|
1511
1626
|
headers: {
|
|
1512
1627
|
accept: "application/json",
|
|
@@ -1526,7 +1641,7 @@ async function sendHypercoreTransaction(request, publishableKey) {
|
|
|
1526
1641
|
async function getCoinbaseLegalAgreements(publishableKey) {
|
|
1527
1642
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1528
1643
|
validatePublishableKey(pk);
|
|
1529
|
-
const response = await
|
|
1644
|
+
const response = await apiFetch(
|
|
1530
1645
|
`${API_BASE_URL}/v1/public/onramps/headless/coinbase/legal_agreements`,
|
|
1531
1646
|
{
|
|
1532
1647
|
method: "GET",
|
|
@@ -1551,7 +1666,7 @@ async function jsonOrThrow(response, label) {
|
|
|
1551
1666
|
async function createOnrampVerificationSession(request, publishableKey) {
|
|
1552
1667
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1553
1668
|
validatePublishableKey(pk);
|
|
1554
|
-
const response = await
|
|
1669
|
+
const response = await apiFetch(`${API_BASE_URL}${VERIFICATION_BASE}`, {
|
|
1555
1670
|
method: "POST",
|
|
1556
1671
|
headers: {
|
|
1557
1672
|
accept: "application/json",
|
|
@@ -1565,7 +1680,7 @@ async function createOnrampVerificationSession(request, publishableKey) {
|
|
|
1565
1680
|
async function postVerificationAction(id, factor, action, body, publishableKey) {
|
|
1566
1681
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1567
1682
|
validatePublishableKey(pk);
|
|
1568
|
-
const response = await
|
|
1683
|
+
const response = await apiFetch(
|
|
1569
1684
|
`${API_BASE_URL}${VERIFICATION_BASE}/${encodeURIComponent(id)}/${factor}/${action}`,
|
|
1570
1685
|
{
|
|
1571
1686
|
method: "POST",
|
|
@@ -1600,7 +1715,7 @@ async function verifyOnrampVerificationOtp(id, factor, clientSecret, code, publi
|
|
|
1600
1715
|
async function exchangeOnrampVerificationToken(id, clientSecret, publishableKey) {
|
|
1601
1716
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1602
1717
|
validatePublishableKey(pk);
|
|
1603
|
-
const response = await
|
|
1718
|
+
const response = await apiFetch(
|
|
1604
1719
|
`${API_BASE_URL}${VERIFICATION_BASE}/${encodeURIComponent(id)}/token`,
|
|
1605
1720
|
{
|
|
1606
1721
|
method: "POST",
|
|
@@ -1622,100 +1737,157 @@ async function getOnrampVerificationSession(id, clientSecret, publishableKey) {
|
|
|
1622
1737
|
validatePublishableKey(pk);
|
|
1623
1738
|
const url = new URL(`${API_BASE_URL}${VERIFICATION_BASE}/${encodeURIComponent(id)}`);
|
|
1624
1739
|
url.searchParams.set("client_secret", clientSecret);
|
|
1625
|
-
const response = await
|
|
1740
|
+
const response = await apiFetch(url.toString(), {
|
|
1626
1741
|
method: "GET",
|
|
1627
1742
|
headers: { accept: "application/json", "x-publishable-key": pk }
|
|
1628
1743
|
});
|
|
1629
1744
|
return jsonOrThrow(response, "Failed to fetch verification session");
|
|
1630
1745
|
}
|
|
1631
|
-
|
|
1746
|
+
var WALLET_PAY_LABEL = {
|
|
1747
|
+
apple_pay: "Apple Pay",
|
|
1748
|
+
google_pay: "Google Pay"
|
|
1749
|
+
};
|
|
1750
|
+
function isWalletPayLimitReached(response) {
|
|
1632
1751
|
return response.limits.some((l) => l.remaining === "0");
|
|
1633
1752
|
}
|
|
1634
|
-
function
|
|
1753
|
+
function getWalletPayLimitUpgradeStatus(response) {
|
|
1635
1754
|
const opt = response.limit_upgrade_options?.[0];
|
|
1636
1755
|
if (!opt || typeof opt.status !== "string") return null;
|
|
1637
1756
|
return opt.status;
|
|
1638
1757
|
}
|
|
1639
|
-
|
|
1758
|
+
var isApplePayLimitReached = isWalletPayLimitReached;
|
|
1759
|
+
var isGooglePayLimitReached = isWalletPayLimitReached;
|
|
1760
|
+
var getApplePayLimitUpgradeStatus = getWalletPayLimitUpgradeStatus;
|
|
1761
|
+
var getGooglePayLimitUpgradeStatus = getWalletPayLimitUpgradeStatus;
|
|
1762
|
+
async function getCoinbaseWalletPayLimits(phone, publishableKey, signal) {
|
|
1640
1763
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1641
1764
|
validatePublishableKey(pk);
|
|
1642
|
-
const
|
|
1643
|
-
|
|
1644
|
-
{
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1765
|
+
const init = {
|
|
1766
|
+
method: "POST",
|
|
1767
|
+
headers: {
|
|
1768
|
+
accept: "application/json",
|
|
1769
|
+
"x-publishable-key": pk,
|
|
1770
|
+
"Content-Type": "application/json"
|
|
1771
|
+
},
|
|
1772
|
+
body: JSON.stringify({ phone }),
|
|
1773
|
+
signal
|
|
1774
|
+
};
|
|
1775
|
+
const base = `${API_BASE_URL}/v1/public/onramps/headless/coinbase`;
|
|
1776
|
+
const response = await fetchWalletPayRoute(
|
|
1777
|
+
{ url: `${base}/limits`, init },
|
|
1778
|
+
{ url: `${base}/apple_pay/limits`, init }
|
|
1654
1779
|
);
|
|
1655
|
-
const raw = await jsonOrThrow(response, "Failed to fetch
|
|
1780
|
+
const raw = await jsonOrThrow(response, "Failed to fetch guest checkout limits");
|
|
1656
1781
|
return {
|
|
1657
1782
|
limits: raw.limits,
|
|
1658
1783
|
limit_upgrade_options: raw.limit_upgrade_options,
|
|
1659
|
-
limit_reached:
|
|
1660
|
-
upgrade_status:
|
|
1784
|
+
limit_reached: isWalletPayLimitReached(raw),
|
|
1785
|
+
upgrade_status: getWalletPayLimitUpgradeStatus(raw)
|
|
1661
1786
|
};
|
|
1662
1787
|
}
|
|
1663
|
-
|
|
1788
|
+
var getCoinbaseApplePayLimits = getCoinbaseWalletPayLimits;
|
|
1789
|
+
async function requestCoinbaseWalletPayLimitUpgrade(request, publishableKey, signal) {
|
|
1664
1790
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1665
1791
|
validatePublishableKey(pk);
|
|
1666
|
-
const
|
|
1667
|
-
|
|
1668
|
-
{
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1792
|
+
const init = {
|
|
1793
|
+
method: "POST",
|
|
1794
|
+
headers: {
|
|
1795
|
+
accept: "application/json",
|
|
1796
|
+
"x-publishable-key": pk,
|
|
1797
|
+
"Content-Type": "application/json"
|
|
1798
|
+
},
|
|
1799
|
+
body: JSON.stringify(request),
|
|
1800
|
+
signal
|
|
1801
|
+
};
|
|
1802
|
+
const base = `${API_BASE_URL}/v1/public/onramps/headless/coinbase`;
|
|
1803
|
+
const response = await fetchWalletPayRoute(
|
|
1804
|
+
{ url: `${base}/limits/upgrade`, init },
|
|
1805
|
+
{ url: `${base}/apple_pay/limits/upgrade`, init }
|
|
1678
1806
|
);
|
|
1679
1807
|
return jsonOrThrow(
|
|
1680
1808
|
response,
|
|
1681
|
-
"Failed to request
|
|
1809
|
+
"Failed to request a guest checkout limit upgrade"
|
|
1682
1810
|
);
|
|
1683
1811
|
}
|
|
1684
|
-
|
|
1812
|
+
var requestCoinbaseApplePayLimitUpgrade = requestCoinbaseWalletPayLimitUpgrade;
|
|
1813
|
+
async function createCoinbaseWalletPaySession(method, request, onrampToken, publishableKey, signal) {
|
|
1685
1814
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
1686
1815
|
validatePublishableKey(pk);
|
|
1687
|
-
const
|
|
1688
|
-
|
|
1816
|
+
const headers = {
|
|
1817
|
+
accept: "application/json",
|
|
1818
|
+
"x-publishable-key": pk,
|
|
1819
|
+
"Content-Type": "application/json",
|
|
1820
|
+
"x-onramp-token": onrampToken
|
|
1821
|
+
};
|
|
1822
|
+
const { payment_method_type: _unused, ...fields } = request;
|
|
1823
|
+
const base = `${API_BASE_URL}/v1/public/onramps/headless/coinbase`;
|
|
1824
|
+
const response = await fetchWalletPayRoute(
|
|
1689
1825
|
{
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
}
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1826
|
+
url: `${base}/sessions`,
|
|
1827
|
+
init: {
|
|
1828
|
+
method: "POST",
|
|
1829
|
+
headers,
|
|
1830
|
+
body: JSON.stringify({ ...fields, payment_method_type: method }),
|
|
1831
|
+
signal
|
|
1832
|
+
}
|
|
1833
|
+
},
|
|
1834
|
+
method === "apple_pay" ? {
|
|
1835
|
+
url: `${base}/apple_pay/sessions`,
|
|
1836
|
+
init: { method: "POST", headers, body: JSON.stringify(fields), signal }
|
|
1837
|
+
} : null
|
|
1700
1838
|
);
|
|
1701
1839
|
return jsonOrThrow(
|
|
1702
1840
|
response,
|
|
1703
|
-
|
|
1841
|
+
`Failed to create ${WALLET_PAY_LABEL[method]} session`
|
|
1704
1842
|
);
|
|
1705
1843
|
}
|
|
1844
|
+
function createCoinbaseApplePaySession(request, onrampToken, publishableKey, signal) {
|
|
1845
|
+
return createCoinbaseWalletPaySession("apple_pay", request, onrampToken, publishableKey, signal);
|
|
1846
|
+
}
|
|
1847
|
+
function createCoinbaseGooglePaySession(request, onrampToken, publishableKey, signal) {
|
|
1848
|
+
return createCoinbaseWalletPaySession("google_pay", request, onrampToken, publishableKey, signal);
|
|
1849
|
+
}
|
|
1706
1850
|
|
|
1707
1851
|
// src/lib/events.ts
|
|
1708
1852
|
var DepositEventType = /* @__PURE__ */ ((DepositEventType2) => {
|
|
1709
1853
|
DepositEventType2["ONRAMP_SESSION_CREATED"] = "onramp_session.created";
|
|
1710
1854
|
DepositEventType2["DIRECT_EXECUTION_SUCCEEDED"] = "direct_execution.succeeded";
|
|
1855
|
+
DepositEventType2["DIRECT_EXECUTION_FAILED"] = "direct_execution.failed";
|
|
1856
|
+
DepositEventType2["METHOD_SELECTED"] = "deposit.method_selected";
|
|
1857
|
+
DepositEventType2["TOKEN_SELECTED"] = "deposit.token_selected";
|
|
1858
|
+
DepositEventType2["WALLET_SELECTED"] = "deposit.wallet_selected";
|
|
1859
|
+
DepositEventType2["PROVIDER_SELECTED"] = "deposit.provider_selected";
|
|
1860
|
+
DepositEventType2["VERIFICATION_STARTED"] = "deposit.verification_started";
|
|
1861
|
+
DepositEventType2["VERIFICATION_COMPLETED"] = "deposit.verification_completed";
|
|
1862
|
+
DepositEventType2["VERIFICATION_FAILED"] = "deposit.verification_failed";
|
|
1863
|
+
DepositEventType2["ACCOUNT_CONNECTION_STARTED"] = "deposit.account_connection_started";
|
|
1864
|
+
DepositEventType2["ACCOUNT_CONNECTED"] = "deposit.account_connected";
|
|
1865
|
+
DepositEventType2["ACCOUNT_CONNECTION_FAILED"] = "deposit.account_connection_failed";
|
|
1866
|
+
DepositEventType2["WALLET_CONNECTION_STARTED"] = "deposit.wallet_connection_started";
|
|
1867
|
+
DepositEventType2["WALLET_CONNECTED"] = "deposit.wallet_connected";
|
|
1868
|
+
DepositEventType2["WALLET_CONNECTION_FAILED"] = "deposit.wallet_connection_failed";
|
|
1869
|
+
DepositEventType2["FLOW_STARTED"] = "deposit.flow_started";
|
|
1870
|
+
DepositEventType2["FLOW_FAILED"] = "deposit.flow_failed";
|
|
1871
|
+
DepositEventType2["LIMIT_REACHED"] = "deposit.limit_reached";
|
|
1711
1872
|
return DepositEventType2;
|
|
1712
1873
|
})(DepositEventType || {});
|
|
1713
1874
|
var WithdrawEventType = /* @__PURE__ */ ((WithdrawEventType2) => {
|
|
1714
1875
|
WithdrawEventType2["DIRECT_EXECUTION_SUCCEEDED"] = "direct_execution.succeeded";
|
|
1876
|
+
WithdrawEventType2["DIRECT_EXECUTION_FAILED"] = "direct_execution.failed";
|
|
1877
|
+
WithdrawEventType2["TOKEN_SELECTED"] = "withdraw.token_selected";
|
|
1878
|
+
WithdrawEventType2["FLOW_STARTED"] = "withdraw.flow_started";
|
|
1715
1879
|
return WithdrawEventType2;
|
|
1716
1880
|
})(WithdrawEventType || {});
|
|
1717
1881
|
var CheckoutEventType = /* @__PURE__ */ ((CheckoutEventType2) => {
|
|
1718
1882
|
CheckoutEventType2["PAYMENT_INTENT_SUCCEEDED"] = "payment_intent.succeeded";
|
|
1883
|
+
CheckoutEventType2["METHOD_SELECTED"] = "checkout.method_selected";
|
|
1884
|
+
CheckoutEventType2["TOKEN_SELECTED"] = "checkout.token_selected";
|
|
1885
|
+
CheckoutEventType2["WALLET_SELECTED"] = "checkout.wallet_selected";
|
|
1886
|
+
CheckoutEventType2["WALLET_CONNECTION_STARTED"] = "checkout.wallet_connection_started";
|
|
1887
|
+
CheckoutEventType2["WALLET_CONNECTED"] = "checkout.wallet_connected";
|
|
1888
|
+
CheckoutEventType2["WALLET_CONNECTION_FAILED"] = "checkout.wallet_connection_failed";
|
|
1889
|
+
CheckoutEventType2["FLOW_STARTED"] = "checkout.flow_started";
|
|
1890
|
+
CheckoutEventType2["FLOW_FAILED"] = "checkout.flow_failed";
|
|
1719
1891
|
return CheckoutEventType2;
|
|
1720
1892
|
})(CheckoutEventType || {});
|
|
1721
1893
|
|
|
@@ -2696,6 +2868,8 @@ var i18n = en_default;
|
|
|
2696
2868
|
confirmIntegrationTransfer,
|
|
2697
2869
|
createCashAppSession,
|
|
2698
2870
|
createCoinbaseApplePaySession,
|
|
2871
|
+
createCoinbaseGooglePaySession,
|
|
2872
|
+
createCoinbaseWalletPaySession,
|
|
2699
2873
|
createDepositAddress,
|
|
2700
2874
|
createExchangeSession,
|
|
2701
2875
|
createIntegrationTransfer,
|
|
@@ -2717,6 +2891,7 @@ var i18n = en_default;
|
|
|
2717
2891
|
getChainName,
|
|
2718
2892
|
getCoinbaseApplePayLimits,
|
|
2719
2893
|
getCoinbaseLegalAgreements,
|
|
2894
|
+
getCoinbaseWalletPayLimits,
|
|
2720
2895
|
getDefaultOnrampToken,
|
|
2721
2896
|
getDepositAddress,
|
|
2722
2897
|
getDepositQuote,
|
|
@@ -2725,6 +2900,8 @@ var i18n = en_default;
|
|
|
2725
2900
|
getExternalWallets,
|
|
2726
2901
|
getFiatCurrencies,
|
|
2727
2902
|
getFiatExchangeRates,
|
|
2903
|
+
getGooglePayLimitUpgradeStatus,
|
|
2904
|
+
getGooglePayProviders,
|
|
2728
2905
|
getIconUrl,
|
|
2729
2906
|
getIconUrlWithCdn,
|
|
2730
2907
|
getIntegrationExchanges,
|
|
@@ -2743,9 +2920,13 @@ var i18n = en_default;
|
|
|
2743
2920
|
getTokenMetadata,
|
|
2744
2921
|
getWalletByChainType,
|
|
2745
2922
|
getWalletMobileDeepLink,
|
|
2923
|
+
getWalletPayLimitUpgradeStatus,
|
|
2924
|
+
getWalletPayProviders,
|
|
2746
2925
|
i18n,
|
|
2747
2926
|
isApplePayLimitReached,
|
|
2748
2927
|
isDepositAddressValidationError,
|
|
2928
|
+
isGooglePayLimitReached,
|
|
2929
|
+
isWalletPayLimitReached,
|
|
2749
2930
|
listPaymentIntentExecutions,
|
|
2750
2931
|
mapDirectExecution,
|
|
2751
2932
|
mapWalletToDepositAddress,
|
|
@@ -2753,6 +2934,7 @@ var i18n = en_default;
|
|
|
2753
2934
|
queryExecutions,
|
|
2754
2935
|
refreshIntegrationToken,
|
|
2755
2936
|
requestCoinbaseApplePayLimitUpgrade,
|
|
2937
|
+
requestCoinbaseWalletPayLimitUpgrade,
|
|
2756
2938
|
retrievePaymentIntent,
|
|
2757
2939
|
revokeIntegrationToken,
|
|
2758
2940
|
sendHypercoreTransaction,
|