@unifold/core 0.1.46 → 0.1.47
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 +42 -1
- package/dist/index.d.ts +42 -1
- package/dist/index.js +43 -0
- package/dist/index.mjs +41 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -308,6 +308,7 @@ interface OnrampSessionRequest {
|
|
|
308
308
|
wallet_address: string;
|
|
309
309
|
subdivision_code?: string;
|
|
310
310
|
redirect_url?: string;
|
|
311
|
+
external_id?: string;
|
|
311
312
|
}
|
|
312
313
|
interface OnrampSessionResponse {
|
|
313
314
|
url: string;
|
|
@@ -754,6 +755,46 @@ declare function buildHypercoreTransaction(request: BuildHypercoreTransactionReq
|
|
|
754
755
|
*/
|
|
755
756
|
declare function sendHypercoreTransaction(request: SendHypercoreTransactionRequest, publishableKey?: string): Promise<SendHypercoreTransactionResponse>;
|
|
756
757
|
|
|
758
|
+
/**
|
|
759
|
+
* Generate a KSUID-like prefixed ID without external dependencies.
|
|
760
|
+
* Format: `{prefix}_{base62(4-byte-timestamp + 16-random-bytes)}` (27 chars after prefix).
|
|
761
|
+
*/
|
|
762
|
+
declare function generatePrefixedKSUID(prefix: string): string;
|
|
763
|
+
|
|
764
|
+
/** Event types emitted by the deposit flow, following `resource.action` convention */
|
|
765
|
+
declare enum DepositEventType {
|
|
766
|
+
ONRAMP_SESSION_CREATED = "onramp_session.created"
|
|
767
|
+
}
|
|
768
|
+
/** `data.object` payload for {@link DepositEventType.ONRAMP_SESSION_CREATED} */
|
|
769
|
+
interface OnrampSessionCreatedData {
|
|
770
|
+
externalId: string;
|
|
771
|
+
}
|
|
772
|
+
/** Map from event type to its `data.object` shape */
|
|
773
|
+
interface DepositEventDataMap {
|
|
774
|
+
[DepositEventType.ONRAMP_SESSION_CREATED]: OnrampSessionCreatedData;
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Event envelope emitted by the deposit flow, inspired by the server-side
|
|
778
|
+
* webhook payload shape: top-level metadata (`id`, `type`, `created`) with
|
|
779
|
+
* the resource nested under `data.object`.
|
|
780
|
+
*
|
|
781
|
+
* Uses `sevt_` prefix for IDs to distinguish from backend webhook `evt_` IDs.
|
|
782
|
+
*/
|
|
783
|
+
type DepositEvent = {
|
|
784
|
+
[K in DepositEventType]: {
|
|
785
|
+
id: string;
|
|
786
|
+
type: K;
|
|
787
|
+
created: number;
|
|
788
|
+
data: {
|
|
789
|
+
object: DepositEventDataMap[K];
|
|
790
|
+
};
|
|
791
|
+
};
|
|
792
|
+
}[DepositEventType];
|
|
793
|
+
/** Convenience type for a fully-typed `onramp_session.created` event */
|
|
794
|
+
type OnrampSessionCreatedEvent = Extract<DepositEvent, {
|
|
795
|
+
type: DepositEventType.ONRAMP_SESSION_CREATED;
|
|
796
|
+
}>;
|
|
797
|
+
|
|
757
798
|
/**
|
|
758
799
|
* User IP information interface
|
|
759
800
|
*/
|
|
@@ -874,4 +915,4 @@ declare const i18n: {
|
|
|
874
915
|
};
|
|
875
916
|
type I18nStrings = typeof i18n;
|
|
876
917
|
|
|
877
|
-
export { ActionType, type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AutoSwapRequest, type AutoSwapResponse, type BuildHypercoreTransactionRequest, type BuildHypercoreTransactionResponse, type BuildSolanaTransactionRequest, type BuildSolanaTransactionResponse, type ChainType, type CreateDepositAddressRequest, type CreateExchangeSessionRequest, type CreateExchangeSessionResponse, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, type DepositQuote, type DepositQuoteRequest, type DestinationToken, type DestinationTokenChain, type ExchangeProviderInfo, type ExchangeProvidersResponse, type ExchangeSessionStartParams, type ExchangeWalletAddress, ExecutionStatus, type FeaturedToken, type FiatCurrenciesResponse, type FiatCurrency, type GetExchangesQuery, type HypercoreActionType, type HypercoreActivationRequest, type HypercoreActivationResponse, type I18nStrings, type IconUrl, IneligibilityReason, type IpAddressResponse, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentIntent, type PaymentIntentDepositAddress, type PaymentIntentExecutionsResponse, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, SOLANA_USDC_ADDRESS, type SendHypercoreTransactionRequest, type SendHypercoreTransactionResponse, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SupportedChain, type SupportedDepositTokensResponse, type SupportedDestinationTokensResponse, type SupportedToken, type TokenBalance, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenIconUrl, type TokenInfo, type TokenMetadata, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, buildHypercoreTransaction, buildSolanaTransaction, checkHypercoreActivation, createDepositAddress, createExchangeSession, createOnrampSession, getAddressBalance, getAddressBalances, getApiBaseUrl, getChainName, getDefaultOnrampToken, getDepositQuote, getExchangeSessionStartUrl, getExchanges, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, listPaymentIntentExecutions, pollDirectExecutions, queryExecutions, retrievePaymentIntent, sendHypercoreTransaction, sendSolanaTransaction, setApiConfig, useUserIp, verifyRecipientAddress };
|
|
918
|
+
export { ActionType, type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AutoSwapRequest, type AutoSwapResponse, type BuildHypercoreTransactionRequest, type BuildHypercoreTransactionResponse, type BuildSolanaTransactionRequest, type BuildSolanaTransactionResponse, type ChainType, type CreateDepositAddressRequest, type CreateExchangeSessionRequest, type CreateExchangeSessionResponse, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, type DepositEvent, DepositEventType, type DepositQuote, type DepositQuoteRequest, type DestinationToken, type DestinationTokenChain, type ExchangeProviderInfo, type ExchangeProvidersResponse, type ExchangeSessionStartParams, type ExchangeWalletAddress, ExecutionStatus, type FeaturedToken, type FiatCurrenciesResponse, type FiatCurrency, type GetExchangesQuery, type HypercoreActionType, type HypercoreActivationRequest, type HypercoreActivationResponse, type I18nStrings, type IconUrl, IneligibilityReason, type IpAddressResponse, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionCreatedData, type OnrampSessionCreatedEvent, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentIntent, type PaymentIntentDepositAddress, type PaymentIntentExecutionsResponse, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, SOLANA_USDC_ADDRESS, type SendHypercoreTransactionRequest, type SendHypercoreTransactionResponse, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SupportedChain, type SupportedDepositTokensResponse, type SupportedDestinationTokensResponse, type SupportedToken, type TokenBalance, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenIconUrl, type TokenInfo, type TokenMetadata, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, buildHypercoreTransaction, buildSolanaTransaction, checkHypercoreActivation, createDepositAddress, createExchangeSession, createOnrampSession, generatePrefixedKSUID, getAddressBalance, getAddressBalances, getApiBaseUrl, getChainName, getDefaultOnrampToken, getDepositQuote, getExchangeSessionStartUrl, getExchanges, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, listPaymentIntentExecutions, pollDirectExecutions, queryExecutions, retrievePaymentIntent, sendHypercoreTransaction, sendSolanaTransaction, setApiConfig, useUserIp, verifyRecipientAddress };
|
package/dist/index.d.ts
CHANGED
|
@@ -308,6 +308,7 @@ interface OnrampSessionRequest {
|
|
|
308
308
|
wallet_address: string;
|
|
309
309
|
subdivision_code?: string;
|
|
310
310
|
redirect_url?: string;
|
|
311
|
+
external_id?: string;
|
|
311
312
|
}
|
|
312
313
|
interface OnrampSessionResponse {
|
|
313
314
|
url: string;
|
|
@@ -754,6 +755,46 @@ declare function buildHypercoreTransaction(request: BuildHypercoreTransactionReq
|
|
|
754
755
|
*/
|
|
755
756
|
declare function sendHypercoreTransaction(request: SendHypercoreTransactionRequest, publishableKey?: string): Promise<SendHypercoreTransactionResponse>;
|
|
756
757
|
|
|
758
|
+
/**
|
|
759
|
+
* Generate a KSUID-like prefixed ID without external dependencies.
|
|
760
|
+
* Format: `{prefix}_{base62(4-byte-timestamp + 16-random-bytes)}` (27 chars after prefix).
|
|
761
|
+
*/
|
|
762
|
+
declare function generatePrefixedKSUID(prefix: string): string;
|
|
763
|
+
|
|
764
|
+
/** Event types emitted by the deposit flow, following `resource.action` convention */
|
|
765
|
+
declare enum DepositEventType {
|
|
766
|
+
ONRAMP_SESSION_CREATED = "onramp_session.created"
|
|
767
|
+
}
|
|
768
|
+
/** `data.object` payload for {@link DepositEventType.ONRAMP_SESSION_CREATED} */
|
|
769
|
+
interface OnrampSessionCreatedData {
|
|
770
|
+
externalId: string;
|
|
771
|
+
}
|
|
772
|
+
/** Map from event type to its `data.object` shape */
|
|
773
|
+
interface DepositEventDataMap {
|
|
774
|
+
[DepositEventType.ONRAMP_SESSION_CREATED]: OnrampSessionCreatedData;
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Event envelope emitted by the deposit flow, inspired by the server-side
|
|
778
|
+
* webhook payload shape: top-level metadata (`id`, `type`, `created`) with
|
|
779
|
+
* the resource nested under `data.object`.
|
|
780
|
+
*
|
|
781
|
+
* Uses `sevt_` prefix for IDs to distinguish from backend webhook `evt_` IDs.
|
|
782
|
+
*/
|
|
783
|
+
type DepositEvent = {
|
|
784
|
+
[K in DepositEventType]: {
|
|
785
|
+
id: string;
|
|
786
|
+
type: K;
|
|
787
|
+
created: number;
|
|
788
|
+
data: {
|
|
789
|
+
object: DepositEventDataMap[K];
|
|
790
|
+
};
|
|
791
|
+
};
|
|
792
|
+
}[DepositEventType];
|
|
793
|
+
/** Convenience type for a fully-typed `onramp_session.created` event */
|
|
794
|
+
type OnrampSessionCreatedEvent = Extract<DepositEvent, {
|
|
795
|
+
type: DepositEventType.ONRAMP_SESSION_CREATED;
|
|
796
|
+
}>;
|
|
797
|
+
|
|
757
798
|
/**
|
|
758
799
|
* User IP information interface
|
|
759
800
|
*/
|
|
@@ -874,4 +915,4 @@ declare const i18n: {
|
|
|
874
915
|
};
|
|
875
916
|
type I18nStrings = typeof i18n;
|
|
876
917
|
|
|
877
|
-
export { ActionType, type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AutoSwapRequest, type AutoSwapResponse, type BuildHypercoreTransactionRequest, type BuildHypercoreTransactionResponse, type BuildSolanaTransactionRequest, type BuildSolanaTransactionResponse, type ChainType, type CreateDepositAddressRequest, type CreateExchangeSessionRequest, type CreateExchangeSessionResponse, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, type DepositQuote, type DepositQuoteRequest, type DestinationToken, type DestinationTokenChain, type ExchangeProviderInfo, type ExchangeProvidersResponse, type ExchangeSessionStartParams, type ExchangeWalletAddress, ExecutionStatus, type FeaturedToken, type FiatCurrenciesResponse, type FiatCurrency, type GetExchangesQuery, type HypercoreActionType, type HypercoreActivationRequest, type HypercoreActivationResponse, type I18nStrings, type IconUrl, IneligibilityReason, type IpAddressResponse, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentIntent, type PaymentIntentDepositAddress, type PaymentIntentExecutionsResponse, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, SOLANA_USDC_ADDRESS, type SendHypercoreTransactionRequest, type SendHypercoreTransactionResponse, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SupportedChain, type SupportedDepositTokensResponse, type SupportedDestinationTokensResponse, type SupportedToken, type TokenBalance, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenIconUrl, type TokenInfo, type TokenMetadata, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, buildHypercoreTransaction, buildSolanaTransaction, checkHypercoreActivation, createDepositAddress, createExchangeSession, createOnrampSession, getAddressBalance, getAddressBalances, getApiBaseUrl, getChainName, getDefaultOnrampToken, getDepositQuote, getExchangeSessionStartUrl, getExchanges, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, listPaymentIntentExecutions, pollDirectExecutions, queryExecutions, retrievePaymentIntent, sendHypercoreTransaction, sendSolanaTransaction, setApiConfig, useUserIp, verifyRecipientAddress };
|
|
918
|
+
export { ActionType, type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AutoSwapRequest, type AutoSwapResponse, type BuildHypercoreTransactionRequest, type BuildHypercoreTransactionResponse, type BuildSolanaTransactionRequest, type BuildSolanaTransactionResponse, type ChainType, type CreateDepositAddressRequest, type CreateExchangeSessionRequest, type CreateExchangeSessionResponse, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, type DepositEvent, DepositEventType, type DepositQuote, type DepositQuoteRequest, type DestinationToken, type DestinationTokenChain, type ExchangeProviderInfo, type ExchangeProvidersResponse, type ExchangeSessionStartParams, type ExchangeWalletAddress, ExecutionStatus, type FeaturedToken, type FiatCurrenciesResponse, type FiatCurrency, type GetExchangesQuery, type HypercoreActionType, type HypercoreActivationRequest, type HypercoreActivationResponse, type I18nStrings, type IconUrl, IneligibilityReason, type IpAddressResponse, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionCreatedData, type OnrampSessionCreatedEvent, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentIntent, type PaymentIntentDepositAddress, type PaymentIntentExecutionsResponse, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, SOLANA_USDC_ADDRESS, type SendHypercoreTransactionRequest, type SendHypercoreTransactionResponse, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SupportedChain, type SupportedDepositTokensResponse, type SupportedDestinationTokensResponse, type SupportedToken, type TokenBalance, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenIconUrl, type TokenInfo, type TokenMetadata, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, buildHypercoreTransaction, buildSolanaTransaction, checkHypercoreActivation, createDepositAddress, createExchangeSession, createOnrampSession, generatePrefixedKSUID, getAddressBalance, getAddressBalances, getApiBaseUrl, getChainName, getDefaultOnrampToken, getDepositQuote, getExchangeSessionStartUrl, getExchanges, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, listPaymentIntentExecutions, pollDirectExecutions, queryExecutions, retrievePaymentIntent, sendHypercoreTransaction, sendSolanaTransaction, setApiConfig, useUserIp, verifyRecipientAddress };
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
ActionType: () => ActionType,
|
|
24
|
+
DepositEventType: () => DepositEventType,
|
|
24
25
|
ExecutionStatus: () => ExecutionStatus,
|
|
25
26
|
IneligibilityReason: () => IneligibilityReason,
|
|
26
27
|
SOLANA_USDC_ADDRESS: () => SOLANA_USDC_ADDRESS,
|
|
@@ -30,6 +31,7 @@ __export(index_exports, {
|
|
|
30
31
|
createDepositAddress: () => createDepositAddress,
|
|
31
32
|
createExchangeSession: () => createExchangeSession,
|
|
32
33
|
createOnrampSession: () => createOnrampSession,
|
|
34
|
+
generatePrefixedKSUID: () => generatePrefixedKSUID,
|
|
33
35
|
getAddressBalance: () => getAddressBalance,
|
|
34
36
|
getAddressBalances: () => getAddressBalances,
|
|
35
37
|
getApiBaseUrl: () => getApiBaseUrl,
|
|
@@ -358,6 +360,9 @@ function getOnrampSessionStartUrl(request, publishableKey) {
|
|
|
358
360
|
if (request.subdivision_code) {
|
|
359
361
|
params.append("subdivision_code", request.subdivision_code);
|
|
360
362
|
}
|
|
363
|
+
if (request.external_id) {
|
|
364
|
+
params.append("external_id", request.external_id);
|
|
365
|
+
}
|
|
361
366
|
return `${API_BASE_URL}/v1/public/onramps/sessions/start?${params.toString()}`;
|
|
362
367
|
}
|
|
363
368
|
async function getDefaultOnrampToken(params, publishableKey) {
|
|
@@ -748,6 +753,42 @@ async function sendHypercoreTransaction(request, publishableKey) {
|
|
|
748
753
|
return response.json();
|
|
749
754
|
}
|
|
750
755
|
|
|
756
|
+
// src/lib/utils.ts
|
|
757
|
+
function generatePrefixedKSUID(prefix) {
|
|
758
|
+
const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
759
|
+
const KSUID_EPOCH = 14e8;
|
|
760
|
+
const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
|
|
761
|
+
const payload = new Uint8Array(20);
|
|
762
|
+
payload[0] = timestampSeconds >>> 24 & 255;
|
|
763
|
+
payload[1] = timestampSeconds >>> 16 & 255;
|
|
764
|
+
payload[2] = timestampSeconds >>> 8 & 255;
|
|
765
|
+
payload[3] = timestampSeconds & 255;
|
|
766
|
+
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
767
|
+
crypto.getRandomValues(payload.subarray(4));
|
|
768
|
+
} else {
|
|
769
|
+
for (let i = 4; i < 20; i++) {
|
|
770
|
+
payload[i] = Math.floor(Math.random() * 256);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
let value = 0n;
|
|
774
|
+
for (const byte of payload) {
|
|
775
|
+
value = value << 8n | BigInt(byte);
|
|
776
|
+
}
|
|
777
|
+
let encoded = "";
|
|
778
|
+
while (value > 0n) {
|
|
779
|
+
encoded = BASE62[Number(value % 62n)] + encoded;
|
|
780
|
+
value = value / 62n;
|
|
781
|
+
}
|
|
782
|
+
encoded = encoded.padStart(27, "0");
|
|
783
|
+
return `${prefix}_${encoded}`;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
// src/lib/events.ts
|
|
787
|
+
var DepositEventType = /* @__PURE__ */ ((DepositEventType2) => {
|
|
788
|
+
DepositEventType2["ONRAMP_SESSION_CREATED"] = "onramp_session.created";
|
|
789
|
+
return DepositEventType2;
|
|
790
|
+
})(DepositEventType || {});
|
|
791
|
+
|
|
751
792
|
// src/hooks/use-user-ip.ts
|
|
752
793
|
var import_react_query = require("@tanstack/react-query");
|
|
753
794
|
function useUserIp() {
|
|
@@ -880,6 +921,7 @@ var i18n = en_default;
|
|
|
880
921
|
// Annotate the CommonJS export names for ESM import in node:
|
|
881
922
|
0 && (module.exports = {
|
|
882
923
|
ActionType,
|
|
924
|
+
DepositEventType,
|
|
883
925
|
ExecutionStatus,
|
|
884
926
|
IneligibilityReason,
|
|
885
927
|
SOLANA_USDC_ADDRESS,
|
|
@@ -889,6 +931,7 @@ var i18n = en_default;
|
|
|
889
931
|
createDepositAddress,
|
|
890
932
|
createExchangeSession,
|
|
891
933
|
createOnrampSession,
|
|
934
|
+
generatePrefixedKSUID,
|
|
892
935
|
getAddressBalance,
|
|
893
936
|
getAddressBalances,
|
|
894
937
|
getApiBaseUrl,
|
package/dist/index.mjs
CHANGED
|
@@ -292,6 +292,9 @@ function getOnrampSessionStartUrl(request, publishableKey) {
|
|
|
292
292
|
if (request.subdivision_code) {
|
|
293
293
|
params.append("subdivision_code", request.subdivision_code);
|
|
294
294
|
}
|
|
295
|
+
if (request.external_id) {
|
|
296
|
+
params.append("external_id", request.external_id);
|
|
297
|
+
}
|
|
295
298
|
return `${API_BASE_URL}/v1/public/onramps/sessions/start?${params.toString()}`;
|
|
296
299
|
}
|
|
297
300
|
async function getDefaultOnrampToken(params, publishableKey) {
|
|
@@ -682,6 +685,42 @@ async function sendHypercoreTransaction(request, publishableKey) {
|
|
|
682
685
|
return response.json();
|
|
683
686
|
}
|
|
684
687
|
|
|
688
|
+
// src/lib/utils.ts
|
|
689
|
+
function generatePrefixedKSUID(prefix) {
|
|
690
|
+
const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
691
|
+
const KSUID_EPOCH = 14e8;
|
|
692
|
+
const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
|
|
693
|
+
const payload = new Uint8Array(20);
|
|
694
|
+
payload[0] = timestampSeconds >>> 24 & 255;
|
|
695
|
+
payload[1] = timestampSeconds >>> 16 & 255;
|
|
696
|
+
payload[2] = timestampSeconds >>> 8 & 255;
|
|
697
|
+
payload[3] = timestampSeconds & 255;
|
|
698
|
+
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
699
|
+
crypto.getRandomValues(payload.subarray(4));
|
|
700
|
+
} else {
|
|
701
|
+
for (let i = 4; i < 20; i++) {
|
|
702
|
+
payload[i] = Math.floor(Math.random() * 256);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
let value = 0n;
|
|
706
|
+
for (const byte of payload) {
|
|
707
|
+
value = value << 8n | BigInt(byte);
|
|
708
|
+
}
|
|
709
|
+
let encoded = "";
|
|
710
|
+
while (value > 0n) {
|
|
711
|
+
encoded = BASE62[Number(value % 62n)] + encoded;
|
|
712
|
+
value = value / 62n;
|
|
713
|
+
}
|
|
714
|
+
encoded = encoded.padStart(27, "0");
|
|
715
|
+
return `${prefix}_${encoded}`;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
// src/lib/events.ts
|
|
719
|
+
var DepositEventType = /* @__PURE__ */ ((DepositEventType2) => {
|
|
720
|
+
DepositEventType2["ONRAMP_SESSION_CREATED"] = "onramp_session.created";
|
|
721
|
+
return DepositEventType2;
|
|
722
|
+
})(DepositEventType || {});
|
|
723
|
+
|
|
685
724
|
// src/hooks/use-user-ip.ts
|
|
686
725
|
import { useQuery } from "@tanstack/react-query";
|
|
687
726
|
function useUserIp() {
|
|
@@ -813,6 +852,7 @@ var en_default = {
|
|
|
813
852
|
var i18n = en_default;
|
|
814
853
|
export {
|
|
815
854
|
ActionType,
|
|
855
|
+
DepositEventType,
|
|
816
856
|
ExecutionStatus,
|
|
817
857
|
IneligibilityReason,
|
|
818
858
|
SOLANA_USDC_ADDRESS,
|
|
@@ -822,6 +862,7 @@ export {
|
|
|
822
862
|
createDepositAddress,
|
|
823
863
|
createExchangeSession,
|
|
824
864
|
createOnrampSession,
|
|
865
|
+
generatePrefixedKSUID,
|
|
825
866
|
getAddressBalance,
|
|
826
867
|
getAddressBalances,
|
|
827
868
|
getApiBaseUrl,
|