@unifold/core 0.1.61 → 0.1.63

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 CHANGED
@@ -457,9 +457,11 @@ interface ProjectConfigResponse {
457
457
  project_name?: string;
458
458
  asset_cdn_url: string;
459
459
  transfer_crypto: {
460
+ enabled?: boolean;
460
461
  networks: FeaturedToken[];
461
462
  };
462
463
  connect_wallet: {
464
+ enabled?: boolean;
463
465
  wallets: FeaturedWallet[];
464
466
  };
465
467
  payment_networks: {
@@ -467,12 +469,21 @@ interface ProjectConfigResponse {
467
469
  };
468
470
  blocked_country_codes?: string[];
469
471
  blocked_country_subdivisions?: BlockedCountrySubdivision[];
472
+ connect_exchange?: {
473
+ enabled: boolean;
474
+ };
475
+ cash_app?: {
476
+ enabled: boolean;
477
+ };
470
478
  pay_with_exchange?: {
471
479
  enabled: boolean;
472
480
  };
473
481
  fiat_onramp?: {
474
482
  enabled: boolean;
475
483
  };
484
+ deposit_tracker?: {
485
+ enabled: boolean;
486
+ };
476
487
  hypercore_sponsorship?: {
477
488
  enabled: boolean;
478
489
  };
@@ -1195,6 +1206,11 @@ declare function sendHypercoreTransaction(request: SendHypercoreTransactionReque
1195
1206
  * formatStablecoinAmount("10000000", 6) // "10.00" (whole number)
1196
1207
  */
1197
1208
  declare function formatStablecoinAmount(baseUnits: string, decimals: number): string;
1209
+ /**
1210
+ * Generate a KSUID-like ID without external dependencies.
1211
+ * Format: `base62(4-byte-timestamp + 16-random-bytes)` (27 chars).
1212
+ */
1213
+ declare function generateKSUID(): string;
1198
1214
  /**
1199
1215
  * Generate a KSUID-like prefixed ID without external dependencies.
1200
1216
  * Format: `{prefix}_{base62(4-byte-timestamp + 16-random-bytes)}` (27 chars after prefix).
@@ -1357,4 +1373,4 @@ declare const i18n: {
1357
1373
  };
1358
1374
  type I18nStrings = typeof i18n;
1359
1375
 
1360
- export { ActionType, type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AuthenticateOAuthResult, type AutoSwapRequest, type AutoSwapResponse, type BlockedCountrySubdivision, type BuildHypercoreTransactionRequest, type BuildHypercoreTransactionResponse, type BuildSolanaTransactionRequest, type BuildSolanaTransactionResponse, type CashAppLimits, type CashAppSessionRequest, type CashAppSessionResponse, type CashAppSessionStatusResponse, type ChainType, type ConfirmIntegrationTransferResult, type CreateDepositAddressRequest, type CreateExchangeSessionRequest, type CreateExchangeSessionResponse, type CreateIntegrationTransferParams, type CreateIntegrationTransferResult, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, type DepositEvent, DepositEventType, type DepositQuote, type DepositQuoteRequest, type DestinationToken, type DestinationTokenChain, type EvmContractCall, type ExchangeProviderInfo, type ExchangeProvidersResponse, type ExchangeSessionStartParams, type ExchangeWalletAddress, ExecutionStatus, type FeaturedToken, type FeaturedWallet, type FiatCurrenciesResponse, type FiatCurrency, type GetExchangesQuery, type HypercoreActionType, type HypercoreActivationRequest, type HypercoreActivationResponse, type I18nStrings, type IconUrl, IneligibilityReason, type IntegrationAccount, type IntegrationExchangeInfo, type IntegrationExchangesResponse, type IntegrationFeeAmount, type IntegrationHoldingsResponse, IntegrationProvider, type IpAddressResponse, type LockedQuoteLimits, type LockedQuotePreview, type LockedQuotePreviewRequest, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionCreatedData, type OnrampSessionCreatedEvent, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentIntent, type PaymentIntentDepositAddress, type PaymentIntentExecutionsResponse, type PaymentIntentStatus, type PaymentIntentType, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProductType, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, type RefreshIntegrationTokenResult, SOLANA_USDC_ADDRESS, type SendHypercoreTransactionRequest, type SendHypercoreTransactionResponse, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SourceToken, type SourceTokenNetwork, type StartIntegrationOAuthResult, type SupportedChain, type SupportedDepositTokensResponse, type SupportedDestinationTokensResponse, type SupportedSourceTokensQuery, type SupportedSourceTokensResponse, type SupportedToken, type TokenBalance, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenIconUrl, type TokenInfo, type TokenMetadata, type TransferDefaultTokenParams, type TransferDefaultTokenResult, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, authenticateIntegrationOAuth, buildHypercoreTransaction, buildSolanaTransaction, checkHypercoreActivation, confirmIntegrationTransfer, createCashAppSession, createDepositAddress, createExchangeSession, createIntegrationTransfer, createOnrampSession, formatStablecoinAmount, generatePrefixedKSUID, getAddressBalance, getAddressBalances, getApiBaseUrl, getCashAppLimits, getCashAppSessionStatus, getChainName, getDefaultOnrampToken, getDepositAddress, getDepositQuote, getExchangeSessionStartUrl, getExchanges, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIntegrationExchanges, getIntegrationHoldings, getIntegrationTransferDefaultToken, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, listPaymentIntentExecutions, pollDirectExecutions, queryExecutions, refreshIntegrationToken, retrievePaymentIntent, revokeIntegrationToken, sendHypercoreTransaction, sendSolanaTransaction, setApiConfig, startIntegrationOAuth, useUserIp, verifyRecipientAddress };
1376
+ export { ActionType, type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AuthenticateOAuthResult, type AutoSwapRequest, type AutoSwapResponse, type BlockedCountrySubdivision, type BuildHypercoreTransactionRequest, type BuildHypercoreTransactionResponse, type BuildSolanaTransactionRequest, type BuildSolanaTransactionResponse, type CashAppLimits, type CashAppSessionRequest, type CashAppSessionResponse, type CashAppSessionStatusResponse, type ChainType, type ConfirmIntegrationTransferResult, type CreateDepositAddressRequest, type CreateExchangeSessionRequest, type CreateExchangeSessionResponse, type CreateIntegrationTransferParams, type CreateIntegrationTransferResult, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, type DepositEvent, DepositEventType, type DepositQuote, type DepositQuoteRequest, type DestinationToken, type DestinationTokenChain, type EvmContractCall, type ExchangeProviderInfo, type ExchangeProvidersResponse, type ExchangeSessionStartParams, type ExchangeWalletAddress, ExecutionStatus, type FeaturedToken, type FeaturedWallet, type FiatCurrenciesResponse, type FiatCurrency, type GetExchangesQuery, type HypercoreActionType, type HypercoreActivationRequest, type HypercoreActivationResponse, type I18nStrings, type IconUrl, IneligibilityReason, type IntegrationAccount, type IntegrationExchangeInfo, type IntegrationExchangesResponse, type IntegrationFeeAmount, type IntegrationHoldingsResponse, IntegrationProvider, type IpAddressResponse, type LockedQuoteLimits, type LockedQuotePreview, type LockedQuotePreviewRequest, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionCreatedData, type OnrampSessionCreatedEvent, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentIntent, type PaymentIntentDepositAddress, type PaymentIntentExecutionsResponse, type PaymentIntentStatus, type PaymentIntentType, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProductType, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, type RefreshIntegrationTokenResult, SOLANA_USDC_ADDRESS, type SendHypercoreTransactionRequest, type SendHypercoreTransactionResponse, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SourceToken, type SourceTokenNetwork, type StartIntegrationOAuthResult, type SupportedChain, type SupportedDepositTokensResponse, type SupportedDestinationTokensResponse, type SupportedSourceTokensQuery, type SupportedSourceTokensResponse, type SupportedToken, type TokenBalance, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenIconUrl, type TokenInfo, type TokenMetadata, type TransferDefaultTokenParams, type TransferDefaultTokenResult, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, authenticateIntegrationOAuth, buildHypercoreTransaction, buildSolanaTransaction, checkHypercoreActivation, confirmIntegrationTransfer, createCashAppSession, createDepositAddress, createExchangeSession, createIntegrationTransfer, createOnrampSession, formatStablecoinAmount, generateKSUID, generatePrefixedKSUID, getAddressBalance, getAddressBalances, getApiBaseUrl, getCashAppLimits, getCashAppSessionStatus, getChainName, getDefaultOnrampToken, getDepositAddress, getDepositQuote, getExchangeSessionStartUrl, getExchanges, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIntegrationExchanges, getIntegrationHoldings, getIntegrationTransferDefaultToken, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, listPaymentIntentExecutions, pollDirectExecutions, queryExecutions, refreshIntegrationToken, retrievePaymentIntent, revokeIntegrationToken, sendHypercoreTransaction, sendSolanaTransaction, setApiConfig, startIntegrationOAuth, useUserIp, verifyRecipientAddress };
package/dist/index.d.ts CHANGED
@@ -457,9 +457,11 @@ interface ProjectConfigResponse {
457
457
  project_name?: string;
458
458
  asset_cdn_url: string;
459
459
  transfer_crypto: {
460
+ enabled?: boolean;
460
461
  networks: FeaturedToken[];
461
462
  };
462
463
  connect_wallet: {
464
+ enabled?: boolean;
463
465
  wallets: FeaturedWallet[];
464
466
  };
465
467
  payment_networks: {
@@ -467,12 +469,21 @@ interface ProjectConfigResponse {
467
469
  };
468
470
  blocked_country_codes?: string[];
469
471
  blocked_country_subdivisions?: BlockedCountrySubdivision[];
472
+ connect_exchange?: {
473
+ enabled: boolean;
474
+ };
475
+ cash_app?: {
476
+ enabled: boolean;
477
+ };
470
478
  pay_with_exchange?: {
471
479
  enabled: boolean;
472
480
  };
473
481
  fiat_onramp?: {
474
482
  enabled: boolean;
475
483
  };
484
+ deposit_tracker?: {
485
+ enabled: boolean;
486
+ };
476
487
  hypercore_sponsorship?: {
477
488
  enabled: boolean;
478
489
  };
@@ -1195,6 +1206,11 @@ declare function sendHypercoreTransaction(request: SendHypercoreTransactionReque
1195
1206
  * formatStablecoinAmount("10000000", 6) // "10.00" (whole number)
1196
1207
  */
1197
1208
  declare function formatStablecoinAmount(baseUnits: string, decimals: number): string;
1209
+ /**
1210
+ * Generate a KSUID-like ID without external dependencies.
1211
+ * Format: `base62(4-byte-timestamp + 16-random-bytes)` (27 chars).
1212
+ */
1213
+ declare function generateKSUID(): string;
1198
1214
  /**
1199
1215
  * Generate a KSUID-like prefixed ID without external dependencies.
1200
1216
  * Format: `{prefix}_{base62(4-byte-timestamp + 16-random-bytes)}` (27 chars after prefix).
@@ -1357,4 +1373,4 @@ declare const i18n: {
1357
1373
  };
1358
1374
  type I18nStrings = typeof i18n;
1359
1375
 
1360
- export { ActionType, type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AuthenticateOAuthResult, type AutoSwapRequest, type AutoSwapResponse, type BlockedCountrySubdivision, type BuildHypercoreTransactionRequest, type BuildHypercoreTransactionResponse, type BuildSolanaTransactionRequest, type BuildSolanaTransactionResponse, type CashAppLimits, type CashAppSessionRequest, type CashAppSessionResponse, type CashAppSessionStatusResponse, type ChainType, type ConfirmIntegrationTransferResult, type CreateDepositAddressRequest, type CreateExchangeSessionRequest, type CreateExchangeSessionResponse, type CreateIntegrationTransferParams, type CreateIntegrationTransferResult, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, type DepositEvent, DepositEventType, type DepositQuote, type DepositQuoteRequest, type DestinationToken, type DestinationTokenChain, type EvmContractCall, type ExchangeProviderInfo, type ExchangeProvidersResponse, type ExchangeSessionStartParams, type ExchangeWalletAddress, ExecutionStatus, type FeaturedToken, type FeaturedWallet, type FiatCurrenciesResponse, type FiatCurrency, type GetExchangesQuery, type HypercoreActionType, type HypercoreActivationRequest, type HypercoreActivationResponse, type I18nStrings, type IconUrl, IneligibilityReason, type IntegrationAccount, type IntegrationExchangeInfo, type IntegrationExchangesResponse, type IntegrationFeeAmount, type IntegrationHoldingsResponse, IntegrationProvider, type IpAddressResponse, type LockedQuoteLimits, type LockedQuotePreview, type LockedQuotePreviewRequest, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionCreatedData, type OnrampSessionCreatedEvent, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentIntent, type PaymentIntentDepositAddress, type PaymentIntentExecutionsResponse, type PaymentIntentStatus, type PaymentIntentType, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProductType, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, type RefreshIntegrationTokenResult, SOLANA_USDC_ADDRESS, type SendHypercoreTransactionRequest, type SendHypercoreTransactionResponse, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SourceToken, type SourceTokenNetwork, type StartIntegrationOAuthResult, type SupportedChain, type SupportedDepositTokensResponse, type SupportedDestinationTokensResponse, type SupportedSourceTokensQuery, type SupportedSourceTokensResponse, type SupportedToken, type TokenBalance, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenIconUrl, type TokenInfo, type TokenMetadata, type TransferDefaultTokenParams, type TransferDefaultTokenResult, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, authenticateIntegrationOAuth, buildHypercoreTransaction, buildSolanaTransaction, checkHypercoreActivation, confirmIntegrationTransfer, createCashAppSession, createDepositAddress, createExchangeSession, createIntegrationTransfer, createOnrampSession, formatStablecoinAmount, generatePrefixedKSUID, getAddressBalance, getAddressBalances, getApiBaseUrl, getCashAppLimits, getCashAppSessionStatus, getChainName, getDefaultOnrampToken, getDepositAddress, getDepositQuote, getExchangeSessionStartUrl, getExchanges, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIntegrationExchanges, getIntegrationHoldings, getIntegrationTransferDefaultToken, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, listPaymentIntentExecutions, pollDirectExecutions, queryExecutions, refreshIntegrationToken, retrievePaymentIntent, revokeIntegrationToken, sendHypercoreTransaction, sendSolanaTransaction, setApiConfig, startIntegrationOAuth, useUserIp, verifyRecipientAddress };
1376
+ export { ActionType, type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AuthenticateOAuthResult, type AutoSwapRequest, type AutoSwapResponse, type BlockedCountrySubdivision, type BuildHypercoreTransactionRequest, type BuildHypercoreTransactionResponse, type BuildSolanaTransactionRequest, type BuildSolanaTransactionResponse, type CashAppLimits, type CashAppSessionRequest, type CashAppSessionResponse, type CashAppSessionStatusResponse, type ChainType, type ConfirmIntegrationTransferResult, type CreateDepositAddressRequest, type CreateExchangeSessionRequest, type CreateExchangeSessionResponse, type CreateIntegrationTransferParams, type CreateIntegrationTransferResult, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, type DepositEvent, DepositEventType, type DepositQuote, type DepositQuoteRequest, type DestinationToken, type DestinationTokenChain, type EvmContractCall, type ExchangeProviderInfo, type ExchangeProvidersResponse, type ExchangeSessionStartParams, type ExchangeWalletAddress, ExecutionStatus, type FeaturedToken, type FeaturedWallet, type FiatCurrenciesResponse, type FiatCurrency, type GetExchangesQuery, type HypercoreActionType, type HypercoreActivationRequest, type HypercoreActivationResponse, type I18nStrings, type IconUrl, IneligibilityReason, type IntegrationAccount, type IntegrationExchangeInfo, type IntegrationExchangesResponse, type IntegrationFeeAmount, type IntegrationHoldingsResponse, IntegrationProvider, type IpAddressResponse, type LockedQuoteLimits, type LockedQuotePreview, type LockedQuotePreviewRequest, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionCreatedData, type OnrampSessionCreatedEvent, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentIntent, type PaymentIntentDepositAddress, type PaymentIntentExecutionsResponse, type PaymentIntentStatus, type PaymentIntentType, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProductType, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, type RefreshIntegrationTokenResult, SOLANA_USDC_ADDRESS, type SendHypercoreTransactionRequest, type SendHypercoreTransactionResponse, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SourceToken, type SourceTokenNetwork, type StartIntegrationOAuthResult, type SupportedChain, type SupportedDepositTokensResponse, type SupportedDestinationTokensResponse, type SupportedSourceTokensQuery, type SupportedSourceTokensResponse, type SupportedToken, type TokenBalance, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenIconUrl, type TokenInfo, type TokenMetadata, type TransferDefaultTokenParams, type TransferDefaultTokenResult, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, authenticateIntegrationOAuth, buildHypercoreTransaction, buildSolanaTransaction, checkHypercoreActivation, confirmIntegrationTransfer, createCashAppSession, createDepositAddress, createExchangeSession, createIntegrationTransfer, createOnrampSession, formatStablecoinAmount, generateKSUID, generatePrefixedKSUID, getAddressBalance, getAddressBalances, getApiBaseUrl, getCashAppLimits, getCashAppSessionStatus, getChainName, getDefaultOnrampToken, getDepositAddress, getDepositQuote, getExchangeSessionStartUrl, getExchanges, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIntegrationExchanges, getIntegrationHoldings, getIntegrationTransferDefaultToken, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, listPaymentIntentExecutions, pollDirectExecutions, queryExecutions, refreshIntegrationToken, retrievePaymentIntent, revokeIntegrationToken, sendHypercoreTransaction, sendSolanaTransaction, setApiConfig, startIntegrationOAuth, useUserIp, verifyRecipientAddress };
package/dist/index.js CHANGED
@@ -37,6 +37,7 @@ __export(index_exports, {
37
37
  createIntegrationTransfer: () => createIntegrationTransfer,
38
38
  createOnrampSession: () => createOnrampSession,
39
39
  formatStablecoinAmount: () => formatStablecoinAmount,
40
+ generateKSUID: () => generateKSUID,
40
41
  generatePrefixedKSUID: () => generatePrefixedKSUID,
41
42
  getAddressBalance: () => getAddressBalance,
42
43
  getAddressBalances: () => getAddressBalances,
@@ -81,6 +82,44 @@ __export(index_exports, {
81
82
  });
82
83
  module.exports = __toCommonJS(index_exports);
83
84
 
85
+ // src/lib/utils.ts
86
+ function formatStablecoinAmount(baseUnits, decimals) {
87
+ const raw = Number(baseUnits) / 10 ** decimals;
88
+ const floored = Math.floor(raw * 100) / 100;
89
+ const ceiled = raw > floored ? floored + 0.01 : raw;
90
+ return ceiled.toFixed(2);
91
+ }
92
+ function generateKSUID() {
93
+ const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
94
+ const KSUID_EPOCH = 14e8;
95
+ const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
96
+ const payload = new Uint8Array(20);
97
+ payload[0] = timestampSeconds >>> 24 & 255;
98
+ payload[1] = timestampSeconds >>> 16 & 255;
99
+ payload[2] = timestampSeconds >>> 8 & 255;
100
+ payload[3] = timestampSeconds & 255;
101
+ if (typeof crypto !== "undefined" && crypto.getRandomValues) {
102
+ crypto.getRandomValues(payload.subarray(4));
103
+ } else {
104
+ for (let i = 4; i < 20; i++) {
105
+ payload[i] = Math.floor(Math.random() * 256);
106
+ }
107
+ }
108
+ let value = 0n;
109
+ for (const byte of payload) {
110
+ value = value << 8n | BigInt(byte);
111
+ }
112
+ let encoded = "";
113
+ while (value > 0n) {
114
+ encoded = BASE62[Number(value % 62n)] + encoded;
115
+ value = value / 62n;
116
+ }
117
+ return encoded.padStart(27, "0");
118
+ }
119
+ function generatePrefixedKSUID(prefix) {
120
+ return `${prefix}_${generateKSUID()}`;
121
+ }
122
+
84
123
  // src/lib/api.ts
85
124
  var API_BASE_URL = (() => {
86
125
  try {
@@ -408,9 +447,7 @@ function getOnrampSessionStartUrl(request, publishableKey) {
408
447
  if (request.subdivision_code) {
409
448
  params.append("subdivision_code", request.subdivision_code);
410
449
  }
411
- if (request.external_id) {
412
- params.append("external_id", request.external_id);
413
- }
450
+ params.append("external_id", request.external_id ?? generatePrefixedKSUID("ors"));
414
451
  if (request.email) {
415
452
  params.append("email", request.email);
416
453
  }
@@ -645,9 +682,7 @@ function getExchangeSessionStartUrl(request, publishableKey) {
645
682
  if (request.source_amount) {
646
683
  params.append("source_amount", request.source_amount);
647
684
  }
648
- if (request.external_id) {
649
- params.append("external_id", request.external_id);
650
- }
685
+ params.append("external_id", request.external_id ?? generatePrefixedKSUID("exc"));
651
686
  return `${API_BASE_URL}/v1/public/onramps/exchanges/sessions/start?${params.toString()}`;
652
687
  }
653
688
  async function getIntegrationExchanges(publishableKey) {
@@ -1028,42 +1063,6 @@ async function sendHypercoreTransaction(request, publishableKey) {
1028
1063
  return response.json();
1029
1064
  }
1030
1065
 
1031
- // src/lib/utils.ts
1032
- function formatStablecoinAmount(baseUnits, decimals) {
1033
- const raw = Number(baseUnits) / 10 ** decimals;
1034
- const floored = Math.floor(raw * 100) / 100;
1035
- const ceiled = raw > floored ? floored + 0.01 : raw;
1036
- return ceiled.toFixed(2);
1037
- }
1038
- function generatePrefixedKSUID(prefix) {
1039
- const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
1040
- const KSUID_EPOCH = 14e8;
1041
- const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
1042
- const payload = new Uint8Array(20);
1043
- payload[0] = timestampSeconds >>> 24 & 255;
1044
- payload[1] = timestampSeconds >>> 16 & 255;
1045
- payload[2] = timestampSeconds >>> 8 & 255;
1046
- payload[3] = timestampSeconds & 255;
1047
- if (typeof crypto !== "undefined" && crypto.getRandomValues) {
1048
- crypto.getRandomValues(payload.subarray(4));
1049
- } else {
1050
- for (let i = 4; i < 20; i++) {
1051
- payload[i] = Math.floor(Math.random() * 256);
1052
- }
1053
- }
1054
- let value = 0n;
1055
- for (const byte of payload) {
1056
- value = value << 8n | BigInt(byte);
1057
- }
1058
- let encoded = "";
1059
- while (value > 0n) {
1060
- encoded = BASE62[Number(value % 62n)] + encoded;
1061
- value = value / 62n;
1062
- }
1063
- encoded = encoded.padStart(27, "0");
1064
- return `${prefix}_${encoded}`;
1065
- }
1066
-
1067
1066
  // src/lib/events.ts
1068
1067
  var DepositEventType = /* @__PURE__ */ ((DepositEventType2) => {
1069
1068
  DepositEventType2["ONRAMP_SESSION_CREATED"] = "onramp_session.created";
@@ -1220,6 +1219,7 @@ var i18n = en_default;
1220
1219
  createIntegrationTransfer,
1221
1220
  createOnrampSession,
1222
1221
  formatStablecoinAmount,
1222
+ generateKSUID,
1223
1223
  generatePrefixedKSUID,
1224
1224
  getAddressBalance,
1225
1225
  getAddressBalances,
package/dist/index.mjs CHANGED
@@ -1,3 +1,41 @@
1
+ // src/lib/utils.ts
2
+ function formatStablecoinAmount(baseUnits, decimals) {
3
+ const raw = Number(baseUnits) / 10 ** decimals;
4
+ const floored = Math.floor(raw * 100) / 100;
5
+ const ceiled = raw > floored ? floored + 0.01 : raw;
6
+ return ceiled.toFixed(2);
7
+ }
8
+ function generateKSUID() {
9
+ const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
10
+ const KSUID_EPOCH = 14e8;
11
+ const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
12
+ const payload = new Uint8Array(20);
13
+ payload[0] = timestampSeconds >>> 24 & 255;
14
+ payload[1] = timestampSeconds >>> 16 & 255;
15
+ payload[2] = timestampSeconds >>> 8 & 255;
16
+ payload[3] = timestampSeconds & 255;
17
+ if (typeof crypto !== "undefined" && crypto.getRandomValues) {
18
+ crypto.getRandomValues(payload.subarray(4));
19
+ } else {
20
+ for (let i = 4; i < 20; i++) {
21
+ payload[i] = Math.floor(Math.random() * 256);
22
+ }
23
+ }
24
+ let value = 0n;
25
+ for (const byte of payload) {
26
+ value = value << 8n | BigInt(byte);
27
+ }
28
+ let encoded = "";
29
+ while (value > 0n) {
30
+ encoded = BASE62[Number(value % 62n)] + encoded;
31
+ value = value / 62n;
32
+ }
33
+ return encoded.padStart(27, "0");
34
+ }
35
+ function generatePrefixedKSUID(prefix) {
36
+ return `${prefix}_${generateKSUID()}`;
37
+ }
38
+
1
39
  // src/lib/api.ts
2
40
  var API_BASE_URL = (() => {
3
41
  try {
@@ -325,9 +363,7 @@ function getOnrampSessionStartUrl(request, publishableKey) {
325
363
  if (request.subdivision_code) {
326
364
  params.append("subdivision_code", request.subdivision_code);
327
365
  }
328
- if (request.external_id) {
329
- params.append("external_id", request.external_id);
330
- }
366
+ params.append("external_id", request.external_id ?? generatePrefixedKSUID("ors"));
331
367
  if (request.email) {
332
368
  params.append("email", request.email);
333
369
  }
@@ -562,9 +598,7 @@ function getExchangeSessionStartUrl(request, publishableKey) {
562
598
  if (request.source_amount) {
563
599
  params.append("source_amount", request.source_amount);
564
600
  }
565
- if (request.external_id) {
566
- params.append("external_id", request.external_id);
567
- }
601
+ params.append("external_id", request.external_id ?? generatePrefixedKSUID("exc"));
568
602
  return `${API_BASE_URL}/v1/public/onramps/exchanges/sessions/start?${params.toString()}`;
569
603
  }
570
604
  async function getIntegrationExchanges(publishableKey) {
@@ -945,42 +979,6 @@ async function sendHypercoreTransaction(request, publishableKey) {
945
979
  return response.json();
946
980
  }
947
981
 
948
- // src/lib/utils.ts
949
- function formatStablecoinAmount(baseUnits, decimals) {
950
- const raw = Number(baseUnits) / 10 ** decimals;
951
- const floored = Math.floor(raw * 100) / 100;
952
- const ceiled = raw > floored ? floored + 0.01 : raw;
953
- return ceiled.toFixed(2);
954
- }
955
- function generatePrefixedKSUID(prefix) {
956
- const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
957
- const KSUID_EPOCH = 14e8;
958
- const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
959
- const payload = new Uint8Array(20);
960
- payload[0] = timestampSeconds >>> 24 & 255;
961
- payload[1] = timestampSeconds >>> 16 & 255;
962
- payload[2] = timestampSeconds >>> 8 & 255;
963
- payload[3] = timestampSeconds & 255;
964
- if (typeof crypto !== "undefined" && crypto.getRandomValues) {
965
- crypto.getRandomValues(payload.subarray(4));
966
- } else {
967
- for (let i = 4; i < 20; i++) {
968
- payload[i] = Math.floor(Math.random() * 256);
969
- }
970
- }
971
- let value = 0n;
972
- for (const byte of payload) {
973
- value = value << 8n | BigInt(byte);
974
- }
975
- let encoded = "";
976
- while (value > 0n) {
977
- encoded = BASE62[Number(value % 62n)] + encoded;
978
- value = value / 62n;
979
- }
980
- encoded = encoded.padStart(27, "0");
981
- return `${prefix}_${encoded}`;
982
- }
983
-
984
982
  // src/lib/events.ts
985
983
  var DepositEventType = /* @__PURE__ */ ((DepositEventType2) => {
986
984
  DepositEventType2["ONRAMP_SESSION_CREATED"] = "onramp_session.created";
@@ -1136,6 +1134,7 @@ export {
1136
1134
  createIntegrationTransfer,
1137
1135
  createOnrampSession,
1138
1136
  formatStablecoinAmount,
1137
+ generateKSUID,
1139
1138
  generatePrefixedKSUID,
1140
1139
  getAddressBalance,
1141
1140
  getAddressBalances,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unifold/core",
3
- "version": "0.1.61",
3
+ "version": "0.1.63",
4
4
  "description": "Unifold Core SDK - Core types, API client, and business logic",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",